diff options
| author | Chris Denton <christophersdenton@gmail.com> | 2021-03-17 03:52:02 +0000 |
|---|---|---|
| committer | Chris Denton <christophersdenton@gmail.com> | 2021-05-19 23:54:56 +0100 |
| commit | 2c2c1593acc5479a4b502d51bb5fea239766c235 (patch) | |
| tree | 80b1cf6e859bb5f57199bb645e8bd6c91ec0b654 /library/std/src/sys | |
| parent | 3e827cc21e0734edd26170e8d1481f0d66a1426b (diff) | |
| download | rust-2c2c1593acc5479a4b502d51bb5fea239766c235.tar.gz rust-2c2c1593acc5479a4b502d51bb5fea239766c235.zip | |
Move the implementation of `Path::exists` to `sys_common::fs` so platforms can specialize it
Windows implementation of `fs::try_exists`
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/hermit/fs.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unix/fs.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unsupported/fs.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys/wasi/fs.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/windows/fs.rs | 1 |
5 files changed, 8 insertions, 3 deletions
diff --git a/library/std/src/sys/hermit/fs.rs b/library/std/src/sys/hermit/fs.rs index 5b3f2fa4e82..76ea70d997f 100644 --- a/library/std/src/sys/hermit/fs.rs +++ b/library/std/src/sys/hermit/fs.rs @@ -12,7 +12,7 @@ use crate::sys::time::SystemTime; use crate::sys::unsupported; use crate::sys_common::os_str_bytes::OsStrExt; -pub use crate::sys_common::fs::copy; +pub use crate::sys_common::fs::{copy, try_exists}; //pub use crate::sys_common::fs::remove_dir_all; fn cstr(path: &Path) -> io::Result<CString> { diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 79617aa77b7..ef14865fbcd 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -48,7 +48,7 @@ use libc::{ dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, readdir64_r, stat64, }; -pub use crate::sys_common::fs::remove_dir_all; +pub use crate::sys_common::fs::{remove_dir_all, try_exists}; pub struct File(FileDesc); diff --git a/library/std/src/sys/unsupported/fs.rs b/library/std/src/sys/unsupported/fs.rs index cd533761e37..6b45e29c145 100644 --- a/library/std/src/sys/unsupported/fs.rs +++ b/library/std/src/sys/unsupported/fs.rs @@ -275,6 +275,10 @@ pub fn remove_dir_all(_path: &Path) -> io::Result<()> { unsupported() } +pub fn try_exists(_path: &Path) -> io::Result<bool> { + unsupported() +} + pub fn readlink(_p: &Path) -> io::Result<PathBuf> { unsupported() } diff --git a/library/std/src/sys/wasi/fs.rs b/library/std/src/sys/wasi/fs.rs index ed0f03e4b71..45e38f68b8c 100644 --- a/library/std/src/sys/wasi/fs.rs +++ b/library/std/src/sys/wasi/fs.rs @@ -14,7 +14,7 @@ use crate::sys::time::SystemTime; use crate::sys::unsupported; use crate::sys_common::FromInner; -pub use crate::sys_common::fs::remove_dir_all; +pub use crate::sys_common::fs::{remove_dir_all, try_exists}; pub struct File { fd: WasiFd, diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs index 8e6bd76f85f..36b395507b1 100644 --- a/library/std/src/sys/windows/fs.rs +++ b/library/std/src/sys/windows/fs.rs @@ -11,6 +11,7 @@ use crate::sync::Arc; use crate::sys::handle::Handle; use crate::sys::time::SystemTime; use crate::sys::{c, cvt}; +pub use crate::sys_common::fs::try_exists; use crate::sys_common::FromInner; use super::to_u16s; |
