Removed buffered file IO which fixes a bug
This commit is contained in:
parent
54e389b13b
commit
15c2f580f0
|
@ -91,7 +91,7 @@ Var
|
||||||
MIndex : LongInt;
|
MIndex : LongInt;
|
||||||
Copied : RecMessageBase;
|
Copied : RecMessageBase;
|
||||||
HasCopy : Boolean = False;
|
HasCopy : Boolean = False;
|
||||||
MBaseFile : TBufFile;
|
MBaseFile : File of RecMessageBase;
|
||||||
MBase : RecMessageBase;
|
MBase : RecMessageBase;
|
||||||
|
|
||||||
Procedure GlobalEdit (Global: RecMessageBase);
|
Procedure GlobalEdit (Global: RecMessageBase);
|
||||||
|
@ -161,8 +161,8 @@ Var
|
||||||
#21 : If ShowMsgBox(1, 'Update with these settings?') Then Begin
|
#21 : If ShowMsgBox(1, 'Update with these settings?') Then Begin
|
||||||
For Count := 1 to List.ListMax Do
|
For Count := 1 to List.ListMax Do
|
||||||
If List.List[Count]^.Tagged = 1 Then Begin
|
If List.List[Count]^.Tagged = 1 Then Begin
|
||||||
MBaseFile.Seek (Count - 1);
|
Seek (MBaseFile, Count - 1);
|
||||||
MBaseFile.Read (MBase);
|
Read (MBaseFile, MBase);
|
||||||
|
|
||||||
If Active[01] Then MBase.Path := Global.Path;
|
If Active[01] Then MBase.Path := Global.Path;
|
||||||
If Active[02] Then MBase.ListACS := Global.ListACS;
|
If Active[02] Then MBase.ListACS := Global.ListACS;
|
||||||
|
@ -192,8 +192,8 @@ Var
|
||||||
If Active[25] Then BitSet(2, 4, MBase.Flags, (Global.Flags AND MBKillKludge <> 0));
|
If Active[25] Then BitSet(2, 4, MBase.Flags, (Global.Flags AND MBKillKludge <> 0));
|
||||||
If Active[26] Then BitSet(5, 4, MBase.Flags, (Global.Flags AND MBPrivate <> 0));
|
If Active[26] Then BitSet(5, 4, MBase.Flags, (Global.Flags AND MBPrivate <> 0));
|
||||||
|
|
||||||
MBaseFile.Seek (Count - 1);
|
Seek (MBaseFile, Count - 1);
|
||||||
MBaseFile.Write (MBase);
|
Write (MBaseFile, MBase);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Break;
|
Break;
|
||||||
|
@ -214,14 +214,14 @@ Var
|
||||||
Begin
|
Begin
|
||||||
List.Clear;
|
List.Clear;
|
||||||
|
|
||||||
MBaseFile.Reset;
|
Reset (MBaseFile);
|
||||||
|
|
||||||
While Not MBaseFile.EOF Do Begin
|
While Not EOF(MBaseFile) Do Begin
|
||||||
If MBaseFile.FilePos = 0 Then Tag := 2 Else Tag := 0;
|
If FilePos(MBaseFile) = 0 Then Tag := 2 Else Tag := 0;
|
||||||
|
|
||||||
MBaseFile.Read (MBase);
|
Read (MBaseFile, MBase);
|
||||||
|
|
||||||
List.Add(strPadR(strI2S(MBaseFile.FilePos - 1), 5, ' ') + ' ' + strStripMCI(MBase.Name), Tag);
|
List.Add(strPadR(strI2S(FilePos(MBaseFile) - 1), 5, ' ') + ' ' + strStripMCI(MBase.Name), Tag);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
List.Add('', 2);
|
List.Add('', 2);
|
||||||
|
@ -231,18 +231,18 @@ Var
|
||||||
Begin
|
Begin
|
||||||
MIndex := List.Picked;
|
MIndex := List.Picked;
|
||||||
|
|
||||||
MBaseFile.Reset;
|
Reset (MBaseFile);
|
||||||
|
|
||||||
While Not MBaseFile.EOF Do Begin
|
While Not EOF(MBaseFile) Do Begin
|
||||||
MBaseFile.Read (MBase);
|
Read (MBaseFile, MBase);
|
||||||
|
|
||||||
If MIndex = MBase.Index Then Begin
|
If MIndex = MBase.Index Then Begin
|
||||||
Inc (MIndex);
|
Inc (MIndex);
|
||||||
MBaseFile.Reset;
|
Reset (MBaseFile);
|
||||||
End;
|
End;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
MBaseFile.RecordInsert (List.Picked);
|
AddRecord (MBaseFile, List.Picked, SizeOf(RecMessageBase));
|
||||||
|
|
||||||
FillChar (MBase, SizeOf(RecMessageBase), 0);
|
FillChar (MBase, SizeOf(RecMessageBase), 0);
|
||||||
|
|
||||||
|
@ -277,16 +277,14 @@ Var
|
||||||
End;
|
End;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
MBaseFile.Write(MBase);
|
Write(MBaseFile, MBase);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
MBaseFile := TBufFile.Create(4096);
|
Assign (MBaseFile, Config.DataPath + 'mbases.dat');
|
||||||
|
|
||||||
If Not MBaseFile.Open(Config.DataPath + 'mbases.dat', fmOpenCreate, fmReadWrite + fmDenyNone, SizeOf(RecMessageBase)) Then Begin
|
If Not ioReset(MBaseFile, SizeOf(MBase), fmRWDN) Then
|
||||||
MBaseFile.Free;
|
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
|
||||||
|
|
||||||
Box := TAnsiMenuBox.Create;
|
Box := TAnsiMenuBox.Create;
|
||||||
List := TAnsiMenuList.Create;
|
List := TAnsiMenuList.Create;
|
||||||
|
@ -296,7 +294,7 @@ Begin
|
||||||
List.AllowTag := True;
|
List.AllowTag := True;
|
||||||
List.SearchY := 21;
|
List.SearchY := 21;
|
||||||
|
|
||||||
If MBaseFile.FileSize = 0 Then AssignRecord(True);
|
If FileSize(MBaseFile) = 0 Then AssignRecord(True);
|
||||||
|
|
||||||
Box.Open (15, 5, 65, 21);
|
Box.Open (15, 5, 65, 21);
|
||||||
|
|
||||||
|
@ -319,10 +317,10 @@ Begin
|
||||||
End;
|
End;
|
||||||
'D' : If (List.Picked > 1) and (List.Picked < List.ListMax) Then
|
'D' : If (List.Picked > 1) and (List.Picked < List.ListMax) Then
|
||||||
If ShowMsgBox(1, 'Delete this entry?') Then Begin
|
If ShowMsgBox(1, 'Delete this entry?') Then Begin
|
||||||
MBaseFile.Seek (List.Picked - 1);
|
Seek (MBaseFile, List.Picked - 1);
|
||||||
MBaseFile.Read (MBase);
|
Read (MBaseFile, MBase);
|
||||||
|
|
||||||
MBaseFile.RecordDelete (List.Picked);
|
KillRecord (MBaseFile, List.Picked, SizeOf(MBase));
|
||||||
|
|
||||||
If ShowMsgBox(1, 'Delete data files?') Then Begin
|
If ShowMsgBox(1, 'Delete data files?') Then Begin
|
||||||
FileErase (MBase.Path + MBase.FileName + '.jhr');
|
FileErase (MBase.Path + MBase.FileName + '.jhr');
|
||||||
|
@ -338,36 +336,37 @@ Begin
|
||||||
MakeList;
|
MakeList;
|
||||||
End;
|
End;
|
||||||
'C' : If List.Picked <> List.ListMax Then Begin
|
'C' : If List.Picked <> List.ListMax Then Begin
|
||||||
MBaseFile.Seek (List.Picked - 1);
|
Seek (MBaseFile, List.Picked - 1);
|
||||||
MBaseFile.Read (Copied);
|
Read (MBaseFile, Copied);
|
||||||
|
|
||||||
HasCopy := True;
|
HasCopy := True;
|
||||||
End;
|
End;
|
||||||
'P' : If HasCopy And (List.Picked > 1) Then Begin
|
'P' : If HasCopy And (List.Picked > 1) Then Begin
|
||||||
MBaseFile.RecordInsert (List.Picked);
|
AddRecord (MBaseFile, List.Picked, SizeOf(MBase));
|
||||||
MBaseFile.Write (Copied);
|
Write (MBaseFile, Copied);
|
||||||
|
|
||||||
MakeList;
|
MakeList;
|
||||||
End;
|
End;
|
||||||
'G' : If List.Marked = 0 Then
|
'G' : If List.Marked = 0 Then
|
||||||
ShowMsgBox(0, 'You must tag areas for global edit')
|
ShowMsgBox(0, 'Use TAB to tag areas for global edit')
|
||||||
Else Begin
|
Else Begin
|
||||||
If List.Picked > 1 Then Begin
|
If (List.Picked > 1) And (List.Picked < List.ListMax) Then Begin
|
||||||
MBaseFile.Seek (List.Picked - 1);
|
Seek (MBaseFile, List.Picked - 1);
|
||||||
MBaseFile.Read (MBase);
|
Read (MBaseFile, MBase);
|
||||||
End;
|
End Else
|
||||||
|
FillChar (MBase, SizeOf(MBase), 0);
|
||||||
|
|
||||||
GlobalEdit (MBase);
|
GlobalEdit (MBase);
|
||||||
End;
|
End;
|
||||||
End;
|
End;
|
||||||
#13 : If List.Picked < List.ListMax Then Begin
|
#13 : If List.Picked < List.ListMax Then Begin
|
||||||
MBaseFile.Seek (List.Picked - 1);
|
Seek (MBaseFile, List.Picked - 1);
|
||||||
MBaseFile.Read (MBase);
|
Read (MBaseFile, MBase);
|
||||||
|
|
||||||
EditMessageBase (MBase);
|
EditMessageBase (MBase);
|
||||||
|
|
||||||
MBaseFile.Seek (List.Picked - 1);
|
Seek (MBaseFile, List.Picked - 1);
|
||||||
MBaseFile.Write (MBase);
|
Write (MBaseFile, MBase);
|
||||||
End;
|
End;
|
||||||
#27 : Break;
|
#27 : Break;
|
||||||
End;
|
End;
|
||||||
|
@ -375,8 +374,8 @@ Begin
|
||||||
|
|
||||||
Box.Close;
|
Box.Close;
|
||||||
|
|
||||||
MBaseFile.Close;
|
Close (MBaseFile);
|
||||||
MBaseFile.Free;
|
|
||||||
List.Free;
|
List.Free;
|
||||||
Box.Free;
|
Box.Free;
|
||||||
End;
|
End;
|
||||||
|
|
Loading…
Reference in New Issue