diff --git a/source/list/cache.cpp b/source/list/cache.cpp index 846569f0..9cbc4b52 100644 --- a/source/list/cache.cpp +++ b/source/list/cache.cpp @@ -1,7 +1,6 @@ #include "cache.hpp" -template -CCache::CCache(T &tmp, string path, u32 index, CMode mode) /* Load/Save One */ +CCache::CCache(dir_discHdr &tmp, string path, u32 index, CMode mode) /* Load/Save One */ { filename = path; //gprintf("Openning DB: %s\n", filename.c_str()); @@ -22,8 +21,7 @@ CCache::CCache(T &tmp, string path, u32 index, CMode mode) /* Load/Save One * } } -template -CCache::CCache(vector &list, string path , CMode mode) /* Load/Save All */ +CCache::CCache(vector &list, string path , CMode mode) /* Load/Save All */ { filename = path; //gprintf("Opening DB: %s\n", filename.c_str()); @@ -44,8 +42,7 @@ CCache::CCache(vector &list, string path , CMode mode) /* Load/Save All */ } } -template -CCache::CCache(vector &list, string path, T tmp, CMode mode) /* Add One */ +CCache::CCache(vector &list, string path, dir_discHdr tmp, CMode mode) /* Add One */ { filename = path; //gprintf("Openning DB: %s\n", filename.c_str()); @@ -63,8 +60,7 @@ CCache::CCache(vector &list, string path, T tmp, CMode mode) /* Add One */ } } -template -CCache::CCache(vector &list, string path, u32 index, CMode mode) /* Remove One */ +CCache::CCache(vector &list, string path, u32 index, CMode mode) /* Remove One */ { filename = path; //gprintf("Openning DB: %s\n", filename.c_str()); @@ -82,44 +78,40 @@ CCache::CCache(vector &list, string path, u32 index, CMode mode) /* Remov } } -template -CCache::~CCache() +CCache::~CCache() { //gprintf("Closing DB: %s\n", filename.c_str()); if(cache) fclose(cache); cache = NULL; } -template -void CCache::SaveAll(vector list) +void CCache::SaveAll(vector list) { //gprintf("Updating DB: %s\n", filename.c_str()); if(!cache) return; - fwrite((void *)&list[0], 1, list.size() * sizeof(T), cache); + fwrite((void *)&list[0], 1, list.size() * sizeof(dir_discHdr), cache); } -template -void CCache::SaveOne(T tmp, u32 index) +void CCache::SaveOne(dir_discHdr tmp, u32 index) { //gprintf("Updating Item number %u in DB: %s\n", index, filename.c_str()); if(!cache) return; - fseek(cache, index * sizeof(T), SEEK_SET); - fwrite((void *)&tmp, 1, sizeof(T), cache); + fseek(cache, index * sizeof(dir_discHdr), SEEK_SET); + fwrite((void *)&tmp, 1, sizeof(dir_discHdr), cache); } -template -void CCache::LoadAll(vector &list) +void CCache::LoadAll(vector &list) { if(!cache) return; //gprintf("Loading DB: %s\n", filename.c_str()); - T tmp; + dir_discHdr tmp; fseek(cache, 0, SEEK_END); u64 fileSize = ftell(cache); fseek(cache, 0, SEEK_SET); - u32 count = (u32)(fileSize / sizeof(T)); + u32 count = (u32)(fileSize / sizeof(dir_discHdr)); list.reserve(count + list.size()); for(u32 i = 0; i < count; i++) @@ -129,34 +121,28 @@ void CCache::LoadAll(vector &list) } } - -template -void CCache::LoadOne(T &tmp, u32 index) +void CCache::LoadOne(dir_discHdr &tmp, u32 index) { if(!cache) return; //gprintf("Fetching Item number %u in DB: %s\n", index, filename.c_str()); - fseek(cache, index * sizeof(T), SEEK_SET); - fread((void *)&tmp, 1, sizeof(T), cache); + fseek(cache, index * sizeof(dir_discHdr), SEEK_SET); + fread((void *)&tmp, 1, sizeof(dir_discHdr), cache); //gprintf("Path %s\n", tmp.path); } -template -void CCache::AddOne(vector &list, T tmp) +void CCache::AddOne(vector &list, dir_discHdr tmp) { //gprintf("Adding Item number %u in DB: %s\n", list.size()+1, filename.c_str()); list.push_back(tmp); if(!cache) return; - fwrite((void *)&tmp, 1, sizeof(T), cache); // FILE* is opened as "ab+" so its always written to the EOF. + fwrite((void *)&tmp, 1, sizeof(dir_discHdr), cache); // FILE* is opened as "ab+" so its always written to the EOF. } -template -void CCache::RemoveOne(vector &list, u32 index) +void CCache::RemoveOne(vector &list, u32 index) { //gprintf("Removing Item number %u in DB: %s\n", index, filename.c_str()); list.erase(list.begin() + index); SaveAll(list); } - -template class CCache; \ No newline at end of file diff --git a/source/list/cache.hpp b/source/list/cache.hpp index 635254dd..a4860b33 100644 --- a/source/list/cache.hpp +++ b/source/list/cache.hpp @@ -25,23 +25,22 @@ enum CMode REMOVE }; -template class CCache { public: - CCache(T &tmp, string path, u32 index, CMode mode); /* Load/Save One */ - CCache(vector &list, string path, CMode mode); /* Load/Save All */ - CCache(vector &list, string path, T tmp, CMode mode); /* Add One */ - CCache(vector &list, string path, u32 index, CMode mode); /* Remove One */ + CCache(dir_discHdr &tmp, string path, u32 index, CMode mode); /* Load/Save One */ + CCache(vector &list, string path, CMode mode); /* Load/Save All */ + CCache(vector &list, string path, dir_discHdr tmp, CMode mode); /* Add One */ + CCache(vector &list, string path, u32 index, CMode mode); /* Remove One */ ~CCache(); private: - void SaveAll(vector list); - void SaveOne(T tmp, u32 index); - void LoadAll(vector &list); - void LoadOne(T &tmp, u32 index); + void SaveAll(vector list); + void SaveOne(dir_discHdr tmp, u32 index); + void LoadAll(vector &list); + void LoadOne(dir_discHdr &tmp, u32 index); - void AddOne(vector &list, T tmp); - void RemoveOne(vector &list, u32 index); + void AddOne(vector &list, dir_discHdr tmp); + void RemoveOne(vector &list, u32 index); FILE *cache; string filename; diff --git a/source/list/cachedlist.cpp b/source/list/cachedlist.cpp index 246fc939..2b20feea 100644 --- a/source/list/cachedlist.cpp +++ b/source/list/cachedlist.cpp @@ -1,8 +1,7 @@ #include "cachedlist.hpp" #include -template -void CachedList::Load(string path, string containing, string m_lastLanguage, Config &m_plugin) /* Load All */ +void CachedList::Load(string path, string containing, string m_lastLanguage, Config &m_plugin) /* Load All */ { gprintf("\nLoading files containing %s in %s\n", containing.c_str(), path.c_str()); m_loaded = false; @@ -16,10 +15,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, bool update_emu = false; bool ditimes = false; - bool music = typeid(T) == typeid(std::string); - if(music) - gprintf("Loading music list from path: %s\n", path.c_str()); - else if(!m_wbfsFS) + if(!m_wbfsFS) { gprintf("Database file: %s\n", m_database.c_str()); @@ -56,7 +52,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, 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 && !music) + if(m_extcheck && !m_update) { bool m_chupdate = false; DIR *dir = opendir(path.c_str()); @@ -80,12 +76,12 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, if(update_dml) force_update[COVERFLOW_DML] = false; - if(m_update || m_wbfsFS || music) + if(m_update || m_wbfsFS) { 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)), (!update_emu && !music)); + list.GetPaths(pathlist, containing, path, m_wbfsFS, (update_dml || (m_update && strcasestr(path.c_str(), ":/games") != NULL)), !update_emu); list.GetHeaders(pathlist, *this, m_settingsDir, m_curLanguage, m_DMLgameDir, m_plugin); path.append("/touch.db"); @@ -96,19 +92,18 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, m_loaded = true; m_update = false; - if(!music && pathlist.size() > 0) + if(pathlist.size() > 0) Save(); pathlist.clear(); } else { - CCache(*this, m_database, LOAD); + CCache(*this, m_database, LOAD); m_loaded = true; } } -template<> -void CachedList::LoadChannels(string path, u32 channelType, string m_lastLanguage) /* Load All */ +void CachedList::LoadChannels(string path, u32 channelType, string m_lastLanguage) /* Load All */ { m_loaded = false; m_update = true; @@ -148,13 +143,12 @@ void CachedList::LoadChannels(string path, u32 channelType, string if(this->size() > 0 && emu) Save(); } else - CCache(*this, m_database, LOAD); + CCache(*this, m_database, LOAD); m_loaded = true; } -template -string CachedList::make_db_name(string path) +string CachedList::make_db_name(string path) { string buffer = path; size_t find = buffer.find(":/"); @@ -170,5 +164,3 @@ string CachedList::make_db_name(string path) return buffer; } -template class CachedList; -template class CachedList; diff --git a/source/list/cachedlist.hpp b/source/list/cachedlist.hpp index 10ace70c..2a611e30 100644 --- a/source/list/cachedlist.hpp +++ b/source/list/cachedlist.hpp @@ -17,8 +17,7 @@ enum { COVERFLOW_MAX }; -template -class CachedList : public vector +class CachedList : public vector { public: void Init(string cachedir, string settingsDir, string curLanguage, string DMLgameDir, bool extcheck) /* Initialize Private Variables */ @@ -54,13 +53,13 @@ class CachedList : public vector void LoadChannels(string path, u32 channelType, string m_lastLanguage); void Unload(){if(m_loaded) {this->clear(); m_loaded = false; m_database = "";}}; - void Save() {if(m_loaded) CCache(*this, m_database, SAVE);} /* Save All */ + void Save() {if(m_loaded) CCache(*this, m_database, SAVE);} /* Save All */ - void Get(T tmp, u32 index) {if(m_loaded) CCache(tmp, m_database, index, LOAD);} /* Load One */ - void Set(T tmp, u32 index) {if(m_loaded) CCache(tmp, m_database, index, SAVE);} /* Save One */ + void Get(dir_discHdr tmp, u32 index) {if(m_loaded) CCache(tmp, m_database, index, LOAD);} /* Load One */ + void Set(dir_discHdr tmp, u32 index) {if(m_loaded) CCache(tmp, m_database, index, SAVE);} /* Save One */ - void Add(T tmp) {if(m_loaded) CCache(*this, m_database, tmp, ADD);} /* Add One */ - void Remove(u32 index) {if(m_loaded) CCache(*this, m_database, index, REMOVE);} /* Remove One */ + void Add(dir_discHdr tmp) {if(m_loaded) CCache(*this, m_database, tmp, ADD);} /* Add One */ + void Remove(u32 index) {if(m_loaded) CCache(*this, m_database, index, REMOVE);} /* Remove One */ void SetLanguage(string curLanguage) { m_curLanguage = curLanguage; } private: @@ -71,7 +70,7 @@ class CachedList : public vector bool m_wbfsFS; bool m_extcheck; u8 force_update[COVERFLOW_MAX]; - CList list; + CList list; string m_database; string m_cacheDir; string m_settingsDir; diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 25d8c843..194033ca 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -59,7 +59,7 @@ private: CButtonsMgr m_btnMgr; CCoverFlow m_cf; CFanart m_fa; - CachedList m_gameList; + CachedList m_gameList; Config m_cfg; Config m_loc; Config m_cat;