From e390fd0f4e853ceb7beb23eb44a79b42486f66dd Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 5 May 2019 16:14:55 +0200 Subject: [PATCH] GCMemcard: Remove unused ability of ImportGci() to write a GCI file to disk. --- Source/Core/Core/HW/GCMemcard/GCMemcard.cpp | 44 +++------------------ Source/Core/Core/HW/GCMemcard/GCMemcard.h | 9 ++--- Source/Core/DolphinQt/GCMemcardManager.cpp | 2 +- 3 files changed, 9 insertions(+), 46 deletions(-) diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp index 10f18ee80e..e121b887b0 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp @@ -837,22 +837,20 @@ GCMemcardImportFileRetVal GCMemcard::CopyFrom(const GCMemcard& source, u8 index) } } -GCMemcardImportFileRetVal GCMemcard::ImportGci(const std::string& inputFile, - const std::string& outputFile) +GCMemcardImportFileRetVal GCMemcard::ImportGci(const std::string& inputFile) { - if (outputFile.empty() && !m_valid) + if (!m_valid) return GCMemcardImportFileRetVal::OPENFAIL; File::IOFile gci(inputFile, "rb"); if (!gci) return GCMemcardImportFileRetVal::OPENFAIL; - return ImportGciInternal(std::move(gci), inputFile, outputFile); + return ImportGciInternal(std::move(gci), inputFile); } GCMemcardImportFileRetVal GCMemcard::ImportGciInternal(File::IOFile&& gci, - const std::string& inputFile, - const std::string& outputFile) + const std::string& inputFile) { unsigned int offset; std::string fileType; @@ -907,39 +905,7 @@ GCMemcardImportFileRetVal GCMemcard::ImportGciInternal(File::IOFile&& gci, gci.ReadBytes(b.m_block.data(), b.m_block.size()); saveData.push_back(b); } - GCMemcardImportFileRetVal ret; - if (!outputFile.empty()) - { - File::IOFile gci2(outputFile, "wb"); - bool completeWrite = true; - if (!gci2) - { - return GCMemcardImportFileRetVal::OPENFAIL; - } - gci2.Seek(0, SEEK_SET); - - if (!gci2.WriteBytes(&tempDEntry, DENTRY_SIZE)) - completeWrite = false; - int fileBlocks = tempDEntry.m_block_count; - gci2.Seek(DENTRY_SIZE, SEEK_SET); - - for (int i = 0; i < fileBlocks; ++i) - { - if (!gci2.WriteBytes(saveData[i].m_block.data(), saveData[i].m_block.size())) - completeWrite = false; - } - - // TODO: This is interpreted as failure by the calling code if it only checks for SUCCESS. - // What is the logic here? - if (completeWrite) - ret = GCMemcardImportFileRetVal::GCS; - else - ret = GCMemcardImportFileRetVal::WRITEFAIL; - } - else - ret = ImportFile(tempDEntry, saveData); - - return ret; + return ImportFile(tempDEntry, saveData); } GCMemcardExportFileRetVal GCMemcard::ExportGci(u8 index, const std::string& fileName, diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.h b/Source/Core/Core/HW/GCMemcard/GCMemcard.h index dc226b68c7..75017fe28b 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.h +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.h @@ -60,8 +60,6 @@ enum class GCMemcardImportFileRetVal SAVFAIL, OPENFAIL, LENGTHFAIL, - WRITEFAIL, - GCS, }; enum class GCMemcardExportFileRetVal @@ -380,8 +378,7 @@ private: int m_active_directory; int m_active_bat; - GCMemcardImportFileRetVal ImportGciInternal(File::IOFile&& gci, const std::string& inputFile, - const std::string& outputFile); + GCMemcardImportFileRetVal ImportGciInternal(File::IOFile&& gci, const std::string& inputFile); void InitActiveDirBat(); const Directory& GetActiveDirectory() const; @@ -456,8 +453,8 @@ public: // reads a save from another memcard, and imports the data into this memcard GCMemcardImportFileRetVal CopyFrom(const GCMemcard& source, u8 index); - // reads a .gci/.gcs/.sav file and calls ImportFile or saves out a gci file - GCMemcardImportFileRetVal ImportGci(const std::string& inputFile, const std::string& outputFile); + // reads a .gci/.gcs/.sav file and calls ImportFile + GCMemcardImportFileRetVal ImportGci(const std::string& inputFile); // writes a .gci file to disk containing index GCMemcardExportFileRetVal ExportGci(u8 index, const std::string& fileName, diff --git a/Source/Core/DolphinQt/GCMemcardManager.cpp b/Source/Core/DolphinQt/GCMemcardManager.cpp index 1bfdfd0c73..d763d01ebb 100644 --- a/Source/Core/DolphinQt/GCMemcardManager.cpp +++ b/Source/Core/DolphinQt/GCMemcardManager.cpp @@ -330,7 +330,7 @@ void GCMemcardManager::ImportFile() if (path.isEmpty()) return; - const auto result = m_slot_memcard[m_active_slot]->ImportGci(path.toStdString(), ""); + const auto result = m_slot_memcard[m_active_slot]->ImportGci(path.toStdString()); if (result != GCMemcardImportFileRetVal::SUCCESS) {