mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 05:26:24 +02:00
Add quick method to check file existence by content URI.
Seems to speed up bringing up the pause screen slightly (checking for save state files).
This commit is contained in:
1 parent
15fafe5415
commit
4f10ff9d31
4 files changed
+39
-6
No files matched your search
@@ -14,6 +14,7 @@ static jmethodID contentUriCreateDirectory;
|
||||
static jmethodID contentUriRemoveFile;
|
||||
static jmethodID contentUriRenameFileTo;
|
||||
static jmethodID contentUriGetFileInfo;
|
||||
static jmethodID contentUriFileExists;
|
||||
static jmethodID contentUriGetFreeStorageSpace;
|
||||
static jmethodID filePathGetFreeStorageSpace;
|
||||
|
||||
@@ -38,6 +39,8 @@ void Android_RegisterStorageCallbacks(JNIEnv * env, jobject obj) {
|
||||
_dbg_assert_(contentUriRenameFileTo);
|
||||
contentUriGetFileInfo = env->GetMethodID(env->GetObjectClass(obj), "contentUriGetFileInfo", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
_dbg_assert_(contentUriGetFileInfo);
|
||||
contentUriFileExists = env->GetMethodID(env->GetObjectClass(obj), "contentUriFileExists", "(Ljava/lang/String;)Z");
|
||||
_dbg_assert_(contentUriFileExists);
|
||||
contentUriGetFreeStorageSpace = env->GetMethodID(env->GetObjectClass(obj), "contentUriGetFreeStorageSpace", "(Ljava/lang/String;)J");
|
||||
_dbg_assert_(contentUriGetFreeStorageSpace);
|
||||
filePathGetFreeStorageSpace = env->GetMethodID(env->GetObjectClass(obj), "filePathGetFreeStorageSpace", "(Ljava/lang/String;)J");
|
||||
@@ -156,6 +159,16 @@ bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *fileInfo) {
|
||||
return retval && fileInfo->exists;
|
||||
}
|
||||
|
||||
bool Android_FileExists(const std::string &fileUri) {
|
||||
if (!g_nativeActivity) {
|
||||
return false;
|
||||
}
|
||||
auto env = getEnv();
|
||||
jstring paramFileUri = env->NewStringUTF(fileUri.c_str());
|
||||
bool exists = env->CallBooleanMethod(g_nativeActivity, contentUriFileExists, paramFileUri);
|
||||
return exists;
|
||||
}
|
||||
|
||||
std::vector<File::FileInfo> Android_ListContentUri(const std::string &path) {
|
||||
if (!g_nativeActivity) {
|
||||
return std::vector<File::FileInfo>();
|
||||
|
||||
Reference in new issue
Block a user