From 84cf5611727f8bbab69fd93cbf5a6506de067628 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sun, 20 May 2012 20:05:16 +0000 Subject: [PATCH] -added subdirectory reading for music files, means you now finally can have your albums in the music folder organized ;) --- source/list/cachedlist.cpp | 2 +- source/list/list.cpp | 36 +++++++++++++++++++++--------------- source/list/list.hpp | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/source/list/cachedlist.cpp b/source/list/cachedlist.cpp index 32ebd76c..6615aefd 100644 --- a/source/list/cachedlist.cpp +++ b/source/list/cachedlist.cpp @@ -79,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))); + list.GetPaths(pathlist, containing, path, m_wbfsFS, (update_dml || (m_update && strcasestr(path.c_str(), ":/games") != NULL)), 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 905e3218..cea49693 100644 --- a/source/list/list.cpp +++ b/source/list/list.cpp @@ -7,7 +7,7 @@ #include "gc.h" template -void CList::GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs, bool dml) +void CList::GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool music) { if (!wbfs_fs) { @@ -44,12 +44,12 @@ void CList::GetPaths(vector &pathlist, string containing, string dire if(temp_pathlist.size() > 0) { bool FoundDMLgame; - for(vector::iterator templist = temp_pathlist.begin(); templist != temp_pathlist.end(); templist++) + for(u32 i = 0; i < temp_pathlist.size(); i++) { - if((*templist).size() == 0) + if(temp_pathlist[i].size() == 0) continue; - dir_itr = opendir((*templist).c_str()); + dir_itr = opendir(temp_pathlist[i].c_str()); if(!dir_itr) continue; @@ -58,29 +58,35 @@ void CList::GetPaths(vector &pathlist, string containing, string dire /* Read secondary entries */ while((ent = readdir(dir_itr)) != NULL) { - if(ent->d_type == DT_REG && strlen(ent->d_name) > 7) + if (ent->d_name[0] == '.') continue; + if(ent->d_type == DT_REG && (strlen(ent->d_name) > 7 || music)) { for(vector::iterator compare = compares.begin(); compare != compares.end(); compare++) { if(strcasestr(ent->d_name, (*compare).c_str()) != NULL) { FoundDMLgame = true; - //gprintf("Pushing %s to the list.\n", sfmt("%s/%s", (*templist).c_str(), ent->d_name).c_str()); - pathlist.push_back(sfmt("%s/%s", (*templist).c_str(), ent->d_name)); + //gprintf("Pushing %s to the list.\n", sfmt("%s/%s", temp_pathlist[i].c_str(), ent->d_name).c_str()); + pathlist.push_back(sfmt("%s/%s", temp_pathlist[i].c_str(), ent->d_name)); break; } } } - else if(dml && !FoundDMLgame && strncasecmp(ent->d_name, "sys", 3) == 0) + else { - FILE *f; - f = fopen(fmt("%s/%s/boot.bin", (*templist).c_str(), ent->d_name), "rb"); - if(f) + if(music) + temp_pathlist.push_back(sfmt("%s/%s", temp_pathlist[i].c_str(), ent->d_name)); + else if(dml && !FoundDMLgame && strncasecmp(ent->d_name, "sys", 3) == 0) { - fclose(f); - //gprintf("Pushing %s to the list.\n", sfmt("%s/%s/boot.bin", (*templist).c_str(), ent->d_name).c_str()); - pathlist.push_back(sfmt("%s/%s/boot.bin", (*templist).c_str(), ent->d_name)); - break; + FILE *f; + f = fopen(fmt("%s/%s/boot.bin", temp_pathlist[i].c_str(), ent->d_name), "rb"); + if(f) + { + fclose(f); + //gprintf("Pushing %s to the list.\n", sfmt("%s/%s/boot.bin", temp_pathlist[i].c_str(), ent->d_name).c_str()); + pathlist.push_back(sfmt("%s/%s/boot.bin", temp_pathlist[i].c_str(), ent->d_name)); + break; + } } } } diff --git a/source/list/list.hpp b/source/list/list.hpp index a5ba7d1d..7d0ff860 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); + void GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs = false, bool dml = false, bool music = false); void GetHeaders(vector pathlist, vector &headerlist, string, string, string, Config &plugin); void GetChannels(vector &headerlist, string, u32, string); private: