LoadImageFromFile for CImageBox

This commit is contained in:
d1str4ught
2025-09-22 01:43:01 +02:00
parent cc98bdb2da
commit 81c61692f1
5 changed files with 56 additions and 5 deletions

View File

@@ -1,4 +1,6 @@
#include "PackManager.h"
#include <fstream>
#include <filesystem>
bool CPackManager::AddPack(const std::string& path)
{
@@ -11,9 +13,23 @@ bool CPackManager::GetFile(std::string_view path, TPackFile& result)
thread_local std::string buf;
NormalizePath(path, buf);
auto it = m_entries.find(buf);
if (it != m_entries.end()) {
return it->second.first->GetFile(it->second.second, result);
if (m_load_from_pack) {
auto it = m_entries.find(buf);
if (it != m_entries.end()) {
return it->second.first->GetFile(it->second.second, result);
}
}
else {
std::ifstream ifs(buf, std::ios::binary);
if (ifs.is_open()) {
ifs.seekg(0, std::ios::end);
size_t size = ifs.tellg();
ifs.seekg(0, std::ios::beg);
result.resize(size);
if (ifs.read((char*)result.data(), size)) {
return true;
}
}
}
return false;
@@ -24,8 +40,13 @@ bool CPackManager::IsExist(std::string_view path) const
thread_local std::string buf;
NormalizePath(path, buf);
auto it = m_entries.find(buf);
return it != m_entries.end();
if (m_load_from_pack) {
auto it = m_entries.find(buf);
return it != m_entries.end();
}
else {
return std::filesystem::exists(buf);
}
}
void CPackManager::NormalizePath(std::string_view in, std::string& out) const