diff --git a/openVulkanoCpp/Host/WebResourceLoader.cpp b/openVulkanoCpp/Host/WebResourceLoader.cpp index 578f8d4..08e63bc 100644 --- a/openVulkanoCpp/Host/WebResourceLoader.cpp +++ b/openVulkanoCpp/Host/WebResourceLoader.cpp @@ -12,16 +12,10 @@ #include #include -#if __has_include("curl/curl.h") - #include -#else - #pragma message ("Missing curl.h even though HAS_CURL is set") - #undef HAS_CURL -#endif +#include namespace OpenVulkano { -#ifdef HAS_CURL namespace { size_t CurlDownloader(void* contents, size_t size, size_t memBlockCount, void* userData) @@ -32,7 +26,6 @@ namespace OpenVulkano return totalSize; } } -#endif bool WebResourceLoader::IsUrl(const std::string& str) { @@ -43,16 +36,12 @@ namespace OpenVulkano { m_cacheDirectory = AppFolders::GetAppCacheDir() / "resources"; std::filesystem::create_directories(m_cacheDirectory); -#ifdef HAS_CURL curl_global_init(CURL_GLOBAL_DEFAULT); -#endif } WebResourceLoader::~WebResourceLoader() { -#ifdef HAS_CURL curl_global_cleanup(); -#endif } std::filesystem::path WebResourceLoader::GetCacheFilePath(const std::string& url) @@ -66,7 +55,6 @@ namespace OpenVulkano Array WebResourceLoader::DownloadResource(const std::string& url) { std::vector buffer; -#ifdef HAS_CURL CURL* curl = curl_easy_init(); if (curl) { @@ -81,8 +69,9 @@ namespace OpenVulkano CURLcode result = curl_easy_perform(curl); if (result != CURLE_OK) { + std::string error = curl_easy_strerror(result); + Logger::APP->error("Failed to download resource: '" + url + "' - " + error); curl_easy_cleanup(curl); - Logger::APP->error("Failed to download resource: '" + url + "' - " + curl_easy_strerror(result)); return Array(); } curl_easy_cleanup(curl); @@ -91,7 +80,7 @@ namespace OpenVulkano std::filesystem::path cacheFilePath = GetCacheFilePath(url); std::ofstream file(cacheFilePath, std::ios::binary); file.write(buffer.data(), buffer.size()); -#endif + return Array(buffer); } diff --git a/openVulkanoCpp/Host/WebResourceLoader.hpp b/openVulkanoCpp/Host/WebResourceLoader.hpp index 5159e85..a4a87af 100644 --- a/openVulkanoCpp/Host/WebResourceLoader.hpp +++ b/openVulkanoCpp/Host/WebResourceLoader.hpp @@ -14,6 +14,7 @@ namespace OpenVulkano { class WebResourceLoader : public ResourceLoader { + protected: std::filesystem::path m_cacheDirectory; std::filesystem::path GetCacheFilePath(const std::string& url);