Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf3ced9d

Browse files
authored
Rollup merge of#126140 - eduardosm:stabilize-fs_try_exists, r=Amanieu
Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_existsFCP completed in tracking issue.Tracking issue:#83186Closes#83186Stabilized API:```rustmod fs { pub fn exists<P: AsRef<Path>>(path: P) -> io::Result<bool>;}```
2 parentsac47dba +6a04dfe commitf3ced9d

File tree

10 files changed

+18
-19
lines changed

10 files changed

+18
-19
lines changed

‎library/std/src/fs.rs‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,18 +2742,15 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
27422742
/// # Examples
27432743
///
27442744
/// ```no_run
2745-
/// #![feature(fs_try_exists)]
27462745
/// use std::fs;
27472746
///
2748-
/// assert!(!fs::try_exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
2749-
/// assert!(fs::try_exists("/root/secret_file.txt").is_err());
2747+
/// assert!(!fs::exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
2748+
/// assert!(fs::exists("/root/secret_file.txt").is_err());
27502749
/// ```
27512750
///
27522751
/// [`Path::exists`]: crate::path::Path::exists
2753-
// FIXME: stabilization should modify documentation of `exists()` to recommend this method
2754-
// instead.
2755-
#[unstable(feature ="fs_try_exists", issue ="83186")]
2752+
#[stable(feature ="fs_try_exists", since ="CURRENT_RUSTC_VERSION")]
27562753
#[inline]
2757-
pubfntry_exists<P:AsRef<Path>>(path:P) -> io::Result<bool>{
2758-
fs_imp::try_exists(path.as_ref())
2754+
pubfnexists<P:AsRef<Path>>(path:P) -> io::Result<bool>{
2755+
fs_imp::exists(path.as_ref())
27592756
}

‎library/std/src/path.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2907,6 +2907,8 @@ impl Path {
29072907
/// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios
29082908
/// where those bugs are not an issue.
29092909
///
2910+
/// This is an alias for [`std::fs::exists`](crate::fs::exists).
2911+
///
29102912
/// # Examples
29112913
///
29122914
/// ```no_run
@@ -2919,7 +2921,7 @@ impl Path {
29192921
#[stable(feature ="path_try_exists", since ="1.63.0")]
29202922
#[inline]
29212923
pubfntry_exists(&self) -> io::Result<bool>{
2922-
fs::try_exists(self)
2924+
fs::exists(self)
29232925
}
29242926

29252927
/// Returns `true` if the path exists on disk and is pointing at a regular file.

‎library/std/src/sys/pal/hermit/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::sys::time::SystemTime;
1818
usecrate::sys::unsupported;
1919
usecrate::sys_common::{AsInner,AsInnerMut,FromInner,IntoInner};
2020

21-
pubusecrate::sys_common::fs::{copy,try_exists};
21+
pubusecrate::sys_common::fs::{copy,exists};
2222

2323
#[derive(Debug)]
2424
pubstructFile(FileDesc);

‎library/std/src/sys/pal/solid/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
sys::unsupported,
1313
};
1414

15-
pubusecrate::sys_common::fs::try_exists;
15+
pubusecrate::sys_common::fs::exists;
1616

1717
/// A file descriptor.
1818
#[derive(Clone,Copy)]

‎library/std/src/sys/pal/unix/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ use libc::{
9797
))]
9898
use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64};
9999

100-
pubusecrate::sys_common::fs::try_exists;
100+
pubusecrate::sys_common::fs::exists;
101101

102102
pubstructFile(FileDesc);
103103

‎library/std/src/sys/pal/unix/thread.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ mod cgroups {
478478
479479
usecrate::borrow::Cow;
480480
usecrate::ffi::OsString;
481-
usecrate::fs::{try_exists,File};
481+
usecrate::fs::{exists,File};
482482
usecrate::io::Read;
483483
usecrate::io::{BufRead,BufReader};
484484
usecrate::os::unix::ffi::OsStringExt;
@@ -556,7 +556,7 @@ mod cgroups {
556556
path.push("cgroup.controllers");
557557

558558
// skip if we're not looking at cgroup2
559-
ifmatches!(try_exists(&path),Err(_) |Ok(false)){
559+
ifmatches!(exists(&path),Err(_) |Ok(false)){
560560
return usize::MAX;
561561
};
562562

@@ -613,7 +613,7 @@ mod cgroups {
613613
path.push(&group_path);
614614

615615
// skip if we guessed the mount incorrectly
616-
ifmatches!(try_exists(&path),Err(_) |Ok(false)){
616+
ifmatches!(exists(&path),Err(_) |Ok(false)){
617617
continue;
618618
}
619619

‎library/std/src/sys/pal/unsupported/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub fn remove_dir_all(_path: &Path) -> io::Result<()> {
291291
unsupported()
292292
}
293293

294-
pubfntry_exists(_path:&Path) -> io::Result<bool>{
294+
pubfnexists(_path:&Path) -> io::Result<bool>{
295295
unsupported()
296296
}
297297

‎library/std/src/sys/pal/wasi/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::sys::time::SystemTime;
1717
usecrate::sys::unsupported;
1818
usecrate::sys_common::{AsInner,FromInner,IntoInner};
1919

20-
pubusecrate::sys_common::fs::try_exists;
20+
pubusecrate::sys_common::fs::exists;
2121

2222
pubstructFile{
2323
fd:WasiFd,

‎library/std/src/sys/pal/windows/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ pub fn junction_point(original: &Path, link: &Path) -> io::Result<()> {
15311531
}
15321532

15331533
// Try to see if a file exists but, unlike `exists`, report I/O errors.
1534-
pubfntry_exists(path:&Path) -> io::Result<bool>{
1534+
pubfnexists(path:&Path) -> io::Result<bool>{
15351535
// Open the file to ensure any symlinks are followed to their target.
15361536
letmut opts =OpenOptions::new();
15371537
// No read, write, etc access rights are needed.

‎library/std/src/sys_common/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> {
4242
fs::remove_dir(path)
4343
}
4444

45-
pubfntry_exists(path:&Path) -> io::Result<bool>{
45+
pubfnexists(path:&Path) -> io::Result<bool>{
4646
match fs::metadata(path){
4747
Ok(_) =>Ok(true),
4848
Err(error)if error.kind() == io::ErrorKind::NotFound =>Ok(false),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp