mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 04:26:13 +02:00
* fix returned value for FileRead and FileWrite in case of an error and change the default sharing mode to doDenyRW to be compatible with other platforms
git-svn-id: trunk@29668 -
This commit is contained in:
parent
97a902eb14
commit
d676a503c0
@ -80,9 +80,9 @@ Var
|
|||||||
Rc, Action: cardinal;
|
Rc, Action: cardinal;
|
||||||
begin
|
begin
|
||||||
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
|
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
|
||||||
(* DenyNone if sharing not specified. *)
|
(* DenyReadWrite if sharing not specified. *)
|
||||||
if (Mode and 112 = 0) or (Mode and 112 > 64) then
|
if (Mode and 112 = 0) or (Mode and 112 > 64) then
|
||||||
Mode := Mode or 64;
|
Mode := Mode or doDenyRW;
|
||||||
Rc:=Sys_DosOpenL(PChar (SystemFileName), Handle, Action, 0, 0, 1, Mode, nil);
|
Rc:=Sys_DosOpenL(PChar (SystemFileName), Handle, Action, 0, 0, 1, Mode, nil);
|
||||||
If Rc=0 then
|
If Rc=0 then
|
||||||
FileOpen:=Handle
|
FileOpen:=Handle
|
||||||
@ -135,9 +135,13 @@ Var
|
|||||||
RC: cardinal;
|
RC: cardinal;
|
||||||
begin
|
begin
|
||||||
RC := DosRead (Handle, Buffer, Count, T);
|
RC := DosRead (Handle, Buffer, Count, T);
|
||||||
FileRead := longint (T);
|
if RC = 0 then
|
||||||
if RC <> 0 then
|
FileRead := longint (T)
|
||||||
OSErrorWatch (RC);
|
else
|
||||||
|
begin
|
||||||
|
FileRead := -1;
|
||||||
|
OSErrorWatch (RC);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FileWrite (Handle: THandle; const Buffer; Count: longint): longint;
|
function FileWrite (Handle: THandle; const Buffer; Count: longint): longint;
|
||||||
@ -146,9 +150,13 @@ Var
|
|||||||
RC: cardinal;
|
RC: cardinal;
|
||||||
begin
|
begin
|
||||||
RC := DosWrite (Handle, Buffer, Count, T);
|
RC := DosWrite (Handle, Buffer, Count, T);
|
||||||
FileWrite := longint (T);
|
if RC = 0 then
|
||||||
if RC <> 0 then
|
FileWrite := longint (T)
|
||||||
OSErrorWatch (RC);
|
else
|
||||||
|
begin
|
||||||
|
FileWrite := -1;
|
||||||
|
OSErrorWatch (RC);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FileSeek (Handle: THandle; FOffset, Origin: longint): longint;
|
function FileSeek (Handle: THandle; FOffset, Origin: longint): longint;
|
||||||
|
Loading…
Reference in New Issue
Block a user