mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 13:50:06 +02:00
IDE: fixed searching in PATH on Windows
git-svn-id: branches/fixes_1_6@50866 -
This commit is contained in:
parent
fe582332c2
commit
edce120278
@ -316,7 +316,7 @@ end;
|
|||||||
function TCodeToolsOptions.FindDefaultCompilerFilename: string;
|
function TCodeToolsOptions.FindDefaultCompilerFilename: string;
|
||||||
begin
|
begin
|
||||||
Result:=SearchFileInPath(GetDefaultCompilerFilename,'',
|
Result:=SearchFileInPath(GetDefaultCompilerFilename,'',
|
||||||
GetEnvironmentVariableUTF8('PATH'),':',ctsfcDefault);
|
GetEnvironmentVariableUTF8('PATH'),PathSeparator,ctsfcDefault);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodeToolsOptions.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
procedure TCodeToolsOptions.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||||
|
@ -370,7 +370,7 @@ var
|
|||||||
begin
|
begin
|
||||||
File1:=GetPhysicalFilename(Filename1,pfeOriginal);
|
File1:=GetPhysicalFilename(Filename1,pfeOriginal);
|
||||||
File2:=GetPhysicalFilename(Filename2,pfeOriginal);
|
File2:=GetPhysicalFilename(Filename2,pfeOriginal);
|
||||||
Result:=CompareFilenames(File1,File2);
|
Result:=LazFileUtils.CompareFilenames(File1,File2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareFilenames(Filename1: PChar; Len1: integer;
|
function CompareFilenames(Filename1: PChar; Len1: integer;
|
||||||
@ -394,14 +394,14 @@ begin
|
|||||||
if ResolveLinks then
|
if ResolveLinks then
|
||||||
Result:=ComparePhysicalFilenames(File1,File2)
|
Result:=ComparePhysicalFilenames(File1,File2)
|
||||||
else
|
else
|
||||||
Result:=CompareFilenames(File1,File2);
|
Result:=LazFileUtils.CompareFilenames(File1,File2);
|
||||||
end else begin
|
end else begin
|
||||||
{$IFDEF NotLiteralFilenames}
|
{$IFDEF NotLiteralFilenames}
|
||||||
SetLength(File1,Len1);
|
SetLength(File1,Len1);
|
||||||
System.Move(Filename1^,File1[1],Len1);
|
System.Move(Filename1^,File1[1],Len1);
|
||||||
SetLength(File2,Len2);
|
SetLength(File2,Len2);
|
||||||
System.Move(Filename2^,File2[1],Len2);
|
System.Move(Filename2^,File2[1],Len2);
|
||||||
Result:=CompareFilenames(File1,File2);
|
Result:=LazFileUtils.CompareFilenames(File1,File2);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result:=0;
|
Result:=0;
|
||||||
i:=0;
|
i:=0;
|
||||||
@ -421,7 +421,7 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
for i:=Low(PascalFileExt) to High(PascalFileExt) do
|
for i:=Low(PascalFileExt) to High(PascalFileExt) do
|
||||||
if CompareFileExt(Filename,PascalFileExt[i],false)=0 then
|
if LazFileUtils.CompareFileExt(Filename,PascalFileExt[i],false)=0 then
|
||||||
exit(true);
|
exit(true);
|
||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
@ -454,8 +454,8 @@ var
|
|||||||
CurFilename: String;
|
CurFilename: String;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
CurSrcDir:=CleanAndExpandDirectory(DirectoryName);
|
CurSrcDir:=LazFileUtils.CleanAndExpandDirectory(DirectoryName);
|
||||||
if FindFirstUTF8(CurSrcDir+GetAllFilesMask,DeleteMask,FileInfo)=0 then begin
|
if LazFileUtils.FindFirstUTF8(CurSrcDir+GetAllFilesMask,DeleteMask,FileInfo)=0 then begin
|
||||||
repeat
|
repeat
|
||||||
// check if special file
|
// check if special file
|
||||||
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then
|
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then
|
||||||
@ -465,12 +465,12 @@ begin
|
|||||||
{$ifdef unix} and ((FileInfo.Attr and faSymLink)=0) {$endif unix} then begin
|
{$ifdef unix} and ((FileInfo.Attr and faSymLink)=0) {$endif unix} then begin
|
||||||
if not DeleteDirectory(CurFilename,false) then exit;
|
if not DeleteDirectory(CurFilename,false) then exit;
|
||||||
end else begin
|
end else begin
|
||||||
if not DeleteFileUTF8(CurFilename) then exit;
|
if not LazFileUtils.DeleteFileUTF8(CurFilename) then exit;
|
||||||
end;
|
end;
|
||||||
until FindNextUTF8(FileInfo)<>0;
|
until LazFileUtils.FindNextUTF8(FileInfo)<>0;
|
||||||
end;
|
end;
|
||||||
FindCloseUTF8(FileInfo);
|
LazFileUtils.FindCloseUTF8(FileInfo);
|
||||||
if (not OnlyChildren) and (not RemoveDirUTF8(CurSrcDir)) then exit;
|
if (not OnlyChildren) and (not LazFileUtils.RemoveDirUTF8(CurSrcDir)) then exit;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ function ProgramDirectory: string;
|
|||||||
var
|
var
|
||||||
Flags: TSearchFileInPathFlags;
|
Flags: TSearchFileInPathFlags;
|
||||||
begin
|
begin
|
||||||
Result:=ParamStrUTF8(0);
|
Result:=LazUTF8.ParamStrUTF8(0);
|
||||||
if ExtractFilePath(Result)='' then begin
|
if ExtractFilePath(Result)='' then begin
|
||||||
// program was started via PATH
|
// program was started via PATH
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
@ -486,12 +486,12 @@ begin
|
|||||||
{$ELSE}
|
{$ELSE}
|
||||||
Flags:=[sffDontSearchInBasePath];
|
Flags:=[sffDontSearchInBasePath];
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result:=SearchFileInPath(Result,'',GetEnvironmentVariableUTF8('PATH'),':',Flags);
|
Result:=SearchFileInPath(Result,'',LazUTF8.GetEnvironmentVariableUTF8('PATH'),PathSeparator,Flags);
|
||||||
end;
|
end;
|
||||||
// resolve links
|
// resolve links
|
||||||
Result:=GetPhysicalFilename(Result,pfeOriginal);
|
Result:=GetPhysicalFilename(Result,pfeOriginal);
|
||||||
// extract file path and expand to full name
|
// extract file path and expand to full name
|
||||||
Result:=ExpandFileNameUTF8(ExtractFilePath(Result));
|
Result:=LazFileUtils.ExpandFileNameUTF8(ExtractFilePath(Result));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
|
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
|
||||||
@ -506,7 +506,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=SearchPath;
|
Result:=SearchPath;
|
||||||
if (SearchPath='') or (BaseDirectory='') then exit;
|
if (SearchPath='') or (BaseDirectory='') then exit;
|
||||||
BaseDir:=AppendPathDelim(BaseDirectory);
|
BaseDir:=LazFileUtils.AppendPathDelim(BaseDirectory);
|
||||||
|
|
||||||
PathLen:=length(Result);
|
PathLen:=length(Result);
|
||||||
EndPos:=1;
|
EndPos:=1;
|
||||||
@ -519,7 +519,7 @@ begin
|
|||||||
EndPos:=StartPos;
|
EndPos:=StartPos;
|
||||||
while (EndPos<=PathLen) and (Result[EndPos]<>';') do inc(EndPos);
|
while (EndPos<=PathLen) and (Result[EndPos]<>';') do inc(EndPos);
|
||||||
CurDir:=copy(Result,StartPos,EndPos-StartPos);
|
CurDir:=copy(Result,StartPos,EndPos-StartPos);
|
||||||
if not FilenameIsAbsolute(CurDir) then begin
|
if not LazFileUtils.FilenameIsAbsolute(CurDir) then begin
|
||||||
NewCurDir:=BaseDir+CurDir;
|
NewCurDir:=BaseDir+CurDir;
|
||||||
if NewCurDir<>CurDir then begin
|
if NewCurDir<>CurDir then begin
|
||||||
DiffLen:=length(NewCurDir)-length(CurDir);
|
DiffLen:=length(NewCurDir)-length(CurDir);
|
||||||
@ -535,7 +535,7 @@ end;
|
|||||||
|
|
||||||
function CreateAbsolutePath(const Filename, BaseDirectory: string): string;
|
function CreateAbsolutePath(const Filename, BaseDirectory: string): string;
|
||||||
begin
|
begin
|
||||||
if (Filename='') or FilenameIsAbsolute(Filename) then
|
if (Filename='') or LazFileUtils.FilenameIsAbsolute(Filename) then
|
||||||
Result:=Filename
|
Result:=Filename
|
||||||
{$IFDEF Windows}
|
{$IFDEF Windows}
|
||||||
else if (Filename[1]='\') then
|
else if (Filename[1]='\') then
|
||||||
@ -543,8 +543,8 @@ begin
|
|||||||
Result:=ExtractFileDrive(BaseDirectory)+Filename
|
Result:=ExtractFileDrive(BaseDirectory)+Filename
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
else
|
else
|
||||||
Result:=AppendPathDelim(BaseDirectory)+Filename;
|
Result:=LazFileUtils.AppendPathDelim(BaseDirectory)+Filename;
|
||||||
Result:=TrimFilename(Result);
|
Result:=LazFileUtils.TrimFilename(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FileIsInPath(const Filename, Path: string): boolean;
|
function FileIsInPath(const Filename, Path: string): boolean;
|
||||||
@ -553,11 +553,11 @@ var
|
|||||||
ExpPath: String;
|
ExpPath: String;
|
||||||
l: integer;
|
l: integer;
|
||||||
begin
|
begin
|
||||||
ExpFile:=CleanAndExpandFilename(Filename);
|
ExpFile:=LazFileUtils.CleanAndExpandFilename(Filename);
|
||||||
ExpPath:=CleanAndExpandDirectory(Path);
|
ExpPath:=LazFileUtils.CleanAndExpandDirectory(Path);
|
||||||
l:=length(ExpPath);
|
l:=length(ExpPath);
|
||||||
Result:=(l>0) and (length(ExpFile)>l) and (ExpFile[l] in AllowDirectorySeparators)
|
Result:=(l>0) and (length(ExpFile)>l) and (ExpFile[l] in AllowDirectorySeparators)
|
||||||
and (CompareFilenames(ExpPath,LeftStr(ExpFile,l))=0);
|
and (LazFileUtils.CompareFilenames(ExpPath,LeftStr(ExpFile,l))=0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FileIsInDirectory(const Filename, Directory: string): boolean;
|
function FileIsInDirectory(const Filename, Directory: string): boolean;
|
||||||
@ -568,14 +568,14 @@ var
|
|||||||
LenDir: Integer;
|
LenDir: Integer;
|
||||||
p: LongInt;
|
p: LongInt;
|
||||||
begin
|
begin
|
||||||
ExpFile:=CleanAndExpandFilename(Filename);
|
ExpFile:=LazFileUtils.CleanAndExpandFilename(Filename);
|
||||||
ExpDir:=CleanAndExpandDirectory(Directory);
|
ExpDir:=LazFileUtils.CleanAndExpandDirectory(Directory);
|
||||||
LenFile:=length(ExpFile);
|
LenFile:=length(ExpFile);
|
||||||
LenDir:=length(ExpDir);
|
LenDir:=length(ExpDir);
|
||||||
p:=LenFile;
|
p:=LenFile;
|
||||||
while (p>0) and not (ExpFile[p] in AllowDirectorySeparators) do dec(p);
|
while (p>0) and not (ExpFile[p] in AllowDirectorySeparators) do dec(p);
|
||||||
Result:=(p=LenDir) and (p<LenFile)
|
Result:=(p=LenDir) and (p<LenFile)
|
||||||
and (CompareFilenames(ExpDir,LeftStr(ExpFile,p))=0);
|
and (LazFileUtils.CompareFilenames(ExpDir,LeftStr(ExpFile,p))=0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CopyFile(const SrcFilename, DestFilename: String;
|
function CopyFile(const SrcFilename, DestFilename: String;
|
||||||
@ -588,16 +588,16 @@ var
|
|||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
// check overwrite
|
// check overwrite
|
||||||
if (not (cffOverwriteFile in Flags)) and FileExistsUTF8(DestFileName) then
|
if (not (cffOverwriteFile in Flags)) and LazFileUtils.FileExistsUTF8(DestFileName) then
|
||||||
exit;
|
exit;
|
||||||
// check directory
|
// check directory
|
||||||
if (cffCreateDestDirectory in Flags)
|
if (cffCreateDestDirectory in Flags)
|
||||||
and (not DirectoryExistsUTF8(ExtractFilePath(DestFileName)))
|
and (not LazFileUtils.DirectoryExistsUTF8(ExtractFilePath(DestFileName)))
|
||||||
and (not ForceDirectoriesUTF8(ExtractFilePath(DestFileName))) then
|
and (not LazFileUtils.ForceDirectoriesUTF8(ExtractFilePath(DestFileName))) then
|
||||||
exit;
|
exit;
|
||||||
TryCount := 0;
|
TryCount := 0;
|
||||||
While TryCount <> 3 Do Begin
|
While TryCount <> 3 Do Begin
|
||||||
SrcHandle := FileOpenUTF8(SrcFilename, fmOpenRead or fmShareDenyWrite);
|
SrcHandle := LazFileUtils.FileOpenUTF8(SrcFilename, fmOpenRead or fmShareDenyWrite);
|
||||||
if (THandle(SrcHandle)=feInvalidHandle) then Begin
|
if (THandle(SrcHandle)=feInvalidHandle) then Begin
|
||||||
Inc(TryCount);
|
Inc(TryCount);
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
@ -615,7 +615,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
try
|
try
|
||||||
DestHandle := FileCreateUTF8(DestFileName);
|
DestHandle := LazFileUtils.FileCreateUTF8(DestFileName);
|
||||||
if (THandle(DestHandle)=feInvalidHandle) then
|
if (THandle(DestHandle)=feInvalidHandle) then
|
||||||
begin
|
begin
|
||||||
if ExceptionOnError then
|
if ExceptionOnError then
|
||||||
@ -640,7 +640,7 @@ begin
|
|||||||
FileClose(DestHandle);
|
FileClose(DestHandle);
|
||||||
end;
|
end;
|
||||||
if (cffPreserveTime in Flags) then
|
if (cffPreserveTime in Flags) then
|
||||||
FileSetDateUTF8(DestFilename, FileGetDate(SrcHandle));
|
LazFileUtils.FileSetDateUTF8(DestFilename, FileGetDate(SrcHandle));
|
||||||
Result := True;
|
Result := True;
|
||||||
finally
|
finally
|
||||||
FileClose(SrcHandle);
|
FileClose(SrcHandle);
|
||||||
@ -688,8 +688,8 @@ var
|
|||||||
begin
|
begin
|
||||||
NewPath:=StringReplace(FileName, FSourceDir, FTargetDir, []);
|
NewPath:=StringReplace(FileName, FSourceDir, FTargetDir, []);
|
||||||
// ToDo: make directories also respect cffPreserveTime flag.
|
// ToDo: make directories also respect cffPreserveTime flag.
|
||||||
if not DirectoryExistsUTF8(NewPath) then
|
if not LazFileUtils.DirectoryExistsUTF8(NewPath) then
|
||||||
if not ForceDirectoriesUTF8(NewPath) then
|
if not LazFileUtils.ForceDirectoriesUTF8(NewPath) then
|
||||||
Inc(FCopyFailedCount);
|
Inc(FCopyFailedCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -743,7 +743,7 @@ begin
|
|||||||
try
|
try
|
||||||
Setlength(s, FileSize(Filename));
|
Setlength(s, FileSize(Filename));
|
||||||
if s='' then exit;
|
if s='' then exit;
|
||||||
SrcHandle := FileOpenUTF8(Filename, fmOpenRead or fmShareDenyWrite);
|
SrcHandle := LazFileUtils.FileOpenUTF8(Filename, fmOpenRead or fmShareDenyWrite);
|
||||||
if (THandle(SrcHandle)=feInvalidHandle) then
|
if (THandle(SrcHandle)=feInvalidHandle) then
|
||||||
exit;
|
exit;
|
||||||
try
|
try
|
||||||
@ -771,20 +771,20 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
// check if filename absolute
|
// check if filename absolute
|
||||||
if FilenameIsAbsolute(Filename) then begin
|
if LazFileUtils.FilenameIsAbsolute(Filename) then begin
|
||||||
if FileExistsUTF8(Filename) then begin
|
if LazFileUtils.FileExistsUTF8(Filename) then begin
|
||||||
Result:=CleanAndExpandFilename(Filename);
|
Result:=LazFileUtils.CleanAndExpandFilename(Filename);
|
||||||
exit;
|
exit;
|
||||||
end else begin
|
end else begin
|
||||||
Result:='';
|
Result:='';
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Base:=CleanAndExpandDirectory(BasePath);
|
Base:=LazFileUtils.CleanAndExpandDirectory(BasePath);
|
||||||
// search in current directory
|
// search in current directory
|
||||||
if (not (sffDontSearchInBasePath in Flags))
|
if (not (sffDontSearchInBasePath in Flags))
|
||||||
and FileExistsUTF8(Base+Filename) then begin
|
and LazFileUtils.FileExistsUTF8(Base+Filename) then begin
|
||||||
Result:=CleanAndExpandFilename(Base+Filename);
|
Result:=LazFileUtils.CleanAndExpandFilename(Base+Filename);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
// search in search path
|
// search in search path
|
||||||
@ -793,12 +793,12 @@ begin
|
|||||||
while StartPos<=l do begin
|
while StartPos<=l do begin
|
||||||
p:=StartPos;
|
p:=StartPos;
|
||||||
while (p<=l) and (pos(SearchPath[p],Delimiter)<1) do inc(p);
|
while (p<=l) and (pos(SearchPath[p],Delimiter)<1) do inc(p);
|
||||||
CurPath:=TrimFilename(copy(SearchPath,StartPos,p-StartPos));
|
CurPath:=LazFileUtils.TrimFilename(copy(SearchPath,StartPos,p-StartPos));
|
||||||
if CurPath<>'' then begin
|
if CurPath<>'' then begin
|
||||||
if not FilenameIsAbsolute(CurPath) then
|
if not LazFileUtils.FilenameIsAbsolute(CurPath) then
|
||||||
CurPath:=Base+CurPath;
|
CurPath:=Base+CurPath;
|
||||||
Result:=CleanAndExpandFilename(AppendPathDelim(CurPath)+Filename);
|
Result:=LazFileUtils.CleanAndExpandFilename(LazFileUtils.AppendPathDelim(CurPath)+Filename);
|
||||||
if FileExistsUTF8(Result) then exit;
|
if LazFileUtils.FileExistsUTF8(Result) then exit;
|
||||||
end;
|
end;
|
||||||
StartPos:=p+1;
|
StartPos:=p+1;
|
||||||
end;
|
end;
|
||||||
@ -812,13 +812,13 @@ function SearchAllFilesInPath(const Filename, BasePath, SearchPath,
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
NewFilename:=TrimFilename(NewFilename);
|
NewFilename:=LazFileUtils.TrimFilename(NewFilename);
|
||||||
if not FileExistsUTF8(NewFilename) then exit;
|
if not LazFileUtils.FileExistsUTF8(NewFilename) then exit;
|
||||||
if Result=nil then begin
|
if Result=nil then begin
|
||||||
Result:=TStringList.Create;
|
Result:=TStringList.Create;
|
||||||
end else begin
|
end else begin
|
||||||
for i:=0 to Result.Count-1 do
|
for i:=0 to Result.Count-1 do
|
||||||
if CompareFilenames(Result[i],NewFilename)=0 then exit;
|
if LazFileUtils.CompareFilenames(Result[i],NewFilename)=0 then exit;
|
||||||
end;
|
end;
|
||||||
Result.Add(NewFilename);
|
Result.Add(NewFilename);
|
||||||
end;
|
end;
|
||||||
@ -830,14 +830,14 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
if (Filename='') then exit;
|
if (Filename='') then exit;
|
||||||
// check if filename absolute
|
// check if filename absolute
|
||||||
if FilenameIsAbsolute(Filename) then begin
|
if LazFileUtils.FilenameIsAbsolute(Filename) then begin
|
||||||
Add(CleanAndExpandFilename(Filename));
|
Add(LazFileUtils.CleanAndExpandFilename(Filename));
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
Base:=CleanAndExpandDirectory(BasePath);
|
Base:=LazFileUtils.CleanAndExpandDirectory(BasePath);
|
||||||
// search in current directory
|
// search in current directory
|
||||||
if (not (sffDontSearchInBasePath in Flags)) then begin
|
if (not (sffDontSearchInBasePath in Flags)) then begin
|
||||||
Add(CleanAndExpandFilename(Base+Filename));
|
Add(LazFileUtils.CleanAndExpandFilename(Base+Filename));
|
||||||
end;
|
end;
|
||||||
// search in search path
|
// search in search path
|
||||||
StartPos:=1;
|
StartPos:=1;
|
||||||
@ -845,11 +845,11 @@ begin
|
|||||||
while StartPos<=l do begin
|
while StartPos<=l do begin
|
||||||
p:=StartPos;
|
p:=StartPos;
|
||||||
while (p<=l) and (pos(SearchPath[p],Delimiter)<1) do inc(p);
|
while (p<=l) and (pos(SearchPath[p],Delimiter)<1) do inc(p);
|
||||||
CurPath:=TrimFilename(copy(SearchPath,StartPos,p-StartPos));
|
CurPath:=LazFileUtils.TrimFilename(copy(SearchPath,StartPos,p-StartPos));
|
||||||
if CurPath<>'' then begin
|
if CurPath<>'' then begin
|
||||||
if not FilenameIsAbsolute(CurPath) then
|
if not LazFileUtils.FilenameIsAbsolute(CurPath) then
|
||||||
CurPath:=Base+CurPath;
|
CurPath:=Base+CurPath;
|
||||||
Add(CleanAndExpandFilename(AppendPathDelim(CurPath)+Filename));
|
Add(LazFileUtils.CleanAndExpandFilename(LazFileUtils.AppendPathDelim(CurPath)+Filename));
|
||||||
end;
|
end;
|
||||||
StartPos:=p+1;
|
StartPos:=p+1;
|
||||||
end;
|
end;
|
||||||
@ -870,7 +870,7 @@ var
|
|||||||
Ambiguous: Boolean;
|
Ambiguous: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=Filename;
|
Result:=Filename;
|
||||||
if not FileExistsUTF8(Filename) then exit;
|
if not LazFileUtils.FileExistsUTF8(Filename) then exit;
|
||||||
//Sanitize result first (otherwise result can contain things like foo/\bar on Windows)
|
//Sanitize result first (otherwise result can contain things like foo/\bar on Windows)
|
||||||
Result := ResolveDots(Result);
|
Result := ResolveDots(Result);
|
||||||
// check every directory and filename
|
// check every directory and filename
|
||||||
@ -898,14 +898,14 @@ begin
|
|||||||
CurFile:=copy(Result,StartPos,EndPos-StartPos);
|
CurFile:=copy(Result,StartPos,EndPos-StartPos);
|
||||||
AliasFile:='';
|
AliasFile:='';
|
||||||
Ambiguous:=false;
|
Ambiguous:=false;
|
||||||
if FindFirstUTF8(CurDir+GetAllFilesMask,faAnyFile,FileInfo)=0 then
|
if LazFileUtils.FindFirstUTF8(CurDir+GetAllFilesMask,faAnyFile,FileInfo)=0 then
|
||||||
begin
|
begin
|
||||||
repeat
|
repeat
|
||||||
// check if special file
|
// check if special file
|
||||||
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='')
|
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='')
|
||||||
then
|
then
|
||||||
continue;
|
continue;
|
||||||
if CompareFilenamesIgnoreCase(FileInfo.Name,CurFile)=0 then begin
|
if LazFileUtils.CompareFilenamesIgnoreCase(FileInfo.Name,CurFile)=0 then begin
|
||||||
//debugln('FindDiskFilename ',FileInfo.Name,' ',CurFile);
|
//debugln('FindDiskFilename ',FileInfo.Name,' ',CurFile);
|
||||||
if FileInfo.Name=CurFile then begin
|
if FileInfo.Name=CurFile then begin
|
||||||
// file found, has already the correct name
|
// file found, has already the correct name
|
||||||
@ -921,9 +921,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
until FindNextUTF8(FileInfo)<>0;
|
until LazFileUtils.FindNextUTF8(FileInfo)<>0;
|
||||||
end;
|
end;
|
||||||
FindCloseUTF8(FileInfo);
|
LazFileUtils.FindCloseUTF8(FileInfo);
|
||||||
if (AliasFile<>'') and (not Ambiguous) then begin
|
if (AliasFile<>'') and (not Ambiguous) then begin
|
||||||
// better filename found -> replace
|
// better filename found -> replace
|
||||||
Result:=CurDir+AliasFile+copy(Result,EndPos,length(Result));
|
Result:=CurDir+AliasFile+copy(Result,EndPos,length(Result));
|
||||||
@ -941,14 +941,14 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
CurDir:=ExtractFilePath(ResolveDots(Filename));
|
CurDir:=ExtractFilePath(ResolveDots(Filename));
|
||||||
if FindFirstUTF8(CurDir+GetAllFilesMask,faAnyFile, FileInfo)=0 then begin
|
if LazFileUtils.FindFirstUTF8(CurDir+GetAllFilesMask,faAnyFile, FileInfo)=0 then begin
|
||||||
ShortFilename:=ExtractFilename(Filename);
|
ShortFilename:=ExtractFilename(Filename);
|
||||||
repeat
|
repeat
|
||||||
// check if special file
|
// check if special file
|
||||||
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='')
|
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='')
|
||||||
then
|
then
|
||||||
continue;
|
continue;
|
||||||
if CompareFilenamesIgnoreCase(FileInfo.Name,ShortFilename)=0 then begin
|
if LazFileUtils.CompareFilenamesIgnoreCase(FileInfo.Name,ShortFilename)=0 then begin
|
||||||
if FileInfo.Name=ShortFilename then begin
|
if FileInfo.Name=ShortFilename then begin
|
||||||
// fits exactly
|
// fits exactly
|
||||||
//Don't return (unaltered) Filename: otherwise possible changes by ResolveDots get lost
|
//Don't return (unaltered) Filename: otherwise possible changes by ResolveDots get lost
|
||||||
@ -959,32 +959,32 @@ begin
|
|||||||
Result:=CurDir+FileInfo.Name;
|
Result:=CurDir+FileInfo.Name;
|
||||||
// search further
|
// search further
|
||||||
end;
|
end;
|
||||||
until FindNextUTF8(FileInfo)<>0;
|
until LazFileUtils.FindNextUTF8(FileInfo)<>0;
|
||||||
end;
|
end;
|
||||||
FindCloseUTF8(FileInfo);
|
LazFileUtils.FindCloseUTF8(FileInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FindDefaultExecutablePath(const Executable: string;
|
function FindDefaultExecutablePath(const Executable: string;
|
||||||
const BaseDir: string): string;
|
const BaseDir: string): string;
|
||||||
begin
|
begin
|
||||||
if FilenameIsAbsolute(Executable) then begin
|
if LazFileUtils.FilenameIsAbsolute(Executable) then begin
|
||||||
Result:=Executable;
|
Result:=Executable;
|
||||||
if FileExistsUTF8(Result) then exit;
|
if LazFileUtils.FileExistsUTF8(Result) then exit;
|
||||||
{$IFDEF Windows}
|
{$IFDEF Windows}
|
||||||
if ExtractFileExt(Result)='' then begin
|
if ExtractFileExt(Result)='' then begin
|
||||||
Result:=Result+'.exe';
|
Result:=Result+'.exe';
|
||||||
if FileExistsUTF8(Result) then exit;
|
if LazFileUtils.FileExistsUTF8(Result) then exit;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end else begin
|
end else begin
|
||||||
Result:=SearchFileInPath(Executable,BaseDir,
|
Result:=SearchFileInPath(Executable,BaseDir,
|
||||||
GetEnvironmentVariableUTF8('PATH'), PathSeparator,
|
LazUTF8.GetEnvironmentVariableUTF8('PATH'), PathSeparator,
|
||||||
[sffDontSearchInBasePath]);
|
[sffDontSearchInBasePath]);
|
||||||
if Result<>'' then exit;
|
if Result<>'' then exit;
|
||||||
{$IFDEF Windows}
|
{$IFDEF Windows}
|
||||||
if ExtractFileExt(Executable)='' then begin
|
if ExtractFileExt(Executable)='' then begin
|
||||||
Result:=SearchFileInPath(Executable+'.exe',BaseDir,
|
Result:=SearchFileInPath(Executable+'.exe',BaseDir,
|
||||||
GetEnvironmentVariableUTF8('PATH'), PathSeparator,
|
LazUTF8.GetEnvironmentVariableUTF8('PATH'), PathSeparator,
|
||||||
[sffDontSearchInBasePath]);
|
[sffDontSearchInBasePath]);
|
||||||
if Result<>'' then exit;
|
if Result<>'' then exit;
|
||||||
end;
|
end;
|
||||||
@ -1123,7 +1123,7 @@ var
|
|||||||
begin
|
begin
|
||||||
P := APath + AllDirectoryEntriesMask;
|
P := APath + AllDirectoryEntriesMask;
|
||||||
|
|
||||||
if FindFirstUTF8(P, FileAttribute, PathInfo) = 0 then
|
if LazFileUtils.FindFirstUTF8(P, FileAttribute, PathInfo) = 0 then
|
||||||
try
|
try
|
||||||
repeat
|
repeat
|
||||||
// skip special files
|
// skip special files
|
||||||
@ -1151,19 +1151,19 @@ var
|
|||||||
DoDirectoryFound;
|
DoDirectoryFound;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
until (FindNextUTF8(PathInfo) <> 0) or not FSearching;
|
until (LazFileUtils.FindNextUTF8(PathInfo) <> 0) or not FSearching;
|
||||||
finally
|
finally
|
||||||
FindCloseUTF8(PathInfo);
|
LazFileUtils.FindCloseUTF8(PathInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if ASearchSubDirs or (ALevel > 0) then
|
if ASearchSubDirs or (ALevel > 0) then
|
||||||
// search recursively in directories
|
// search recursively in directories
|
||||||
if FindFirstUTF8(P, DirectoryAttribute, PathInfo) = 0 then
|
if LazFileUtils.FindFirstUTF8(P, DirectoryAttribute, PathInfo) = 0 then
|
||||||
try
|
try
|
||||||
repeat
|
repeat
|
||||||
if (PathInfo.Name = '.') or (PathInfo.Name = '..') or
|
if (PathInfo.Name = '.') or (PathInfo.Name = '..') or
|
||||||
(PathInfo.Name = '') or ((PathInfo.Attr and faDirectory) = 0) or
|
(PathInfo.Name = '') or ((PathInfo.Attr and faDirectory) = 0) or
|
||||||
(not FFollowSymLink and FileIsSymlink(APath + PathInfo.Name))
|
(not FFollowSymLink and LazFileUtils.FileIsSymlink(APath + PathInfo.Name))
|
||||||
then Continue;
|
then Continue;
|
||||||
|
|
||||||
FPath := APath;
|
FPath := APath;
|
||||||
@ -1172,11 +1172,11 @@ var
|
|||||||
DoDirectoryEnter;
|
DoDirectoryEnter;
|
||||||
if not FSearching then Break;
|
if not FSearching then Break;
|
||||||
|
|
||||||
DoSearch(AppendPathDelim(APath + PathInfo.Name), Succ(ALevel));
|
DoSearch(LazFileUtils.AppendPathDelim(APath + PathInfo.Name), Succ(ALevel));
|
||||||
|
|
||||||
until (FindNextUTF8(PathInfo) <> 0);
|
until (LazFileUtils.FindNextUTF8(PathInfo) <> 0);
|
||||||
finally
|
finally
|
||||||
FindCloseUTF8(PathInfo);
|
LazFileUtils.FindCloseUTF8(PathInfo);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1200,14 +1200,14 @@ begin
|
|||||||
p:=Pos(';',ASearchPath);
|
p:=Pos(';',ASearchPath);
|
||||||
if p<1 then
|
if p<1 then
|
||||||
p:=length(ASearchPath)+1;
|
p:=length(ASearchPath)+1;
|
||||||
Dir:=TrimFilename(LeftStr(ASearchPath,p-1));
|
Dir:=LazFileUtils.TrimFilename(LeftStr(ASearchPath,p-1));
|
||||||
Delete(ASearchPath,1,p);
|
Delete(ASearchPath,1,p);
|
||||||
if Dir='' then continue;
|
if Dir='' then continue;
|
||||||
Dir:=ChompPathDelim(Dir);
|
Dir:=LazFileUtils.ChompPathDelim(Dir);
|
||||||
for i:=SearchDirectories.Count-1 downto 0 do
|
for i:=SearchDirectories.Count-1 downto 0 do
|
||||||
begin
|
begin
|
||||||
OtherDir:=SearchDirectories[i];
|
OtherDir:=SearchDirectories[i];
|
||||||
if (CompareFilenames(Dir,OtherDir)=0)
|
if (LazFileUtils.CompareFilenames(Dir,OtherDir)=0)
|
||||||
or (ASearchSubDirs and (FileIsInPath(Dir,OtherDir))) then
|
or (ASearchSubDirs and (FileIsInPath(Dir,OtherDir))) then
|
||||||
begin
|
begin
|
||||||
// directory Dir is already searched
|
// directory Dir is already searched
|
||||||
@ -1227,7 +1227,7 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
for i:=0 to SearchDirectories.Count-1 do
|
for i:=0 to SearchDirectories.Count-1 do
|
||||||
DoSearch(AppendPathDelim(SearchDirectories[i]), 0);
|
DoSearch(LazFileUtils.AppendPathDelim(SearchDirectories[i]), 0);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
SearchDirectories.Free;
|
SearchDirectories.Free;
|
||||||
|
@ -276,7 +276,7 @@ begin
|
|||||||
|
|
||||||
// check if there are several compilers in path
|
// check if there are several compilers in path
|
||||||
CompilerFiles:=SearchAllFilesInPath(GetDefaultCompilerFilename,'',
|
CompilerFiles:=SearchAllFilesInPath(GetDefaultCompilerFilename,'',
|
||||||
GetEnvironmentVariableUTF8('PATH'),':',[sffDontSearchInBasePath]);
|
GetEnvironmentVariableUTF8('PATH'),PathSeparator,[sffDontSearchInBasePath]);
|
||||||
try
|
try
|
||||||
ResolveLinksInFileList(CompilerFiles,false);
|
ResolveLinksInFileList(CompilerFiles,false);
|
||||||
RemoveDoubles(CompilerFiles);
|
RemoveDoubles(CompilerFiles);
|
||||||
|
@ -212,7 +212,7 @@ begin
|
|||||||
Result:=Executable
|
Result:=Executable
|
||||||
else
|
else
|
||||||
Result:=SearchFileInPath(Executable,'',
|
Result:=SearchFileInPath(Executable,'',
|
||||||
GetEnvironmentVariableUTF8('PATH'),':',
|
GetEnvironmentVariableUTF8('PATH'),PathSeparator,
|
||||||
[sffDontSearchInBasePath]);
|
[sffDontSearchInBasePath]);
|
||||||
Result:=TrimFilename(Result);
|
Result:=TrimFilename(Result);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user