summaryrefslogtreecommitdiff
path: root/Source/Core/Common/FileUtil.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2017-01-15 21:46:32 +0100
committerJosJuice <josjuice@gmail.com>2017-06-15 21:33:50 +0200
commitf09ceaa735080b8cde5f9102e7f061530d9b474e (patch)
tree5dfc15fa2b363db2165bca24d5b7e97bcdfcb4a8 /Source/Core/Common/FileUtil.cpp
parent67dbbc67c0b3fa09e4f5c94ea67a83190c4e1a5e (diff)
Move IOFile to a separate file
Reduces the number of files that need to be recompiled when making changes to FileUtil.h.
Diffstat (limited to 'Source/Core/Common/FileUtil.cpp')
-rw-r--r--Source/Core/Common/FileUtil.cpp115
1 files changed, 1 insertions, 114 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp
index 203ddbac4b..0a1a425830 100644
--- a/Source/Core/Common/FileUtil.cpp
+++ b/Source/Core/Common/FileUtil.cpp
@@ -16,6 +16,7 @@
#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
+#include "Common/File.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
@@ -901,118 +902,4 @@ bool ReadFileToString(const std::string& filename, std::string& str)
return retval;
}
-IOFile::IOFile() : 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[]) : m_file(nullptr), m_good(true)
-{
- Open(filename, openmode);
-}
-
-IOFile::~IOFile()
-{
- Close();
-}
-
-IOFile::IOFile(IOFile&& other) noexcept : m_file(nullptr), m_good(true)
-{
- Swap(other);
-}
-
-IOFile& IOFile::operator=(IOFile&& other) noexcept
-{
- Swap(other);
- return *this;
-}
-
-void IOFile::Swap(IOFile& other) noexcept
-{
- 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();
-#ifdef _WIN32
- _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str());
-#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))
- m_good = false;
-
- m_file = nullptr;
- return m_good;
-}
-
-void IOFile::SetHandle(std::FILE* file)
-{
- Close();
- Clear();
- m_file = file;
-}
-
-u64 IOFile::GetSize()
-{
- if (IsOpen())
- return File::GetSize(m_file);
- else
- return 0;
-}
-
-bool IOFile::Seek(s64 off, int origin)
-{
- if (!IsOpen() || 0 != fseeko(m_file, off, origin))
- m_good = false;
-
- return m_good;
-}
-
-u64 IOFile::Tell() const
-{
- if (IsOpen())
- return ftello(m_file);
- else
- return UINT64_MAX;
-}
-
-bool IOFile::Flush()
-{
- if (!IsOpen() || 0 != std::fflush(m_file))
- m_good = false;
-
- return m_good;
-}
-
-bool IOFile::Resize(u64 size)
-{
- if (!IsOpen() ||
- 0 !=
-#ifdef _WIN32
- // ector: _chsize sucks, not 64-bit safe
- // F|RES: changed to _chsize_s. i think it is 64-bit safe
- _chsize_s(_fileno(m_file), size)
-#else
- // TODO: handle 64bit and growing
- ftruncate(fileno(m_file), size)
-#endif
- )
- m_good = false;
-
- return m_good;
-}
-
} // namespace