mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 14:40:29 +02:00
LCL/Cocoa: Implement SelectInFolder for macOS.
This commit is contained in:
parent
0d5e804de9
commit
b855e211b6
@ -1,5 +1,26 @@
|
|||||||
{%MainUnit ../lclintf.pas}
|
{%MainUnit ../lclintf.pas}
|
||||||
|
|
||||||
|
function DoOpen(APath: String; Param: String): Boolean;
|
||||||
|
var
|
||||||
|
ResultingPath: string;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
if not FileExistsUTF8(APath) and not DirectoryExistsUTF8(Apath) then begin
|
||||||
|
// OpenDocument handles URLs as well
|
||||||
|
Result := OpenURL(Apath);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
// Paths with spaces need to be quoted, see bug 21651
|
||||||
|
if (APath<>'') and (APath[1]<>'''') then
|
||||||
|
ResultingPath:=QuotedStr(APath)
|
||||||
|
else
|
||||||
|
ResultingPath:=APath;
|
||||||
|
|
||||||
|
if Param<>'' then
|
||||||
|
ResultingPath:=Param+' '+ResultingPath;
|
||||||
|
|
||||||
|
RunCmdFromPath('open',ResultingPath);
|
||||||
|
end;
|
||||||
|
|
||||||
function FindDefaultBrowser(out ABrowser, AParams: String): Boolean;
|
function FindDefaultBrowser(out ABrowser, AParams: String): Boolean;
|
||||||
begin
|
begin
|
||||||
@ -34,28 +55,13 @@ end;
|
|||||||
|
|
||||||
// Open a document with the default application associated with it in the system
|
// Open a document with the default application associated with it in the system
|
||||||
function OpenDocument(APath: String): Boolean;
|
function OpenDocument(APath: String): Boolean;
|
||||||
var
|
|
||||||
ResultingPath: string;
|
|
||||||
lpath: string;
|
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result:=DoOpen(APath,'');
|
||||||
if not FileExistsUTF8(APath) and not DirectoryExistsUTF8(Apath) then begin
|
|
||||||
// OpenDocument handles URLs as well
|
|
||||||
Result := OpenURL(Apath);
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
// Paths with spaces need to be quoted, see bug 21651
|
|
||||||
if (APath<>'') and (APath[1]<>'''') then
|
|
||||||
ResultingPath:=QuotedStr(APath)
|
|
||||||
else
|
|
||||||
ResultingPath:=APath;
|
|
||||||
RunCmdFromPath('open',ResultingPath);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// ToDo: Implement
|
// open the folder and select the file in system filemanager.
|
||||||
// Now just open the folder in system filemanager.
|
|
||||||
function SelectInFolder(AFullPath: String): Boolean;
|
function SelectInFolder(AFullPath: String): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := OpenDocument(ExtractFilePath(AFullPath));
|
Result := DoOpen(AFullPath,'-R');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user