// Copyright (c) 2018 The predicates-rs Project Developers. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
use std::fmt; use std::fs; use std::io; use std::path;
impl fmt::Display for FileType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let t = match *self {
FileType::File => "file",
FileType::Dir => "dir",
FileType::Symlink => "symlink",
};
write!(f, "{t}")
}
}
/// Predicate that checks the `std::fs::FileType`. /// /// This is created by the `predicate::path::is_file`, `predicate::path::is_dir`, and `predicate::path::is_symlink`. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pubstruct FileTypePredicate {
ft: FileType,
follow: bool,
}
impl FileTypePredicate { /// Follow symbolic links. /// /// When yes is true, symbolic links are followed as if they were normal directories and files. /// /// Default: disabled. pubfn follow_links(mutself, yes: bool) -> Self { self.follow = yes; self
}
/// Allow to create an `FileTypePredicate` from a `path` pubfn from_path(path: &path::Path) -> io::Result<FileTypePredicate> {
Ok(FileTypePredicate {
ft: FileType::from_path(path, true)?,
follow: true,
})
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.