Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support seeking past the end of a file. (#266)
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
- Loading branch information