CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/File/AndroidStorage.h
Views: 1401
#pragma once12#include <vector>3#include <string>4#include <string_view>56#include "Common/File/DirListing.h"78// To emphasize that Android storage mode strings are different, let's just use9// an enum.10enum class Android_OpenContentUriMode {11READ = 0, // "r"12READ_WRITE = 1, // "rw"13READ_WRITE_TRUNCATE = 2, // "rwt"14};1516// Matches the constants in PpssppActivity.java.17enum class StorageError {18SUCCESS = 0,19UNKNOWN = -1,20NOT_FOUND = -2,21DISK_FULL = -3,22ALREADY_EXISTS = -4,23};2425inline StorageError StorageErrorFromInt(int ival) {26if (ival >= 0) {27return StorageError::SUCCESS;28} else {29return (StorageError)ival;30}31}3233extern std::string g_extFilesDir;34extern std::string g_externalDir;35extern std::string g_nativeLibDir;3637#if PPSSPP_PLATFORM(ANDROID) && !defined(__LIBRETRO__)3839#include <jni.h>4041void Android_StorageSetNativeActivity(jobject nativeActivity);4243bool Android_IsContentUri(std::string_view uri);44int Android_OpenContentUriFd(std::string_view uri, const Android_OpenContentUriMode mode);45StorageError Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName);46StorageError Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName);47StorageError Android_MoveFile(const std::string &fileUri, const std::string &srcParentUri, const std::string &destParentUri);48StorageError Android_CopyFile(const std::string &fileUri, const std::string &destParentUri);4950// WARNING: This is very powerful, it will delete directories recursively!51StorageError Android_RemoveFile(const std::string &fileUri);5253StorageError Android_RenameFileTo(const std::string &fileUri, const std::string &newName);54bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *info);55bool Android_FileExists(const std::string &fileUri);56int64_t Android_ComputeRecursiveDirectorySize(const std::string &fileUri);57int64_t Android_GetFreeSpaceByContentUri(const std::string &uri);58int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath);59bool Android_IsExternalStoragePreservedLegacy();60const char *Android_ErrorToString(StorageError error);6162std::vector<File::FileInfo> Android_ListContentUri(const std::string &uri, bool *exists);6364void Android_RegisterStorageCallbacks(JNIEnv * env, jobject obj);6566#else6768// Stub out the Android Storage wrappers, so that we can avoid ifdefs everywhere.6970// See comments for the corresponding functions above.7172inline bool Android_IsContentUri(std::string_view uri) { return false; }73inline int Android_OpenContentUriFd(std::string_view uri, const Android_OpenContentUriMode mode) { return -1; }74inline StorageError Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName) { return StorageError::UNKNOWN; }75inline StorageError Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName) { return StorageError::UNKNOWN; }76inline StorageError Android_MoveFile(const std::string &fileUri, const std::string &srcParentUri, const std::string &destParentUri) { return StorageError::UNKNOWN; }77inline StorageError Android_CopyFile(const std::string &fileUri, const std::string &destParentUri) { return StorageError::UNKNOWN; }78inline StorageError Android_RemoveFile(const std::string &fileUri) { return StorageError::UNKNOWN; }79inline StorageError Android_RenameFileTo(const std::string &fileUri, const std::string &newName) { return StorageError::UNKNOWN; }80inline bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *info) { return false; }81inline bool Android_FileExists(const std::string &fileUri) { return false; }82inline int64_t Android_ComputeRecursiveDirectorySize(const std::string &fileUri) { return -1; }83inline int64_t Android_GetFreeSpaceByContentUri(const std::string &uri) { return -1; }84inline int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath) { return -1; }85inline bool Android_IsExternalStoragePreservedLegacy() { return false; }86inline const char *Android_ErrorToString(StorageError error) { return ""; }87inline std::vector<File::FileInfo> Android_ListContentUri(const std::string &uri, bool *exists) {88*exists = false;89return std::vector<File::FileInfo>();90}9192#endif939495