| ... | @@ -268,6 +268,12 @@ pub const SetLengthError = error{ | ... | @@ -268,6 +268,12 @@ pub const SetLengthError = error{ |
| 268 | /// Truncates or expands the file, populating any new data with zeroes. | 268 | /// Truncates or expands the file, populating any new data with zeroes. |
| 269 | /// | 269 | /// |
| 270 | /// The file offset after this call is left unchanged. | 270 | /// The file offset after this call is left unchanged. |
| | 271 | /// |
| | 272 | /// This function operates on an open file handle. There is not an equivalent |
| | 273 | /// function in `Dir` which operates on paths because generally, such |
| | 274 | /// functionality will introduce Time-Of-Check, Time-Of-Use (TOCTOU) bugs. In |
| | 275 | /// the rare case when those semantics are actually needed, it is reasonable to |
| | 276 | /// open the file with the truncate flag. |
| 271 | pub fn setLength(file: File, io: Io, new_length: u64) SetLengthError!void { | 277 | pub fn setLength(file: File, io: Io, new_length: u64) SetLengthError!void { |
| 272 | return io.vtable.fileSetLength(io.userdata, file, new_length); | 278 | return io.vtable.fileSetLength(io.userdata, file, new_length); |
| 273 | } | 279 | } |