Honor append and truncate flags in native Windows file opening
- Dominant language
- Rust
- Stars
- 53
- Forks
- 16
- Avg merge
- 4h 22m
- Merged PRs (30d)
- 46
Description
Two branches in Windows `open` do not preserve the advertised file flags:
- `FS_O_TRUNC` only influences creation disposition when `FS_O_CREAT` is also present. Opening an existing file with WRONLY | TRUNC selects OPEN_EXISTING and leaves its contents intact.
- APPEND adds FILE_APPEND_DATA to GENERIC_WRITE and seeks to EOF once at open time. GENERIC_WRITE still allows positional writes. A later seek can make a write overwrite existing content, and independently opened append handles can retain the same old EOF position.
These belong in one review of native open-flag translation, rather than separate reports for every flag combination.
Source evidence at the head of #520:
- [std/sys/windows/fs.wave:104](https://github.com/wavefnd/Wave/blob/2ae0a91c57fd76323124c0e4dff552adbfadbe1b/std/sys/windows/fs.wave#L104) — `pub fun open`
Acceptance:
- [ ] Implement truncation of an existing writable file without requiring CREAT, while a missing file still fails without CREAT.
- [ ] Make each append write target EOF using native append semantics; a one-time seek is insufficient.
- [ ] Cover append after an explicit seek, two independently opened append handles, TRUNC without CREAT, and CREAT|EXCL on an existing file.
- [ ] Check native call failures and preserve existing data when opening fails.
API/reference context: [CreateFile creation dispositions](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea) and [file access rights](https://learn.microsoft.com/en-us/windows/win32/fileio/file-security-and-access-rights).
Related: #385.
Audit status: identified by static source inspection; the scenarios above have not been executed during this audit. The permalink fixes the reviewed revision; this report does not claim the defect was introduced by #520.
Contributor guide
Research direction
Start at pub fun open in std/sys/windows/fs.wave:104 and compare its flag translation with the linked CreateFile creation dispositions and access-rights references. Exercise the listed truncation, append, exclusive-create, seek, and independent-handle scenarios; done means native failures are checked and failed opens preserve existing data.
Written by the indexing model from the issue text.
Assessment
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100