-
-
Notifications
You must be signed in to change notification settings - Fork 844
Add read_entire_file_as_cstring to os2 #5647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add read_entire_file_as_cstring to os2 #5647
Conversation
|
It would be very surprising for It would be better to have a complementary |
|
Alternatively, a proc group entry could be added that accepts a user provided buffer to write the file data into, which would be pre-sized to accommodate the null terminated character. |
|
I think this is probably a bad idea, especially to do by default. If anything, we should have a separate procedure as @Kelimion states like |
I'm leaning toward the buffer for its flexibility. Something like |
The returned data is unchanged, a null byte is only added to the backing memory, after the file data. Which in a lot of cases is already there due to aligning. This just guarantees that it's there so you can cast safely.
That's fine as well. I only modified
Isn't that just |
It's not a bad idea to make
I'm curious to know what @gingerBill thinks about this distinction. I still feel like it should be its own procedure. |
So the input buffer param would be Should |
|
Another issues: adding an extra NUL terminator does cause issues with things like the |
235825e to
816696e
Compare
|
I've changed it to add an explicit |
|
One concern I have here is that if there are any null bytes in the middle of the file then this is stuffed. |
Add extra byte to the allocated read_entire_file buffer so it could be safely cast to a cstring.
Just so you can do
cstring(raw_data(file_data))without copying.