Picture of Wim 4127
Registered 6 years 245 days
Wim 4127 Tuesday, 14 December 2021, 01:56 PM
FileSystem::WriteWholeFile doesn't write whole file unless it is text
It isn't documented that the function FileSystem::WriteWholeFile only writes text content to a file, and does not write binary data to a file.

That is a bit confusing since you ask a buffer and the length, but you write only until the first 0 byte... so the length is not needed there. Actually, the length suggests that it would write binary data.

We only found out it doens't write binary because the IFileWrite Write function has a void * input instead of a char * input of the WriteWholeFile, and we assumed this is innovaphone's funny way of saying you only do text.

Anyway, would be better to write binary in both cases, since there is no reason why the WriteWholeFile cannot be done for binary content and is equally usefull as for test.
If there is some obscure reason why it cannot be done, it would be nice to document this explicitly! Actually, this would always be usefull to document if it only works for text, because it avoids devs having to find this out by trial and error sad
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 114 days
Daniel Deterding (innovaphone) Tuesday, 14 December 2021, 03:52 PM
Re: FileSystem::WriteWholeFile doesn't write whole file unless it is text
Hi Wim,

thanks for the hint. We'll update the documentation and in addition we'll add a function FileSystem::WriteBinaryFile in 13r2 which will behave as expected.
We cannot simply "fix" the old function as it's unclear if somebody simply hands strings with incorrect length ...

Greetings,
Daniel
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 114 days
Daniel Deterding (innovaphone) Tuesday, 21 December 2021, 12:32 PM
Re: FileSystem::WriteWholeFile doesn't write whole file unless it is text
Hi Wim,

13r2 SR8 will contain the WriteBinaryFile function.

Greetings,
Daniel
← You can define your color theme preference here