/* * WiVRn VR streaming * Copyright (C) 2024 Guillaume Meunier * Copyright (C) 2024 Patrick Nicolas * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include #include #ifdef __ANDROID__ struct AAsset; #endif class asset { #ifdef __ANDROID__ AAsset * android_asset = nullptr; std::span bytes; #else static std::filesystem::path asset_root(); static std::filesystem::path locale_root(); std::vector bytes; #endif public: asset() = default; asset(const std::filesystem::path & path); #ifdef __ANDROID__ asset(asset && other); asset & operator=(asset && other); ~asset(); #else asset(asset && other) = default; asset & operator=(asset && other) = default; #endif asset(const asset &) = delete; asset & operator=(const asset &) = delete; const std::byte * data() const { return bytes.data(); } size_t size() const { return bytes.size(); } operator std::span() const { return bytes; } operator std::string() const { return std::string(reinterpret_cast(data()), size()); } };