CFile::Delete(path);
}
+bool CTextureCache::ClearCachedImage(int id)
+{
+ CStdString cachedFile;
+ if (ClearCachedTexture(id, cachedFile))
+ {
+ cachedFile = GetCachedPath(cachedFile);
+ if (CFile::Exists(cachedFile))
+ CFile::Delete(cachedFile);
+ cachedFile = URIUtils::ReplaceExtension(cachedFile, ".dds");
+ if (CFile::Exists(cachedFile))
+ CFile::Delete(cachedFile);
+ return true;
+ }
+ return false;
+}
+
bool CTextureCache::GetCachedTexture(const CStdString &url, CTextureDetails &details)
{
CSingleLock lock(m_databaseSection);
return m_database.ClearCachedTexture(url, cachedURL);
}
+bool CTextureCache::ClearCachedTexture(int id, CStdString &cachedURL)
+{
+ CSingleLock lock(m_databaseSection);
+ return m_database.ClearCachedTexture(id, cachedURL);
+}
+
CStdString CTextureCache::GetCacheFile(const CStdString &url)
{
Crc32 crc;
*/
void ClearCachedImage(const CStdString &image, bool deleteSource = false);
+ /*! \brief clear the cached version of the image with given id
+ \param database id of the image
+ \sa GetCachedImage
+ */
+ bool ClearCachedImage(int textureID);
+
/*! \brief retrieve a cache file (relative to the cache path) to associate with the given image, excluding extension
Use GetCachedPath(GetCacheFile(url)+extension) for the full path to the file.
\param url location of the image
\return true if we had a cached version of this image, false otherwise.
*/
bool ClearCachedTexture(const CStdString &url, CStdString &cacheFile);
+ bool ClearCachedTexture(int textureID, CStdString &cacheFile);
/*! \brief Increment the use count of a texture
Stores locally before calling CTextureDatabase::IncrementUseCount via a CUseCountJob
bool CTextureDatabase::ClearCachedTexture(const CStdString &url, CStdString &cacheFile)
{
+ std::string id = GetSingleValue(PrepareSQL("select id from texture where url='%s'", url.c_str()));
+ return !id.empty() ? ClearCachedTexture(strtol(id.c_str(), NULL, 10), cacheFile) : false;
+}
+
+bool CTextureDatabase::ClearCachedTexture(int id, CStdString &cacheFile)
+{
try
{
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
- CStdString sql = PrepareSQL("select id, cachedurl from texture where url='%s'", url.c_str());
+ CStdString sql = PrepareSQL("select cachedurl from texture where id=%u", id);
m_pDS->query(sql.c_str());
if (!m_pDS->eof())
{ // have some information
- int textureID = m_pDS->fv(0).get_asInt();
- cacheFile = m_pDS->fv(1).get_asString();
+ cacheFile = m_pDS->fv(0).get_asString();
m_pDS->close();
// remove it
- sql = PrepareSQL("delete from texture where id=%u", textureID);
+ sql = PrepareSQL("delete from texture where id=%u", id);
m_pDS->exec(sql.c_str());
return true;
}
}
catch (...)
{
- CLog::Log(LOGERROR, "%s, failed on url '%s'", __FUNCTION__, url.c_str());
+ CLog::Log(LOGERROR, "%s, failed on texture id %u", __FUNCTION__, id);
}
return false;
}
bool AddCachedTexture(const CStdString &originalURL, const CTextureDetails &details);
bool SetCachedTextureValid(const CStdString &originalURL, bool updateable);
bool ClearCachedTexture(const CStdString &originalURL, CStdString &cacheFile);
+ bool ClearCachedTexture(int textureID, CStdString &cacheFile);
bool IncrementUseCount(const CTextureDetails &details);
/*! \brief Invalidate a previously cached texture