-
-
Notifications
You must be signed in to change notification settings - Fork 109
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 #23
Comments
I don't think this is a bug with walkdir. You'll probably want to reproduce this with a normal File::open call and file a bug on rust-lang/rust. |
You're right. std::fs::read_dir is the problem. |
More information has come up. This is a limitation of the operating system. On Linux, you can find out the maximal length for a relative path with
|
I'm not sure walkdir should be changing the current working directory automatically. Keep in mind that this is a library, not a command line tool like |
Doing a fn read_deep_dir<P: AsRef<Path>>(path: P) -> Result<ReadDir> {
let len = path.as_os_str().len();
if (len >= max_path) {
let dir = current_dir()?;
get_close_to(path);
let r = read_dir(path);
set_current_dir(dir)?;
r
} else {
read_dir(path)
}
} The path length limitation is unfortunate. Changing the working directory, even briefly, is risky.
int openat(int fd, const char *path, int oflag, ...);
https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu/libc/fn.openat.html |
@vandenoever I understand the overhead can probably be minimized. That's not really my concern. My concern is that library shouldn't be changing process global state. Consider what happens when there are multiple walkdir iterators running in parallel in the same process. Bad bad things will happen.
|
Agreed. It'll require a fork of |
Yeah, that is unfortunate, but shouldn't be too bad. Forking might actually be a blessing in disguise. Last time I looked (which was a while ago), I had the suspicion that I could remove an allocation or two... |
I did a little digging on this today, and to my amazement, |
Yep, unless you pass |
WalkDir cannot handle long paths that
find
handles fine.The text was updated successfully, but these errors were encountered: