diff options
author | reduz <reduzio@gmail.com> | 2014-06-11 01:19:39 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2014-06-11 01:19:39 -0300 |
commit | bb0dd1c5f9c1219eb5d4880f5521943f66b8d03f (patch) | |
tree | d7bd13bad144c41f2e8bb448d5d233b46402738b /platform/android/dir_access_jandroid.cpp | |
parent | 2bf34875debd1b60809d22cf61a300b56cdfe084 (diff) | |
parent | e6c1689b69e9e0ec530902b550c9e1e2d1cd0aae (diff) |
Merge pull request #459 from marynate/PR-diracccess-dir-exists
Add DirAccess:dir_exist api
Diffstat (limited to 'platform/android/dir_access_jandroid.cpp')
-rw-r--r-- | platform/android/dir_access_jandroid.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 0c8a5785f8..f32e16e7d8 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -179,6 +179,32 @@ bool DirAccessJAndroid::file_exists(String p_file){ return exists; } +bool DirAccessJAndroid::dir_exists(String p_dir) { + + JNIEnv *env = ThreadAndroid::get_env(); + + String sd; + if (current_dir=="") + sd=p_dir; + else + sd=current_dir+"/"+p_dir; + + String path=fix_path(sd).simplify_path(); + if (path.begins_with("/")) + path=path.substr(1,path.length()); + else if (path.begins_with("res://")) + path=path.substr(6,path.length()); + + jstring js = env->NewStringUTF(path.utf8().get_data()); + int res = env->CallIntMethod(io,_dir_open,js); + if (res<=0) + return false; + + env->CallVoidMethod(io,_dir_close,res); + env->DeleteLocalRef(js); + + return true; +} Error DirAccessJAndroid::make_dir(String p_dir){ |