utils::ReadFile nullTerminateString addition
This commit is contained in:
@@ -61,7 +61,7 @@ namespace OpenVulkano
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<char> Utils::ReadFile(const std::string& filePath, bool emptyOnMissing)
|
Array<char> Utils::ReadFile(const std::string& filePath, bool emptyOnMissing, bool nullTerminateString)
|
||||||
{
|
{
|
||||||
std::ifstream file(filePath, std::ios::ate | std::ios::binary);
|
std::ifstream file(filePath, std::ios::ate | std::ios::binary);
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
@@ -69,7 +69,9 @@ namespace OpenVulkano
|
|||||||
if (emptyOnMissing) return {};
|
if (emptyOnMissing) return {};
|
||||||
throw std::runtime_error("Failed to open file '" + filePath + "'!");
|
throw std::runtime_error("Failed to open file '" + filePath + "'!");
|
||||||
}
|
}
|
||||||
const size_t fileSize = static_cast<size_t>(file.tellg());
|
size_t fileSize = static_cast<size_t>(file.tellg());
|
||||||
|
if (nullTerminateString) fileSize++;
|
||||||
|
|
||||||
Array<char> data(fileSize);
|
Array<char> data(fileSize);
|
||||||
file.seekg(0);
|
file.seekg(0);
|
||||||
file.read(data.Data(), fileSize);
|
file.read(data.Data(), fileSize);
|
||||||
|
|||||||
@@ -159,7 +159,8 @@ namespace OpenVulkano
|
|||||||
return subs;
|
return subs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Array<char> ReadFile(const std::string& filePath, bool emptyOnMissing = false);
|
static Array<char> ReadFile(const std::string& filePath, bool emptyOnMissing = false,
|
||||||
|
bool nullTerminateString = false);
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
static int GetUniqueTypeId()
|
static int GetUniqueTypeId()
|
||||||
|
|||||||
Reference in New Issue
Block a user