We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
std::fs::try_exists
std::fs::exists
1 parente3c3ce6 commit0637c43Copy full SHA for 0637c43
library/std/src/fs.rs
@@ -2739,18 +2739,15 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
2739
/// # Examples
2740
///
2741
/// ```no_run
2742
-/// #![feature(fs_try_exists)]
2743
/// use std::fs;
2744
2745
-/// assert!(!fs::try_exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
2746
-/// assert!(fs::try_exists("/root/secret_file.txt").is_err());
+/// assert!(!fs::exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
+/// assert!(fs::exists("/root/secret_file.txt").is_err());
2747
/// ```
2748
2749
/// [`Path::exists`]: crate::path::Path::exists
2750
-// FIXME: stabilization should modify documentation of `exists()` to recommend this method
2751
-// instead.
2752
-#[unstable(feature ="fs_try_exists", issue ="83186")]
+#[stable(feature ="fs_try_exists", since ="CURRENT_RUSTC_VERSION")]
2753
#[inline]
2754
-pubfntry_exists<P:AsRef<Path>>(path:P) -> io::Result<bool>{
2755
- fs_imp::try_exists(path.as_ref())
+pubfnexists<P:AsRef<Path>>(path:P) -> io::Result<bool>{
+ fs_imp::exists(path.as_ref())
2756
}
library/std/src/path.rs
@@ -2888,6 +2888,8 @@ impl Path {
2888
/// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios
2889
/// where those bugs are not an issue.
2890
2891
+/// This is an alias for [`std::fs::exists`](crate::fs::exists).
2892
+///
2893
2894
2895
@@ -2900,7 +2902,7 @@ impl Path {
2900
2902
#[stable(feature ="path_try_exists", since ="1.63.0")]
2901
2903
2904
pubfntry_exists(&self) -> io::Result<bool>{
- fs::try_exists(self)
2905
+ fs::exists(self)
2906
2907
2908
/// Returns `true` if the path exists on disk and is pointing at a regular file.
library/std/src/sys/pal/unix/fs.rs
@@ -101,7 +101,7 @@ use libc::{
101
))]
102
use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64};
103
104
-pubusecrate::sys_common::fs::try_exists;
+pubusecrate::sys_common::fs::exists;
105
106
pubstructFile(FileDesc);
107
library/std/src/sys/pal/unix/thread.rs
@@ -477,7 +477,7 @@ mod cgroups {
477
//! output and we don't unescape
478
usecrate::borrow::Cow;
479
usecrate::ffi::OsString;
480
-usecrate::fs::{try_exists,File};
+usecrate::fs::{exists,File};
481
usecrate::io::Read;
482
usecrate::io::{BufRead,BufReader};
483
usecrate::os::unix::ffi::OsStringExt;
@@ -555,7 +555,7 @@ mod cgroups {
555
path.push("cgroup.controllers");
556
557
// skip if we're not looking at cgroup2
558
-ifmatches!(try_exists(&path),Err(_) |Ok(false)){
+ifmatches!(exists(&path),Err(_) |Ok(false)){
559
return usize::MAX;
560
};
561
@@ -612,7 +612,7 @@ mod cgroups {
612
path.push(&group_path);
613
614
// skip if we guessed the mount incorrectly
615
616
continue;
617
618
library/std/src/sys/pal/unsupported/fs.rs
@@ -291,7 +291,7 @@ pub fn remove_dir_all(_path: &Path) -> io::Result<()> {
291
unsupported()
292
293
294
-pubfntry_exists(_path:&Path) -> io::Result<bool>{
+pubfnexists(_path:&Path) -> io::Result<bool>{
295
296
297
library/std/src/sys/pal/windows/fs.rs
@@ -1531,7 +1531,7 @@ pub fn junction_point(original: &Path, link: &Path) -> io::Result<()> {
1531
1532
1533
// Try to see if a file exists but, unlike `exists`, report I/O errors.
1534
-pubfntry_exists(path:&Path) -> io::Result<bool>{
+pubfnexists(path:&Path) -> io::Result<bool>{
1535
// Open the file to ensure any symlinks are followed to their target.
1536
letmut opts =OpenOptions::new();
1537
// No read, write, etc access rights are needed.
library/std/src/sys_common/fs.rs
@@ -42,7 +42,7 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> {
42
fs::remove_dir(path)
43
44
45
46
match fs::metadata(path){
47
Ok(_) =>Ok(true),
48
Err(error)if error.kind() == io::ErrorKind::NotFound =>Ok(false),