diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/file_util.cpp | 25 | ||||
| -rw-r--r-- | src/common/file_util.h | 9 |
2 files changed, 4 insertions, 30 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 9ada09f8a..578c673b9 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -824,13 +824,12 @@ size_t WriteStringToFile(bool text_file, const std::string &str, const char *fil | |||
| 824 | 824 | ||
| 825 | size_t ReadFileToString(bool text_file, const char *filename, std::string &str) | 825 | size_t ReadFileToString(bool text_file, const char *filename, std::string &str) |
| 826 | { | 826 | { |
| 827 | FileUtil::IOFile file(filename, text_file ? "r" : "rb"); | 827 | IOFile file(filename, text_file ? "r" : "rb"); |
| 828 | auto const f = file.GetHandle(); | ||
| 829 | 828 | ||
| 830 | if (!f) | 829 | if (!file) |
| 831 | return false; | 830 | return false; |
| 832 | 831 | ||
| 833 | str.resize(static_cast<u32>(GetSize(f))); | 832 | str.resize(static_cast<u32>(file.GetSize())); |
| 834 | return file.ReadArray(&str[0], str.size()); | 833 | return file.ReadArray(&str[0], str.size()); |
| 835 | } | 834 | } |
| 836 | 835 | ||
| @@ -880,10 +879,6 @@ IOFile::IOFile() | |||
| 880 | : m_file(nullptr), m_good(true) | 879 | : m_file(nullptr), m_good(true) |
| 881 | {} | 880 | {} |
| 882 | 881 | ||
| 883 | IOFile::IOFile(std::FILE* file) | ||
| 884 | : m_file(file), m_good(true) | ||
| 885 | {} | ||
| 886 | |||
| 887 | IOFile::IOFile(const std::string& filename, const char openmode[]) | 882 | IOFile::IOFile(const std::string& filename, const char openmode[]) |
| 888 | : m_file(nullptr), m_good(true) | 883 | : m_file(nullptr), m_good(true) |
| 889 | { | 884 | { |
| @@ -935,20 +930,6 @@ bool IOFile::Close() | |||
| 935 | return m_good; | 930 | return m_good; |
| 936 | } | 931 | } |
| 937 | 932 | ||
| 938 | std::FILE* IOFile::ReleaseHandle() | ||
| 939 | { | ||
| 940 | std::FILE* const ret = m_file; | ||
| 941 | m_file = nullptr; | ||
| 942 | return ret; | ||
| 943 | } | ||
| 944 | |||
| 945 | void IOFile::SetHandle(std::FILE* file) | ||
| 946 | { | ||
| 947 | Close(); | ||
| 948 | Clear(); | ||
| 949 | m_file = file; | ||
| 950 | } | ||
| 951 | |||
| 952 | u64 IOFile::GetSize() | 933 | u64 IOFile::GetSize() |
| 953 | { | 934 | { |
| 954 | if (IsOpen()) | 935 | if (IsOpen()) |
diff --git a/src/common/file_util.h b/src/common/file_util.h index dd151575f..8f72fb4e2 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h | |||
| @@ -176,7 +176,6 @@ class IOFile : public NonCopyable | |||
| 176 | { | 176 | { |
| 177 | public: | 177 | public: |
| 178 | IOFile(); | 178 | IOFile(); |
| 179 | explicit IOFile(std::FILE* file); | ||
| 180 | IOFile(const std::string& filename, const char openmode[]); | 179 | IOFile(const std::string& filename, const char openmode[]); |
| 181 | 180 | ||
| 182 | ~IOFile(); | 181 | ~IOFile(); |
| @@ -245,13 +244,7 @@ public: | |||
| 245 | 244 | ||
| 246 | // m_good is set to false when a read, write or other function fails | 245 | // m_good is set to false when a read, write or other function fails |
| 247 | bool IsGood() const { return m_good; } | 246 | bool IsGood() const { return m_good; } |
| 248 | operator void*() { return m_good ? m_file : nullptr; } | 247 | explicit operator bool() const { return IsGood(); } |
| 249 | |||
| 250 | std::FILE* ReleaseHandle(); | ||
| 251 | |||
| 252 | std::FILE* GetHandle() { return m_file; } | ||
| 253 | |||
| 254 | void SetHandle(std::FILE* file); | ||
| 255 | 248 | ||
| 256 | bool Seek(s64 off, int origin); | 249 | bool Seek(s64 off, int origin); |
| 257 | u64 Tell(); | 250 | u64 Tell(); |