Skip to content

Commit 55d550e

Browse files
authored
Merge pull request #112 from nico-abram/uwu
Fixes #111
2 parents 949a5b0 + 47c0cf3 commit 55d550e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,15 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Result<Paths, PatternE
178178
#[cfg(windows)]
179179
fn check_windows_verbatim(p: &Path) -> bool {
180180
match p.components().next() {
181-
Some(Component::Prefix(ref p)) => p.kind().is_verbatim(),
181+
Some(Component::Prefix(ref p)) => {
182+
// Allow VerbatimDisk paths. std canonicalize() generates them, and they work fine
183+
p.kind().is_verbatim()
184+
&& if let std::path::Prefix::VerbatimDisk(_) = p.kind() {
185+
false
186+
} else {
187+
true
188+
}
189+
}
182190
_ => false,
183191
}
184192
}

tests/glob-std.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ fn main() {
9191
)
9292
);
9393

94+
// std-canonicalized windows verbatim disk paths should work
95+
if env::consts::FAMILY == "windows" {
96+
let r_verbatim = PathBuf::from("r").canonicalize().unwrap();
97+
assert_eq!(
98+
glob_vec(&format!("{}\\**", r_verbatim.display().to_string()))
99+
.into_iter()
100+
.map(|p| p.strip_prefix(&r_verbatim).unwrap().to_owned())
101+
.collect::<Vec<_>>(),
102+
vec!(
103+
PathBuf::from("another"),
104+
PathBuf::from("one"),
105+
PathBuf::from("one\\another"),
106+
PathBuf::from("one\\another\\deep"),
107+
PathBuf::from("three"),
108+
PathBuf::from("two")
109+
)
110+
);
111+
}
112+
94113
// collapse consecutive recursive patterns
95114
assert_eq!(
96115
glob_vec("r/**/**"),

0 commit comments

Comments
 (0)