* more compatibility fixes for objects unit

This commit is contained in:
carl 2002-10-31 12:47:30 +00:00
parent 88b1b352d1
commit 4cfe3217c0

View File

@ -980,6 +980,10 @@ END;
CONSTRUCTOR TStream.Init; CONSTRUCTOR TStream.Init;
BEGIN BEGIN
Status := StOK;
ErrorInfo := 0;
StreamSize := 0;
Position := 0;
TPCompatible := DefaultTPCompatible; TPCompatible := DefaultTPCompatible;
END; END;
@ -1073,7 +1077,7 @@ END;
{---------------------------------------------------------------------------} {---------------------------------------------------------------------------}
PROCEDURE TStream.Reset; PROCEDURE TStream.Reset;
BEGIN BEGIN
Status := 0; { Clear status } Status := stOK; { Clear status }
ErrorInfo := 0; { Clear error info } ErrorInfo := 0; { Clear error info }
END; END;
@ -1390,8 +1394,8 @@ PROCEDURE TDosStream.Read (Var Buf; Count: Sw_Word);
VAR BytesMoved: Sw_Word; VAR BytesMoved: Sw_Word;
DosStreamError : Word; DosStreamError : Word;
BEGIN BEGIN
{ Assume status is StOK } If Status = StOK then
Status := StOk; Begin
If (Position + Count > StreamSize) Then { Insufficient data } If (Position + Count > StreamSize) Then { Insufficient data }
Error(stReadError, 0); { Read beyond end!!! } Error(stReadError, 0); { Read beyond end!!! }
If (Handle = InvalidHandle) Then If (Handle = InvalidHandle) Then
@ -1403,10 +1407,16 @@ BEGIN
BytesMoved := 0; { Clear bytes moved } BytesMoved := 0; { Clear bytes moved }
If (DosStreamError <> 0) Then If (DosStreamError <> 0) Then
Error(stReadError, DosStreamError) { Specific read error } Error(stReadError, DosStreamError) { Specific read error }
Else Error(stReadError, 0); { Non specific error } Else
FillChar(Buf, Count, #0); { Error clear buffer } Error(stReadError, 0); { Non specific error }
End; End;
Inc(Position, BytesMoved); { Adjust position } Inc(Position, BytesMoved); { Adjust position }
End;
{ If there was already an error, or an error was just
generated, fill the vuffer with NULL
}
If Status <> StOK then
FillChar(Buf, Count, #0); { Error clear buffer }
END; END;
{--TDosStream---------------------------------------------------------------} {--TDosStream---------------------------------------------------------------}
@ -1416,8 +1426,9 @@ PROCEDURE TDosStream.Write (Var Buf; Count: Sw_Word);
VAR BytesMoved: Sw_Word; VAR BytesMoved: Sw_Word;
DosStreamError : Word; DosStreamError : Word;
BEGIN BEGIN
{ Assume status is StOk } { If status is not OK, simply exit }
Status := StOK; if Status <> StOK then
exit;
If (Handle = InvalidHandle) Then If (Handle = InvalidHandle) Then
Error(stWriteError, 103); { File not open } Error(stWriteError, 103); { File not open }
BlockWrite(FileInfo, Buf, Count, BytesMoved); { Write to file } BlockWrite(FileInfo, Buf, Count, BytesMoved); { Write to file }
@ -1478,8 +1489,8 @@ PROCEDURE TBufStream.Flush;
VAR W: Sw_Word; VAR W: Sw_Word;
DosStreamError : Word; DosStreamError : Word;
BEGIN BEGIN
{ Assume status is StOK } If Status <> StOK then
Status := StOK; exit;
If (LastMode=2) AND (BufPtr<>0) Then Begin { Must update file } If (LastMode=2) AND (BufPtr<>0) Then Begin { Must update file }
If (Handle = InvalidHandle) Then DosStreamError := 103 { File is not open } If (Handle = InvalidHandle) Then DosStreamError := 103 { File is not open }
Else Else
@ -1536,8 +1547,11 @@ PROCEDURE TBufStream.Read (Var Buf; Count: Sw_Word);
VAR Success: Integer; W, Bw: Sw_Word; P: PByteArray; VAR Success: Integer; W, Bw: Sw_Word; P: PByteArray;
DosStreamError : Word; DosStreamError : Word;
BEGIN BEGIN
{ Assume status is StOK } If Status <> StOk then
Status := StOK; begin
FillChar(P^, Count, #0); { Error clear buffer }
exit;
end;
If (Position + Count > StreamSize) Then { Read pas stream end } If (Position + Count > StreamSize) Then { Read pas stream end }
Error(stReadError, 0); { Call stream error } Error(stReadError, 0); { Call stream error }
If (Handle = InvalidHandle) Then Error(stReadError, 103); { File not open } If (Handle = InvalidHandle) Then Error(stReadError, 103); { File not open }
@ -1581,8 +1595,7 @@ PROCEDURE TBufStream.Write (Var Buf; Count: Sw_Word);
VAR Success: Integer; W: Sw_Word; P: PByteArray; VAR Success: Integer; W: Sw_Word; P: PByteArray;
DosStreamError : Word; DosStreamError : Word;
BEGIN BEGIN
{ Assume status is StOK } if Status <> StOK then exit; { Exit if error }
Status := StOK;
If (Handle = InvalidHandle) Then Error(stWriteError, 103); { File not open } If (Handle = InvalidHandle) Then Error(stWriteError, 103); { File not open }
If (LastMode=1) Then Flush; { Flush read buffer } If (LastMode=1) Then Flush; { Flush read buffer }
LastMode := 2; { Now set write mode } LastMode := 2; { Now set write mode }
@ -2888,7 +2901,10 @@ END;
END. END.
{ {
$Log$ $Log$
Revision 1.14 2002-10-30 22:44:44 carl Revision 1.15 2002-10-31 12:47:30 carl
* more compatibility fixes for objects unit
Revision 1.14 2002/10/30 22:44:44 carl
* Bugfix for error checking * Bugfix for error checking
- DosStreamError is no longer global (bugfix 2043) - DosStreamError is no longer global (bugfix 2043)