There is an issue related to this. If you open a file in append mode and File.Write() is buffered, the buffer won't be written to disk immediatly when you setWithin the writing script you may check
File.PosagainstFile.Length. WheneverFile.PosexceedsFile.Lengthdata are buffered internally.
File.Length := File.Pos. It remains in the buffer instead and will be appended later to the new end-of-file. This should be fixed soon.#NoEnv
FilePath := A_ScriptDir . "\Test.txt"
ToWrite := ""
Loop, 512
ToWrite .= "A"
FO := {}
FileDelete, %FilePath%
HFile := FileOpen(FilePath, "a")
FO.Insert({Pos: HFile.Pos, Len: HFile.Length, Cmd: "FileOpen"})
BW := HFile.Write(ToWrite)
FO.Insert({Pos: HFile.Pos, Len: HFile.Length, Cmd: "File.Write()"})
HFile.Length := HFile.Pos
FO.Insert({Pos: HFile.Pos, Len: HFile.Length, Cmd: "File.Length := File.Pos"})
HFile.__Handle
FO.Insert({Pos: HFile.Pos, Len: HFile.Length, Cmd: "File.__Handle"})
HFile.Close()
Gui, Color, F0F0F0
Gui, Margin, 20, 20
Gui, Add, ListView, w400 r5 Grid, File.Pos|File.Length|After
For K, O In FO
LV_Add("", O.Pos, O.Len, O.Cmd)
Loop, % FO.MaxIndex()
LV_ModifyCol(A_Index, "AutoHdr")
Gui, Show, , File - bytes written = %BW%
Return
GuiClose:
GuiEscape:
ExitAppThe file object is using an own internal buffer of 8188 bytes for I/O-buffering. If an application opens a LOG file on start and closes it on exit (which is good practice in other programming languages), over 100 records will be buffered when the records have an average length of 80 bytes. In case of a crash all the records will be lost. So AHK should offer an option for unbuffered I/O, e.g. an additional option "U"(nbuffered) for FileOpen.




