现在才是代码完成。

This commit is contained in:
xsl
2025-10-20 15:27:33 +08:00
parent d2da523636
commit e6a776665f
6 changed files with 323 additions and 167 deletions
+33
View File
@@ -22,6 +22,39 @@ void VK_CHECK(VkResult ret)
// return path;
//}
std::vector<unsigned char> AppBase::readFileEx(const std::string& path)
{
std::vector<unsigned char> buffer;
#ifdef _WIN32
std::string enginePath = "app/src/main/assets/" + path;
std::ifstream file{ enginePath, std::ios::ate | std::ios::binary };
if (!file.is_open())
{
throw std::runtime_error("failed to open file: " + enginePath);
}
size_t fileSize = static_cast<size_t>(file.tellg());
buffer.resize(fileSize);
file.seekg(0);
file.read((char*)buffer.data(), fileSize);
file.close();
#else
AAsset* asset = AAssetManager_open(g_assetManager, path.c_str(), AASSET_MODE_BUFFER);
if (!asset) {
logOut << "Failed to load file: " << path.c_str() << std::endl;
return buffer;
}
size_t length = AAsset_getLength(asset);
buffer.resize(length);
AAsset_read(asset, (char*)buffer.data(), length);
AAsset_close(asset);
#endif // _WIN32
return buffer;
}
std::vector<char> AppBase::readFile(const std::string& path)
{
std::vector<char> buffer;