18#include "sdl_resource_manager.hpp"
20#if __has_include(<filesystem>)
22namespace fs = std::filesystem;
23#elif __has_include(<experimental/filesystem>)
24#include <experimental/filesystem>
25namespace fs = std::experimental::filesystem;
27#error Could not find system header "<filesystem>" or "<experimental/filesystem>"
35std::string SDLResourceManager::typeImages()
40void 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);
47bool SDLResourceManager::useCompiledResources()
49#if defined(SDL_USE_COMPILED_RESOURCES)
56const 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())
71std::string SDLResourceManager::filename([[maybe_unused]]
const std::string& type,
72 [[maybe_unused]]
const std::string&
id)
74#if defined(SDL_RESOURCE_ROOT)
75 std::string uuid = type +
"/" + id;
76 fs::path path(SDL_RESOURCE_ROOT);
80 if (!fs::exists(path))
82 std::cerr <<
"sdl-freerdp expects resource '" << uuid <<
"' at location "
83 << fs::absolute(path) << std::endl;
84 std::cerr <<
"file not found, application will fail" << std::endl;
87 return path.u8string();
93std::map<std::string, std::vector<unsigned char>>& SDLResourceManager::resources()
96 static std::map<std::string, std::vector<unsigned char>> resources = {};
97#if defined(SDL_USE_COMPILED_RESOURCES)
98 if (resources.empty())
static std::string typeFonts()