From 36cfcb530f6810afca93e75c47f767a453a99361 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 29 Jan 2022 05:58:31 +0100 Subject: IOFile: Make origin parameter to Seek() an enum class. --- Source/Core/DiscIO/TGCBlob.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Source/Core/DiscIO/TGCBlob.cpp') diff --git a/Source/Core/DiscIO/TGCBlob.cpp b/Source/Core/DiscIO/TGCBlob.cpp index b6402a44bc..b0571726fa 100644 --- a/Source/Core/DiscIO/TGCBlob.cpp +++ b/Source/Core/DiscIO/TGCBlob.cpp @@ -48,15 +48,18 @@ namespace DiscIO std::unique_ptr TGCFileReader::Create(File::IOFile file) { TGCHeader header; - if (file.Seek(0, SEEK_SET) && file.ReadArray(&header, 1) && header.magic == TGC_MAGIC) + if (file.Seek(0, File::SeekOrigin::Begin) && file.ReadArray(&header, 1) && + header.magic == TGC_MAGIC) + { return std::unique_ptr(new TGCFileReader(std::move(file))); + } return nullptr; } TGCFileReader::TGCFileReader(File::IOFile file) : m_file(std::move(file)) { - m_file.Seek(0, SEEK_SET); + m_file.Seek(0, File::SeekOrigin::Begin); m_file.ReadArray(&m_header, 1); m_size = m_file.GetSize(); @@ -64,8 +67,11 @@ TGCFileReader::TGCFileReader(File::IOFile file) : m_file(std::move(file)) const u32 fst_offset = Common::swap32(m_header.fst_real_offset); const u32 fst_size = Common::swap32(m_header.fst_size); m_fst.resize(fst_size); - if (!m_file.Seek(fst_offset, SEEK_SET) || !m_file.ReadBytes(m_fst.data(), m_fst.size())) + if (!m_file.Seek(fst_offset, File::SeekOrigin::Begin) || + !m_file.ReadBytes(m_fst.data(), m_fst.size())) + { m_fst.clear(); + } constexpr size_t FST_ENTRY_SIZE = 12; if (m_fst.size() < FST_ENTRY_SIZE) @@ -101,7 +107,8 @@ bool TGCFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) { const u32 tgc_header_size = Common::swap32(m_header.tgc_header_size); - if (m_file.Seek(offset + tgc_header_size, SEEK_SET) && m_file.ReadBytes(out_ptr, nbytes)) + if (m_file.Seek(offset + tgc_header_size, File::SeekOrigin::Begin) && + m_file.ReadBytes(out_ptr, nbytes)) { const u32 replacement_dol_offset = SubtractBE32(m_header.dol_real_offset, tgc_header_size); const u32 replacement_fst_offset = SubtractBE32(m_header.fst_real_offset, tgc_header_size); -- cgit v1.2.3 From a336c4386c154746ef2ea732b13872f5293666be Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 29 Jan 2022 06:01:03 +0100 Subject: IOFile: Rename Clear() to ClearError() for clarity. --- Source/Core/DiscIO/TGCBlob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/DiscIO/TGCBlob.cpp') diff --git a/Source/Core/DiscIO/TGCBlob.cpp b/Source/Core/DiscIO/TGCBlob.cpp index b0571726fa..c61d0763a4 100644 --- a/Source/Core/DiscIO/TGCBlob.cpp +++ b/Source/Core/DiscIO/TGCBlob.cpp @@ -121,7 +121,7 @@ bool TGCFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) return true; } - m_file.Clear(); + m_file.ClearError(); return false; } -- cgit v1.2.3