Ensure FileWriter creates new files when overwrite unset

This commit is contained in:
Jack Andersen 2016-09-17 11:32:09 -10:00
parent 161206fdd9
commit e253854269
1 changed files with 15 additions and 1 deletions

View File

@ -51,12 +51,26 @@ void FileWriter::open(bool overwrite)
if (overwrite) if (overwrite)
m_fileHandle = _wfopen(m_filename.c_str(), L"w+b"); m_fileHandle = _wfopen(m_filename.c_str(), L"w+b");
else else
{
m_fileHandle = _wfopen(m_filename.c_str(), L"r+b"); m_fileHandle = _wfopen(m_filename.c_str(), L"r+b");
if (m_fileHandle)
{
fclose(m_fileHandle);
m_fileHandle = _wfopen(m_filename.c_str(), L"r+b");
}
}
#else #else
if (overwrite) if (overwrite)
m_fileHandle = fopen(m_filename.c_str(), "w+b"); m_fileHandle = fopen(m_filename.c_str(), "w+b");
else else
m_fileHandle = fopen(m_filename.c_str(), "r+b"); {
m_fileHandle = fopen(m_filename.c_str(), "a+b");
if (m_fileHandle)
{
fclose(m_fileHandle);
m_fileHandle = fopen(m_filename.c_str(), "r+b");
}
}
#endif #endif
if (!m_fileHandle) if (!m_fileHandle)