Browse Source

+ Added CurDirRelPath
* Exchanged hardcoded "./" to CurDirRelPath

olle 21 years ago
parent
commit
61645ef149
1 changed files with 27 additions and 6 deletions
  1. 27 6
      compiler/globals.pas

+ 27 - 6
compiler/globals.pas

@@ -281,7 +281,11 @@ interface
     function filetimestring( t : longint) : string;
     function filetimestring( t : longint) : string;
 
 
     procedure DefaultReplacements(var s:string);
     procedure DefaultReplacements(var s:string);
+    {Gives the absolute path to the current directory}
     function  GetCurrentDir:string;
     function  GetCurrentDir:string;
+    {Gives the relative path to the current directory, 
+     with a trailing dir separator. E. g. on unix ./ }
+    function CurDirRelPath(systeminfo: tsysteminfo): string;
     function  path_absolute(const s : string) : boolean;
     function  path_absolute(const s : string) : boolean;
     Function  PathExists ( F : String) : Boolean;
     Function  PathExists ( F : String) : Boolean;
     Function  FileExists ( Const F : String) : Boolean;
     Function  FileExists ( Const F : String) : Boolean;
@@ -463,6 +467,8 @@ implementation
 
 
      var
      var
        CachedCurrentDir : string;
        CachedCurrentDir : string;
+
+   {Gives the absolute path to the current directory}
    function GetCurrentDir:string;
    function GetCurrentDir:string;
      begin
      begin
        if CachedCurrentDir='' then
        if CachedCurrentDir='' then
@@ -473,6 +479,17 @@ implementation
        result:=CachedCurrentDir;
        result:=CachedCurrentDir;
      end;
      end;
 
 
+   {Gives the relative path to the current directory, 
+    with a trailing dir separator. E. g. on unix ./ }
+   function CurDirRelPath(systeminfo: tsysteminfo): string;
+
+   begin
+     if systeminfo.system <> system_powerpc_macos then
+       CurDirRelPath:= '.'+systeminfo.DirSep
+     else
+       CurDirRelPath:= ':'
+   end;
+    
 
 
    function path_absolute(const s : string) : boolean;
    function path_absolute(const s : string) : boolean;
    {
    {
@@ -1039,16 +1056,16 @@ implementation
 
 
          { fix pathname }
          { fix pathname }
          if currPath='' then
          if currPath='' then
-          currPath:='.'+source_info.DirSep
+           currPath:= CurDirRelPath(source_info)
          else
          else
           begin
           begin
             currPath:=FixPath(FExpand(currPath),false);
             currPath:=FixPath(FExpand(currPath),false);
             if (CurrentDir<>'') and (Copy(currPath,1,length(CurrentDir))=CurrentDir) then
             if (CurrentDir<>'') and (Copy(currPath,1,length(CurrentDir))=CurrentDir) then
              begin
              begin
 {$ifdef AMIGA}
 {$ifdef AMIGA}
-               currPath:=CurrentDir+Copy(currPath,length(CurrentDir)+1,255);
+               currPath:= CurrentDir+Copy(currPath,length(CurrentDir)+1,255);
 {$else}
 {$else}
-               currPath:='.'+source_info.DirSep+Copy(currPath,length(CurrentDir)+1,255);
+               currPath:= CurDirRelPath(source_info)+Copy(currPath,length(CurrentDir)+1,255);
 {$endif}
 {$endif}
              end;
              end;
           end;
           end;
@@ -1392,7 +1409,7 @@ implementation
       { later, this should be replaced by the math unit }
       { later, this should be replaced by the math unit }
       const
       const
         Default8087CW : word = $1332;
         Default8087CW : word = $1332;
-	
+  
       procedure Set8087CW(cw:word);assembler;
       procedure Set8087CW(cw:word);assembler;
         asm
         asm
           movw cw,%ax
           movw cw,%ax
@@ -1424,7 +1441,7 @@ implementation
       { later, this should be replaced by the math unit }
       { later, this should be replaced by the math unit }
       const
       const
         Default8087CW : word = $1332;
         Default8087CW : word = $1332;
-	
+  
       procedure Set8087CW(cw:word);assembler;
       procedure Set8087CW(cw:word);assembler;
         asm
         asm
           movw cw,%ax
           movw cw,%ax
@@ -2030,7 +2047,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.141  2004-09-21 23:33:43  hajny
+  Revision 1.142  2004-10-09 11:27:59  olle
+    + Added CurDirRelPath
+    * Exchanged hardcoded "./" to CurDirRelPath
+
+  Revision 1.141  2004/09/21 23:33:43  hajny
     * better PathExists, fix for too long command line, correction of message
     * better PathExists, fix for too long command line, correction of message
 
 
   Revision 1.140  2004/09/21 19:59:51  peter
   Revision 1.140  2004/09/21 19:59:51  peter