mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-10 06:58:30 +02:00
* also check fmInput,fmOutput
This commit is contained in:
parent
e0b2f65f9a
commit
b32111a3e2
113
rtl/inc/file.inc
113
rtl/inc/file.inc
@ -57,7 +57,7 @@ Begin
|
|||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
exit;
|
exit;
|
||||||
Case FileRec(f).mode Of
|
Case FileRec(f).mode Of
|
||||||
fmInOut : Close(f);
|
fmInOut,fmInput,fmOutput : Close(f);
|
||||||
fmClosed : ;
|
fmClosed : ;
|
||||||
else
|
else
|
||||||
Begin
|
Begin
|
||||||
@ -83,7 +83,7 @@ Begin
|
|||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
Exit;
|
Exit;
|
||||||
Case FileRec(f).mode Of
|
Case FileRec(f).mode Of
|
||||||
fmInOut : Close(f);
|
fmInOut,fmInput,fmOutput : Close(f);
|
||||||
fmClosed : ;
|
fmClosed : ;
|
||||||
else
|
else
|
||||||
Begin
|
Begin
|
||||||
@ -131,11 +131,14 @@ Begin
|
|||||||
Result:=0;
|
Result:=0;
|
||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
exit;
|
exit;
|
||||||
if FileRec(f).Mode<>fmInOut then
|
case FileRec(f).Mode of
|
||||||
begin
|
fmInOut,fmOutput : ;
|
||||||
InOutRes:=103;
|
else
|
||||||
exit;
|
begin
|
||||||
end;
|
InOutRes:=103;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -187,11 +190,14 @@ Begin
|
|||||||
Result:=0;
|
Result:=0;
|
||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
exit;
|
exit;
|
||||||
if FileRec(f).Mode<>fmInOut then
|
case FileRec(f).Mode of
|
||||||
begin
|
fmInOut,fmInput : ;
|
||||||
InOutRes:=103;
|
else
|
||||||
exit;
|
begin
|
||||||
end;
|
InOutRes:=103;
|
||||||
|
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;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
@ -244,11 +250,14 @@ Begin
|
|||||||
FilePos:=0;
|
FilePos:=0;
|
||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
exit;
|
exit;
|
||||||
if FileRec(f).Mode<>fmInOut then
|
case FileRec(f).Mode of
|
||||||
begin
|
fmInOut,fmInput,fmOutput : ;
|
||||||
InOutRes:=103;
|
else
|
||||||
exit;
|
begin
|
||||||
end;
|
InOutRes:=103;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
FilePos:=Do_FilePos(FileRec(f).Handle) div FileRec(f).RecSize;
|
FilePos:=Do_FilePos(FileRec(f).Handle) div FileRec(f).RecSize;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
@ -261,11 +270,14 @@ Begin
|
|||||||
FileSize:=0;
|
FileSize:=0;
|
||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
exit;
|
exit;
|
||||||
if FileRec(f).Mode<>fmInOut then
|
case FileRec(f).Mode of
|
||||||
begin
|
fmInOut,fmInput,fmOutput : ;
|
||||||
InOutRes:=103;
|
else
|
||||||
exit;
|
begin
|
||||||
end;
|
InOutRes:=103;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
if (FileRec(f).RecSize>0) then
|
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;
|
||||||
@ -279,11 +291,14 @@ Begin
|
|||||||
Eof:=false;
|
Eof:=false;
|
||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
exit;
|
exit;
|
||||||
if FileRec(f).Mode<>fmInOut then
|
case FileRec(f).Mode of
|
||||||
begin
|
fmInOut,fmInput,fmOutput : ;
|
||||||
InOutRes:=103;
|
else
|
||||||
exit;
|
begin
|
||||||
end;
|
InOutRes:=103;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
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;
|
||||||
@ -296,11 +311,14 @@ Procedure Seek(var f:File;Pos:Longint);[IOCheck];
|
|||||||
Begin
|
Begin
|
||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
exit;
|
exit;
|
||||||
if FileRec(f).Mode<>fmInOut then
|
case FileRec(f).Mode of
|
||||||
begin
|
fmInOut,fmInput,fmOutput : ;
|
||||||
InOutRes:=103;
|
else
|
||||||
exit;
|
begin
|
||||||
end;
|
InOutRes:=103;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
Do_Seek(FileRec(f).Handle,Pos*FileRec(f).RecSize);
|
Do_Seek(FileRec(f).Handle,Pos*FileRec(f).RecSize);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
@ -312,11 +330,14 @@ Procedure Truncate(Var f:File);[IOCheck];
|
|||||||
Begin
|
Begin
|
||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
exit;
|
exit;
|
||||||
if FileRec(f).Mode<>fmInOut then
|
case FileRec(f).Mode of
|
||||||
begin
|
fmInOut,fmOutput : ;
|
||||||
InOutRes:=103;
|
else
|
||||||
exit;
|
begin
|
||||||
end;
|
InOutRes:=103;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
Do_Truncate(FileRec(f).Handle,FilePos(f)*FileRec(f).RecSize);
|
Do_Truncate(FileRec(f).Handle,FilePos(f)*FileRec(f).RecSize);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
@ -328,11 +349,14 @@ Procedure Close(var f:File);[IOCheck];
|
|||||||
Begin
|
Begin
|
||||||
If InOutRes <> 0 then
|
If InOutRes <> 0 then
|
||||||
exit;
|
exit;
|
||||||
if FileRec(f).Mode<>fmInOut then
|
case FileRec(f).Mode of
|
||||||
begin
|
fmInOut,fmInput,fmOutput : ;
|
||||||
InOutRes:=103;
|
else
|
||||||
exit;
|
begin
|
||||||
end;
|
InOutRes:=103;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
FileRec(f).mode:=fmClosed;
|
FileRec(f).mode:=fmClosed;
|
||||||
if FileRec(f).Handle>4 then
|
if FileRec(f).Handle>4 then
|
||||||
Do_Close(FileRec(f).Handle);
|
Do_Close(FileRec(f).Handle);
|
||||||
@ -385,7 +409,10 @@ End;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.9 1998-11-29 22:28:11 peter
|
Revision 1.10 1998-11-29 23:10:12 peter
|
||||||
|
* also check fmInput,fmOutput
|
||||||
|
|
||||||
|
Revision 1.9 1998/11/29 22:28:11 peter
|
||||||
+ io-error 103 added
|
+ io-error 103 added
|
||||||
|
|
||||||
Revision 1.8 1998/09/17 16:34:16 peter
|
Revision 1.8 1998/09/17 16:34:16 peter
|
||||||
|
Loading…
Reference in New Issue
Block a user