Browse Source

pastojs: fixed DirectoryExists

mattias 5 years ago
parent
commit
4ecdea7f66
1 changed files with 13 additions and 1 deletions
  1. 13 1
      compiler/packages/pastojs/src/pas2jsfilecache.pp

+ 13 - 1
compiler/packages/pastojs/src/pas2jsfilecache.pp

@@ -906,13 +906,25 @@ end;
 function TPas2jsCachedDirectories.DirectoryExists(Filename: string): boolean;
 function TPas2jsCachedDirectories.DirectoryExists(Filename: string): boolean;
 var
 var
   Info: TFileInfo;
   Info: TFileInfo;
+  Dir: TPas2jsCachedDirectory;
 begin
 begin
   Info.Filename:=Filename;
   Info.Filename:=Filename;
   if not GetFileInfo(Info) then exit(false);
   if not GetFileInfo(Info) then exit(false);
   if Info.Dir<>nil then
   if Info.Dir<>nil then
     Result:=(Info.Dir.FileAttr(Info.ShortFilename) and faDirectory)>0
     Result:=(Info.Dir.FileAttr(Info.ShortFilename) and faDirectory)>0
   else
   else
-    Result:={$IFDEF pas2js}NodeJSFS{$ELSE}SysUtils{$ENDIF}.DirectoryExists(Info.Filename);
+    begin
+    Dir:=GetDirectory(Filename,true,false);
+    if Dir<>nil then
+      Result:=Dir.Count>0
+    else
+      begin
+      Filename:=ChompPathDelim(ResolveDots(Filename));
+      if not FilenameIsAbsolute(Filename) then
+        Filename:=WorkingDirectory+Filename;
+      Result:={$IFDEF pas2js}NodeJSFS{$ELSE}SysUtils{$ENDIF}.DirectoryExists(Filename);
+      end;
+    end;
 end;
 end;
 
 
 function TPas2jsCachedDirectories.FileExists(Filename: string): boolean;
 function TPas2jsCachedDirectories.FileExists(Filename: string): boolean;