summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-11-10 04:22:22 -0600
committerGitHub <noreply@github.com>2017-11-10 04:22:22 -0600
commitc54e64c5377d299d67b6a9f2d735ba49740a7ae6 (patch)
tree234fe1ed52131981730d59fa5dc2317ad818ca1d /src
parenteccc0bfa8ea72a382c6e342f9e2f70af1c045a18 (diff)
parent7f0aa6c6da1b62848eeccb40baadbe0ef3c11c1b (diff)
Auto merge of #1146 - seemyvest:fix-metadata, r=emilio
Don't unwrap header metadata Fix for a comment in #1092. r? @fitzgen
Diffstat (limited to 'src')
-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() {