Fix some Windows issues

This commit is contained in:
Georg Hagen
2025-02-09 18:30:32 +01:00
parent 3c7c6ae207
commit 8bbb22bd64
2 changed files with 11 additions and 9 deletions

View File

@@ -69,7 +69,10 @@ namespace OpenVulkano
bool ArchiveReader::Open(const std::filesystem::path& archiveFile) bool ArchiveReader::Open(const std::filesystem::path& archiveFile)
{ {
PrepOpen(); PrepOpen();
if constexpr (std::is_same_v<std::filesystem::path::value_type, char>)
ChkErr(archive_read_open_filename(m_archive, archiveFile.c_str(), BUFFER_SIZE)); 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(); ReadNextHeader();
return HasNext(); return HasNext();
} }
@@ -221,7 +224,7 @@ namespace OpenVulkano
{ {
size_t count = 0; size_t count = 0;
std::optional<FileDescription> fd; std::optional<FileDescription> fd;
while (fd = ExtractNext(targetDir)) while ((fd = ExtractNext(targetDir)))
{ {
extractionCallback(fd.value()); extractionCallback(fd.value());
count++; count++;
@@ -276,14 +279,14 @@ namespace OpenVulkano
if (SkipTill(std::filesystem::file_type::regular)) if (SkipTill(std::filesystem::file_type::regular))
{ {
FileDescription fileDescription = GetNextDescription(); FileDescription fileDescription = GetNextDescription();
std::filesystem::path outputFilePath; std::string outputFilePath;
if (m_filePathRewrite) if (m_filePathRewrite)
outputFilePath = targetDir / m_filePathRewrite(fileDescription.path); outputFilePath = (targetDir / m_filePathRewrite(fileDescription.path)).string();
else else
outputFilePath = targetDir / fileDescription.path; outputFilePath = (targetDir / fileDescription.path).string();
std::unique_ptr<archive, decltype(archive_write_free)*> a(archive_write_disk_new(), archive_write_free); const std::unique_ptr<archive, decltype(archive_write_free)*> a(archive_write_disk_new(), archive_write_free);
std::unique_ptr<archive_entry, decltype(archive_entry_free)*> entry(archive_entry_clone(m_archiveEntry), archive_entry_free); const std::unique_ptr<archive_entry, decltype(archive_entry_free)*> entry(archive_entry_clone(m_archiveEntry), archive_entry_free);
archive_entry_set_pathname(entry.get(), outputFilePath.c_str()); archive_entry_set_pathname(entry.get(), outputFilePath.c_str());

View File

@@ -56,8 +56,7 @@ namespace OpenVulkano
[[nodiscard]] std::filesystem::path GetXDGFolderDefault(const char* envName, std::string_view defaultRelativePath) [[nodiscard]] std::filesystem::path GetXDGFolderDefault(const char* envName, std::string_view defaultRelativePath)
{ {
#ifndef TARGET_OS_IOS != 1 #ifndef TARGET_OS_IOS != 1
const char* envValue = std::getenv(envName); if (const char* envValue = std::getenv(envName))
if (envValue)
{ {
if (envValue[0] == '/') return envValue; 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."; std::cerr << "Ignoring environment '" << envName << "' (value: '" << envValue << "') because it's relative! XDG specifies it should be absolute path. Falling back to default path.";