diff --git a/components/lazutils/fileutil.inc b/components/lazutils/fileutil.inc index e4ac0f4fd2..de3e201afe 100644 --- a/components/lazutils/fileutil.inc +++ b/components/lazutils/fileutil.inc @@ -1007,21 +1007,25 @@ begin end; procedure TCopyDirTree.DoDirectoryFound; +var + NewPath:String; begin - // ToDo: create destination path here instead of calling CopyFile with cffCreateDestDirectory. + NewPath:=StringReplace(FileName, FSourceDir, FTargetDir, []); + if not DirectoryExistsUTF8(NewPath) then + if not ForceDirectoriesUTF8(NewPath) then + Inc(FCopyFailedCount); end; -function CopyDirTree(const SourceDir, TargetDir: string; - PreserveTime: boolean = False): Boolean; +function CopyDirTree(const SourceDir, TargetDir: string; Flags: TCopyFileFlags=[]): Boolean; var Searcher: TCopyDirTree; begin Result:=False; Searcher:=TCopyDirTree.Create; try - Searcher.FFlags:=[cffCreateDestDirectory]; - if PreserveTime then - Searcher.FFlags:=Searcher.FFlags+[cffPreserveTime]; + // Destination directories are always created. User setting has no effect! + Flags:=Flags-[cffCreateDestDirectory]; + Searcher.FFlags:=Flags; Searcher.FCopyFailedCount:=0; Searcher.FSourceDir:=SourceDir; Searcher.FTargetDir:=TargetDir; diff --git a/components/lazutils/fileutil.pas b/components/lazutils/fileutil.pas index f67e4dedf5..2fa06f1bea 100644 --- a/components/lazutils/fileutil.pas +++ b/components/lazutils/fileutil.pas @@ -185,8 +185,7 @@ function CopyFile(const SrcFilename, DestFilename: string; Flags: TCopyFileFlags=[cffOverwriteFile]): boolean; function CopyFile(const SrcFilename, DestFilename: string; PreserveTime: boolean): boolean; deprecated {$IFDEF VER2_5}'use cffPreserveTime in Flags parameter instead'{$ENDIF}; -function CopyDirTree(const SourceDir, TargetDir: string; - PreserveTime: boolean = False): boolean; +function CopyDirTree(const SourceDir, TargetDir: string; Flags: TCopyFileFlags=[]): Boolean; // file actions function ReadFileToString(const Filename: string): string;