Skip to content

Commit

Permalink
do not force resource_path on android
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrouget committed Oct 2, 2017
1 parent 65d9b34 commit aaab56c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions components/config/resource_files.rs
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 aaab56c

Please sign in to comment.