mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-04 22:32:57 +12:00
Pandroid: Storage Access Framework (SAF) (#408)
This commit is contained in:
parent
3c25be4c63
commit
6af4a04987
20 changed files with 292 additions and 63 deletions
|
@ -21,6 +21,10 @@
|
|||
#include <unistd.h> // For ftruncate
|
||||
#endif
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "android_utils.hpp"
|
||||
#endif
|
||||
|
||||
IOFile::IOFile(const std::filesystem::path& path, const char* permissions) : handle(nullptr) { open(path, permissions); }
|
||||
|
||||
bool IOFile::open(const std::filesystem::path& path, const char* permissions) {
|
||||
|
@ -34,8 +38,19 @@ bool IOFile::open(const char* filename, const char* permissions) {
|
|||
if (isOpen()) {
|
||||
close();
|
||||
}
|
||||
#ifdef __ANDROID__
|
||||
std::string path(filename);
|
||||
|
||||
// Check if this is a URI directory, which will need special handling due to SAF
|
||||
if (path.find("://") != std::string::npos ) {
|
||||
handle = fdopen(AndroidUtils::openDocument(filename, permissions), permissions);
|
||||
} else {
|
||||
handle = std::fopen(filename, permissions);
|
||||
}
|
||||
#else
|
||||
handle = std::fopen(filename, permissions);
|
||||
#endif
|
||||
|
||||
handle = std::fopen(filename, permissions);
|
||||
return isOpen();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue