From bd40c72b13960f95fe9dc47cadf77be62599063c Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Tue, 22 May 2012 18:06:43 +0000 Subject: [PATCH] -fixed double gamecube games created --- source/list/cachedlist.cpp | 7 +++---- source/list/list.cpp | 25 +++++++++---------------- source/list/list.hpp | 2 +- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/source/list/cachedlist.cpp b/source/list/cachedlist.cpp index 1e187e8a..517ef6f3 100644 --- a/source/list/cachedlist.cpp +++ b/source/list/cachedlist.cpp @@ -17,7 +17,6 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, bool ditimes = false; bool music = typeid(T) == typeid(std::string); - bool emu = strcasestr(path.c_str(), m_plugin.getString("PLUGIN","romDir","").c_str()) != NULL; if(music) gprintf("Loading music list from path: %s\n",path.c_str()); else if(!m_wbfsFS) @@ -26,7 +25,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, update_games = strcasestr(path.c_str(), "wbfs") != NULL && force_update[COVERFLOW_USB]; update_homebrew = strcasestr(path.c_str(), "apps") != NULL && force_update[COVERFLOW_HOMEBREW]; - update_emu = emu && force_update[COVERFLOW_EMU]; + update_emu = strcasestr(path.c_str(), m_plugin.getString("PLUGIN","romDir","").c_str()) != NULL && force_update[COVERFLOW_EMU]; const char* partition = DeviceName[DeviceHandler::Instance()->PathToDriveType(path.c_str())]; update_dml = strcasestr(path.c_str(), fmt(strncmp(partition, "sd", 2) != 0 ? m_DMLgameDir.c_str() : "%s:/games", partition)) != NULL && force_update[COVERFLOW_DML]; @@ -47,7 +46,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, ditimes = discinfo.st_mtime > cache.st_mtime; m_update = update_lang || noDB || mtimes || ditimes; - if(m_update) gprintf("Cache of %s is being updated because:", path.c_str()); + if(m_update) gprintf("Cache of %s is being updated because:\n", path.c_str()); if(update_lang) gprintf("Languages are different!\nOld language string: %s\nNew language string: %s\n", m_lastLanguage.c_str(), m_curLanguage.c_str()); if(noDB) gprintf("A database was not found!\n"); if(mtimes || ditimes) gprintf("The WBFS folder was modified!\nCache date: %i\nFolder date: %i\n", cache.st_mtime, filestat.st_mtime); @@ -80,7 +79,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, gprintf("Calling list to update filelist\n"); vector pathlist; - list.GetPaths(pathlist, containing, path, m_wbfsFS, (update_dml || (m_update && strcasestr(path.c_str(), ":/games") != NULL)), (music || emu)); + list.GetPaths(pathlist, containing, path, m_wbfsFS, (update_dml || (m_update && strcasestr(path.c_str(), ":/games") != NULL)), (!update_emu && !music)); list.GetHeaders(pathlist, *this, m_settingsDir, m_curLanguage, m_DMLgameDir, m_plugin); path.append("/touch.db"); diff --git a/source/list/list.cpp b/source/list/list.cpp index b89ffa57..16f5a68d 100644 --- a/source/list/list.cpp +++ b/source/list/list.cpp @@ -8,7 +8,7 @@ #include "fileOps.h" template -void CList::GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool no_depth_limit) +void CList::GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool depth_limit) { if (!wbfs_fs) { @@ -24,18 +24,20 @@ void CList::GetPaths(vector &pathlist, string containing, string dire /* Read primary entries */ while((ent = readdir(dir_itr)) != NULL) { - if (ent->d_name[0] == '.') + if(ent->d_name[0] == '.') continue; if(ent->d_type == DT_REG) { for(vector::iterator compare = compares.begin(); compare != compares.end(); compare++) + { if (strcasestr(ent->d_name, (*compare).c_str()) != NULL) { //gprintf("Pushing %s to the list.\n", sfmt("%s/%s", directory.c_str(), ent->d_name).c_str()); pathlist.push_back(sfmt("%s/%s", directory.c_str(), ent->d_name)); break; } + } } else temp_pathlist.push_back(sfmt("%s/%s", directory.c_str(), ent->d_name)); @@ -45,26 +47,18 @@ void CList::GetPaths(vector &pathlist, string containing, string dire bool FoundFile; while(temp_pathlist.size()) { - if(temp_pathlist[0].size() == 0) - { + while((dir_itr = opendir(temp_pathlist[0].c_str())) && !dir_itr) temp_pathlist.erase(temp_pathlist.begin()); - continue; - } - - dir_itr = opendir(temp_pathlist[0].c_str()); - if(!dir_itr) - { - temp_pathlist.erase(temp_pathlist.begin()); - continue; - } FoundFile = false; /* Read subdirectory */ while((ent = readdir(dir_itr)) != NULL) { - if (ent->d_name[0] == '.') + if(ent->d_name[0] == '.') continue; + if(dml && FoundFile) + break; if(ent->d_type == DT_REG) { for(vector::iterator compare = compares.begin(); compare != compares.end(); compare++) @@ -80,7 +74,7 @@ void CList::GetPaths(vector &pathlist, string containing, string dire } else { - if(no_depth_limit) + if(!depth_limit) temp_pathlist.push_back(sfmt("%s/%s", temp_pathlist[0].c_str(), ent->d_name)); else if(dml && !FoundFile && strncasecmp(ent->d_name, "sys", 3) == 0 && fsop_FileExist(fmt("%s/%s/boot.bin", temp_pathlist[0].c_str(), ent->d_name))) @@ -88,7 +82,6 @@ void CList::GetPaths(vector &pathlist, string containing, string dire FoundFile = true; //gprintf("Pushing %s to the list.\n", sfmt("%s/%s/boot.bin", temp_pathlist[0].c_str(), ent->d_name).c_str()); pathlist.push_back(sfmt("%s/%s/boot.bin", temp_pathlist[0].c_str(), ent->d_name)); - break; } } } diff --git a/source/list/list.hpp b/source/list/list.hpp index f864c62e..4c1c36e8 100644 --- a/source/list/list.hpp +++ b/source/list/list.hpp @@ -22,7 +22,7 @@ class CList public: CList(){}; ~CList(){}; - void GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs = false, bool dml = false, bool no_depth_limit = false); + void GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs = false, bool dml = false, bool depth_limit = true); void GetHeaders(vector pathlist, vector &headerlist, string, string, string, Config &plugin); void GetChannels(vector &headerlist, string, u32, string); private: