|
@@ -543,6 +543,56 @@ begin
|
|
end;
|
|
end;
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
+{$IFDEF DARWIN}
|
|
|
|
+function RunAppleScriptLine(AScriptLine: string): boolean;
|
|
|
|
+var
|
|
|
|
+ p: TProcess;
|
|
|
|
+begin
|
|
|
|
+ p := nil;
|
|
|
|
+ try
|
|
|
|
+ p := TProcess.Create(nil);
|
|
|
|
+ p.Executable := 'osascript';
|
|
|
|
+ p.Parameters.Add('-e');
|
|
|
|
+ p.Parameters.Add(AScriptLine);
|
|
|
|
+ p.Options := [poWaitOnExit];
|
|
|
|
+ p.Execute;
|
|
|
|
+ result := true;
|
|
|
|
+ except
|
|
|
|
+ result := false;
|
|
|
|
+ end;
|
|
|
|
+ p.Free;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function AppleScriptEscape(AText: string): string;
|
|
|
|
+begin
|
|
|
|
+ result := StringReplace(AText, '\', '\\', [rfReplaceAll]);
|
|
|
|
+ result := StringReplace(result, '"', '\"', [rfReplaceAll]);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function MoveToTrashOnMacOS(AForm: TForm; const AFilenamesUTF8: array of string; AConfirmationCallback: TDeleteConfirmationFunction): boolean;
|
|
|
|
+var
|
|
|
|
+ appleScript: String;
|
|
|
|
+ i: Integer;
|
|
|
|
+begin
|
|
|
|
+ if length(AFilenamesUTF8) = 0 then exit(true);
|
|
|
|
+ if Assigned(AConfirmationCallback) then
|
|
|
|
+ begin
|
|
|
|
+ if not AConfirmationCallback(AForm, AFilenamesUTF8, False) then exit(false);
|
|
|
|
+ end;
|
|
|
|
+ appleScript := 'tell application "Finder" to delete {';
|
|
|
|
+ for i := 0 to high(AFilenamesUTF8) do
|
|
|
|
+ begin
|
|
|
|
+ if i > 0 then appleScript += ', ';
|
|
|
|
+ appleScript += 'POSIX file "' + AppleScriptEscape(AFilenamesUTF8[i]) + '"';
|
|
|
|
+ end;
|
|
|
|
+ appleScript += '}';
|
|
|
|
+ if not RunAppleScriptLine(appleScript) then exit(false);
|
|
|
|
+ result := true;
|
|
|
|
+ for i := 0 to high(AFilenamesUTF8) do
|
|
|
|
+ if FileExists(AFilenamesUTF8[i]) then result := false;
|
|
|
|
+end;
|
|
|
|
+{$ENDIF}
|
|
|
|
+
|
|
function IsMultiFileContainerName(AFilenameUTF8: string): boolean;
|
|
function IsMultiFileContainerName(AFilenameUTF8: string): boolean;
|
|
var
|
|
var
|
|
ext: String;
|
|
ext: String;
|
|
@@ -612,7 +662,11 @@ begin
|
|
{$IFDEF WINDOWS}
|
|
{$IFDEF WINDOWS}
|
|
result := MoveToTrashOnWindows(AForm, realFiles, AConfirmationCallback);
|
|
result := MoveToTrashOnWindows(AForm, realFiles, AConfirmationCallback);
|
|
{$ELSE}
|
|
{$ELSE}
|
|
- result := false;
|
|
|
|
|
|
+ {$IFDEF DARWIN}
|
|
|
|
+ result := MoveToTrashOnMacOS(AForm, realFiles, AConfirmationCallback);
|
|
|
|
+ {$ELSE}
|
|
|
|
+ result := false;
|
|
|
|
+ {$ENDIF}
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
end;
|
|
end;
|