diff --git a/components/lazutils/fileutil.inc b/components/lazutils/fileutil.inc index 761382b7fa..7c1444c429 100644 --- a/components/lazutils/fileutil.inc +++ b/components/lazutils/fileutil.inc @@ -696,8 +696,6 @@ end; function CopyDirTree(const SourceDir, TargetDir: string; Flags: TCopyFileFlags=[]): Boolean; var Searcher: TCopyDirTree; - RelPath: String; - B: Boolean; begin Result:=False; Searcher:=TCopyDirTree.Create; @@ -710,10 +708,11 @@ begin Searcher.FTargetDir:=LazFileUtils.TrimFilename(SetDirSeparators(TargetDir)); // Don't even try to copy to a subdirectory of SourceDir. - B := TryCreateRelativePath(LazFileUtils.ExpandFilenameUtf8(Searcher.FSourceDir), - LazFileUtils.ExpandFilenameUtf8(Searcher.FTargetDir), False, True, RelPath); - if B and ((Copy(RelPath,1,2) = '..') or (RelPath = '')) then Exit; - + {$ifdef CaseInsensitiveFilenames} + if AnsiStartsText(Searcher.FSourceDir, Searcher.FTargetDir) then Exit; + {$ELSE} + if AnsiStartsStr(Searcher.FSourceDir, Searcher.FTargetDir) then Exit; + {$ENDIF} Searcher.Search(SourceDir); Result:=Searcher.FCopyFailedCount=0; finally diff --git a/components/lazutils/fileutil.pas b/components/lazutils/fileutil.pas index 4df5348662..f1a5b2c451 100644 --- a/components/lazutils/fileutil.pas +++ b/components/lazutils/fileutil.pas @@ -33,7 +33,7 @@ interface uses Classes, SysUtils, - Masks, LazUTF8, LazFileUtils; + Masks, LazUTF8, LazFileUtils, StrUtils; {$if defined(Windows) or defined(darwin)} {$define CaseInsensitiveFilenames}