mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Android: Fix missing directories and files with externalstorage when trying to browse it through MTP.
This commit is contained in:
@@ -27,6 +27,10 @@
|
||||
#include "Filesystem.h"
|
||||
#include "filesystem/FileData.h"
|
||||
|
||||
#ifdef LOVE_ANDROID
|
||||
#include "common/android.h"
|
||||
#endif
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace filesystem
|
||||
@@ -50,6 +54,21 @@ File::File(const std::string &filename, Mode mode)
|
||||
{
|
||||
if (!open(mode))
|
||||
throw love::Exception("Could not open file at path %s", filename.c_str());
|
||||
|
||||
#ifdef LOVE_ANDROID
|
||||
// In Android with t.externalstorage = true, make sure the file opened or
|
||||
// created in the save directory has permissions of ug+rw (0660) so that
|
||||
// it's accessible through MTP.
|
||||
auto fs = Module::getInstance<love::filesystem::Filesystem>(Module::M_FILESYSTEM);
|
||||
if (fs != nullptr && fs->isAndroidSaveExternal())
|
||||
{
|
||||
const char *realdir = PHYSFS_getRealDir(filename.c_str());
|
||||
const std::string &savedir = fs->getFullCommonPath(Filesystem::COMMONPATH_APP_SAVEDIR);
|
||||
|
||||
if (realdir != nullptr && strcmp(realdir, savedir.c_str()) == 0)
|
||||
love::android::fixupPermissionSingleFile(savedir, filename);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
File::File(const File &other)
|
||||
|
||||
Reference in New Issue
Block a user