mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-26 12:16:20 +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);
|
||||
}
|
||||
|
||||
IOFile::IOFile(const std::string& filename, const char openmode[], int shflag)
|
||||
: m_file(nullptr), m_good(true)
|
||||
{
|
||||
OpenShared(filename, openmode, shflag);
|
||||
}
|
||||
|
||||
IOFile::~IOFile()
|
||||
{
|
||||
Close();
|
||||
|
@ -69,6 +75,19 @@ bool IOFile::Open(const std::string& filename, const char openmode[])
|
|||
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()
|
||||
{
|
||||
if (!IsOpen() || 0 != std::fclose(m_file))
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
IOFile();
|
||||
IOFile(std::FILE* file);
|
||||
IOFile(const std::string& filename, const char openmode[]);
|
||||
IOFile(const std::string& filename, const char openmode[], int shflag);
|
||||
|
||||
~IOFile();
|
||||
|
||||
|
@ -33,6 +34,9 @@ public:
|
|||
void Swap(IOFile& other) noexcept;
|
||||
|
||||
bool Open(const std::string& filename, const char openmode[]);
|
||||
|
||||
bool OpenShared(const std::string& filename, const char openmode[], int shflag);
|
||||
|
||||
bool Close();
|
||||
|
||||
template <typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue