Skip to content

Windows verbatim paths shouldn't normalize path when .push-ed #11594

Closed
@erickt

Description

@erickt

cc: @kballard

If I understand windows verbatim paths correctly, a path like \\?\a\b\ should not normalize away that last trailing slash. WindowsPath::new does this correctly. However, if we break up the paths into \\?a and b\ and use push to join the paths, that trailing slash is removed:

fn main() {
    let path = WindowsPath::new("\\\\?\\a\\b\\");
    println!("{:?}\n{}\n{:?}", path, path.display(), path.str_components().to_owned_vec());

    let mut path = WindowsPath::new("\\\\?\\a");
    path.push("b\\");
    println!("{:?}\n{}\n{:?}", path, path.display(), path.str_components().to_owned_vec());
}
std::path::windows::Path{repr: ~"\\\\?\\a\\b\\", prefix: Some(VerbatimPrefix(1u)), sepidx: Some(5u)}
\\?\a\b\
~[Some("b")]
std::path::windows::Path{repr: ~"\\\\?\\a\\b", prefix: Some(VerbatimPrefix(1u)), sepidx: Some(5u)}
\\?\a\b
~[Some("b")]

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-windowsOperating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions