You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is perhaps some corner case, but consider that you want to use file_descriptor to manage some log file. Writes to log files are typically write-only-to-the-end, but you may also want to do random reads on logs. Random reads via pread are no problem in Linux (they don't move file pointer), but random reads via ReadFile with offsets specified in OVERLAPPED struct actually move file pointer, so subsequent writes will not be at the end of file.
The problem is fixed by opening a file with O_APPEND/FILE_APPEND_DATA when creating a new file. It would be nice to be able to forcefully open a "fresh" file with std::ios_base::app flag. I imagine this could be done by allowing std::ios_base::trunc | std::ios_base::app combo. The effect should be as follows:
This is perhaps some corner case, but consider that you want to use
file_descriptor
to manage some log file. Writes to log files are typically write-only-to-the-end, but you may also want to do random reads on logs. Random reads viapread
are no problem in Linux (they don't move file pointer), but random reads viaReadFile
with offsets specified inOVERLAPPED
struct actually move file pointer, so subsequent writes will not be at the end of file.The problem is fixed by opening a file with O_APPEND/FILE_APPEND_DATA when creating a new file. It would be nice to be able to forcefully open a "fresh" file with
std::ios_base::app flag
. I imagine this could be done by allowingstd::ios_base::trunc | std::ios_base::app
combo. The effect should be as follows:The text was updated successfully, but these errors were encountered: