fixed: Some skin folders weren't ignored by the texture cache.
authorjmarshallnz <jmarshallnz@svn>
Thu, 30 Sep 2010 23:04:48 +0000 (23:04 +0000)
committerjmarshallnz <jmarshallnz@svn>
Thu, 30 Sep 2010 23:04:48 +0000 (23:04 +0000)
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@34347 568bbfeb-2a22-0410-94d2-cc84cf5bfa90

xbmc/TextureCache.cpp
xbmc/URIUtils.cpp
xbmc/URIUtils.h

index ede0898..d4a79b2 100644 (file)
@@ -32,7 +32,7 @@
 #include "DDSImage.h"
 #include "Picture.h"
 #include "TextureManager.h"
-#include "SpecialProtocol.h"
+#include "URIUtils.h"
 
 using namespace XFILE;
 
@@ -150,19 +150,11 @@ void CTextureCache::Deinitialize()
 
 bool CTextureCache::IsCachedImage(const CStdString &url) const
 {
-  if (0 == strncmp(url.c_str(), "special://skin/", 15)) // a skin image
-    return true;
   if (url != "-" && !CURL::IsFullPath(url))
     return true;
-  CStdString basePath(g_settings.GetThumbnailsFolder());
-  if (0 == strncmp(url.c_str(), basePath.c_str(), basePath.GetLength()))
+  if (CURIUtils::IsInPath(url, "special://skin/") ||
+      CURIUtils::IsInPath(url, g_settings.GetThumbnailsFolder()))
     return true;
-  if (basePath.Left(8).Equals("special:"))
-  {
-    basePath = CSpecialProtocol::TranslatePath(basePath);
-    if (0 == strncmp(url.c_str(), basePath.c_str(), basePath.GetLength()))
-      return true;
-  }
   return false;
 }
 
@@ -190,7 +182,7 @@ CStdString CTextureCache::CheckAndCacheImage(const CStdString &url, bool returnD
   CStdString path(GetCachedImage(url));
   if (!path.IsEmpty())
   {
-    if (returnDDS && 0 != strncmp(url.c_str(), "special://skin/", 15)) // TODO: should skin images be .dds'd (currently they're not necessarily writeable)
+    if (returnDDS && !CURIUtils::IsInPath(url, "special://skin/")) // TODO: should skin images be .dds'd (currently they're not necessarily writeable)
     { // check for dds version
       CStdString ddsPath = CUtil::ReplaceExtension(path, ".dds");
       if (CFile::Exists(ddsPath))
index 31a3f46..39afa88 100644 (file)
@@ -21,6 +21,7 @@
 #include "system.h"\r
 #include "Util.h"\r
 #include "URIUtils.h"\r
+#include "SpecialProtocol.h"
 \r
 CStdString CURIUtils::GetParentFolderURI(const CStdString& uri, bool preserveFileNameInPath)\r
 {\r
@@ -29,3 +30,10 @@ CStdString CURIUtils::GetParentFolderURI(const CStdString& uri, bool preserveFil
   else\r
     return CUtil::GetParentPath(uri);\r
 }\r
+\r
+bool CURIUtils::IsInPath(const CStdString &uri, const CStdString &baseURI)\r
+{\r
+  CStdString uriPath = CSpecialProtocol::TranslatePath(uri);\r
+  CStdString basePath = CSpecialProtocol::TranslatePath(baseURI);\r
+  return (strncmp(uriPath.c_str(), basePath.c_str(), basePath.GetLength()) == 0);\r
+}\r
index eed4db8..c1adcc5 100644 (file)
@@ -26,4 +26,5 @@ public:
   CURIUtils(void);\r
   virtual ~CURIUtils(void);\r
   static CStdString GetParentFolderURI(const CStdString& uri, bool preserveFileNameInPath);\r
+  static bool IsInPath(const CStdString &uri, const CStdString &baseURI);\r
 };\r