mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-27 04:36:18 +00:00
File IO Functions
This commit is contained in:
parent
0ea09f309d
commit
54467c18b1
2 changed files with 23 additions and 0 deletions
|
@ -34,6 +34,12 @@ IOFile::IOFile(const std::string& filename, const char openmode[]) : m_file(null
|
||||||
Open(filename, openmode);
|
Open(filename, openmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IOFile::IOFile(const std::string& filename, const char openmode[], int shflag)
|
||||||
|
: m_file(nullptr), m_good(true)
|
||||||
|
{
|
||||||
|
OpenShared(filename, openmode, shflag);
|
||||||
|
}
|
||||||
|
|
||||||
IOFile::~IOFile()
|
IOFile::~IOFile()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
@ -69,6 +75,19 @@ bool IOFile::Open(const std::string& filename, const char openmode[])
|
||||||
return m_good;
|
return m_good;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IOFile::OpenShared(const std::string& filename, const char openmode[], int shflag)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
#ifdef _WIN32
|
||||||
|
m_file = _fsopen(filename.c_str(), openmode, shflag);
|
||||||
|
#else
|
||||||
|
m_file = fopen(filename.c_str(), openmode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_good = IsOpen();
|
||||||
|
return m_good;
|
||||||
|
}
|
||||||
|
|
||||||
bool IOFile::Close()
|
bool IOFile::Close()
|
||||||
{
|
{
|
||||||
if (!IsOpen() || 0 != std::fclose(m_file))
|
if (!IsOpen() || 0 != std::fclose(m_file))
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
IOFile();
|
IOFile();
|
||||||
IOFile(std::FILE* file);
|
IOFile(std::FILE* file);
|
||||||
IOFile(const std::string& filename, const char openmode[]);
|
IOFile(const std::string& filename, const char openmode[]);
|
||||||
|
IOFile(const std::string& filename, const char openmode[], int shflag);
|
||||||
|
|
||||||
~IOFile();
|
~IOFile();
|
||||||
|
|
||||||
|
@ -33,6 +34,9 @@ public:
|
||||||
void Swap(IOFile& other) noexcept;
|
void Swap(IOFile& other) noexcept;
|
||||||
|
|
||||||
bool Open(const std::string& filename, const char openmode[]);
|
bool Open(const std::string& filename, const char openmode[]);
|
||||||
|
|
||||||
|
bool OpenShared(const std::string& filename, const char openmode[], int shflag);
|
||||||
|
|
||||||
bool Close();
|
bool Close();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue