review fixes

This commit is contained in:
Metehan Tuncbilek
2024-07-16 14:59:09 +03:00
parent 97518bd57b
commit ac1c5f20ec
6 changed files with 59 additions and 66 deletions

View File

@@ -7,9 +7,9 @@
#include "Utils.hpp"
#ifdef _MSC_VER
#include <Windows.h>
#include <Windows.h>
#else
#include <pthread.h>
#include <pthread.h>
#endif
#include <fstream>
#include <string>
@@ -57,7 +57,7 @@ namespace OpenVulkano
#ifdef _MSC_VER
return (uint64_t)::GetThreadId(::GetCurrentThread());
#else
return (uint64_t)pthread_self();
return (uint64_t) pthread_self();
#endif
}
@@ -69,8 +69,16 @@ namespace OpenVulkano
if (emptyOnMissing) return {};
throw std::runtime_error("Failed to open file '" + filePath + "'!");
}
size_t fileSize = static_cast<size_t>(file.tellg());
if (nullTerminateString) fileSize++;
const size_t fileSize = static_cast<size_t>(file.tellg());
if (nullTerminateString)
{
Array<char> data(fileSize + 1);
file.seekg(0);
file.read(data.Data(), fileSize);
data[fileSize] = '\0';
file.close();
return data;
}
Array<char> data(fileSize);
file.seekg(0);