diff --git a/openVulkanoCpp/Host/WebResourceLoader.cpp b/openVulkanoCpp/Host/WebResourceLoader.cpp index 91f6e94..419f87e 100644 --- a/openVulkanoCpp/Host/WebResourceLoader.cpp +++ b/openVulkanoCpp/Host/WebResourceLoader.cpp @@ -11,7 +11,10 @@ #include #include +#if __has_include("curl/curl.h") #include +#define HAS_CURL +#endif namespace OpenVulkano { @@ -35,10 +38,17 @@ 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() { curl_global_cleanup(); } + WebResourceLoader::~WebResourceLoader() + { +#ifdef HAS_CURL + curl_global_cleanup(); +#endif + } std::filesystem::path WebResourceLoader::GetCacheFilePath(const std::string& url) { @@ -51,7 +61,7 @@ namespace OpenVulkano Array WebResourceLoader::DownloadResource(const std::string& url) { std::vector buffer; - +#ifdef HAS_CURL CURL* curl = curl_easy_init(); if (curl) { @@ -76,6 +86,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); } @@ -89,4 +100,4 @@ namespace OpenVulkano } return Array(); } -} \ No newline at end of file +}