From 8bbb22bd64a28da567a40b7a6cf4a3098f027d55 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Sun, 9 Feb 2025 18:30:32 +0100 Subject: [PATCH] Fix some Windows issues --- openVulkanoCpp/IO/Archive/ArchiveReader.cpp | 17 ++++++++++------- openVulkanoCpp/IO/PlatformFolders.cpp | 3 +-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/openVulkanoCpp/IO/Archive/ArchiveReader.cpp b/openVulkanoCpp/IO/Archive/ArchiveReader.cpp index 3acdc63..4e98bee 100644 --- a/openVulkanoCpp/IO/Archive/ArchiveReader.cpp +++ b/openVulkanoCpp/IO/Archive/ArchiveReader.cpp @@ -69,7 +69,10 @@ namespace OpenVulkano bool ArchiveReader::Open(const std::filesystem::path& archiveFile) { PrepOpen(); - ChkErr(archive_read_open_filename(m_archive, archiveFile.c_str(), BUFFER_SIZE)); + if constexpr (std::is_same_v) + ChkErr(archive_read_open_filename(m_archive, archiveFile.c_str(), BUFFER_SIZE)); + else + ChkErr(archive_read_open_filename_w(m_archive, (wchar_t*)archiveFile.c_str(), BUFFER_SIZE)); ReadNextHeader(); return HasNext(); } @@ -221,7 +224,7 @@ namespace OpenVulkano { size_t count = 0; std::optional fd; - while (fd = ExtractNext(targetDir)) + while ((fd = ExtractNext(targetDir))) { extractionCallback(fd.value()); count++; @@ -276,14 +279,14 @@ namespace OpenVulkano if (SkipTill(std::filesystem::file_type::regular)) { FileDescription fileDescription = GetNextDescription(); - std::filesystem::path outputFilePath; + std::string outputFilePath; if (m_filePathRewrite) - outputFilePath = targetDir / m_filePathRewrite(fileDescription.path); + outputFilePath = (targetDir / m_filePathRewrite(fileDescription.path)).string(); else - outputFilePath = targetDir / fileDescription.path; + outputFilePath = (targetDir / fileDescription.path).string(); - std::unique_ptr a(archive_write_disk_new(), archive_write_free); - std::unique_ptr entry(archive_entry_clone(m_archiveEntry), archive_entry_free); + const std::unique_ptr a(archive_write_disk_new(), archive_write_free); + const std::unique_ptr entry(archive_entry_clone(m_archiveEntry), archive_entry_free); archive_entry_set_pathname(entry.get(), outputFilePath.c_str()); diff --git a/openVulkanoCpp/IO/PlatformFolders.cpp b/openVulkanoCpp/IO/PlatformFolders.cpp index b9d6acd..84bf797 100644 --- a/openVulkanoCpp/IO/PlatformFolders.cpp +++ b/openVulkanoCpp/IO/PlatformFolders.cpp @@ -56,8 +56,7 @@ namespace OpenVulkano [[nodiscard]] std::filesystem::path GetXDGFolderDefault(const char* envName, std::string_view defaultRelativePath) { #ifndef TARGET_OS_IOS != 1 - const char* envValue = std::getenv(envName); - if (envValue) + if (const char* envValue = std::getenv(envName)) { if (envValue[0] == '/') return envValue; std::cerr << "Ignoring environment '" << envName << "' (value: '" << envValue << "') because it's relative! XDG specifies it should be absolute path. Falling back to default path.";