Skip to content

Commit a297341

Browse files
Rollup merge of #166155 - RalfJung:windows-seek-write-append, r=ChrisDenton
windows seek_write: document interaction with append mode [MS docs](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntwritefile) say that the offset is ignored for files opened with FILE_APPEND_DATA. Our `append(true)` [maps to](https://github.com/rust-lang/rust/blob/0df97849e3a1abbaff8969ec3b9cd9334ab68790/library/std/src/sys/fs/windows.rs#L294-L295) `c::FILE_GENERIC_WRITE & !c::FILE_WRITE_DATA` for `CreateFileW`... which then presumably translates into `FILE_APPEND_DATA` for `NtCreateFile`? r? @ChrisDenton
2 parents a2741a5 + 438f8b6 commit a297341

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • library/std/src/os/windows

‎library/std/src/os/windows/fs.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ pub trait FileExt {
219219
/// from the current cursor. The current cursor **is** affected by this
220220
/// function, it is set to the end of the write.
221221
///
222+
/// If the file was opened for appending (via [`OpenOptions::append`]), this is equivalent
223+
/// to `write`: the `offset` is ignored, and `buf` is appended at the end of the file.
224+
///
222225
/// When writing beyond the end of the file, the file is appropriately
223226
/// extended and the intermediate bytes are set to zero.
224227
///

0 commit comments

Comments
 (0)