mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-29 22:57:25 +01:00
sysutils/GetEnvironmentVariable() now handles PATH lengths above 255 chars
git-svn-id: trunk@26832 -
This commit is contained in:
parent
e286a7462c
commit
1c930b5d24
@ -612,11 +612,54 @@ end;
|
|||||||
OS utility functions
|
OS utility functions
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
var
|
||||||
|
StrOfPaths: String;
|
||||||
|
|
||||||
|
function GetPathString: String;
|
||||||
|
var
|
||||||
|
f : text;
|
||||||
|
s : string;
|
||||||
|
tmpBat: string;
|
||||||
|
tmpList: string;
|
||||||
begin
|
begin
|
||||||
Result:=Dos.Getenv(shortstring(EnvVar));
|
s := '';
|
||||||
|
result := '';
|
||||||
|
|
||||||
|
tmpBat:='T:'+HexStr(FindTask(nil));
|
||||||
|
tmpList:=tmpBat+'_path.tmp';
|
||||||
|
tmpBat:=tmpBat+'_path.sh';
|
||||||
|
|
||||||
|
assign(f,tmpBat);
|
||||||
|
rewrite(f);
|
||||||
|
writeln(f,'path >'+tmpList);
|
||||||
|
close(f);
|
||||||
|
exec('C:Execute',tmpBat);
|
||||||
|
erase(f);
|
||||||
|
|
||||||
|
assign(f,tmpList);
|
||||||
|
reset(f);
|
||||||
|
{ skip the first line, garbage }
|
||||||
|
if not eof(f) then readln(f,s);
|
||||||
|
while not eof(f) do begin
|
||||||
|
readln(f,s);
|
||||||
|
if result = '' then
|
||||||
|
result := s
|
||||||
|
else
|
||||||
|
result := result + ';' + s;
|
||||||
|
end;
|
||||||
|
close(f);
|
||||||
|
erase(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
||||||
|
begin
|
||||||
|
if UpCase(envvar) = 'PATH' then begin
|
||||||
|
if StrOfpaths = '' then StrOfPaths := GetPathString;
|
||||||
|
Result:=StrOfPaths;
|
||||||
|
end else
|
||||||
|
Result:=Dos.Getenv(shortstring(EnvVar));
|
||||||
|
end;
|
||||||
|
|
||||||
Function GetEnvironmentVariableCount : Integer;
|
Function GetEnvironmentVariableCount : Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -709,6 +752,8 @@ Initialization
|
|||||||
InitInternational; { Initialize internationalization settings }
|
InitInternational; { Initialize internationalization settings }
|
||||||
OnBeep:=Nil; { No SysBeep() on MorphOS, for now. Figure out if we want
|
OnBeep:=Nil; { No SysBeep() on MorphOS, for now. Figure out if we want
|
||||||
to use intuition.library/DisplayBeep() for this (KB) }
|
to use intuition.library/DisplayBeep() for this (KB) }
|
||||||
|
StrOfPaths:='';
|
||||||
|
|
||||||
Finalization
|
Finalization
|
||||||
DoneExceptions;
|
DoneExceptions;
|
||||||
end.
|
end.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user