Browse Source

+ io-error 103 added

peter 27 years ago
parent
commit
97bbe41037
3 changed files with 105 additions and 43 deletions
  1. 8 2
      rtl/dos/go32v1/system.pp
  2. 6 1
      rtl/dos/go32v2/system.pp
  3. 91 40
      rtl/inc/file.inc

+ 8 - 2
rtl/dos/go32v1/system.pp

@@ -86,6 +86,7 @@ type
 var
 var
   stub_info       : p_stub_info;
   stub_info       : p_stub_info;
   go32_info_block : t_go32_info_block;
   go32_info_block : t_go32_info_block;
+  LFNSupport : boolean;
 
 
 { Needed for CRT unit }
 { Needed for CRT unit }
 function do_read(h,addr,len : longint) : longint;
 function do_read(h,addr,len : longint) : longint;
@@ -138,7 +139,6 @@ begin
   end['EAX','EBX'];
   end['EAX','EBX'];
   HandleError(202);
   HandleError(202);
 end;
 end;
-{$I386_ATT}
 
 
 procedure halt(errnum : byte);
 procedure halt(errnum : byte);
 begin
 begin
@@ -227,6 +227,9 @@ asm
         pushl   %ebp
         pushl   %ebp
         intl    $0x21
         intl    $0x21
         popl    %ebp
         popl    %ebp
+        jnc     .LCLOSE1
+        movw    %ax,inoutres
+.LCLOSE1:
 end;
 end;
 
 
 
 
@@ -609,7 +612,10 @@ Begin
 End.
 End.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  1998-11-16 14:15:01  pierre
+  Revision 1.11  1998-11-29 22:28:09  peter
+    + io-error 103 added
+
+  Revision 1.10  1998/11/16 14:15:01  pierre
     * changed getdir(byte,string) to getdir(byte,shortstring)
     * changed getdir(byte,string) to getdir(byte,shortstring)
 
 
   Revision 1.9  1998/09/14 10:48:03  peter
   Revision 1.9  1998/09/14 10:48:03  peter

+ 6 - 1
rtl/dos/go32v2/system.pp

@@ -721,6 +721,8 @@ begin
 {$endif SYSTEMDEBUG}
 {$endif SYSTEMDEBUG}
   regs.realeax:=$3e00;
   regs.realeax:=$3e00;
   sysrealintr($21,regs);
   sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   InOutRes:=lo(regs.realeax);
 end;
 end;
 
 
 
 
@@ -1225,7 +1227,10 @@ Begin
 End.
 End.
 {
 {
   $Log$
   $Log$
-  Revision 1.23  1998-11-16 14:15:02  pierre
+  Revision 1.24  1998-11-29 22:28:10  peter
+    + io-error 103 added
+
+  Revision 1.23  1998/11/16 14:15:02  pierre
     * changed getdir(byte,string) to getdir(byte,shortstring)
     * changed getdir(byte,string) to getdir(byte,shortstring)
 
 
   Revision 1.22  1998/10/26 14:49:46  pierre
   Revision 1.22  1998/10/26 14:49:46  pierre

+ 91 - 40
rtl/inc/file.inc

@@ -56,6 +56,15 @@ Procedure Rewrite(var f:File;l:Longint);[IOCheck];
 Begin
 Begin
   If InOutRes <> 0 then
   If InOutRes <> 0 then
    exit;
    exit;
+  Case FileRec(f).mode Of
+   fmInOut : Close(f);
+   fmClosed : ;
+  else
+   Begin
+     InOutRes:=102;
+     exit;
+   End;
+  End;
   If l=0 Then
   If l=0 Then
    InOutRes:=2
    InOutRes:=2
   else
   else
@@ -73,6 +82,15 @@ Procedure Reset(var f:File;l:Longint);[IOCheck];
 Begin
 Begin
   If InOutRes <> 0 then
   If InOutRes <> 0 then
    Exit;
    Exit;
+  Case FileRec(f).mode Of
+   fmInOut : Close(f);
+   fmClosed : ;
+  else
+   Begin
+     InOutRes:=102;
+     exit;
+   End;
+  End;
   If l=0 Then
   If l=0 Then
    InOutRes:=2
    InOutRes:=2
   else
   else
@@ -110,7 +128,14 @@ Procedure BlockWrite(Var f:File;Var Buf;Count:Longint;var Result:Longint);[IOChe
   Write Count records from Buf to file f, return written records in result
   Write Count records from Buf to file f, return written records in result
 }
 }
 Begin
 Begin
-  If InOutRes <> 0 then exit;
+  Result:=0;
+  If InOutRes <> 0 then
+   exit;
+  if FileRec(f).Mode<>fmInOut then
+   begin
+     InOutRes:=103;
+     exit;
+   end;
   Result:=Do_Write(FileRec(f).Handle,Longint(@Buf),Count*FileRec(f).RecSize) div FileRec(f).RecSize;
   Result:=Do_Write(FileRec(f).Handle,Longint(@Buf),Count*FileRec(f).RecSize) div FileRec(f).RecSize;
 End;
 End;
 
 
@@ -122,8 +147,6 @@ Procedure BlockWrite(Var f:File;Var Buf;Count:Word;var Result:Word);[IOCheck];
 var
 var
   l : longint;
   l : longint;
 Begin
 Begin
-  If InOutRes <> 0 then
-   exit;
   BlockWrite(f,Buf,Count,l);
   BlockWrite(f,Buf,Count,l);
   Result:=l;
   Result:=l;
 End;
 End;
@@ -136,8 +159,6 @@ Procedure BlockWrite(Var f:File;Var Buf;Count:Word;var Result:Integer);[IOCheck]
 var
 var
   l : longint;
   l : longint;
 Begin
 Begin
-  If InOutRes <> 0 then
-   exit;
   BlockWrite(f,Buf,Count,l);
   BlockWrite(f,Buf,Count,l);
   Result:=l;
   Result:=l;
 End;
 End;
@@ -151,8 +172,6 @@ Procedure BlockWrite(Var f:File;Var Buf;Count:Longint);[IOCheck];
 var
 var
   Result : Longint;
   Result : Longint;
 Begin
 Begin
-  If InOutRes <> 0 then
-   exit;
   BlockWrite(f,Buf,Count,Result);
   BlockWrite(f,Buf,Count,Result);
   If (Result=0) and (Count>0) Then
   If (Result=0) and (Count>0) Then
    InOutRes:=101;
    InOutRes:=101;
@@ -165,9 +184,12 @@ Procedure BlockRead(var f:File;var Buf;Count:Longint;var Result:Longint);[IOChec
   Result
   Result
 }
 }
 Begin
 Begin
+  Result:=0;
   If InOutRes <> 0 then
   If InOutRes <> 0 then
+   exit;
+  if FileRec(f).Mode<>fmInOut then
    begin
    begin
-     Result:=0;
+     InOutRes:=103;
      exit;
      exit;
    end;
    end;
   Result:=Do_Read(FileRec(f).Handle,Longint(@Buf),count*FileRec(f).RecSize) div FileRec(f).RecSize;
   Result:=Do_Read(FileRec(f).Handle,Longint(@Buf),count*FileRec(f).RecSize) div FileRec(f).RecSize;
@@ -182,11 +204,6 @@ Procedure BlockRead(var f:File;var Buf;count:Word;var Result:Word);[IOCheck];
 var
 var
   l : longint;
   l : longint;
 Begin
 Begin
-  If InOutRes <> 0 then
-   begin
-     Result:=0;
-     exit;
-   end;
   BlockRead(f,Buf,Count,l);
   BlockRead(f,Buf,Count,l);
   Result:=l;
   Result:=l;
 End;
 End;
@@ -200,11 +217,6 @@ Procedure BlockRead(var f:File;var Buf;count:Word;var Result:Integer);[IOCheck];
 var
 var
   l : longint;
   l : longint;
 Begin
 Begin
-  If InOutRes <> 0 then
-   begin
-     Result:=0;
-     exit;
-   end;
   BlockRead(f,Buf,Count,l);
   BlockRead(f,Buf,Count,l);
   Result:=l;
   Result:=l;
 End;
 End;
@@ -218,8 +230,6 @@ Procedure BlockRead(Var f:File;Var Buf;Count:Longint);[IOCheck];
 var
 var
   Result : Longint;
   Result : Longint;
 Begin
 Begin
-  If InOutRes <> 0 then
-   exit;
   BlockRead(f,Buf,Count,Result);
   BlockRead(f,Buf,Count,Result);
   If (Result=0) and (Count>0) Then
   If (Result=0) and (Count>0) Then
    InOutRes:=100;
    InOutRes:=100;
@@ -231,10 +241,15 @@ Function FilePos(var f:File):Longint;[IOCheck];
   Return current Position In file f in records
   Return current Position In file f in records
 }
 }
 Begin
 Begin
+  FilePos:=0;
   If InOutRes <> 0 then
   If InOutRes <> 0 then
-   FilePos:=0
-  else
-   FilePos:=Do_FilePos(FileRec(f).Handle) div FileRec(f).RecSize;
+   exit;
+  if FileRec(f).Mode<>fmInOut then
+   begin
+     InOutRes:=103;
+     exit;
+   end;
+  FilePos:=Do_FilePos(FileRec(f).Handle) div FileRec(f).RecSize;
 End;
 End;
 
 
 
 
@@ -243,9 +258,15 @@ Function FileSize(var f:File):Longint;[IOCheck];
   Return the size of file f in records
   Return the size of file f in records
 }
 }
 Begin
 Begin
-  if (InOutRes<>0) or (FileRec(f).RecSize=0) then
-   FileSize:=0
-  else
+  FileSize:=0;
+  If InOutRes <> 0 then
+   exit;
+  if FileRec(f).Mode<>fmInOut then
+   begin
+     InOutRes:=103;
+     exit;
+   end;
+  if (FileRec(f).RecSize>0) then
    FileSize:=Do_FileSize(FileRec(f).Handle) div FileRec(f).RecSize;
    FileSize:=Do_FileSize(FileRec(f).Handle) div FileRec(f).RecSize;
 End;
 End;
 
 
@@ -255,7 +276,14 @@ Function Eof(var f:File):Boolean;[IOCheck];
   Return True if we're at the end of the file f, else False is returned
   Return True if we're at the end of the file f, else False is returned
 }
 }
 Begin
 Begin
-  If InOutRes <> 0 then exit;
+  Eof:=false;
+  If InOutRes <> 0 then
+   exit;
+  if FileRec(f).Mode<>fmInOut then
+   begin
+     InOutRes:=103;
+     exit;
+   end;
   {Can't use do_ routines because we need record support}
   {Can't use do_ routines because we need record support}
   Eof:=(FileSize(f)<=FilePos(f));
   Eof:=(FileSize(f)<=FilePos(f));
 End;
 End;
@@ -266,7 +294,13 @@ Procedure Seek(var f:File;Pos:Longint);[IOCheck];
   Goto record Pos in file f
   Goto record Pos in file f
 }
 }
 Begin
 Begin
-  If InOutRes <> 0 then exit;
+  If InOutRes <> 0 then
+   exit;
+  if FileRec(f).Mode<>fmInOut then
+   begin
+     InOutRes:=103;
+     exit;
+   end;
   Do_Seek(FileRec(f).Handle,Pos*FileRec(f).RecSize);
   Do_Seek(FileRec(f).Handle,Pos*FileRec(f).RecSize);
 End;
 End;
 
 
@@ -276,7 +310,13 @@ Procedure Truncate(Var f:File);[IOCheck];
   Truncate/Cut file f at the current record Position
   Truncate/Cut file f at the current record Position
 }
 }
 Begin
 Begin
-  If InOutRes <> 0 then exit;
+  If InOutRes <> 0 then
+   exit;
+  if FileRec(f).Mode<>fmInOut then
+   begin
+     InOutRes:=103;
+     exit;
+   end;
   Do_Truncate(FileRec(f).Handle,FilePos(f)*FileRec(f).RecSize);
   Do_Truncate(FileRec(f).Handle,FilePos(f)*FileRec(f).RecSize);
 End;
 End;
 
 
@@ -286,18 +326,23 @@ Procedure Close(var f:File);[IOCheck];
   Close file f
   Close file f
 }
 }
 Begin
 Begin
-  If InOutRes <> 0 then exit;
-  If (FileRec(f).mode<>fmClosed) Then
-   Begin
-     FileRec(f).mode:=fmClosed;
-     Do_Close(FileRec(f).Handle);
-   End;
+  If InOutRes <> 0 then
+   exit;
+  if FileRec(f).Mode<>fmInOut then
+   begin
+     InOutRes:=103;
+     exit;
+   end;
+  FileRec(f).mode:=fmClosed;
+  if FileRec(f).Handle>4 then
+   Do_Close(FileRec(f).Handle);
 End;
 End;
 
 
 
 
 Procedure Erase(var f : File);[IOCheck];
 Procedure Erase(var f : File);[IOCheck];
 Begin
 Begin
-  If InOutRes <> 0 then exit;
+  If InOutRes <> 0 then
+   exit;
   If FileRec(f).mode=fmClosed Then
   If FileRec(f).mode=fmClosed Then
    Do_Erase(PChar(@FileRec(f).Name));
    Do_Erase(PChar(@FileRec(f).Name));
 End;
 End;
@@ -305,7 +350,8 @@ End;
 
 
 Procedure Rename(var f : File;p:pchar);[IOCheck];
 Procedure Rename(var f : File;p:pchar);[IOCheck];
 Begin
 Begin
-  If InOutRes <> 0 then exit;
+  If InOutRes <> 0 then
+   exit;
   If FileRec(f).mode=fmClosed Then
   If FileRec(f).mode=fmClosed Then
    Begin
    Begin
      Do_Rename(PChar(@FileRec(f).Name),p);
      Do_Rename(PChar(@FileRec(f).Name),p);
@@ -318,7 +364,8 @@ Procedure Rename(var f : File;const s : string);[IOCheck];
 var
 var
   p : array[0..255] Of Char;
   p : array[0..255] Of Char;
 Begin
 Begin
-  If InOutRes <> 0 then exit;
+  If InOutRes <> 0 then
+   exit;
   Move(s[1],p,Length(s));
   Move(s[1],p,Length(s));
   p[Length(s)]:=#0;
   p[Length(s)]:=#0;
   Rename(f,Pchar(@p));
   Rename(f,Pchar(@p));
@@ -329,7 +376,8 @@ Procedure Rename(var f : File;c : char);[IOCheck];
 var
 var
   p : array[0..1] Of Char;
   p : array[0..1] Of Char;
 Begin
 Begin
-  If InOutRes <> 0 then exit;
+  If InOutRes <> 0 then
+   exit;
   p[0]:=c;
   p[0]:=c;
   p[1]:=#0;
   p[1]:=#0;
   Rename(f,Pchar(@p));
   Rename(f,Pchar(@p));
@@ -337,7 +385,10 @@ End;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.8  1998-09-17 16:34:16  peter
+  Revision 1.9  1998-11-29 22:28:11  peter
+    + io-error 103 added
+
+  Revision 1.8  1998/09/17 16:34:16  peter
     * new eof,eoln,seekeoln,seekeof
     * new eof,eoln,seekeoln,seekeof
     * speed upgrade for read_string
     * speed upgrade for read_string
     * inoutres 104/105 updates for read_* and write_*
     * inoutres 104/105 updates for read_* and write_*