|
|
@ -824,13 +824,12 @@ size_t WriteStringToFile(bool text_file, const std::string &str, const char *fil |
|
|
|
|
|
|
|
|
size_t ReadFileToString(bool text_file, const char *filename, std::string &str) |
|
|
size_t ReadFileToString(bool text_file, const char *filename, std::string &str) |
|
|
{ |
|
|
{ |
|
|
FileUtil::IOFile file(filename, text_file ? "r" : "rb"); |
|
|
|
|
|
auto const f = file.GetHandle(); |
|
|
|
|
|
|
|
|
IOFile file(filename, text_file ? "r" : "rb"); |
|
|
|
|
|
|
|
|
if (!f) |
|
|
|
|
|
|
|
|
if (!file) |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
|
|
|
str.resize(static_cast<u32>(GetSize(f))); |
|
|
|
|
|
|
|
|
str.resize(static_cast<u32>(file.GetSize())); |
|
|
return file.ReadArray(&str[0], str.size()); |
|
|
return file.ReadArray(&str[0], str.size()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -880,10 +879,6 @@ IOFile::IOFile() |
|
|
: m_file(nullptr), m_good(true) |
|
|
: m_file(nullptr), m_good(true) |
|
|
{} |
|
|
{} |
|
|
|
|
|
|
|
|
IOFile::IOFile(std::FILE* file) |
|
|
|
|
|
: m_file(file), m_good(true) |
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
IOFile::IOFile(const std::string& filename, const char openmode[]) |
|
|
IOFile::IOFile(const std::string& filename, const char openmode[]) |
|
|
: m_file(nullptr), m_good(true) |
|
|
: m_file(nullptr), m_good(true) |
|
|
{ |
|
|
{ |
|
|
@ -935,20 +930,6 @@ bool IOFile::Close() |
|
|
return m_good; |
|
|
return m_good; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::FILE* IOFile::ReleaseHandle() |
|
|
|
|
|
{ |
|
|
|
|
|
std::FILE* const ret = m_file; |
|
|
|
|
|
m_file = nullptr; |
|
|
|
|
|
return ret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void IOFile::SetHandle(std::FILE* file) |
|
|
|
|
|
{ |
|
|
|
|
|
Close(); |
|
|
|
|
|
Clear(); |
|
|
|
|
|
m_file = file; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
u64 IOFile::GetSize() |
|
|
u64 IOFile::GetSize() |
|
|
{ |
|
|
{ |
|
|
if (IsOpen()) |
|
|
if (IsOpen()) |
|
|
|