Merge pull request #4630 from Red-F/gotham-resume-pvr-lastplayedposition
[vuplus_xbmc] / xbmc / Util.cpp
index 8b1b919..f614f17 100644 (file)
@@ -230,7 +230,7 @@ CStdString CUtil::GetTitleFromPath(const CStdString& strFileNameAndPath, bool bI
   }
   
   // URLDecode since the original path may be an URL
-  CURL::Decode(strFilename);
+  strFilename = CURL::Decode(strFilename);
   return strFilename;
 }
 
@@ -243,8 +243,8 @@ void CUtil::CleanString(const CStdString& strFileName, CStdString& strTitle, CSt
 
   const CStdStringArray &regexps = g_advancedSettings.m_videoCleanStringRegExps;
 
-  CRegExp reTags(true, true);
-  CRegExp reYear(false, true);
+  CRegExp reTags(true, CRegExp::autoUtf8);
+  CRegExp reYear(false, CRegExp::autoUtf8);
 
   if (!reYear.RegComp(g_advancedSettings.m_videoCleanDateTimeRegExp))
   {
@@ -519,7 +519,7 @@ bool CUtil::ExcludeFileOrFolder(const CStdString& strFileOrFolder, const CStdStr
   if (strFileOrFolder.empty())
     return false;
 
-  CRegExp regExExcludes(true, true);  // case insensitive regex
+  CRegExp regExExcludes(true, CRegExp::autoUtf8);  // case insensitive regex
 
   for (unsigned int i = 0; i < regexps.size(); i++)
   {
@@ -1154,6 +1154,9 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES,
   // Check for special protocols
   CURL checkURL(strPath);
 
+  if (StringUtils::StartsWith(strPath, "special://skin/"))
+    return 1;
+
   // stack://
   if (checkURL.GetProtocol() == "stack")
     strPath.erase(0, 8); // remove the stack protocol
@@ -1186,7 +1189,7 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES,
       // since we add the drive status and disc name to the source
       // "Name (Drive Status/Disc Name)"
       size_t iPos = strName.rfind('(');
-      if (iPos > 1)
+      if (iPos != std::string::npos && iPos > 1)
         strName = strName.substr(0, iPos - 1);
     }
     if (strPath.Equals(strName))
@@ -1207,7 +1210,7 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES,
   if (!URIUtils::HasSlashAtEnd(strDest))
     strDest += "/";
 
-  size_t iLength = std::string::npos;
+  size_t iLength = 0;
   size_t iLenPath = strDest.size();
   for (int i = 0; i < (int)VECSOURCES.size(); ++i)
   {
@@ -1393,7 +1396,7 @@ void CUtil::GetRecursiveDirsListing(const CStdString& strPath, CFileItemList& it
 void CUtil::ForceForwardSlashes(CStdString& strPath)
 {
   size_t iPos = strPath.rfind('\\');
-  while (iPos > 0)
+  while (iPos != string::npos)
   {
     strPath.at(iPos) = '/';
     iPos = strPath.rfind('\\');
@@ -2154,26 +2157,26 @@ void CUtil::GetExternalStreamDetailsFromFilename(const CStdString& strVideo, con
           continue;
         }
       }
-      if (info.flag == 0x1111)
+
+      // try to recognize a flag
+      std::string flag_tmp(*it);
+      StringUtils::ToLower(flag_tmp);
+      if (!flag_tmp.compare("none"))
       {
-        std::string  flag_tmp(*it);
-        StringUtils::ToLower(flag_tmp);
-        if (!flag_tmp.compare("none"))
-        {
-          info.flag = CDemuxStream::FLAG_NONE;
-          continue;
-        }
-        else if (!flag_tmp.compare("default"))
-        {
-          info.flag = CDemuxStream::FLAG_DEFAULT;
-          continue;
-        }
-        else if (!flag_tmp.compare("forced"))
-        {
-          info.flag = CDemuxStream::FLAG_FORCED;
-          continue;
-        }
+        info.flag |= CDemuxStream::FLAG_NONE;
+        continue;
+      }
+      else if (!flag_tmp.compare("default"))
+      {
+        info.flag |= CDemuxStream::FLAG_DEFAULT;
+        continue;
       }
+      else if (!flag_tmp.compare("forced"))
+      {
+        info.flag |= CDemuxStream::FLAG_FORCED;
+        continue;
+      }
+
       name += " " + (*it);
     }
   }
@@ -2181,7 +2184,7 @@ void CUtil::GetExternalStreamDetailsFromFilename(const CStdString& strVideo, con
   name += g_localizeStrings.Get(21602); // External
   StringUtils::Trim(name);
   info.name = StringUtils::RemoveDuplicatedSpacesAndTabs(name);
-  if (info.flag == 0x1111)
+  if (info.flag == 0)
     info.flag = CDemuxStream::FLAG_NONE;
 
   CLog::Log(LOGDEBUG, "%s - Language = '%s' / Name = '%s' / Flag = '%u' from %s", __FUNCTION__, info.language.c_str(), info.name.c_str(), info.flag, strStream.c_str());
@@ -2202,7 +2205,7 @@ bool CUtil::FindVobSubPair( const std::vector<CStdString>& vecSubtitles, const C
       CStdString strSubDirectory;
       URIUtils::Split(vecSubtitles[j], strSubDirectory, strSubFile);
       if (URIUtils::IsInArchive(vecSubtitles[j]))
-        CURL::Decode(strSubDirectory);
+        strSubDirectory = CURL::Decode(strSubDirectory);
       if (URIUtils::HasExtension(strSubFile, ".sub") &&
           (URIUtils::ReplaceExtension(strIdxFile,"").Equals(URIUtils::ReplaceExtension(strSubFile,"")) ||
            (strSubDirectory.size() >= 11 &&
@@ -2226,7 +2229,7 @@ bool CUtil::IsVobSub( const std::vector<CStdString>& vecSubtitles, const CStdStr
     CStdString strSubDirectory;
     URIUtils::Split(strSubPath, strSubDirectory, strSubFile);
     if (URIUtils::IsInArchive(strSubPath))
-      CURL::Decode(strSubDirectory);
+      strSubDirectory = CURL::Decode(strSubDirectory);
     for (unsigned int j=0; j < vecSubtitles.size(); j++)
     {
       CStdString strIdxFile;