I currently get 2 extra path separators after the drive e.g. C:\\\Users\Ofek\Desktop\... which does not work in Windows.
Windows 7:
Windows 10:
According to Microsoft:
Note File I/O functions in the Windows API convert
/to\as part of converting the name to an NT-style name, except when using the\\?\prefix as detailed in the following sections.
Source: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
And the Ruby language uses forward slashes for File paths and that works on Windows.
@sharkdp Upon further inspection, it appears that this is something specific to fd. The \\?\ is correctly removed but I don't know where those 2 extra separators come from.
use std::path::Path;
fn main() {
let path = Path::new("C:/Users/Ofek");
println!("{}", path.canonicalize().unwrap().display());
}
yields \\?\C:\Users\Ofek.
This might come from using Path::join.. but that's just a guess. Will take a closer look soon.
Has this already been fixed? I can't repro this behavior on Windows 10.
E:\Development\Rust\Projects\fd>ver
Microsoft Windows [Version 10.0.15063]
E:\Development\Rust\Projects\fd>rustc --version
rustc 1.21.0 (3b72af97e 2017-10-09)
E:\Development\Rust\Projects\fd>git rev-parse --short HEAD
8fc3a83
E:\Development\Rust\Projects\fd>target\debug\fd.exe -a -c never
E:\Development\Rust\Projects\fd\CONTRIBUTING.md
E:\Development\Rust\Projects\fd\Cargo.lock
E:\Development\Rust\Projects\fd\Cargo.toml
E:\Development\Rust\Projects\fd\LICENSE
E:\Development\Rust\Projects\fd\README.md
E:\Development\Rust\Projects\fd\appveyor.yml
E:\Development\Rust\Projects\fd\build.rs
E:\Development\Rust\Projects\fd\src
E:\Development\Rust\Projects\fd\src\app.rs
E:\Development\Rust\Projects\fd\src\fshelper
E:\Development\Rust\Projects\fd\src\fshelper\mod.rs
E:\Development\Rust\Projects\fd\src\internal.rs
E:\Development\Rust\Projects\fd\src\lscolors
E:\Development\Rust\Projects\fd\src\lscolors\mod.rs
E:\Development\Rust\Projects\fd\src\main.rs
E:\Development\Rust\Projects\fd\src\output.rs
E:\Development\Rust\Projects\fd\src\walk.rs
E:\Development\Rust\Projects\fd\tests
E:\Development\Rust\Projects\fd\tests\testenv
E:\Development\Rust\Projects\fd\tests\testenv\mod.rs
E:\Development\Rust\Projects\fd\tests\tests.rs
@reima Thank you for the feedback. It has not been fixed.
I'm not sure, but this issue might only appear if an explicit search path is given (like in target\debug\fd.exe -c never E:\Development)
It works for me even with an explicit path:
E:\Development\Rust\Projects\fd>target\debug\fd.exe -c never . E:\\Development\\Rust\\Projects\\fd
E:\Development\Rust\Projects\fd\CONTRIBUTING.md
E:\Development\Rust\Projects\fd\Cargo.lock
E:\Development\Rust\Projects\fd\Cargo.toml
E:\Development\Rust\Projects\fd\LICENSE
E:\Development\Rust\Projects\fd\README.md
E:\Development\Rust\Projects\fd\appveyor.yml
E:\Development\Rust\Projects\fd\build.rs
E:\Development\Rust\Projects\fd\src
E:\Development\Rust\Projects\fd\src\app.rs
E:\Development\Rust\Projects\fd\src\fshelper
E:\Development\Rust\Projects\fd\src\fshelper\mod.rs
E:\Development\Rust\Projects\fd\src\internal.rs
E:\Development\Rust\Projects\fd\src\lscolors
E:\Development\Rust\Projects\fd\src\lscolors\mod.rs
E:\Development\Rust\Projects\fd\src\main.rs
E:\Development\Rust\Projects\fd\src\output.rs
E:\Development\Rust\Projects\fd\src\walk.rs
E:\Development\Rust\Projects\fd\tests
E:\Development\Rust\Projects\fd\tests\testenv
E:\Development\Rust\Projects\fd\tests\testenv\mod.rs
E:\Development\Rust\Projects\fd\tests\tests.rs
@ofek Can you please tell us how to reproduce this issue?
The bug is in the colored output (which I disabled in my examples). The problem is that the first std::path::Components of an absolute path on Windows are Prefix(_) (the drive letter) and RootDir (root of the drive). The string value of RootDir is the path separator \. So the three consecutive path separators are:
I'll make a PR in a bit.
@reima Great job bug hunting!
Most helpful comment
The bug is in the colored output (which I disabled in my examples). The problem is that the first
std::path::Components of an absolute path on Windows arePrefix(_)(the drive letter) andRootDir(root of the drive). The string value ofRootDiris the path separator\. So the three consecutive path separators are:I'll make a PR in a bit.