summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseemyvest <32128784+seemyvest@users.noreply.github.com>2017-11-10 11:32:32 +1100
committerseemyvest <32128784+seemyvest@users.noreply.github.com>2017-11-10 11:32:32 +1100
commit7f0aa6c6da1b62848eeccb40baadbe0ef3c11c1b (patch)
tree234fe1ed52131981730d59fa5dc2317ad818ca1d
parenteccc0bfa8ea72a382c6e342f9e2f70af1c045a18 (diff)
Don't unwrap header metadata
-rw-r--r--src/lib.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 3bfec0b4..35360d33 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1607,16 +1607,20 @@ impl Bindings {
}
if let Some(h) = options.input_header.as_ref() {
- let md = std::fs::metadata(h).ok().unwrap();
- if !md.is_file() {
- eprintln!("error: '{}' is a folder", h);
- return Err(());
- }
- if !can_read(&md.permissions()) {
- eprintln!("error: insufficient permissions to read '{}'", h);
+ if let Ok(md) = std::fs::metadata(h) {
+ if !md.is_file() {
+ eprintln!("error: '{}' is a folder", h);
+ return Err(());
+ }
+ if !can_read(&md.permissions()) {
+ eprintln!("error: insufficient permissions to read '{}'", h);
+ return Err(());
+ }
+ options.clang_args.push(h.clone())
+ } else {
+ eprintln!("error: header '{}' does not exist.", h);
return Err(());
}
- options.clang_args.push(h.clone())
}
for f in options.input_unsaved_files.iter() {