Add ResourceLoaderAppDirLinux

This commit is contained in:
2023-11-20 14:43:11 +01:00
parent 681fc00a68
commit 89d475fd7c
4 changed files with 72 additions and 3 deletions

View File

@@ -28,10 +28,14 @@ namespace OpenVulkano
#endif
}
Array<char> Utils::ReadFile(const std::string& filePath)
Array<char> Utils::ReadFile(const std::string& filePath, bool emptyOnMissing)
{
std::ifstream file(filePath, std::ios::ate | std::ios::binary);
if (!file.is_open()) throw std::runtime_error("Failed to open file '" + filePath + "'!");
if (!file.is_open())
{
if (emptyOnMissing) return { 0 };
throw std::runtime_error("Failed to open file '" + filePath + "'!");
}
const size_t fileSize = static_cast<size_t>(file.tellg());
Array<char> data(fileSize);
file.seekg(0);