Some cleanup of CWII_IPC_HLE_Device_FileIO:

The real file was never kept open for longer than a single operation so there was no point in dealing with it in DoState.
Saving the real path in the savestate was also probably a bad idea. Savestates should be a bit more portable now.
This commit is contained in:
Jordan Woyak
2013-02-17 13:30:04 -06:00
parent 0cdd4434b9
commit fa9aafeed8
5 changed files with 63 additions and 90 deletions

View File

@ -42,6 +42,7 @@
#endif
#include <fstream>
#include <algorithm>
#include <sys/stat.h>
#ifndef S_ISDIR
@ -774,6 +775,24 @@ IOFile::~IOFile()
Close();
}
IOFile::IOFile(IOFile&& other)
: m_file(NULL), m_good(true)
{
Swap(other);
}
IOFile& IOFile::operator=(IOFile other)
{
Swap(other);
return *this;
}
void IOFile::Swap(IOFile& other)
{
std::swap(m_file, other.m_file);
std::swap(m_good, other.m_good);
}
bool IOFile::Open(const std::string& filename, const char openmode[])
{
Close();

View File

@ -150,7 +150,7 @@ bool ReadFileToString(bool text_file, const char *filename, std::string &str);
// simple wrapper for cstdlib file functions to
// hopefully will make error checking easier
// and make forgetting an fclose() harder
class IOFile : NonCopyable
class IOFile
{
public:
IOFile();
@ -158,6 +158,11 @@ public:
IOFile(const std::string& filename, const char openmode[]);
~IOFile();
IOFile(IOFile&& other);
IOFile& operator=(IOFile other);
void Swap(IOFile& other);
bool Open(const std::string& filename, const char openmode[]);
bool Close();
@ -212,6 +217,7 @@ public:
void Clear() { m_good = true; std::clearerr(m_file); }
private:
IOFile(const IOFile&) /*= delete*/;
IOFile& operator=(const IOFile&) /*= delete*/;
std::FILE* m_file;