Expand a glob pattern rooted at `cwd`, returning absolute paths.
(pattern: &str, cwd: &Path)
| 125 | |
| 126 | /// Expand a glob pattern rooted at `cwd`, returning absolute paths. |
| 127 | fn expand_glob(pattern: &str, cwd: &Path) -> Vec<PathBuf> { |
| 128 | let full = if Path::new(pattern).is_absolute() { |
| 129 | pattern.to_string() |
| 130 | } else { |
| 131 | cwd.join(pattern).to_string_lossy().to_string() |
| 132 | }; |
| 133 | match glob::glob(&full) { |
| 134 | Ok(paths) => paths |
| 135 | .filter_map(|entry| entry.ok()) |
| 136 | .filter(|p| p.is_file()) |
| 137 | .collect(), |
| 138 | Err(_) => Vec::new(), |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | /// Walk up from `start` to `stop`, expanding a glob pattern at each level. |
| 143 | fn glob_up(pattern: &str, start: &Path, stop: &Path) -> Vec<PathBuf> { |