-now also reading all subdirectories for emulator coverflow

-corrected small debug print mistake
-set down mem1 usage a little bit
-enabled randomize_music by default
This commit is contained in:
fix94.1 2012-05-21 12:42:10 +00:00
parent 84cf561172
commit e3e04bd584
6 changed files with 58 additions and 54 deletions

View File

@ -17,6 +17,7 @@ void CachedList<T>::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)
@ -25,7 +26,7 @@ void CachedList<T>::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 = strcasestr(path.c_str(), m_plugin.getString("PLUGIN","romDir","").c_str()) != NULL && force_update[COVERFLOW_EMU];
update_emu = emu && 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];
@ -46,10 +47,10 @@ void CachedList<T>::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(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!\n");
if(m_update) gprintf("Cache of %s is being updated because:", 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);
if(m_extcheck && !m_update)
{
@ -79,7 +80,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)), music);
list.GetPaths(pathlist, containing, path, m_wbfsFS, (update_dml || (m_update && strcasestr(path.c_str(), ":/games") != NULL)), (music || emu));
list.GetHeaders(pathlist, *this, m_settingsDir, m_curLanguage, m_DMLgameDir, m_plugin);
path.append("/touch.db");

View File

@ -5,9 +5,10 @@
#include "defines.h"
#include "channels.h"
#include "gc.h"
#include "fileOps.h"
template <typename T>
void CList<T>::GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool music)
void CList<T>::GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool no_depth_limit)
{
if (!wbfs_fs)
{
@ -23,8 +24,8 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
/* Read primary entries */
while((ent = readdir(dir_itr)) != NULL)
{
if (ent->d_name[0] == '.') continue;
//if (strlen(ent->d_name) < 6) continue;
if (ent->d_name[0] == '.')
continue;
if(ent->d_type == DT_REG)
{
@ -41,57 +42,59 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
}
closedir(dir_itr);
if(temp_pathlist.size() > 0)
bool FoundFile;
while(temp_pathlist.size())
{
bool FoundDMLgame;
for(u32 i = 0; i < temp_pathlist.size(); i++)
if(temp_pathlist[0].size() == 0)
{
if(temp_pathlist[i].size() == 0)
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] == '.')
continue;
dir_itr = opendir(temp_pathlist[i].c_str());
if(!dir_itr)
continue;
FoundDMLgame = false;
/* Read secondary entries */
while((ent = readdir(dir_itr)) != NULL)
if(ent->d_type == DT_REG)
{
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;
//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(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)
{
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;
}
FoundFile = true;
//gprintf("Pushing %s to the list.\n", sfmt("%s/%s", temp_pathlist[0].c_str(), ent->d_name).c_str());
pathlist.push_back(sfmt("%s/%s", temp_pathlist[0].c_str(), ent->d_name));
break;
}
}
}
closedir(dir_itr);
else
{
if(no_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)))
{
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;
}
}
}
closedir(dir_itr);
/* Finished reading subdirectory, erase it */
temp_pathlist.erase(temp_pathlist.begin());
}
}
else

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, bool music = false);
void GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs = false, bool dml = false, bool no_depth_limit = false);
void GetHeaders(vector<string> pathlist, vector<T> &headerlist, string, string, string, Config &plugin);
void GetChannels(vector<T> &headerlist, string, u32, string);
private:

View File

@ -36,7 +36,7 @@ extern "C"
int main(int argc, char **argv)
{
__exception_setreload(5);
MEM1_init((void*)0x80003f00, (void*)0x80b00000);
MEM1_init((void*)0x80004000, (void*)0x80b00000);
// Init video
CVideo vid;

View File

@ -181,7 +181,7 @@ bool GuiSound::Load(const char * filepath)
if(!decoder->IsBufferReady())
{
gprintf("Buffer not ready!!n");
gprintf("Buffer not ready!!\n");
SoundHandler::Instance()->RemoveDecoder(voice);
return false;
}

View File

@ -39,7 +39,7 @@ void MusicPlayer::Init(Config &cfg, string musicDir, string themeMusicDir)
if (dir & NORMAL_MUSIC)
m_music_files.Load(musicDir, ".ogg|.mp3", "EN", cfg); //|.mod|.xm|.s3m|.wav|.aiff");
if (cfg.getBool("GENERAL", "randomize_music", false) && m_music_files.size() > 0)
if (cfg.getBool("GENERAL", "randomize_music", true) && m_music_files.size() > 0)
{
srand(unsigned(time(NULL)));
random_shuffle(m_music_files.begin(), m_music_files.end());