[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lost] [Patch] Pascal RTL: DirectoryExists



Dieser Patch erweitert die Pascal RTL um die Funktion DirectoryExists.
Index: src/modules/pas/lib/rtl/sysutils.pp
===================================================================
--- src/modules/pas/lib/rtl/sysutils.pp	(Revision 636)
+++ src/modules/pas/lib/rtl/sysutils.pp	(Arbeitskopie)
@@ -39,6 +39,11 @@
     SEEK_CUR = 1;
     SEEK_END = 2;
 
+
+
+function c_opendir(dirname: PChar): longint; cdecl; external name 'opendir';
+function c_closedir(dir: longint): longint; cdecl; external name 'closedir';
+
 function c_fopen(filename, mode: PChar): longint; cdecl; external name 'fopen';
 function c_fclose(f: longint): integer; cdecl; external name 'fclose';
 
@@ -190,11 +195,22 @@
     Result := 0; // FIXME
 end;    
 
-function DirectoryExists(const directory: AnsiString):Boolean;
+function DirectoryExists(const Directory: AnsiString) : Boolean;
+var
+    handle: longint;
+    cDirName: String;
 begin
-    Result := true; // FIXME
+    cDirName := Directory + #0;
+    handle := c_opendir(@cDirName[1]);
+    
+    DirectoryExists := handle <> 0;
+    if DirectoryExists then begin
+        c_closedir(handle);
+    end;
 end;
 
+
+
 function FindFirst(const path: AnsiString; attr: LongInt;out rslt: TSearchRec):LongInt;
 begin
     Result := 0; // FIXME