Bläddra i källkod

* fixed findfirst,getfattr,setfattr.

git-svn-id: trunk@4109 -
yury 19 år sedan
förälder
incheckning
2ee656c1ad
1 ändrade filer med 30 tillägg och 15 borttagningar
  1. 30 15
      rtl/wince/dos.pp

+ 30 - 15
rtl/wince/dos.pp

@@ -347,6 +347,11 @@ procedure findfirst(const path : pathstr;attr : word;var f : searchRec);
 var
 var
   buf: array[0..MaxPathLen] of WideChar;
   buf: array[0..MaxPathLen] of WideChar;
 begin
 begin
+  if path = ''then
+    begin
+      DosError:=3;
+      exit;
+    end;
   fillchar(f,sizeof(f),0);
   fillchar(f,sizeof(f),0);
   { no error }
   { no error }
   doserror:=0;
   doserror:=0;
@@ -479,19 +484,27 @@ end;
 
 
 procedure getfattr(var f;var attr : word);
 procedure getfattr(var f;var attr : word);
 var
 var
-  l : longint;
+  l : cardinal;
   buf: array[0..MaxPathLen] of WideChar;
   buf: array[0..MaxPathLen] of WideChar;
 begin
 begin
-  doserror:=0;
-  AnsiToWideBuf(@filerec(f).name, -1, buf, SizeOf(buf));
-  l:=GetFileAttributes(buf);
-  if l=longint($ffffffff) then
-   begin
-     doserror:=Last2DosError(GetLastError);
-     attr:=0;
-   end
+  if filerec(f).name[1] = #0 then 
+    begin
+      doserror:=3;
+      attr:=0;
+    end
   else
   else
-   attr:=l and $ffff;
+    begin  
+      doserror:=0;
+      AnsiToWideBuf(@filerec(f).name, -1, buf, SizeOf(buf));
+      l:=GetFileAttributes(buf);
+      if l = $ffffffff then
+       begin
+         doserror:=Last2DosError(GetLastError);
+         attr:=0;
+       end
+      else
+       attr:=l and $ffff;
+    end;   
 end;
 end;
 
 
 
 
@@ -503,11 +516,13 @@ begin
   if (attr and VolumeID)<>0 then
   if (attr and VolumeID)<>0 then
     doserror:=5
     doserror:=5
   else
   else
-   AnsiToWideBuf(@filerec(f).name, -1, buf, SizeOf(buf));
-   if SetFileAttributes(buf,attr) then
-    doserror:=0
-  else
-    doserror:=Last2DosError(GetLastError);
+    begin
+      AnsiToWideBuf(@filerec(f).name, -1, buf, SizeOf(buf));
+      if SetFileAttributes(buf,attr) then
+        doserror:=0
+      else
+        doserror:=Last2DosError(GetLastError);
+    end;  
 end;
 end;
 
 
 {******************************************************************************
 {******************************************************************************