diff options
| author | JosJuice <josjuice@gmail.com> | 2017-01-05 09:17:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-05 09:17:03 +0100 |
| commit | 41101be545d4e2f10c77503a14b5236c870428ac (patch) | |
| tree | cdc261767045639a3797f3eb53eb6baa56b7a048 /Source/Core | |
| parent | 0eaeca9d6d680b3392fb32b984ca28abf74aa8cb (diff) | |
| parent | 045a8400e6ddb854a79eaaa499d09d54345d3dc3 (diff) | |
Merge pull request #4611 from lioncash/fileutil
IOFile: Minor changes
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/FileUtil.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/Common/FileUtil.h | 13 |
2 files changed, 8 insertions, 11 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 1fae3418f5..4094f5edcf 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -908,18 +908,18 @@ IOFile::~IOFile() Close(); } -IOFile::IOFile(IOFile&& other) : m_file(nullptr), m_good(true) +IOFile::IOFile(IOFile&& other) noexcept : m_file(nullptr), m_good(true) { Swap(other); } -IOFile& IOFile::operator=(IOFile&& other) +IOFile& IOFile::operator=(IOFile&& other) noexcept { Swap(other); return *this; } -void IOFile::Swap(IOFile& other) +void IOFile::Swap(IOFile& other) noexcept { std::swap(m_file, other.m_file); std::swap(m_good, other.m_good); diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h index 1c38bb38d9..ef012ad4ff 100644 --- a/Source/Core/Common/FileUtil.h +++ b/Source/Core/Common/FileUtil.h @@ -168,10 +168,10 @@ public: ~IOFile(); - IOFile(IOFile&& other); - IOFile& operator=(IOFile&& other); + IOFile(IOFile&& other) noexcept; + IOFile& operator=(IOFile&& other) noexcept; - void Swap(IOFile& other); + void Swap(IOFile& other) noexcept; bool Open(const std::string& filename, const char openmode[]); bool Close(); @@ -211,7 +211,7 @@ public: bool IsOpen() const { return nullptr != m_file; } // m_good is set to false when a read, write or other function fails bool IsGood() const { return m_good; } - operator void*() { return m_good ? m_file : nullptr; } + explicit operator bool() const { return IsGood(); } std::FILE* ReleaseHandle(); std::FILE* GetHandle() { return m_file; } @@ -230,12 +230,9 @@ public: std::clearerr(m_file); } +private: std::FILE* m_file; bool m_good; - -private: - IOFile(IOFile&); - IOFile& operator=(IOFile& other); }; } // namespace |
