diff options
| author | JosJuice <josjuice@gmail.com> | 2022-01-29 11:59:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-29 11:59:58 +0100 |
| commit | af5678ea758d493c419ca53c56a0ce4f8fa0ca0f (patch) | |
| tree | 6e76a1fee0e79d593d95c9680d2353f9033b0ac6 /Source/Core/Common/IOFile.cpp | |
| parent | fbe7cf675cf412af12d2f750c6162f6e4151c52c (diff) | |
| parent | a336c4386c154746ef2ea732b13872f5293666be (diff) | |
Merge pull request #10403 from AdmiralCurtiss/iofile-seek
Minor IOFile cleanup.
Diffstat (limited to 'Source/Core/Common/IOFile.cpp')
| -rw-r--r-- | Source/Core/Common/IOFile.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/Source/Core/Common/IOFile.cpp b/Source/Core/Common/IOFile.cpp index 1378906357..374c56ac6f 100644 --- a/Source/Core/Common/IOFile.cpp +++ b/Source/Core/Common/IOFile.cpp @@ -94,7 +94,7 @@ bool IOFile::Close() void IOFile::SetHandle(std::FILE* file) { Close(); - Clear(); + ClearError(); m_file = file; } @@ -106,9 +106,25 @@ u64 IOFile::GetSize() const return 0; } -bool IOFile::Seek(s64 off, int origin) -{ - if (!IsOpen() || 0 != fseeko(m_file, off, origin)) +bool IOFile::Seek(s64 offset, SeekOrigin origin) +{ + int fseek_origin; + switch (origin) + { + case SeekOrigin::Begin: + fseek_origin = SEEK_SET; + break; + case SeekOrigin::Current: + fseek_origin = SEEK_CUR; + break; + case SeekOrigin::End: + fseek_origin = SEEK_END; + break; + default: + return false; + } + + if (!IsOpen() || 0 != fseeko(m_file, offset, fseek_origin)) m_good = false; return m_good; |
