From aaab56c62723c936124607bdd37be4238c1fb143 Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Mon, 2 Oct 2017 09:24:13 +0200 Subject: [PATCH] do not force resource_path on android --- components/config/resource_files.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/config/resource_files.rs b/components/config/resource_files.rs index bc3e9a78e3e..e8fc58328b0 100644 --- a/components/config/resource_files.rs +++ b/components/config/resource_files.rs @@ -27,10 +27,18 @@ pub fn set_resources_path(path: Option) { #[cfg(target_os = "android")] #[allow(unsafe_code)] pub fn resources_dir_path() -> io::Result { - 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"))]