-added subdirectory reading for music files, means you now

finally can have your albums in the music folder organized ;)
This commit is contained in:
fix94.1 2012-05-20 20:05:16 +00:00
parent 8ad310f4dc
commit 84cf561172
3 changed files with 23 additions and 17 deletions

View File

@ -79,7 +79,7 @@ void CachedList<T>::Load(string path, string containing, string m_lastLanguage,
gprintf("Calling list to update filelist\n"); gprintf("Calling list to update filelist\n");
vector<string> pathlist; vector<string> 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); list.GetHeaders(pathlist, *this, m_settingsDir, m_curLanguage, m_DMLgameDir, m_plugin);
path.append("/touch.db"); path.append("/touch.db");

View File

@ -7,7 +7,7 @@
#include "gc.h" #include "gc.h"
template <typename T> template <typename T>
void CList<T>::GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs, bool dml) void CList<T>::GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool music)
{ {
if (!wbfs_fs) if (!wbfs_fs)
{ {
@ -44,12 +44,12 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
if(temp_pathlist.size() > 0) if(temp_pathlist.size() > 0)
{ {
bool FoundDMLgame; bool FoundDMLgame;
for(vector<string>::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; continue;
dir_itr = opendir((*templist).c_str()); dir_itr = opendir(temp_pathlist[i].c_str());
if(!dir_itr) if(!dir_itr)
continue; continue;
@ -58,32 +58,38 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
/* Read secondary entries */ /* Read secondary entries */
while((ent = readdir(dir_itr)) != NULL) 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<string>::iterator compare = compares.begin(); compare != compares.end(); compare++) for(vector<string>::iterator compare = compares.begin(); compare != compares.end(); compare++)
{ {
if(strcasestr(ent->d_name, (*compare).c_str()) != NULL) if(strcasestr(ent->d_name, (*compare).c_str()) != NULL)
{ {
FoundDMLgame = true; FoundDMLgame = true;
//gprintf("Pushing %s to the list.\n", sfmt("%s/%s", (*templist).c_str(), ent->d_name).c_str()); //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", (*templist).c_str(), ent->d_name)); pathlist.push_back(sfmt("%s/%s", temp_pathlist[i].c_str(), ent->d_name));
break; break;
} }
} }
} }
else
{
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) else if(dml && !FoundDMLgame && strncasecmp(ent->d_name, "sys", 3) == 0)
{ {
FILE *f; FILE *f;
f = fopen(fmt("%s/%s/boot.bin", (*templist).c_str(), ent->d_name), "rb"); f = fopen(fmt("%s/%s/boot.bin", temp_pathlist[i].c_str(), ent->d_name), "rb");
if(f) if(f)
{ {
fclose(f); fclose(f);
//gprintf("Pushing %s to the list.\n", sfmt("%s/%s/boot.bin", (*templist).c_str(), ent->d_name).c_str()); //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", (*templist).c_str(), ent->d_name)); pathlist.push_back(sfmt("%s/%s/boot.bin", temp_pathlist[i].c_str(), ent->d_name));
break; break;
} }
} }
} }
}
closedir(dir_itr); closedir(dir_itr);
} }
} }

View File

@ -22,7 +22,7 @@ class CList
public: public:
CList(){}; CList(){};
~CList(){}; ~CList(){};
void GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs = false, bool dml = false); void GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs = false, bool dml = false, bool music = false);
void GetHeaders(vector<string> pathlist, vector<T> &headerlist, string, string, string, Config &plugin); void GetHeaders(vector<string> pathlist, vector<T> &headerlist, string, string, string, Config &plugin);
void GetChannels(vector<T> &headerlist, string, u32, string); void GetChannels(vector<T> &headerlist, string, u32, string);
private: private: