From bff50070c62c54abb61dbc3dd60613f2f4f943ac Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Thu, 16 Jan 2025 17:06:03 +0800 Subject: [PATCH] Android: Support content:// URI in love.filesystem.mountFullPath. --- src/modules/filesystem/physfs/Filesystem.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp index ff13bea6d..ad7777e0f 100644 --- a/src/modules/filesystem/physfs/Filesystem.cpp +++ b/src/modules/filesystem/physfs/Filesystem.cpp @@ -398,6 +398,25 @@ bool Filesystem::mountFullPath(const char *archive, const char *mountpoint, Moun std::string canonarchive = canonicalizeRealPath(archive); +#ifdef LOVE_ANDROID + if (strncmp(archive, "content://", 10) == 0) + { + if (permissions == MOUNT_PERMISSIONS_READWRITE) + // Currently there's no way content:// URIs we got are for read-write. + // TODO: Re-evaluate this in the future, maybe? + return false; + + auto io = (PHYSFS_Io *) love::android::getIOFromContentProtocol(archive); + if (!io) + return false; + + if (PHYSFS_mountIo(io, canonarchive.c_str(), mountpoint, appendToPath)) + return true; + + io->destroy(io); + } +#endif + if (permissions == MOUNT_PERMISSIONS_READWRITE) return PHYSFS_mountRW(canonarchive.c_str(), mountpoint, appendToPath) != 0;