From c1d0ed08c4b7c5dedacfffdba2e0a8cfb244a0b1 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 20 Aug 2013 16:52:36 +0200 Subject: [PATCH] Fix some file browsing issues --- Core/Loaders.cpp | 30 +++++++++++++++++++----------- Core/Loaders.h | 2 ++ UI/GameInfoCache.cpp | 6 +++++- UI/MainScreen.cpp | 2 +- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index 43eb720aa..b308e5d09 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -51,20 +51,24 @@ IdentifiedFileType Identify_File(std::string &filename) } if (info.isDirectory) { - FileInfo ebootInfo; - // Check for existence of EBOOT.PBP, as required for "Directory games". - if (getFileInfo((filename + "/EBOOT.PBP").c_str(), &ebootInfo)) { - if (ebootInfo.exists) { - return FILETYPE_PSP_PBP_DIRECTORY; + if (filename.size() > 4) { + FileInfo ebootInfo; + // Check for existence of EBOOT.PBP, as required for "Directory games". + if (getFileInfo((filename + "/EBOOT.PBP").c_str(), &ebootInfo)) { + if (ebootInfo.exists) { + return FILETYPE_PSP_PBP_DIRECTORY; + } + } + + // check if it's a disc directory + if (getFileInfo((filename + "/PSP_GAME").c_str(), &ebootInfo)) { + if (ebootInfo.exists) { + return FILETYPE_PSP_DISC_DIRECTORY; + } } } - // check if it's a disc directory - if (getFileInfo((filename + "/PSP_GAME").c_str(), &ebootInfo)) { - if (ebootInfo.exists) { - return FILETYPE_PSP_DISC_DIRECTORY; - } - } + return FILETYPE_NORMAL_DIRECTORY; } FILE *f = fopen(filename.c_str(), "rb"); @@ -198,6 +202,10 @@ bool LoadFile(std::string &filename, std::string *error_string) { *error_string = "File is compressed (ZIP).\nPlease decompress first (try WinRAR)"; break; + case FILETYPE_NORMAL_DIRECTORY: + ERROR_LOG(LOADER, "Just a directory."); + break; + case FILETYPE_UNKNOWN_BIN: case FILETYPE_UNKNOWN_ELF: case FILETYPE_UNKNOWN: diff --git a/Core/Loaders.h b/Core/Loaders.h index 1c79a65db..b8f018bbe 100644 --- a/Core/Loaders.h +++ b/Core/Loaders.h @@ -37,6 +37,8 @@ enum IdentifiedFileType { FILETYPE_ARCHIVE_ZIP, FILETYPE_PSP_PS1_PBP, + FILETYPE_NORMAL_DIRECTORY, + FILETYPE_UNKNOWN }; diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 08ca91242..621396a13 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -288,7 +288,11 @@ public: break; } - default: + case FILETYPE_NORMAL_DIRECTORY: + info_->title = gamePath_; + break; + + default: { std::string fn, ext; SplitPath(gamePath_, 0, &fn, &ext); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index b4870e063..afb12c0c3 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -386,7 +386,7 @@ void GameBrowser::Refresh() { std::vector fileInfo; path_.GetListing(fileInfo, "iso:cso:pbp:elf:prx:"); for (size_t i = 0; i < fileInfo.size(); i++) { - if (fileInfo[i].isDirectory && !File::Exists(path_.GetPath() + fileInfo[i].name + "/EBOOT.PBP")) { + if (fileInfo[i].isDirectory && (path_.GetPath().size() < 4 || !File::Exists(path_.GetPath() + fileInfo[i].name + "/EBOOT.PBP"))) { // Check if eboot directory if (allowBrowsing_) dirButtons.push_back(new UI::Button(fileInfo[i].name.c_str(), new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)));