minor refactoring

This commit is contained in:
ohyzha
2024-12-22 13:54:01 +02:00
parent 58b62cff9a
commit 5852aac273
3 changed files with 9 additions and 8 deletions

View File

@@ -15,8 +15,7 @@ namespace OpenVulkano
{ {
Array<char> ExeAppendedZipResourceLoader::GetResource(const std::string& resourceName) Array<char> ExeAppendedZipResourceLoader::GetResource(const std::string& resourceName)
{ {
Array<char> zipData = Utils::ReadFile(GetCurrentExecutablePath()); ArchiveReader reader(GetCurrentExecutablePath(), nullptr, ArchiveType::ZIP);
ArchiveReader reader(zipData.Data(), zipData.Size(), nullptr, ArchiveType::ZIP);
if (auto data = reader.GetFile(resourceName)) if (auto data = reader.GetFile(resourceName))
{ {
return data->second; return data->second;

View File

@@ -18,7 +18,7 @@ namespace OpenVulkano
{ {
std::string exe(MAX_PATH, '\0'); std::string exe(MAX_PATH, '\0');
DWORD len = GetModuleFileNameA(NULL, exe.data(), MAX_PATH); DWORD len = GetModuleFileNameA(NULL, exe.data(), MAX_PATH);
exe.resize(std::max<size_t>(len, exe.size())); exe.resize(len);
return exe; return exe;
} }

View File

@@ -51,8 +51,7 @@ namespace OpenVulkano
m_archive = archive_read_new(); m_archive = archive_read_new();
} }
ChkErr(archive_read_support_filter_all(m_archive)); ChkErr(archive_read_support_filter_all(m_archive));
std::function<int(archive*)> pFunc = GetCurrentFormatReadFunc(); ChkErr(GetCurrentFormatReadFunc()(m_archive));
ChkErr(pFunc(m_archive));
m_open = true; m_open = true;
} }
@@ -295,10 +294,13 @@ namespace OpenVulkano
{ {
while (HasNext()) while (HasNext())
{ {
const std::pair<FileDescription, Array<char>> info = *GetNextFile(); if (path == archive_entry_pathname(m_archiveEntry))
if (info.first.path == path)
{ {
return info; return GetNextFile();
}
if (archive_read_next_header(m_archive, &m_archiveEntry) != ARCHIVE_OK)
{
return {};
} }
} }
return {}; return {};