Files
panopainter/src/asset.h

37 lines
1.1 KiB
C++

#pragma once
class Asset
{
public:
#ifdef __ANDROID__
static AAssetManager* m_am;
AAsset* m_asset = nullptr;
#endif
static std::vector<std::string> list_files(std::string folder, const std::string& filter_regex);
static bool exist(std::string path);
static bool delete_file(const std::string& path);
static std::string absolute(const std::string& path);
static bool is_asset(const std::string& path);
static bool create_dir(const std::string& path);
bool m_stop_async = false;
std::function<bool(float)> on_progress;
std::future<bool> remote_future;
std::vector<uint8_t> tmp_data;
std::string m_current_path;
std::string m_current_url;
FILE* m_fp = nullptr;
int m_len = 0;
uint8_t* m_data = nullptr;
bool open(const char* path);
bool open_url(const std::string& url, std::function<bool(float)> progress = nullptr);
std::future<bool>& open_url_async(const std::string& url, std::function<bool(float)> progress = nullptr,
std::function<void(bool)> complete = nullptr);
uint8_t* read_all();
void close();
void close_remote();
~Asset();
};