Skip to content

Commit

Permalink
servo: Merge #18702 - do not force resource_path on android (from pau…
Browse files Browse the repository at this point in the history
…lrouget:android_res_path); r=Manishearth

I want to be able to configure the resource path via `set_resources_path`.

Source-Repo: https://github.com/servo/servo
Source-Revision: b1c2d7195dd01a131c10d2bc2ad457a51c3fa118
  • Loading branch information
paulrouget committed Oct 4, 2017
1 parent fca334b commit 3ad324a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions servo/components/config/resource_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ pub fn set_resources_path(path: Option<String>) {
#[cfg(target_os = "android")]
#[allow(unsafe_code)]
pub fn resources_dir_path() -> io::Result<PathBuf> {
let dir = unsafe {
let mut dir = CMD_RESOURCE_DIR.lock().unwrap();

if let Some(ref path) = *dir {
return Ok(PathBuf::from(path));
}

let data_path = unsafe {
CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath)
};
Ok(PathBuf::from(dir.to_str().unwrap()))
let path = PathBuf::from(data_path.to_str().unwrap());
*dir = Some(path.to_str().unwrap().to_owned());
Ok(path)
}

#[cfg(not(target_os = "android"))]
Expand Down

0 comments on commit 3ad324a

Please sign in to comment.