Skip to content

Commit

Permalink
Fix CreateNew/CreateAlways reversal
Browse files Browse the repository at this point in the history
  • Loading branch information
CraftSpider committed Feb 12, 2025
1 parent 7fd7210 commit 75e8284
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/shims/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}

match creation_disposition {
CreateNew | OpenAlways => {
CreateAlways | OpenAlways => {
// This is racy, but there doesn't appear to be an std API that both succeeds if a
// file exists but tells us it isn't new. Either we accept racing one way or another,
// or we use an iffy heuristic like file creation time. This implementation prefers
Expand All @@ -241,11 +241,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.set_last_error(IoError::Raw(Scalar::from_u32(0)))?;
}
options.create(true);
if creation_disposition == CreateNew {
if creation_disposition == CreateAlways {
options.truncate(true);
}
}
CreateAlways => {
CreateNew => {
// See comments in
options.create_new(true);
// Per `create_new` documentation:
// The file must be opened with write or append access in order to create a new file.
Expand Down

0 comments on commit 75e8284

Please sign in to comment.