-fixed double gamecube games created

This commit is contained in:
fix94.1 2012-05-22 18:06:43 +00:00
parent 1b33874ca5
commit bd40c72b13
3 changed files with 13 additions and 21 deletions

View File

@ -17,7 +17,6 @@ void CachedList<T>::Load(string path, string containing, string m_lastLanguage,
bool ditimes = false; bool ditimes = false;
bool music = typeid(T) == typeid(std::string); bool music = typeid(T) == typeid(std::string);
bool emu = strcasestr(path.c_str(), m_plugin.getString("PLUGIN","romDir","").c_str()) != NULL;
if(music) if(music)
gprintf("Loading music list from path: %s\n",path.c_str()); gprintf("Loading music list from path: %s\n",path.c_str());
else if(!m_wbfsFS) else if(!m_wbfsFS)
@ -26,7 +25,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_games = strcasestr(path.c_str(), "wbfs") != NULL && force_update[COVERFLOW_USB];
update_homebrew = strcasestr(path.c_str(), "apps") != NULL && force_update[COVERFLOW_HOMEBREW]; update_homebrew = strcasestr(path.c_str(), "apps") != NULL && force_update[COVERFLOW_HOMEBREW];
update_emu = emu && force_update[COVERFLOW_EMU]; update_emu = strcasestr(path.c_str(), m_plugin.getString("PLUGIN","romDir","").c_str()) != NULL && force_update[COVERFLOW_EMU];
const char* partition = DeviceName[DeviceHandler::Instance()->PathToDriveType(path.c_str())]; 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]; update_dml = strcasestr(path.c_str(), fmt(strncmp(partition, "sd", 2) != 0 ? m_DMLgameDir.c_str() : "%s:/games", partition)) != NULL && force_update[COVERFLOW_DML];
@ -47,7 +46,7 @@ void CachedList<T>::Load(string path, string containing, string m_lastLanguage,
ditimes = discinfo.st_mtime > cache.st_mtime; ditimes = discinfo.st_mtime > cache.st_mtime;
m_update = update_lang || noDB || mtimes || ditimes; m_update = update_lang || noDB || mtimes || ditimes;
if(m_update) gprintf("Cache of %s is being updated because:", path.c_str()); if(m_update) gprintf("Cache of %s is being updated because:\n", 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(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(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(mtimes || ditimes) gprintf("The WBFS folder was modified!\nCache date: %i\nFolder date: %i\n", cache.st_mtime, filestat.st_mtime);
@ -80,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)), (music || emu)); list.GetPaths(pathlist, containing, path, m_wbfsFS, (update_dml || (m_update && strcasestr(path.c_str(), ":/games") != NULL)), (!update_emu && !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

@ -8,7 +8,7 @@
#include "fileOps.h" #include "fileOps.h"
template <typename T> template <typename T>
void CList<T>::GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool no_depth_limit) void CList<T>::GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs, bool dml, bool depth_limit)
{ {
if (!wbfs_fs) if (!wbfs_fs)
{ {
@ -24,12 +24,13 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
/* Read primary entries */ /* Read primary entries */
while((ent = readdir(dir_itr)) != NULL) while((ent = readdir(dir_itr)) != NULL)
{ {
if (ent->d_name[0] == '.') if(ent->d_name[0] == '.')
continue; continue;
if(ent->d_type == DT_REG) if(ent->d_type == DT_REG)
{ {
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)
{ {
//gprintf("Pushing %s to the list.\n", sfmt("%s/%s", directory.c_str(), ent->d_name).c_str()); //gprintf("Pushing %s to the list.\n", sfmt("%s/%s", directory.c_str(), ent->d_name).c_str());
@ -37,6 +38,7 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
break; break;
} }
} }
}
else else
temp_pathlist.push_back(sfmt("%s/%s", directory.c_str(), ent->d_name)); temp_pathlist.push_back(sfmt("%s/%s", directory.c_str(), ent->d_name));
} }
@ -45,26 +47,18 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
bool FoundFile; bool FoundFile;
while(temp_pathlist.size()) while(temp_pathlist.size())
{ {
if(temp_pathlist[0].size() == 0) while((dir_itr = opendir(temp_pathlist[0].c_str())) && !dir_itr)
{
temp_pathlist.erase(temp_pathlist.begin()); 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; FoundFile = false;
/* Read subdirectory */ /* Read subdirectory */
while((ent = readdir(dir_itr)) != NULL) while((ent = readdir(dir_itr)) != NULL)
{ {
if (ent->d_name[0] == '.') if(ent->d_name[0] == '.')
continue; continue;
if(dml && FoundFile)
break;
if(ent->d_type == DT_REG) if(ent->d_type == DT_REG)
{ {
for(vector<string>::iterator compare = compares.begin(); compare != compares.end(); compare++) for(vector<string>::iterator compare = compares.begin(); compare != compares.end(); compare++)
@ -80,7 +74,7 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
} }
else else
{ {
if(no_depth_limit) if(!depth_limit)
temp_pathlist.push_back(sfmt("%s/%s", temp_pathlist[0].c_str(), ent->d_name)); 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 && 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))) fsop_FileExist(fmt("%s/%s/boot.bin", temp_pathlist[0].c_str(), ent->d_name)))
@ -88,7 +82,6 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
FoundFile = true; FoundFile = true;
//gprintf("Pushing %s to the list.\n", sfmt("%s/%s/boot.bin", temp_pathlist[0].c_str(), ent->d_name).c_str()); //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)); pathlist.push_back(sfmt("%s/%s/boot.bin", temp_pathlist[0].c_str(), ent->d_name));
break;
} }
} }
} }

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, bool no_depth_limit = false); void GetPaths(vector<string> &pathlist, string containing, string directory, bool wbfs_fs = false, bool dml = false, bool depth_limit = true);
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: