-fixed possible codedump in cover downloader

-added debug prints to see if crc32 is correctly cached
This commit is contained in:
fix94.1 2012-06-17 11:12:07 +00:00
parent 8f16156768
commit a87244c93a
2 changed files with 23 additions and 16 deletions

View File

@ -495,7 +495,7 @@ int CMenu::_coverDownloader(bool missingOnly)
}
Config m_checksums;
m_checksums.load(fmt("%s/" PLUGIN_CRCS_FILENAME, m_settingsDir.c_str()));
m_checksums.load(fmt("%s/%s", m_settingsDir.c_str(), PLUGIN_CRCS_FILENAME));
if (m_coverDLGameId.empty())
{
@ -1218,7 +1218,7 @@ void CMenu::_download(string gameId)
m_thrdStop = false;
m_thrdMessageAdded = false;
if((m_cf.getHdr()->type == TYPE_PLUGIN) && gameId.size())
if(gameId.size() && m_cf.getHdr()->type == TYPE_PLUGIN)
{
char gamePath[256];
if(string(m_cf.getHdr()->path).find_last_of("/") != string::npos)

View File

@ -297,24 +297,31 @@ string Plugin::GenerateCoverLink(dir_discHdr gameHeader, string url, Config &Che
string cachedCRC = Checksums.getString("CHECKSUMS", gamePath, emptyString);
char crc_string[9];
if(cachedCRC != emptyString)
snprintf(crc_string, sizeof(crc_string), "%s", cachedCRC.c_str());
else if(strstr(gameHeader.path, ".zip") == NULL)
{
snprintf(crc_string, sizeof(crc_string), "%08x", crc32file(gameHeader.path));
Checksums.setString("CHECKSUMS", gamePath, crc_string);
Checksums.save();
gprintf("CRC32 of %s is cached\n", gamePath);
snprintf(crc_string, sizeof(crc_string), "%s", cachedCRC.c_str());
}
else
{
u32 crc_buffer;
ifstream infile;
infile.open(gameHeader.path, ios::binary);
infile.seekg(0x0e, ios::beg);
infile.read((char*)&crc_buffer, 8);
infile.close();
snprintf(crc_string, sizeof(crc_string), "%08x", SWAP32(crc_buffer));
Checksums.setString("CHECKSUMS", gamePath, crc_string);
Checksums.save();
gprintf("Generating CRC32 for %s\n", gamePath);
if(strstr(gameHeader.path, ".zip") == NULL)
{
snprintf(crc_string, sizeof(crc_string), "%08x", crc32file(gameHeader.path));
Checksums.setString("CHECKSUMS", gamePath, crc_string);
Checksums.save();
}
else
{
u32 crc_buffer;
ifstream infile;
infile.open(gameHeader.path, ios::binary);
infile.seekg(0x0e, ios::beg);
infile.read((char*)&crc_buffer, 8);
infile.close();
snprintf(crc_string, sizeof(crc_string), "%08x", SWAP32(crc_buffer));
Checksums.setString("CHECKSUMS", gamePath, crc_string);
Checksums.save();
}
}
url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str());
gprintf("URL: %s\n", url.c_str());