forked from tokio-rs/tokio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: tokio-rs#3373
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::path::Path; | ||
|
||
/// Returns `true` if the path points at an existing entity. | ||
/// | ||
/// This function will traverse symbolic links to query information about the | ||
/// destination file. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ```rust,no_run | ||
/// # use tokio::fs; | ||
/// | ||
/// # #[tokio::main] | ||
/// # async fn main() { | ||
/// let exists = fs::exists("/some/file/path.txt").await; | ||
/// // in case the `/some/file/path.txt` points to existing path | ||
/// assert_eq!(exists, true); | ||
/// # } | ||
/// ``` | ||
/// | ||
/// # Note | ||
/// | ||
/// This method returns false in case of errors thus ignoring them. Use [`fs::metadata`][super::metadata()] | ||
/// if you want to check for errors. | ||
pub async fn exists(path: impl AsRef<Path>) -> bool { | ||
super::metadata(&path).await.is_ok() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters