Lines Matching defs:path
32 //! Ok(path) => println!("{:?}", path.display()),
52 //! if let Ok(path) = entry {
53 //! println!("{:?}", path.display())
77 use std::path::{self, Component, Path, PathBuf};
115 /// of the matched path. In other words, each item returned by the iterator
116 /// will either be an `Ok(Path)` if the path matched, or an `Err(GlobError)` if
117 /// the path (partially) matched _but_ its contents could not be read in order
132 /// Ok(path) => println!("{:?}", path.display()),
134 /// // if the path matched but was unreadable,
155 /// for path in glob("/media/pictures/*.jpg").unwrap().filter_map(Result::ok) {
156 /// println!("{}", path.display());
240 pattern[cmp::min(root_len, pattern.len())..].split_terminator(path::is_separator);
254 let last_is_separator = pattern.chars().next_back().map(path::is_separator);
269 /// This is typically returned when a particular path cannot be read
274 path: PathBuf,
280 pub fn path(&self) -> &Path {
281 &self.path
312 self.path.display(),
324 /// This represents either a matched path or a glob iteration error,
350 let (path, mut idx) = match self.todo.pop().unwrap() {
355 // idx -1: was already checked by fill_todo, maybe path was '.' or
358 if self.require_dir && !is_dir(&path) {
361 return Some(Ok(path));
374 if is_dir(&path) {
375 // the path is a directory, so it's a match
382 &path,
389 return Some(Ok(path));
391 // advanced to the next pattern for this path
399 // advanced to the next pattern for this path
407 match path.file_name().and_then(|s| s.to_str()) {
422 if !self.require_dir || is_dir(&path) {
423 return Some(Ok(path));
430 &path,
473 /// sequence **must** form a single path component, so both `**a` and `b**`
537 const ERROR_RECURSIVE_WILDCARDS: &str = "recursive wildcards must form a single path \
572 // ** can only be an entire path component
575 let is_valid = if i == 2 || path::is_separator(chars[i - count - 1]) {
577 if i < chars.len() && path::is_separator(chars[i]) {
698 pub fn matches_path(&self, path: &Path) -> bool {
700 path.to_str().map_or(false, |s| self.matches(s))
711 pub fn matches_path_with(&self, path: &Path, options: MatchOptions) -> bool {
713 path.to_str()
748 follows_separator = path::is_separator(c);
775 let is_sep = path::is_separator(c);
808 // Fills `todo` with paths under `path` to be matched by `patterns[idx]`,
815 path: &Path,
833 // We know it's good, so don't make the iterator match this path
835 // . or .. globs since these never show up as path components.
843 let is_dir = is_dir(path);
844 let curdir = path == Path::new(".");
856 path.join(&s)
863 let dirs = fs::read_dir(path).and_then(|d| {
867 PathBuf::from(e.path().file_name().unwrap())
869 e.path()
888 add(todo, path.join(special));
895 path: path.to_path_buf(),
961 if cfg!(windows) && path::is_separator(a) && path::is_separator(b) {
981 /// Whether or not path-component separator characters (e.g. `/` on
1025 use std::path::Path;
1077 assert!(err.path() == Path::new("/root"));
1095 use std::path::Component;
1103 let path = Path::new(prefix_component.as_os_str());
1104 path.join("*");
1105 Some(path.to_path_buf())
1107 _ => panic!("no prefix in this path"),
1179 // Only start sub-patterns on start of path segment.
1248 assert!(txt_pat.matches("some/path/to/hello.txt"));
1249 assert!(txt_pat.matches("some\\path\\to\\hello.txt"));
1250 assert!(txt_pat.matches("/an/absolute/path/to/hello.txt"));
1254 let dir_pat = Pattern::new("*some/path/to/hello.txt").unwrap();
1255 assert!(dir_pat.matches("some/path/to/hello.txt"));
1256 assert!(dir_pat.matches("a/bigger/some/path/to/hello.txt"));
1257 assert!(!dir_pat.matches("some/path/to/hello.txt-and-then-some"));
1258 assert!(!dir_pat.matches("some/other/path/to/hello.txt"));