Przeglądaj źródła

sysutils/GetEnvironmentVariable() now handles PATH lengths above 255 chars

git-svn-id: trunk@26832 -
Károly Balogh 11 lat temu
rodzic
commit
1c930b5d24
1 zmienionych plików z 47 dodań i 2 usunięć
  1. 47 2
      rtl/morphos/sysutils.pp

+ 47 - 2
rtl/morphos/sysutils.pp

@@ -612,11 +612,54 @@ end;
                               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
+   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;
 
+Function GetEnvironmentVariable(Const EnvVar : String) : String;
 begin
-  Result:=Dos.Getenv(shortstring(EnvVar));
+  if UpCase(envvar) = 'PATH' then begin
+    if StrOfpaths = '' then StrOfPaths := GetPathString;
+    Result:=StrOfPaths;
+  end else
+    Result:=Dos.Getenv(shortstring(EnvVar));
 end;
+
 Function GetEnvironmentVariableCount : Integer;
 
 begin
@@ -709,6 +752,8 @@ Initialization
   InitInternational;    { Initialize internationalization settings }
   OnBeep:=Nil;          { No SysBeep() on MorphOS, for now. Figure out if we want 
                           to use intuition.library/DisplayBeep() for this (KB) }
+  StrOfPaths:='';
+
 Finalization
   DoneExceptions;
 end.