Merge pull request #9318 from JosJuice/android-saf-games

Android: Use storage access framework for game list
This commit is contained in:
JosJuice
2020-12-30 11:10:35 +01:00
committed by GitHub
20 changed files with 795 additions and 193 deletions

View File

@ -18,6 +18,11 @@
#include "Common/StringUtil.h"
#endif
#ifdef ANDROID
#include "Common/StringUtil.h"
#include "jni/AndroidCommon/AndroidCommon.h"
#endif
// User directory indices for GetUserPath
enum
{
@ -109,6 +114,10 @@ public:
u64 GetSize() const;
private:
#ifdef ANDROID
void AndroidContentInit(const std::string& path);
#endif
struct stat m_stat;
bool m_exists;
};
@ -214,14 +223,20 @@ std::string GetExeDirectory();
bool WriteStringToFile(const std::string& filename, std::string_view str);
bool ReadFileToString(const std::string& filename, std::string& str);
// To deal with Windows being dumb at unicode:
// To deal with Windows not fully supporting UTF-8 and Android not fully supporting paths.
template <typename T>
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
{
#ifdef _WIN32
fstream.open(UTF8ToTStr(filename).c_str(), openmode);
#else
fstream.open(filename.c_str(), openmode);
#ifdef ANDROID
// Unfortunately it seems like the non-standard __open is the only way to use a file descriptor
if (IsPathAndroidContent(filename))
fstream.__open(OpenAndroidContent(filename, OpenModeToAndroid(openmode)), openmode);
else
#endif
fstream.open(filename.c_str(), openmode);
#endif
}