Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions library/std/src/path/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,12 +873,12 @@ pub fn test_decompositions_windows() {
);

t!("\\\\.\\foo/bar",
iter: ["\\\\.\\foo/bar", "\\"],
iter: ["\\\\.\\foo", "\\", "bar"],
has_root: true,
is_absolute: true,
parent: None,
file_name: None,
file_stem: None,
parent: Some("\\\\.\\foo/"),
file_name: Some("bar"),
file_stem: Some("bar"),
extension: None
);

Expand Down
5 changes: 3 additions & 2 deletions library/std/src/sys/windows/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix<'_>> {
}
// \\?\cat_pics
_ => {
let idx = path.iter().position(|&b| b == b'\\').unwrap_or(path.len());
let idx =
path.iter().position(|&b| is_verbatim_sep(b)).unwrap_or(path.len());
let slice = &path[..idx];
return Some(Verbatim(unsafe { u8_slice_as_os_str(slice) }));
}
}
}
} else if let Some(path) = path.strip_prefix(b".\\") {
// \\.\COM42
let idx = path.iter().position(|&b| b == b'\\').unwrap_or(path.len());
let idx = path.iter().position(|&b| is_sep_byte(b)).unwrap_or(path.len());
let slice = &path[..idx];
return Some(DeviceNS(unsafe { u8_slice_as_os_str(slice) }));
}
Expand Down