mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 02:55:55 +02:00
lazutils: FindDefaultExecutablePath: on Windows search in BaseDir as well, bug #30802.
git-svn-id: trunk@53236 -
This commit is contained in:
parent
8f692f8a3b
commit
3bcde4474b
@ -976,6 +976,8 @@ end;
|
|||||||
|
|
||||||
function FindDefaultExecutablePath(const Executable: string;
|
function FindDefaultExecutablePath(const Executable: string;
|
||||||
const BaseDir: string): string;
|
const BaseDir: string): string;
|
||||||
|
const
|
||||||
|
Flags : TSearchFileInPathFlags = [{$IFDEF Unix}sffDontSearchInBasePath{$ENDIF}];
|
||||||
begin
|
begin
|
||||||
if LazFileUtils.FilenameIsAbsolute(Executable) then begin
|
if LazFileUtils.FilenameIsAbsolute(Executable) then begin
|
||||||
Result:=Executable;
|
Result:=Executable;
|
||||||
@ -989,13 +991,13 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
Result:=SearchFileInPath(Executable,BaseDir,
|
Result:=SearchFileInPath(Executable,BaseDir,
|
||||||
LazUTF8.GetEnvironmentVariableUTF8('PATH'), PathSeparator,
|
LazUTF8.GetEnvironmentVariableUTF8('PATH'), PathSeparator,
|
||||||
[sffDontSearchInBasePath]);
|
Flags);
|
||||||
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,
|
||||||
LazUTF8.GetEnvironmentVariableUTF8('PATH'), PathSeparator,
|
LazUTF8.GetEnvironmentVariableUTF8('PATH'), PathSeparator,
|
||||||
[sffDontSearchInBasePath]);
|
Flags);
|
||||||
if Result<>'' then exit;
|
if Result<>'' then exit;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
@ -153,7 +153,7 @@ function ReadFileToString(const Filename: string): string;
|
|||||||
// file search
|
// file search
|
||||||
type
|
type
|
||||||
TSearchFileInPathFlag = (
|
TSearchFileInPathFlag = (
|
||||||
sffDontSearchInBasePath,
|
sffDontSearchInBasePath, // do not search in BasePath, search only in SearchPath.
|
||||||
sffSearchLoUpCase
|
sffSearchLoUpCase
|
||||||
);
|
);
|
||||||
TSearchFileInPathFlags = set of TSearchFileInPathFlag;
|
TSearchFileInPathFlags = set of TSearchFileInPathFlag;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<fpdoc-descriptions>
|
<fpdoc-descriptions>
|
||||||
<package name="lazutils">
|
<package name="lazutils">
|
||||||
<!--
|
<!--
|
||||||
@ -767,20 +767,10 @@ else
|
|||||||
</element>
|
</element>
|
||||||
<!-- function Visibility: default -->
|
<!-- function Visibility: default -->
|
||||||
<element name="SearchFileInPath">
|
<element name="SearchFileInPath">
|
||||||
<short>
|
<short><var>SearchFileInPath</var> - searches for <var>Filename</var> in the given <var>SearchPath</var> using the supplied <var>BasePath</var> with the specified <var>Delimiter</var> and the options listed in <var>Flags</var>
|
||||||
<var>SearchFileInPath</var> - searches for
|
|
||||||
<var>Filename</var> in the given
|
|
||||||
<var>SearchPath</var> using the supplied
|
|
||||||
<var>BasePath</var> with the specified
|
|
||||||
<var>Delimiter</var> and the options listed in
|
|
||||||
<var>Flags</var>
|
|
||||||
</short>
|
</short>
|
||||||
<descr>
|
<descr><p><printshort id="SearchFileInPath"/>
|
||||||
<p>
|
</p><p>Searches the whole path. Relative folder file names are expanded using BasePath. By default if BasePath is set it is searched as well, unless <var>sffDontSearchInBasePath</var> flag is present</p><p>Returns the first file that matches the supplied criteria</p>
|
||||||
<printshort id="SearchFileInPath"/>
|
|
||||||
</p>
|
|
||||||
<p>Searches the whole path unless the <var>sffDontSearchInBasePath</var> flag is present</p>
|
|
||||||
<p>Returns the first file that matches the supplied criteria</p>
|
|
||||||
</descr>
|
</descr>
|
||||||
<errors>If the file does not exist, an empty string is returned</errors>
|
<errors>If the file does not exist, an empty string is returned</errors>
|
||||||
</element>
|
</element>
|
||||||
@ -891,11 +881,7 @@ else
|
|||||||
<element name="FindDefaultExecutablePath">
|
<element name="FindDefaultExecutablePath">
|
||||||
<short>
|
<short>
|
||||||
<var>FindDefaultExecutablePath</var> - finds the default path to the named Executable file</short>
|
<var>FindDefaultExecutablePath</var> - finds the default path to the named Executable file</short>
|
||||||
<descr>
|
<descr><p><var>FindDefaultExecutablePath</var> - finds the default path to the named Executable file</p><p>On Windows systems it looks for both with and without the '.EXE' extension</p><p>If Executable is not an absolute filename the executable is searched using the environment variable PATH. Relative directories in PATH are expanded using BaseDir.</p><p>On non Unix systems (e.g. Windows) it searches in BaseDir as well. While on Unix systems (e.g. Linux, OS X) it only searches in BaseDir, if PATH contains the '.' directory.</p>
|
||||||
<p>
|
|
||||||
<var>FindDefaultExecutablePath</var> - finds the default path to the named Executable file</p>
|
|
||||||
<p>On Windows systems, looks for the '.EXE' extension</p>
|
|
||||||
<p>In all systems, searches the 'PATH' environment variable to see if the file is in one of the default paths</p>
|
|
||||||
</descr>
|
</descr>
|
||||||
</element>
|
</element>
|
||||||
<!-- function result Visibility: default -->
|
<!-- function result Visibility: default -->
|
||||||
|
Loading…
Reference in New Issue
Block a user