Browse Source

+ Fixed such that TDosStream functions correctly.

michael 27 years ago
parent
commit
761c27abbc
1 changed files with 13 additions and 10 deletions
  1. 13 10
      rtl/linux/objinc.inc

+ 13 - 10
rtl/linux/objinc.inc

@@ -11,17 +11,20 @@ Var errno : Longint;
 
 
 FUNCTION FileOpen (Var FileName: AsciiZ; Mode: Word): THandle;
 FUNCTION FileOpen (Var FileName: AsciiZ; Mode: Word): THandle;
 
 
-Var LinuxMode : Word;
-
+Var LinuxMode : longint;
+    
 BEGIN
 BEGIN
   LinuxMode:=0;
   LinuxMode:=0;
-  if (Mode and stCreate)=stCreate then LinuxMode:=Open_Creat;
-  if (Mode and stOpenRead)=stOpenRead then LinuxMode:=LinuxMode or Open_RdOnly;
-  If (Mode and stOpenWrite)=stOpenWrite then LinuxMode:=LinuxMode or Open_WrOnly;
-  if (Mode and stOpen)=stOpen then LinuxMode:=LinuxMode or Open_RdWr;
-  FileOpen:=SYS_Open (pchar(@FileName[0]),438 {666 octal},LinuxMode);
+  if (Mode and stCreate)=stCreate then
+     LinuxMode:=Open_Creat;
+  Case (Mode and 3) of
+  0 : LinuxMode:=LinuxMode or Open_RdOnly;
+  1 : LinuxMode:=LinuxMode or Open_WrOnly;
+  2 : LinuxMode:=LinuxMode or Open_RdWr;
+  end;
+  FileOpen:=SYS_Open (pchar(@FileName[0]),LinuxMode,438 {666 octal});
+  If FileOpen=-1 then FileOpen:=0;
   DosStreamError:=Errno;
   DosStreamError:=Errno;
-  FileOpen:=Errno;
 END;
 END;
 
 
 FUNCTION FileRead (Handle: THandle; Var BufferArea; BufferLength: Sw_Word;
 FUNCTION FileRead (Handle: THandle; Var BufferArea; BufferLength: Sw_Word;
@@ -29,7 +32,7 @@ Var BytesMoved: Sw_Word): Word;
 BEGIN
 BEGIN
   BytesMoved:=Sys_read (Handle,Pchar(@BufferArea),BufferLength);
   BytesMoved:=Sys_read (Handle,Pchar(@BufferArea),BufferLength);
   DosStreamError:=Errno;
   DosStreamError:=Errno;
-  FileRead := Errno;
+  FileRead:=Errno;
 END;
 END;
 
 
 FUNCTION FileWrite (Handle:  THandle; Var BufferArea; BufferLength: Sw_Word;
 FUNCTION FileWrite (Handle:  THandle; Var BufferArea; BufferLength: Sw_Word;
@@ -65,7 +68,7 @@ Var sr : syscallregs;
 BEGIN
 BEGIN
   sr.reg2:=Handle;
   sr.reg2:=Handle;
   sr.reg3:=FileSize;
   sr.reg3:=FileSize;
-  Syscall(syscall_nr_Truncate,sr);
+  Syscall(syscall_nr_fTruncate,sr);
   If Errno=0 then  
   If Errno=0 then  
     SetFileSize:=0
     SetFileSize:=0
   else
   else