Browse Source

--- Merging r18186 into '.':
U rtl/go32v2/sysutils.pp
U rtl/emx/sysutils.pp
U rtl/os2/sysutils.pp
--- Merging r18189 into '.':
G rtl/go32v2/sysutils.pp
--- Merging r18844 into '.':
U rtl/os2/doscalls.pas

# revisions: 18186,18189,18844
------------------------------------------------------------------------
r18186 | hajny | 2011-08-13 02:06:14 +0200 (Sat, 13 Aug 2011) | 1 line
Changed paths:
M /trunk/rtl/emx/sysutils.pp
M /trunk/rtl/go32v2/sysutils.pp
M /trunk/rtl/os2/sysutils.pp

* fix for DirectoryExists - proper handling of root directory
------------------------------------------------------------------------
------------------------------------------------------------------------
r18189 | hajny | 2011-08-13 20:18:15 +0200 (Sat, 13 Aug 2011) | 1 line
Changed paths:
M /trunk/rtl/go32v2/sysutils.pp

* fix for a silly typo in the previous revision
------------------------------------------------------------------------
------------------------------------------------------------------------
r18844 | hajny | 2011-08-25 23:19:44 +0200 (Thu, 25 Aug 2011) | 1 line
Changed paths:
M /trunk/rtl/os2/doscalls.pas

* 64-bit versions of TFileStatus* and TFileFindBuf* types added
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_6@18953 -

marco 14 years ago
parent
commit
51d63ea3ec
4 changed files with 72 additions and 51 deletions
  1. 28 33
      rtl/emx/sysutils.pp
  2. 6 10
      rtl/go32v2/sysutils.pp
  3. 23 4
      rtl/os2/doscalls.pas
  4. 15 4
      rtl/os2/sysutils.pp

+ 28 - 33
rtl/emx/sysutils.pp

@@ -578,22 +578,14 @@ begin
 end;
 end;
 
 
 
 
-function FileExists (const FileName: string): boolean; assembler;
-asm
-{$IFDEF REGCALL}
- mov edx, eax
-{$ELSE REGCALL}
- mov edx, FileName
-{$ENDIF REGCALL}
- mov ax, 4300h
- call syscall
- mov eax, 0
- jc @FExistsEnd
- test cx, 18h
- jnz @FExistsEnd
- inc eax
-@FExistsEnd:
-end {['eax', 'ecx', 'edx']};
+function FileExists (const FileName: string): boolean;
+begin
+  if Directory = '' then
+   Result := false
+  else
+   Result := FileGetAttr (ExpandFileName (Directory)) and
+                                                     faDirectory = faDirectory;
+end;
 
 
 
 
 type    TRec = record
 type    TRec = record
@@ -970,29 +962,32 @@ begin
 end;
 end;
 
 
 
 
-{$ASMMODE INTEL}
-function DirectoryExists (const Directory: string): boolean; assembler;
-asm
-{$IFDEF REGCALL}
- mov edx, eax
-{$ELSE REGCALL}
- mov edx, Directory
-{$ENDIF REGCALL}
- mov ax, 4300h
- call syscall
- mov eax, 0
- jc @FExistsEnd
- test cx, 10h
- jz @FExistsEnd
- inc eax
-@FExistsEnd:
-end {['eax', 'ecx', 'edx']};
+function DirectoryExists (const Directory: string): boolean;
+var
+  L: longint;
+begin
+  if Directory = '' then
+   Result := false
+  else
+   begin
+    if (Directory [Length (Directory)] in AllowDirectorySeparators) and
+                                              (Length (Directory) > 1) and
+(* Do not remove '\' after ':' (root directory of a drive) 
+   or in '\\' (invalid path, possibly broken UNC path). *)
+      not (Directory [Length (Directory) - 1] in AllowDriveSeparators + AllowDirectorySeparators) then
+     L := FileGetAttr (ExpandFileName (Copy (Directory, 1, Length (Directory) - 1)))
+    else
+     L := FileGetAttr (ExpandFileName (Directory));
+    Result := (L > 0) and (L and faDirectory = faDirectory);
+   end;
+end;
 
 
 
 
 {****************************************************************************
 {****************************************************************************
                               Time Functions
                               Time Functions
 ****************************************************************************}
 ****************************************************************************}
 
 
+{$ASMMODE INTEL}
 procedure GetLocalTime (var SystemTime: TSystemTime); assembler;
 procedure GetLocalTime (var SystemTime: TSystemTime); assembler;
 asm
 asm
 (* Expects the default record alignment (word)!!! *)
 (* Expects the default record alignment (word)!!! *)

+ 6 - 10
rtl/go32v2/sysutils.pp

@@ -302,7 +302,6 @@ end;
 
 
 Function DirectoryExists (Const Directory : String) : Boolean;
 Function DirectoryExists (Const Directory : String) : Boolean;
 Var
 Var
-  Sr : Searchrec;
   Dir : String;
   Dir : String;
   drive : byte;
   drive : byte;
   StoredIORes : longint;
   StoredIORes : longint;
@@ -334,16 +333,13 @@ begin
 {$ifdef OPT_I}
 {$ifdef OPT_I}
   {$I+}
   {$I+}
 {$endif}
 {$endif}
-  if (length(dir)>1) and (dir[length(dir)] in ['/','\']) then
+  if (Length (Dir) > 1) and
+    (Dir [Length (Dir)] in AllowDirectorySeparators) and
+(* Do not remove '\' after ':' (root directory of a drive) 
+   or in '\\' (invalid path, possibly broken UNC path). *)
+     not (Dir [Length (Dir) - 1] in (AllowDriveSeparators + AllowDirectorySeparators)) then
     dir:=copy(dir,1,length(dir)-1);
     dir:=copy(dir,1,length(dir)-1);
-  DOS.FindFirst(Dir,$3f,sr);
-  if DosError = 0 then
-   begin
-     Result:=(sr.attr and $10)=$10;
-     Dos.FindClose(sr);
-   end
-  else
-   Result:=false;
+  Result := FileGetAttr (Dir) and faDirectory = faDirectory;
 end;
 end;
 
 
 
 

+ 23 - 4
rtl/os2/doscalls.pas

@@ -1087,12 +1087,12 @@ const   faReadOnly      =  1;
         faDirectory     = 16;
         faDirectory     = 16;
         faArchive       = 32;
         faArchive       = 32;
 
 
-        ilStandard      =  1;
-        ilQueryEASize   =  2;
+        ilStandard      =  1; (* Use TFileStatus3/TFindFileBuf3 *)
+        ilQueryEASize   =  2; (* Use TFileStatus4/TFindFileBuf4 *)
         ilQueryEAs      =  3;
         ilQueryEAs      =  3;
         ilQueryFullName =  5;
         ilQueryFullName =  5;
-        ilStandardL     = 11;
-        ilQueryEASizeL  = 12;
+        ilStandardL     = 11; (* Use TFileStatus3L/TFindFileBuf3L *)
+        ilQueryEASizeL  = 12; (* Use TFileStatus4L/TFindFileBuf4L *)
         ilQueryEAsL     = 13;
         ilQueryEAsL     = 13;
 
 
         FIL_Standard    = ilStandard;
         FIL_Standard    = ilStandard;
@@ -1138,6 +1138,25 @@ type
         end;
         end;
         PFileStatus4=^TFileStatus4;
         PFileStatus4=^TFileStatus4;
 
 
+        TFileStatus3L = object (TFileStatus)
+            DateCreation,               {Date of file creation.}
+            TimeCreation,               {Time of file creation.}
+            DateLastAccess,             {Date of last access to file.}
+            TimeLastAccess,             {Time of last access to file.}
+            DateLastWrite,              {Date of last modification of file.}
+            TimeLastWrite:word;         {Time of last modification of file.}
+            FileSize,                   {Size of file.}
+            FileAlloc:int64;         {Amount of space the file really
+                                         occupies on disk.}
+            AttrFile:cardinal;          {Attributes of file.}
+        end;
+        PFileStatus3L=^TFileStatus3L;
+
+        TFileStatus4L=object(TFileStatus3L)
+            cbList:cardinal;            {Length of entire EA set.}
+        end;
+        PFileStatus4L=^TFileStatus4L;
+
         TFileFindBuf3=object(TFileStatus)
         TFileFindBuf3=object(TFileStatus)
             NextEntryOffset: cardinal;  {Offset of next entry}
             NextEntryOffset: cardinal;  {Offset of next entry}
             DateCreation,               {Date of file creation.}
             DateCreation,               {Date of file creation.}

+ 15 - 4
rtl/os2/sysutils.pp

@@ -817,11 +817,22 @@ end;
 
 
 function DirectoryExists (const Directory: string): boolean;
 function DirectoryExists (const Directory: string): boolean;
 var
 var
-  SR: TSearchRec;
+  L: longint;
 begin
 begin
-  DirectoryExists := (FindFirst (Directory, faAnyFile, SR) = 0) and
-                                                (SR.Attr and faDirectory <> 0);
-  FindClose(SR);
+  if Directory = '' then
+   Result := false
+  else
+   begin
+    if (Directory [Length (Directory)] in AllowDirectorySeparators) and
+                                              (Length (Directory) > 1) and
+(* Do not remove '\' after ':' (root directory of a drive) 
+   or in '\\' (invalid path, possibly broken UNC path). *)
+      not (Directory [Length (Directory) - 1] in AllowDriveSeparators + AllowDirectorySeparators) then
+     L := FileGetAttr (ExpandFileName (Copy (Directory, 1, Length (Directory) - 1)))
+    else
+     L := FileGetAttr (ExpandFileName (Directory));
+    Result := (L > 0) and (L and faDirectory = faDirectory);
+   end;
 end;
 end;
 
 
 {****************************************************************************
 {****************************************************************************