From 659e6a2e609661385a71fb79781ef4de6605b4ca Mon Sep 17 00:00:00 2001 From: Albert Liu <45282415+ggrtk@users.noreply.github.com> Date: Sat, 26 Sep 2020 15:38:46 -0700 Subject: [PATCH 1/2] CDImageBin: Remove use of duplicated ReplaceExtension function --- src/common/cd_image_bin.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/common/cd_image_bin.cpp b/src/common/cd_image_bin.cpp index c84710175..f62d48f40 100644 --- a/src/common/cd_image_bin.cpp +++ b/src/common/cd_image_bin.cpp @@ -25,17 +25,6 @@ private: CDSubChannelReplacement m_sbi; }; -static std::string ReplaceExtension(std::string_view path, std::string_view new_extension) -{ - std::string_view::size_type pos = path.rfind('.'); - if (pos == std::string::npos) - return std::string(path); - - std::string ret(path, 0, pos + 1); - ret.append(new_extension); - return ret; -} - CDImageBin::CDImageBin() = default; CDImageBin::~CDImageBin() @@ -101,7 +90,7 @@ bool CDImageBin::Open(const char* filename) AddLeadOutIndex(); - m_sbi.LoadSBI(ReplaceExtension(filename, "sbi").c_str()); + m_sbi.LoadSBI(FileSystem::ReplaceExtension(filename, "sbi").c_str()); return Seek(1, Position{0, 0, 0}); } From 5f3d475f4cc0f26524fc9b6eef98bbaa3eaf95cc Mon Sep 17 00:00:00 2001 From: Albert Liu <45282415+ggrtk@users.noreply.github.com> Date: Sat, 26 Sep 2020 15:42:13 -0700 Subject: [PATCH 2/2] CDImageMemory: Fix SBI loading --- src/common/cd_image_memory.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/common/cd_image_memory.cpp b/src/common/cd_image_memory.cpp index 54a85a692..c3e38cb0b 100644 --- a/src/common/cd_image_memory.cpp +++ b/src/common/cd_image_memory.cpp @@ -110,20 +110,7 @@ bool CDImageMemory::CopyImage(CDImage* image, ProgressCallback* progress) m_filename = image->GetFileName(); m_lba_count = image->GetLBACount(); - if (!image->Seek(0)) - { - progress->ModalError("Failed to seek to start of image for subq read"); - return false; - } - - progress->SetStatusText("Looking for invalid subchannel data..."); - - CDImage::SubChannelQ subq; - for (LBA lba = 0; lba < m_lba_count; lba++) - { - if (ReadSubChannelQ(&subq) && !subq.IsCRCValid()) - m_sbi.AddReplacementSubChannelQ(lba, subq); - } + m_sbi.LoadSBI(FileSystem::ReplaceExtension(m_filename, "sbi").c_str()); return Seek(1, Position{0, 0, 0}); }