diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index aa3bf94ca..e01216734 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -114,7 +114,7 @@ int main(int argc, char **argv) { System::Init(emu_window.get()); SCOPE_EXIT({ System::Shutdown(); }); - std::unique_ptr loader = Loader::GetFileLoader(boot_filename); + std::unique_ptr loader = Loader::GetLoader(boot_filename); if (!loader) { LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", boot_filename.c_str()); return -1; diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index d4ac9c96e..570647539 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -132,30 +132,16 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, bool d if (deep_scan && FileUtil::IsDirectory(physical_name)) { AddFstEntriesToGameList(physical_name, true); } else { - std::string filename_filename, filename_extension; - Common::SplitPath(physical_name, nullptr, &filename_filename, &filename_extension); - - Loader::FileType guessed_filetype = Loader::GuessFromExtension(filename_extension); - if (guessed_filetype == Loader::FileType::Unknown) + std::unique_ptr loader = Loader::GetLoader(physical_name); + if (!loader) return true; - Loader::FileType filetype = Loader::IdentifyFile(physical_name); - if (filetype == Loader::FileType::Unknown) { - LOG_WARNING(Frontend, "File %s is of indeterminate type and is possibly corrupted.", physical_name.c_str()); - return true; - } - if (guessed_filetype != filetype) { - LOG_WARNING(Frontend, "Filetype and extension of file %s do not match.", physical_name.c_str()); - } std::vector smdh; - std::unique_ptr loader = Loader::GetLoader(FileUtil::IOFile(physical_name, "rb"), filetype, filename_filename, physical_name); - - if (loader) - loader->ReadIcon(smdh); + loader->ReadIcon(smdh); emit EntryReady({ new GameListItemPath(QString::fromStdString(physical_name), smdh), - new GameListItem(QString::fromStdString(Loader::GetFileTypeString(filetype))), + new GameListItem(QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), new GameListItemSize(FileUtil::GetSize(physical_name)), }); } diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 9d47014aa..6239160bc 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -272,7 +272,7 @@ bool GMainWindow::InitializeSystem() { } bool GMainWindow::LoadROM(const std::string& filename) { - std::unique_ptr app_loader = Loader::GetFileLoader(filename); + std::unique_ptr app_loader = Loader::GetLoader(filename); if (!app_loader) { LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str()); QMessageBox::critical(this, tr("Error while loading ROM!"), diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index c82688026..9719d30d5 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -91,7 +91,15 @@ const char* GetFileTypeString(FileType type) { return "unknown"; } -std::unique_ptr GetLoader(FileUtil::IOFile&& file, FileType type, +/** + * Get a loader for a file with a specific type + * @param file The file to load + * @param type The type of the file + * @param filename the file name (without path) + * @param filepath the file full path (with name) + * @return std::unique_ptr a pointer to a loader object; nullptr for unsupported type + */ +static std::unique_ptr GetFileLoader(FileUtil::IOFile&& file, FileType type, const std::string& filename, const std::string& filepath) { switch (type) { @@ -113,7 +121,7 @@ std::unique_ptr GetLoader(FileUtil::IOFile&& file, FileType type, } } -std::unique_ptr GetFileLoader(const std::string& filename) { +std::unique_ptr GetLoader(const std::string& filename) { FileUtil::IOFile file(filename, "rb"); if (!file.IsOpen()) { LOG_ERROR(Loader, "Failed to load file %s", filename.c_str()); @@ -134,7 +142,7 @@ std::unique_ptr GetFileLoader(const std::string& filename) { LOG_INFO(Loader, "Loading file %s as %s...", filename.c_str(), GetFileTypeString(type)); - return GetLoader(std::move(file), type, filename_filename, filename); + return GetFileLoader(std::move(file), type, filename_filename, filename); } } // namespace Loader diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 08bab84e5..39aedfeeb 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -202,21 +202,11 @@ protected: */ extern const std::initializer_list default_address_mappings; -/** - * Get a loader for a file with a specific type - * @param file The file to load - * @param type The type of the file - * @param filename the file name (without path) - * @param filepath the file full path (with name) - * @return std::unique_ptr a pointer to a loader object; nullptr for unsupported type - */ -std::unique_ptr GetLoader(FileUtil::IOFile&& file, FileType type, const std::string& filename, const std::string& filepath); - /** * Identifies a bootable file and return a suitable loader * @param filename String filename of bootable file * @return best loader for this file */ -std::unique_ptr GetFileLoader(const std::string& filename); +std::unique_ptr GetLoader(const std::string& filename); } // namespace