2021-06-05 17:29:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "Common/File/DirListing.h"
|
|
|
|
|
|
|
|
// To emphasize that Android storage mode strings are different, let's just use
|
|
|
|
// an enum.
|
|
|
|
enum class Android_OpenContentUriMode {
|
|
|
|
READ = 0, // "r"
|
|
|
|
READ_WRITE = 1, // "rw"
|
|
|
|
READ_WRITE_TRUNCATE = 2, // "rwt"
|
|
|
|
};
|
|
|
|
|
2021-07-20 10:55:33 +00:00
|
|
|
// Matches the constants in PpssppActivity.java.
|
|
|
|
enum class ContentError {
|
|
|
|
SUCCESS = 0,
|
|
|
|
OTHER = -1,
|
|
|
|
NOT_FOUND = -2,
|
|
|
|
DISK_FULL = -3,
|
|
|
|
};
|
|
|
|
|
|
|
|
inline ContentError ContentErrorFromInt(int ival) {
|
|
|
|
if (ival >= 0) {
|
|
|
|
return ContentError::SUCCESS;
|
|
|
|
} else {
|
|
|
|
return (ContentError)ival;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-05 17:29:23 +00:00
|
|
|
#if PPSSPP_PLATFORM(ANDROID) && !defined(__LIBRETRO__)
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
|
|
extern std::string g_extFilesDir;
|
|
|
|
|
|
|
|
void Android_StorageSetNativeActivity(jobject nativeActivity);
|
|
|
|
|
|
|
|
bool Android_IsContentUri(const std::string &uri);
|
|
|
|
int Android_OpenContentUriFd(const std::string &uri, const Android_OpenContentUriMode mode);
|
|
|
|
bool Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName);
|
|
|
|
bool Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName);
|
2021-07-25 13:32:15 +00:00
|
|
|
bool Android_MoveFile(const std::string &fileUri, const std::string &srcParentUri, const std::string &destParentUri);
|
2021-07-20 10:32:08 +00:00
|
|
|
bool Android_CopyFile(const std::string &fileUri, const std::string &destParentUri);
|
2021-06-05 17:29:23 +00:00
|
|
|
bool Android_RemoveFile(const std::string &fileUri);
|
2021-07-18 20:28:30 +00:00
|
|
|
bool Android_RenameFileTo(const std::string &fileUri, const std::string &newName);
|
2021-06-05 17:29:23 +00:00
|
|
|
bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *info);
|
2021-07-18 21:06:14 +00:00
|
|
|
bool Android_FileExists(const std::string &fileUri);
|
2021-06-05 17:29:23 +00:00
|
|
|
int64_t Android_GetFreeSpaceByContentUri(const std::string &uri);
|
|
|
|
int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath);
|
2021-07-20 10:55:33 +00:00
|
|
|
bool Android_IsExternalStoragePreservedLegacy();
|
|
|
|
const char *Android_ErrorToString(ContentError error);
|
2021-06-05 17:29:23 +00:00
|
|
|
|
|
|
|
std::vector<File::FileInfo> Android_ListContentUri(const std::string &uri);
|
|
|
|
|
|
|
|
void Android_RegisterStorageCallbacks(JNIEnv * env, jobject obj);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2021-07-25 13:32:15 +00:00
|
|
|
extern std::string g_extFilesDir;
|
|
|
|
|
2021-06-05 17:29:23 +00:00
|
|
|
// Stub out the Android Storage wrappers, so that we can avoid ifdefs everywhere.
|
|
|
|
|
|
|
|
inline bool Android_IsContentUri(const std::string &uri) { return false; }
|
|
|
|
inline int Android_OpenContentUriFd(const std::string &uri, const Android_OpenContentUriMode mode) { return -1; }
|
|
|
|
inline bool Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName) { return false; }
|
|
|
|
inline bool Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName) { return false; }
|
2021-07-25 13:32:15 +00:00
|
|
|
inline bool Android_MoveFile(const std::string &fileUri, const std::string &srcParentUri, const std::string &destParentUri) { return false; }
|
2021-07-20 10:32:08 +00:00
|
|
|
inline bool Android_CopyFile(const std::string &fileUri, const std::string &destParentUri) { return false; }
|
2021-06-05 17:29:23 +00:00
|
|
|
inline bool Android_RemoveFile(const std::string &fileUri) { return false; }
|
2021-07-18 20:28:30 +00:00
|
|
|
inline bool Android_RenameFileTo(const std::string &fileUri, const std::string &newName) { return false; }
|
2021-07-18 21:06:14 +00:00
|
|
|
inline bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *info) { return false; }
|
|
|
|
inline bool Android_FileExists(const std::string &fileUri) { return false; }
|
2021-06-05 17:29:23 +00:00
|
|
|
inline int64_t Android_GetFreeSpaceByContentUri(const std::string &uri) { return -1; }
|
|
|
|
inline int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath) { return -1; }
|
2021-07-20 10:55:33 +00:00
|
|
|
inline bool Android_IsExternalStoragePreservedLegacy() { return false; }
|
|
|
|
inline const char *Android_ErrorToString(ContentError error) { return ""; }
|
2021-06-05 17:29:23 +00:00
|
|
|
inline std::vector<File::FileInfo> Android_ListContentUri(const std::string &uri) {
|
|
|
|
return std::vector<File::FileInfo>();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|