Update SAF handling

This commit is contained in:
SSimco
2025-08-29 21:17:14 +03:00
parent 6a3b7f0290
commit b8903f21e8
21 changed files with 582 additions and 574 deletions
+58
View File
@@ -0,0 +1,58 @@
#include "FilesystemAndroid.h"
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream_buffer.hpp>
using namespace boost::iostreams;
namespace FilesystemAndroid
{
std::shared_ptr<FilesystemCallbacks> g_filesystemCallbacks = nullptr;
void SetFilesystemCallbacks(const std::shared_ptr<FilesystemCallbacks> &filesystemCallbacks)
{
g_filesystemCallbacks = filesystemCallbacks;
}
int OpenContentUri(const fs::path &uri)
{
if (g_filesystemCallbacks)
return g_filesystemCallbacks->OpenContentUri(uri);
return -1;
}
std::vector<fs::path> ListFiles(const fs::path &uri)
{
if (g_filesystemCallbacks)
return g_filesystemCallbacks->ListFiles(uri);
return {};
}
bool IsDirectory(const fs::path &uri)
{
if (g_filesystemCallbacks)
return g_filesystemCallbacks->IsDirectory(uri);
return false;
}
bool IsFile(const fs::path &uri)
{
if (g_filesystemCallbacks)
return g_filesystemCallbacks->IsFile(uri);
return false;
}
bool Exists(const fs::path &uri)
{
if (g_filesystemCallbacks)
return g_filesystemCallbacks->Exists(uri);
return false;
}
bool IsContentUri(const std::string &uri)
{
static constexpr auto content = "content://";
return uri.starts_with(content);
}
} // namespace FilesystemAndroid