Buffer class changes/bugfix for log roller and fido export
This commit is contained in:
parent
024c502d9f
commit
afa47cad86
|
@ -63,6 +63,7 @@ Type
|
||||||
TFileBufferOpenType = (
|
TFileBufferOpenType = (
|
||||||
fmOpen,
|
fmOpen,
|
||||||
fmOpenCreate,
|
fmOpenCreate,
|
||||||
|
fmOpenAppend,
|
||||||
fmCreate
|
fmCreate
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -596,7 +597,8 @@ Begin
|
||||||
|
|
||||||
Case OpenType of
|
Case OpenType of
|
||||||
fmOpen : If Not ioReset (InFile, 1, OpenMode) Then Exit;
|
fmOpen : If Not ioReset (InFile, 1, OpenMode) Then Exit;
|
||||||
fmOpenCreate : If Not ioReset (InFile, 1, OpenMode) Then
|
fmOpenCreate,
|
||||||
|
fmOpenAppend : If Not ioReset (InFile, 1, OpenMode) Then
|
||||||
If Not FileExist(FN) Then Begin
|
If Not FileExist(FN) Then Begin
|
||||||
If Not ioReWrite (InFile, 1, OpenMode) Then Exit;
|
If Not ioReWrite (InFile, 1, OpenMode) Then Exit;
|
||||||
End Else
|
End Else
|
||||||
|
@ -604,6 +606,9 @@ Begin
|
||||||
fmCreate : If Not ioReWrite (InFile, 1, OpenMode) Then Exit;
|
fmCreate : If Not ioReWrite (InFile, 1, OpenMode) Then Exit;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
If OpenType = fmOpenAppend Then
|
||||||
|
ioSeek (InFile, System.FileSize(InFile));
|
||||||
|
|
||||||
GetMem (Buffer, BufSize);
|
GetMem (Buffer, BufSize);
|
||||||
|
|
||||||
FillBuffer;
|
FillBuffer;
|
||||||
|
@ -708,12 +713,26 @@ Begin
|
||||||
If Offset > 0 Then
|
If Offset > 0 Then
|
||||||
Move (Buf, Buffer^[BufPos], Offset);
|
Move (Buf, Buffer^[BufPos], Offset);
|
||||||
|
|
||||||
|
BufRead := BufSize;
|
||||||
|
|
||||||
FlushBuffer;
|
FlushBuffer;
|
||||||
|
|
||||||
|
// -----
|
||||||
|
Move (TFileBufferRec(Buf)[Offset], Buffer^[0], Size - Offset);
|
||||||
|
|
||||||
|
BufStart := System.FilePos(InFile);
|
||||||
|
BufEnd := BufStart + Size - Offset;
|
||||||
|
BufPos := Size - Offset;
|
||||||
|
BufEOF := System.EOF(InFile);
|
||||||
|
BufRead := BufPos;
|
||||||
|
|
||||||
|
(* the above replaces the 3 lines below... but is it reliable?
|
||||||
FillBuffer;
|
FillBuffer;
|
||||||
|
|
||||||
Move (TFileBufferRec(Buf)[Offset], Buffer^[BufPos], Size - Offset);
|
Move (TFileBufferRec(Buf)[Offset], Buffer^[BufPos], Size - Offset);
|
||||||
|
|
||||||
BufPos := BufPos + Size - Offset;
|
BufPos := BufPos + Size - Offset;
|
||||||
|
*)
|
||||||
End Else Begin
|
End Else Begin
|
||||||
Move (Buf, Buffer^[BufPos], Size);
|
Move (Buf, Buffer^[BufPos], Size);
|
||||||
Inc (BufPos, Size);
|
Inc (BufPos, Size);
|
||||||
|
@ -778,12 +797,14 @@ End;
|
||||||
Function TFileBuffer.FileSizeRaw : LongInt;
|
Function TFileBuffer.FileSizeRaw : LongInt;
|
||||||
Begin
|
Begin
|
||||||
If BufDirty Then FlushBuffer;
|
If BufDirty Then FlushBuffer;
|
||||||
|
|
||||||
Result := System.FileSize(InFile);
|
Result := System.FileSize(InFile);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Function TFileBuffer.FileSizeRecord : LongInt;
|
Function TFileBuffer.FileSizeRecord : LongInt;
|
||||||
Begin
|
Begin
|
||||||
If BufDirty Then FlushBuffer;
|
If BufDirty Then FlushBuffer;
|
||||||
|
|
||||||
Result := System.FileSize(InFile) DIV RecSize;
|
Result := System.FileSize(InFile) DIV RecSize;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue