Skip to content

Commit

Permalink
Update to rustix 0.38 and update MSRV to 1.63
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed Jun 30, 2023
1 parent 1cff81e commit a2dcfad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
]
documentation = "https://docs.rs/tempfile"
edition = "2018"
rust-version = "1.48"
rust-version = "1.63"
homepage = "https://stebalien.com/projects/tempfile-rs/"
keywords = ["tempfile", "tmpfile", "filesystem"]
license = "MIT OR Apache-2.0"
Expand All @@ -21,7 +21,7 @@ cfg-if = "1"
fastrand = "2.0.0"

[target.'cfg(any(unix, target_os = "wasi"))'.dependencies]
rustix = { version = "0.37.11", features = ["fs"] }
rustix = { version = "0.38", features = ["fs"] }

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.48"
Expand Down
10 changes: 5 additions & 5 deletions src/file/imp/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::util;
use std::path::Path;

#[cfg(not(target_os = "redox"))]
use rustix::fs::{cwd, linkat, renameat, unlinkat, AtFlags};
use rustix::fs::{CWD, linkat, renameat, unlinkat, AtFlags};

pub fn create_named(path: &Path, open_options: &mut OpenOptions) -> io::Result<File> {
open_options.read(true).write(true).create_new(true);
Expand Down Expand Up @@ -103,7 +103,7 @@ pub fn reopen(_file: &File, _path: &Path) -> io::Result<File> {
#[cfg(not(target_os = "redox"))]
pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> {
if overwrite {
renameat(cwd(), old_path, cwd(), new_path)?;
renameat(CWD, old_path, CWD, new_path)?;
} else {
// On Linux, use `renameat_with` to avoid overwriting an existing name,
// if the kernel and the filesystem support it.
Expand All @@ -115,7 +115,7 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<

static NOSYS: AtomicBool = AtomicBool::new(false);
if !NOSYS.load(Relaxed) {
match renameat_with(cwd(), old_path, cwd(), new_path, RenameFlags::NOREPLACE) {
match renameat_with(CWD, old_path, CWD, new_path, RenameFlags::NOREPLACE) {
Ok(()) => return Ok(()),
Err(Errno::NOSYS) => NOSYS.store(true, Relaxed),
Err(Errno::INVAL) => {}
Expand All @@ -127,9 +127,9 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<
// Otherwise use `linkat` to create the new filesystem name, which
// will fail if the name already exists, and then `unlinkat` to remove
// the old name.
linkat(cwd(), old_path, cwd(), new_path, AtFlags::empty())?;
linkat(CWD, old_path, CWD, new_path, AtFlags::empty())?;
// Ignore unlink errors. Can we do better?
let _ = unlinkat(cwd(), old_path, AtFlags::empty());
let _ = unlinkat(CWD, old_path, AtFlags::empty());
}
Ok(())
}
Expand Down

0 comments on commit a2dcfad

Please sign in to comment.