Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"File name too long" error at 4096 bytes #42350

Closed
vandenoever opened this issue Jun 1, 2017 · 2 comments
Closed

"File name too long" error at 4096 bytes #42350

vandenoever opened this issue Jun 1, 2017 · 2 comments
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@vandenoever
Copy link

Rust cannot handle long paths on Linux. It fails on paths longer than 4096 bytes.

use std::fs::{create_dir, read_dir};
use std::env::{current_dir, set_current_dir};

fn main() {
    let dir = current_dir().unwrap();
    let name = "a";
    for i in 0..2200 {
        if i % 100 == 0 {
            println!("Create dir at level {}.", i);
        }
        let d = current_dir().unwrap();
        read_dir(d).unwrap(); // fails for long paths
        create_dir(name).unwrap();
        set_current_dir(name).unwrap();
    }
}
@nagisa nagisa added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jun 1, 2017
@vandenoever
Copy link
Author

This is a limitation of the operating system. On Linux, you can find out the maximal length for a relative path with getconf PATH_MAX / on the command-line or with the POSIX function pathconf("/", _PC_PATH_MAX).

@jakwings
Copy link

jakwings commented Apr 7, 2019

Coming from BurntSushi/walkdir#23

I hope you reopen this issue since the doc doesn't specify the detailed implementation of this function. Maybe there could be an improvement? Have people already discussed this topic somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants