18 #include "sdl_resource_manager.hpp"
20 #if __has_include(<filesystem>)
22 namespace fs = std::filesystem;
23 #elif __has_include(<experimental/filesystem>)
24 #include <experimental/filesystem>
25 namespace fs = std::experimental::filesystem;
27 #error Could not find system header "<filesystem>" or "<experimental/filesystem>"
35 std::string SDLResourceManager::typeImages()
40 void SDLResourceManager::insert(
const std::string& type,
const std::string&
id,
41 const std::vector<unsigned char>& data)
43 std::string uuid = type +
"/" + id;
44 resources().emplace(uuid, data);
47 bool SDLResourceManager::useCompiledResources()
49 #if defined(SDL_USE_COMPILED_RESOURCES)
56 const std::vector<unsigned char>* SDLResourceManager::data(
const std::string& type,
57 const std::string&
id)
59 #if defined(SDL_USE_COMPILED_RESOURCES)
60 std::string uuid = type +
"/" + id;
61 auto val = resources().find(uuid);
62 if (val == resources().end())
71 std::string SDLResourceManager::filename(
const std::string& type,
const std::string&
id)
73 #if defined(SDL_RESOURCE_ROOT)
74 std::string uuid = type +
"/" + id;
75 fs::path path(SDL_RESOURCE_ROOT);
79 if (!fs::exists(path))
81 std::cerr <<
"sdl-freerdp expects resource '" << uuid <<
"' at location "
82 << fs::absolute(path) << std::endl;
83 std::cerr <<
"file not found, application will fail" << std::endl;
86 return path.u8string();
92 std::map<std::string, std::vector<unsigned char>>& SDLResourceManager::resources()
95 static std::map<std::string, std::vector<unsigned char>> resources = {};
96 #if defined(SDL_USE_COMPILED_RESOURCES)
97 if (resources.empty())
static std::string typeFonts()