| 83 | } |
| 84 | |
| 85 | void ServerListCache::saveCache() { |
| 86 | std::string fileName = getCacheFilename(); |
| 87 | if (fileName == "") { return; } |
| 88 | |
| 89 | std::ostream* outFile = FILEMGR.createDataOutStream(fileName, true, true); |
| 90 | int lenCpy = max_string; |
| 91 | |
| 92 | if (outFile != NULL) { |
| 93 | char buffer[max_string + 1]; |
| 94 | for (SRV_STR_MAP::iterator iter = serverCache.begin(); iter != serverCache.end(); iter++) { |
| 95 | |
| 96 | // skip items that are more than 30 days old, but always save favorites |
| 97 | if (!iter->second.favorite && iter->second.getAgeMinutes() > 60 * 24 * 30) { |
| 98 | continue; |
| 99 | } |
| 100 | |
| 101 | // write out the index of the map |
| 102 | memset(buffer, 0, sizeof(buffer)); |
| 103 | lenCpy = int((iter->first).size() < max_string ? (iter->first).size() : max_string); |
| 104 | strncpy(buffer, (iter->first.c_str()), lenCpy); |
| 105 | outFile->write(buffer, sizeof(buffer)); |
| 106 | |
| 107 | ServerItem x = iter->second; |
| 108 | // write out the serverinfo -- which is mapped by index |
| 109 | iter->second.writeToFile(*outFile); |
| 110 | } |
| 111 | delete outFile; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | |
| 116 | void ServerListCache::loadCache() { |
nothing calls this directly
no test coverage detected