-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");
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);
path.append("/touch.db");

View File

@ -7,7 +7,7 @@
#include "gc.h"
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)
{
@ -44,12 +44,12 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
if(temp_pathlist.size() > 0)
{
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;
dir_itr = opendir((*templist).c_str());
dir_itr = opendir(temp_pathlist[i].c_str());
if(!dir_itr)
continue;
@ -58,29 +58,35 @@ void CList<T>::GetPaths(vector<string> &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<string>::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;
}
}
}
}

View File

@ -22,7 +22,7 @@ class CList
public:
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 GetChannels(vector<T> &headerlist, string, u32, string);
private: