pub async fn metadata<P: AsRef<Path>>(path: P) -> Result<Metadata>
Expand description
Given a path, query the file system to get information about a file, directory, etc.
This function will traverse symbolic links to query information about the destination file.
§Platform-specific behavior
current implementation is only for Linux.
§Errors
This function will return an error in the following situations, but is not limited to just these cases:
- The user lacks permissions to perform
metadata
call onpath
.- execute(search) permission is required on all of the directories in path that lead to the file.
path
does not exist.
§Examples
use monoio::fs;
#[monoio::main]
async fn main() -> std::io::Result<()> {
let attr = fs::metadata("/some/file/path.txt").await?;
// inspect attr ...
Ok(())
}