-
Notifications
You must be signed in to change notification settings - Fork 65
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
Support seeking past the end of a file. #266
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Rather than rejecting when trying to write past the end of a file this changes the spec to require extending a file with 0 bytes instead. This enables creating sparse files (very useful for certain file formats such as disk images). Additionally this greatly simplifies saving content to a file when the data to be written is received out of order (such as in the case of bittorrent downloads). Without this functionality such a application would have to manually make sure to resize the file either ahead of time or when needed during writing. Note that the behavior here would have already been possible by keeping track of the file size, and inserting appropriate truncate() calls to grow the file whenever trying to write past the end of a file. Not requiring these explicit truncate calls simplifies code, and reduces the chance of bugs in websites (accidentally shrinking files when they don't need to, for example). This fixes #262
5510711
to
882219a
Compare
I found this very confusing, but after reading the spec change I understand you mean "some number of bytes whose value is 0", not "zero new bytes" :) |
Yeah, that was definitely written in a pretty confusing manner. Rephrased the description to be clearer. |
Rather than rejecting when trying to write past the end of a file this changes the spec to require extending a file with 0 bytes instead. This enables creating sparse files (very useful for certain file formats such as disk images). Additionally this greatly simplifies saving content to a file when the data to be written is received out of order (such as in the case of bittorrent downloads). Without this functionality such a application would have to manually make sure to resize the file either ahead of time or when needed during writing. Note that the behavior here would have already been possible by keeping track of the file size, and inserting appropriate truncate() calls to grow the file whenever trying to write past the end of a file. Not requiring these explicit truncate calls simplifies code, and reduces the chance of bugs in websites (accidentally shrinking files when they don't need to, for example). This fixes #262 SHA: edc4d88 Reason: push, by @mkruisselbrink Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Rather than rejecting when trying to write past the end of a file this
changes the spec to require extending a file with some number of
0x00 (NUL) bytes instead.
This enables creating sparse files (very useful for certain file formats
such as disk images). Additionally this greatly simplifies saving content
to a file when the data to be written is received out of order (such as in
the case of bittorrent downloads). Without this functionality such a
application would have to manually make sure to resize the file either
ahead of time or when needed during writing.
Note that the behavior here would have already been possible by keeping
track of the file size, and inserting appropriate truncate() calls to
grow the file whenever trying to write past the end of a file. Not
requiring these explicit truncate calls simplifies code, and reduces the
chance of bugs in websites (accidentally shrinking files when they don't
need to, for example).
This fixes #262
Preview | Diff