aboutsummaryrefslogtreecommitdiffstats
path: root/components/util/resource_files.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/util/resource_files.rs')
-rw-r--r--components/util/resource_files.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/components/util/resource_files.rs b/components/util/resource_files.rs
index 9c2eab83df6..4a155ecf51e 100644
--- a/components/util/resource_files.rs
+++ b/components/util/resource_files.rs
@@ -21,24 +21,24 @@ pub fn set_resources_path(path: Option<String>) {
}
#[cfg(target_os = "android")]
-pub fn resources_dir_path() -> PathBuf {
- PathBuf::from("/sdcard/servo/")
+pub fn resources_dir_path() -> io::Result<PathBuf> {
+ Ok(PathBuf::from("/sdcard/servo/"))
}
#[cfg(not(target_os = "android"))]
-pub fn resources_dir_path() -> PathBuf {
+pub fn resources_dir_path() -> io::Result<PathBuf> {
let mut dir = CMD_RESOURCE_DIR.lock().unwrap();
if let Some(ref path) = *dir {
- return PathBuf::from(path);
+ return Ok(PathBuf::from(path));
}
// FIXME: Find a way to not rely on the executable being
// under `<servo source>[/$target_triple]/target/debug`
// or `<servo source>[/$target_triple]/target/release`.
- let mut path = env::current_exe().expect("can't get exe path");
+ let mut path = try!(env::current_exe());
// Follow symlink
- path = path.canonicalize().expect("path does not exist");
+ path = try!(path.canonicalize());
while path.pop() {
path.push("resources");
@@ -54,11 +54,11 @@ pub fn resources_dir_path() -> PathBuf {
path.pop();
}
*dir = Some(path.to_str().unwrap().to_owned());
- path
+ Ok(path)
}
pub fn read_resource_file<P: AsRef<Path>>(relative_path: P) -> io::Result<Vec<u8>> {
- let mut path = resources_dir_path();
+ let mut path = try!(resources_dir_path());
path.push(relative_path);
let mut file = try!(File::open(&path));
let mut data = Vec::new();