Skip to content

win api and fs module: filepath too long, ntfs on windows 64 #19311

Closed
@viperscape

Description

@viperscape

rust is unable to list directory contents on mounted ntfs drive. ntfs can hold extremely long folder structures but the native win API cannot browse them. This is not always a problem, for example: cygwin's LS executable compiled for windows, or java's file modules can browse these just fine since they do not rely on the win api. linux and mac osx can browse these window server shared folders as well. Does Rust for windows rely on the win api? it's unable to list contents in a deeply nested folder.

See below example, where K is a mounted SMB share that resides on a windows server (this is compile on latest rust 32bit for windows)

use std::io::fs;
fn main () {
    let path = "K:/IT/testing/";
    let sub1 = "wejhflkjwehfhwelhfkljwehfhkwehfkjlhwekjlfhkjwehfhwejkhfuiweh nweuiyfhuih4389578347589069045uyrt98y78yrf78gyv78yr78f76345yughvuidfu89yg7845y78tyg8y9845y78gy7845hy5678346578y78ghvcx jxbzcvjsbguyfg764wtr763 85474678 69346 35/";

    let sub2 = "4375848v 9t489bu89cb n89fg89gf7g89fn89g7df98 g79r 7g9re78976re78er78 t60we6re7er6w7878w46t7834545bytbxcvu8v6r7 fye49th4ui 7878t6r78tg645t6 46uygt78g6xrt645jk6h78t7y8dxzg78e5 ht6455ytr78sr6e4tnovn47654t6/";

    let fullpath = path.to_string() + sub1.to_string() + sub2.to_string(); // fails!
    let mostpath = path.to_string() + sub1.to_string(); // works!

    let path1 = fs::readdir(&Path::new(fullpath.to_string())).unwrap(); //fails with fullpath!

    for src in path1.iter() {
        println!("{}",src.filename_str().unwrap());
    }
}
cargo run --verbose
       Fresh rust_test v0.0.1 (file:///C:/Users/chris/rust_test)
     Running `..\target\rust_test`
task '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: couldn't read directory (OS Error 3: The system cannot find the path specified.
; path=K:\IT\testing\wejhflkjwehfhwelhfkljwehfhkwehfkjlhwekjlfhkjwehfhwejkhfuiweh nweuiyfhuih4389578347589069045uyrt98y78yrf78gyv78yr78f76345yughvuidfu89yg7845y78tyg8y9845y78gy7845hy5678346578y78ghvcx jxbzcvjsbguyfg764wtr763 85474678 69346 35\4375848v 9t489bu89cb n89fg89gf7g89fn89g7df98 g79r 7g9re78976re78er78 t60we6re7er6w7878w46t7834545bytbxcvu8v6r7 fye49th4ui 7878t6r78tg645t6 46uygt78g6xrt645jk6h78t7y8dxzg78e5 ht6455ytr78sr6e4tnovn47654t6)', C:\bot\slave\nightly-win-32\build\src\libcore\result.rs:743
An unknown error occurred
Process didn't exit successfully: `..\target\rust_test` (status=101)

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