pub struct Metadata { /* private fields */ }
root
only.Expand description
Metadata information about a file.
This structure is returned from the metadata
function and represents
known metadata about a file such as its permissions, size, modification
times, etc.
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn is_dir(&self) -> bool
pub fn is_dir(&self) -> bool
Returns true
if this metadata is for a directory. The result is
mutually exclusive to the result of Metadata::is_file
.
§Examples
use relative_path_utils::Root;
let root = Root::new(".")?;
let metadata = root.metadata("foo.txt")?;
assert!(!metadata.is_dir());
Sourcepub fn is_file(&self) -> bool
pub fn is_file(&self) -> bool
Returns true
if this metadata is for a regular file. The result is
mutually exclusive to the result of Metadata::is_dir
.
When the goal is simply to read from (or write to) the source, the most
reliable way to test the source can be read (or written to) is to open
it. Only using is_file
can break workflows like diff <( prog_a )
on
a Unix-like system for example. See Root::open
or
OpenOptions::open
for more information.
§Examples
use relative_path_utils::Root;
let root = Root::new(".")?;
let metadata = root.metadata("foo.txt")?;
assert!(metadata.is_file());
Sourcepub fn is_symlink(&self) -> bool
pub fn is_symlink(&self) -> bool
Returns true
if this metadata is for a symbolic link.
§Examples
use relative_path_utils::Root;
let root = Root::new(".")?;
let metadata = root.metadata("foo.txt")?;
assert!(metadata.is_symlink());