diff --git a/source/list/cachedlist.cpp b/source/list/cachedlist.cpp index 6615aefd..1e187e8a 100644 --- a/source/list/cachedlist.cpp +++ b/source/list/cachedlist.cpp @@ -17,6 +17,7 @@ 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) @@ -25,7 +26,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 = 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::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::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); + 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"); diff --git a/source/list/list.cpp b/source/list/list.cpp index cea49693..b89ffa57 100644 --- a/source/list/list.cpp +++ b/source/list/list.cpp @@ -5,9 +5,10 @@ #include "defines.h" #include "channels.h" #include "gc.h" +#include "fileOps.h" template -void CList::GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool music) +void CList::GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool no_depth_limit) { if (!wbfs_fs) { @@ -23,8 +24,8 @@ void CList::GetPaths(vector &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::GetPaths(vector &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::iterator compare = compares.begin(); compare != compares.end(); compare++) { - for(vector::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 diff --git a/source/list/list.hpp b/source/list/list.hpp index 7d0ff860..f864c62e 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 music = false); + void GetPaths(vector &pathlist, string containing, string directory, bool wbfs_fs = false, bool dml = false, bool no_depth_limit = false); void GetHeaders(vector pathlist, vector &headerlist, string, string, string, Config &plugin); void GetChannels(vector &headerlist, string, u32, string); private: diff --git a/source/main.cpp b/source/main.cpp index 521c5fa3..4ecd1516 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -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; diff --git a/source/music/gui_sound.cpp b/source/music/gui_sound.cpp index 4de4994e..eaf72f31 100644 --- a/source/music/gui_sound.cpp +++ b/source/music/gui_sound.cpp @@ -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; } diff --git a/source/music/musicplayer.cpp b/source/music/musicplayer.cpp index cb6ee874..9360f0d8 100644 --- a/source/music/musicplayer.cpp +++ b/source/music/musicplayer.cpp @@ -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());