void Config::AddRecent(const std::string &file) { // Don't bother with this if the user disabled recents (it's -1). if (iMaxRecent <= 0) return; for (auto str = recentIsos.begin(); str != recentIsos.end(); ++str) { #ifdef _WIN32 if (!strcmpIgnore((*str).c_str(), file.c_str(), "\\", "/")) { #else if (!strcmp((*str).c_str(), file.c_str())) { #endif recentIsos.erase(str); recentIsos.insert(recentIsos.begin(), file); if ((int)recentIsos.size() > iMaxRecent) recentIsos.resize(iMaxRecent); return; } } recentIsos.insert(recentIsos.begin(), file); if ((int)recentIsos.size() > iMaxRecent) recentIsos.resize(iMaxRecent); } void Config::CleanRecent() { std::vector<std::string> cleanedRecent; for (size_t i = 0; i < recentIsos.size(); i++) { if (File::Exists(recentIsos[i])) { // clean the redundant recent games' list. if (cleanedRecent.size()==0) { // add first one cleanedRecent.push_back(recentIsos[i]); } for (size_t j = 0; j < cleanedRecent.size();j++) { if (cleanedRecent[j] == recentIsos[i]) break; // skip if found redundant if (j == cleanedRecent.size() - 1){ // add if no redundant found cleanedRecent.push_back(recentIsos[i]); } } } } recentIsos = cleanedRecent; }
void Config::AddRecent(const std::string &file) { // Don't bother with this if the user disabled recents (it's -1). if (iMaxRecent <= 0) return; for (auto str = recentIsos.begin(); str != recentIsos.end(); ++str) { #ifdef _WIN32 if (!strcmpIgnore((*str).c_str(), file.c_str(), "\\", "/")) { #else if (!strcmp((*str).c_str(), file.c_str())) { #endif recentIsos.erase(str); recentIsos.insert(recentIsos.begin(), file); if ((int)recentIsos.size() > iMaxRecent) recentIsos.resize(iMaxRecent); return; } } recentIsos.insert(recentIsos.begin(), file); if ((int)recentIsos.size() > iMaxRecent) recentIsos.resize(iMaxRecent); } void Config::CleanRecent() { std::vector<std::string> cleanedRecent; for (size_t i = 0; i < recentIsos.size(); i++) { FileLoader *loader = ConstructFileLoader(recentIsos[i]); if (loader->Exists()) { // Make sure we don't have any redundant items. auto duplicate = std::find(cleanedRecent.begin(), cleanedRecent.end(), recentIsos[i]); if (duplicate == cleanedRecent.end()) { cleanedRecent.push_back(recentIsos[i]); } } delete loader; } recentIsos = cleanedRecent; }