You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if there is a file whose filename is too long, about 190 bytes, walk will fail and report error forever.
/mnt/d/tmp/rustmp/a1 - 副本.txt
/mnt/d/tmp/rustmp/a1.txt
failed to access entry
Error 1 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 2 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 3 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 4 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 5 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 6 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
my code is just like this
`
fn walk(inpath:String, list:&mut Vec) {
let mut errv:i32 = 0;
let path = Path::new(&inpath);
for entry in WalkDir::new(path){
match &entry {
Ok(path) => {
println!("{}", path.path().display());
}
}
Err(err) => {
let errpath = err.path().unwrap_or(Path::new("")).display();
println!("failed to access entry {}", errpath);
errv = errv+1;
println!("Error {} {:?}", errv, entry);
let three_seconds = Duration::from_secs(3);
sleep(three_seconds);
continue
}
`
i guess it happens because the program running in Linux is going to read a directory in NTFS of windows, there is a limit of max 256 for filename in linux filesystem, but in windows, there is no such limit.
i wonder how to skip the error entry when it happens, in this case , the program seems to be in a loop, although in the doc it says :"If an error occurs at any point during iteration, then it is returned in place of its corresponding directory entry and iteration continues as normal. "
The text was updated successfully, but these errors were encountered:
Windows certainly has a limit on the length of file paths. You might try using verbatim paths. Otherwise walkdir is just surfacing OS errors. I'm not sure there's anything it can do.
In terms of dealing with the error, you haven't provided code that I can actually run. Please provide a reproducible example.
if there is a file whose filename is too long, about 190 bytes, walk will fail and report error forever.
/mnt/d/tmp/rustmp/a1 - 副本.txt
/mnt/d/tmp/rustmp/a1.txt
failed to access entry
Error 1 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 2 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 3 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 4 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 5 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 6 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
my code is just like this
`
fn walk(inpath:String, list:&mut Vec) {
let mut errv:i32 = 0;
let path = Path::new(&inpath);
for entry in WalkDir::new(path){
match &entry {
Ok(path) => {
println!("{}", path.path().display());
}
}
Err(err) => {
let errpath = err.path().unwrap_or(Path::new("")).display();
println!("failed to access entry {}", errpath);
errv = errv+1;
println!("Error {} {:?}", errv, entry);
let three_seconds = Duration::from_secs(3);
sleep(three_seconds);
continue
}
`
i guess it happens because the program running in Linux is going to read a directory in NTFS of windows, there is a limit of max 256 for filename in linux filesystem, but in windows, there is no such limit.
i wonder how to skip the error entry when it happens, in this case , the program seems to be in a loop, although in the doc it says :"If an error occurs at any point during iteration, then it is returned in place of its corresponding directory entry and iteration continues as normal. "
The text was updated successfully, but these errors were encountered: