[v1/2] file.RawReadWrite truncation if Bytes exceeds DWORD_MAX

Share your ideas as to how the documentation can be improved.
swagfag
Posts: 4129
Joined: 11 Jan 2017, 17:59

[v1/2] file.RawReadWrite truncation if Bytes exceeds DWORD_MAX

Post by swagfag » 15 Aug 2020, 09:53

Code: Select all

size := 0x100000005 ; about 4GB, DWORD_MAX + 5
VarSetCapacity(bigData, size, 0xFF)
FileOpen("large.bin", "w").RawWrite(&bigData, size) ; 5 bytes written
the fact that it truncates/biggest chunk permitted is DWORD_MAX, is undocumented(unless im blind)

or make it default to DWORD_MAX if it exceeds it
or make it throw if it exceeds DWORD_MAX
or change TextStream so it uses size_t-based functions
lexikos
Posts: 7162
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: [v1/2] file.RawReadWrite truncation if Bytes exceeds DWORD_MAX

Post by lexikos » 16 Aug 2020, 03:11

or change TextStream so it uses size_t-based functions
I assume the use of DWORD is based on ReadFile and a 1:1 relation between TextStream Read operations and calls to ReadFile. I suppose that any function capable of reading more than DWORD_MAX at once is really just calling ReadFile multiple times under the hood. It's pretty unusual (and probably a sign of flawed design) to have a 4GB or larger block of file data in memory, so I'm not inclined to do anything about it myself.
Post Reply

Return to “Suggestions on documentation improvements”