2
0
Эх сурвалжийг харах

ADD: apply TDarwinFileUtil.cloneFile() in TFileSystemOperationHelper.CopyFile() on macOS

1. dramatically improve file copy speed on APFS
2. supports copying macOS specific attributes
rich2014 2 сар өмнө
parent
commit
e2f09416b2

+ 26 - 7
src/filesources/filesystem/ufilesystemutil.pas

@@ -185,6 +185,9 @@ uses
   Math, DateUtils
 {$IFDEF UNIX}
   , BaseUnix, Unix, DCUnix
+{$ENDIF}
+{$IFDEF DARWIN}
+  , uDarwinFileUtil
 {$ENDIF}
   ;
 
@@ -640,7 +643,29 @@ var
     if not Assigned(TargetFileStream) and (log_errors in gLogOptions) then
       logWrite(FOperationThread, rsMsgLogError + GetMsgByMode + ': ' + TargetFileName, lmtError, True);
   end;
+
+  procedure doUpdate;
+  begin
+    with FStatistics do
+    begin
+      CurrentFileDoneBytes := CurrentFileDoneBytes + BytesRead;
+      DoneBytes := DoneBytes + BytesRead;
+      UpdateStatistics(FStatistics);
+    end;
+  end;
+
 begin
+{$IFDEF DARWIN}
+  if Mode = fsohcmDefault then begin
+    Result:= TDarwinFileUtil.cloneFile( SourceFile.FullPath, TargetFileName );
+    if Result then begin
+      BytesRead:= SourceFile.Size;
+      doUpdate;
+      Exit;
+    end;
+  end;
+{$ENDIF}
+
   Result := False;
 
   { Check disk free space }
@@ -907,13 +932,7 @@ begin
           end;
         until not bRetryRead;
 
-        with FStatistics do
-        begin
-          CurrentFileDoneBytes := CurrentFileDoneBytes + BytesRead;
-          DoneBytes := DoneBytes + BytesRead;
-
-          UpdateStatistics(FStatistics);
-        end;
+        doUpdate;
 
         AppProcessMessages;
         CheckOperationState; // check pause and stop