Rather than rejecting when trying to write past the end of a file, require extending a file with some number of 0x00 (NUL) bytes instead. This enables creating sparse files and greatly simplifies saving content to a file when the data to be written is received out of order.
Motivation
Without this functionality, applications which receive file contents out of order (ex: bittorrent downloads) would have to manually make sure to resize the file either ahead of time or when needed during writing. 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).
Specification
Status in Chromium
Enabled by default in:
- Chrome for desktop release 90
Consensus & Standardization
- No signal
- No signal
- No signal
- Positive
Owners
Last updated on 2021-04-15