Use the mapped_file class instead of asset for assets

This commit is contained in:
Guillaume Meunier
2025-10-25 10:30:27 +02:00
parent 7963efc034
commit a9f774c67c
14 changed files with 143 additions and 241 deletions
+13 -3
View File
@@ -22,12 +22,22 @@
#include <filesystem>
#include <span>
#ifdef __ANDROID__
struct AAsset;
#endif
namespace utils
{
class mapped_file
{
int fd = -1;
std::span<std::byte> bytes{};
#ifdef __ANDROID__
AAsset * android_asset = nullptr;
#endif
std::span<const std::byte> bytes{};
void map(int fd);
void open(const std::filesystem::path & path);
public:
mapped_file() = default;
@@ -37,7 +47,7 @@ public:
mapped_file & operator=(mapped_file &&);
~mapped_file();
mapped_file(int fd); // Takes ownership of the file descriptor
mapped_file(int fd); // Does not take ownership of the file descriptor
mapped_file(const std::filesystem::path & path);
operator std::span<const std::byte>() const