LazUtils: Revert r51038 #10e166f60e. Fixes bug in CopyDirTree. Issue #0029695.

git-svn-id: trunk@51675 -
This commit is contained in:
bart 2016-02-22 18:13:29 +00:00
parent f42ebf10a7
commit f7005c6649
2 changed files with 6 additions and 7 deletions

View File

@ -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

View File

@ -33,7 +33,7 @@ interface
uses
Classes, SysUtils,
Masks, LazUTF8, LazFileUtils;
Masks, LazUTF8, LazFileUtils, StrUtils;
{$if defined(Windows) or defined(darwin)}
{$define CaseInsensitiveFilenames}