diff --git a/bzip2recover.rs b/bzip2recover.rs index fed4a3373..025007c80 100644 --- a/bzip2recover.rs +++ b/bzip2recover.rs @@ -347,15 +347,12 @@ fn main_help(program_name: &Path, in_filename: &Path) -> Result<(), Error> { ); let mut options = std::fs::File::options(); - options.write(true).create(true); + options.write(true).create_new(true); #[cfg(unix)] #[allow(clippy::unnecessary_cast)] options.mode(libc::S_IWUSR as u32 | libc::S_IRUSR as u32); - #[cfg(unix)] - options.custom_flags(libc::O_EXCL); - let Ok(output_file) = options.open(&out_filename) else { eprintln!("{}: can't write `{}'", progname, out_filename.display()); diff --git a/test-libbzip2-rs-sys/src/lib.rs b/test-libbzip2-rs-sys/src/lib.rs index 5df26691e..d53b8b420 100644 --- a/test-libbzip2-rs-sys/src/lib.rs +++ b/test-libbzip2-rs-sys/src/lib.rs @@ -4,7 +4,6 @@ use std::{ ffi::{c_char, c_int, c_void, CStr}, mem::MaybeUninit, - os::fd::{AsRawFd, IntoRawFd}, path::{Path, PathBuf}, }; @@ -1319,7 +1318,10 @@ mod high_level_interface { } #[test] + #[cfg(unix)] fn open_and_close() { + use std::os::fd::{AsRawFd, IntoRawFd}; + let p = std::env::temp_dir().join("open_and_close.bz2"); const RB: *const c_char = b"rb\0".as_ptr().cast::();