现在才是代码完成。
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user