diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-03-11 11:08:57 +0100 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2015-03-18 13:18:31 -0400 |
commit | 5f15eb5fbfb7a8649132cc8b3a07314389836714 (patch) | |
tree | cc36210329cb1a31709a03685c05c4aaa99407e3 /components/util/resource_files.rs | |
parent | 65d4b12bf20783ea784f1c61f4b33ec0fc975f4f (diff) | |
download | servo-5f15eb5fbfb7a8649132cc8b3a07314389836714.tar.gz servo-5f15eb5fbfb7a8649132cc8b3a07314389836714.zip |
Upgrade rustc to d3c49d2140fc65e8bb7d7cf25bfe74dda6ce5ecf/rustc-1.0.0-dev.
Diffstat (limited to 'components/util/resource_files.rs')
-rw-r--r-- | components/util/resource_files.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/components/util/resource_files.rs b/components/util/resource_files.rs index c1defd887f0..47967981a61 100644 --- a/components/util/resource_files.rs +++ b/components/util/resource_files.rs @@ -2,22 +2,22 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use std::old_io::{File, IoResult}; -use std::old_path::Path; +use std::fs::{File, PathExt}; +use std::io::{self, Read}; +use std::path::PathBuf; #[cfg(target_os = "android")] -pub fn resources_dir_path() -> Path { - Path::new("/sdcard/servo/") +pub fn resources_dir_path() -> PathBuf { + PathBuf::new("/sdcard/servo/") } #[cfg(not(target_os = "android"))] -pub fn resources_dir_path() -> Path { +pub fn resources_dir_path() -> PathBuf { use opts; use std::env; - use std::old_io::fs::PathExtensions; match opts::get().resources_path { - Some(ref path) => Path::new(path), + Some(ref path) => PathBuf::new(path), None => { // FIXME: Find a way to not rely on the executable being // under `<servo source>/components/servo/target` @@ -39,9 +39,13 @@ pub fn resources_dir_path() -> Path { } -pub fn read_resource_file(relative_path_components: &[&str]) -> IoResult<Vec<u8>> { +pub fn read_resource_file(relative_path_components: &[&str]) -> io::Result<Vec<u8>> { let mut path = resources_dir_path(); - path.push_many(relative_path_components); + for component in relative_path_components { + path.push(component); + } let mut file = try!(File::open(&path)); - file.read_to_end() + let mut data = Vec::new(); + try!(file.read_to_end(&mut data)); + Ok(data) } |