Error while doing file completion on windows #136
Skip file(s) which access is denied.
diff --git a/src/completion.rs b/src/completion.rs
index aeb9a34..d754bf7 100644
--- a/src/completion.rs
+++ b/src/completion.rs
@@ -261,14 +261,16 @@
let entry = try!(entry);
if let Some(s) = entry.file_name().to_str() {
if s.starts_with(file_name) {
- let mut path = String::from(dir_name) + s;
- if try!(fs::metadata(entry.path())).is_dir() {
- path.push(sep);
- }
- entries.push(Pair {
- display: String::from(s),
- replacement: escape(path, esc_char, break_chars),
- });
+ if let Ok(metadata) = fs::metadata(entry.path()) {
+ let mut path = String::from(dir_name) + s;
+ if metadata.is_dir() {
+ path.push(sep);
+ }
+ entries.push(Pair {
+ display: String::from(s),
+ replacement: escape(path, esc_char, break_chars),
+ });
+ } // else ignore PermissionDenied
}
}
}