Skip to content

Commit d353717

Browse files
feat(redox): implement persist() (#393)
* misc(Cargo.toml): bump rustix to 1.1.4 Signed-off-by: Anhad Singh <andypython@protonmail.com> * feat(redox): implement persist() Signed-off-by: Anhad Singh <andypython@protonmail.com> --------- Signed-off-by: Anhad Singh <andypython@protonmail.com>
1 parent 64114d7 commit d353717

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ once_cell = { version = "1.19.0", default-features = false, features = ["std"] }
2727
getrandom = { version = ">=0.3.0, <0.5", default-features = false, optional = true }
2828

2929
[target.'cfg(any(unix, target_os = "wasi"))'.dependencies]
30-
rustix = { version = "1.1.3", features = ["fs"] }
30+
rustix = { version = "1.1.4", features = ["fs"] }
3131

3232
[target.'cfg(windows)'.dependencies.windows-sys]
3333
version = ">=0.52, <0.62"

src/file/imp/unix.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::io;
55
use crate::util;
66
use std::path::Path;
77

8-
#[cfg(not(target_os = "redox"))]
98
use {
109
rustix::fs::{rename, unlink},
1110
std::fs::hard_link,
@@ -92,12 +91,11 @@ pub fn reopen(file: &File, path: &Path) -> io::Result<File> {
9291
Ok(new_file)
9392
}
9493

95-
#[cfg(not(target_os = "redox"))]
9694
pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> {
9795
if overwrite {
9896
rename(old_path, new_path)?;
9997
} else {
100-
// On Linux and apple operating systems, use `renameat_with` to avoid overwriting an
98+
// On Linux, apple and redox operating systems, use `renameat_with` to avoid overwriting an
10199
// existing name, if the kernel and the filesystem support it.
102100
#[cfg(any(
103101
target_os = "android",
@@ -107,6 +105,7 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<
107105
target_os = "tvos",
108106
target_os = "visionos",
109107
target_os = "watchos",
108+
target_os = "redox",
110109
))]
111110
{
112111
use rustix::fs::{renameat_with, RenameFlags, CWD};
@@ -135,13 +134,6 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<
135134
Ok(())
136135
}
137136

138-
#[cfg(target_os = "redox")]
139-
pub fn persist(_old_path: &Path, _new_path: &Path, _overwrite: bool) -> io::Result<()> {
140-
// XXX implement when possible
141-
use rustix::io::Errno;
142-
Err(Errno::NOSYS.into())
143-
}
144-
145137
pub fn keep(_: &Path) -> io::Result<()> {
146138
Ok(())
147139
}

0 commit comments

Comments
 (0)