strPath.Replace('/', '\\');
#endif
//g_charsetConverter.unknownToUTF8(strPath);
-
+ CStdString strCachedPath;
+ CUtil::AddFileToFolder(strDir + "rarfolder%04d", CUtil::GetFileName(strPathInRar), strCachedPath);
+ strCachedPath = CUtil::GetNextPathname(strCachedPath, 9999);
+ if (strCachedPath.IsEmpty())
+ {
+ CLog::Log(LOGWARNING, "Could not cache file %s", (strRarPath + strPathInRar).c_str());
+ return false;
+ }
+ strCachedPath = CUtil::MakeLegalPath(strCachedPath);
+ CStdString strCachedDir;
+ CUtil::GetDirectory(strCachedPath, strCachedDir);
int64_t iOffset = -1;
if (iRes != 2)
{
if (iSize > 1024*1024 || iSize == -2) // 1MB
bShowProgress=true;
- CStdString strDir2(strDir);
+ CStdString strDir2(strCachedDir);
CUtil::RemoveSlashAtEnd(strDir2);
+ if (!CDirectory::Exists(strDir2))
+ CDirectory::Create(strDir2);
iRes = urarlib_get(const_cast<char*>(strRarPath.c_str()), const_cast<char*>(strDir2.c_str()),
const_cast<char*>(strPath.c_str()),NULL,&iOffset,bShowProgress);
}
pFile = &(j->second.second[j->second.second.size()-1]);
pFile->m_iUsed = 1;
}
- CUtil::AddFileToFolder(strDir,CUtil::GetFileName(strPathInRar),pFile->m_strCachedPath); // GetFileName
- pFile->m_strCachedPath = CUtil::MakeLegalPath(pFile->m_strCachedPath);
+ pFile->m_strCachedPath = strCachedPath;
pFile->m_bAutoDel = (bOptions & EXFILE_AUTODELETE) != 0;
pFile->m_iOffset = iOffset;
strPathInCache = pFile->m_strCachedPath;
return "";
}
+CStdString CUtil::GetNextPathname(const CStdString &path_template, int max)
+{
+ if (!path_template.Find("%04d"))
+ return "";
+
+ for (int i = 0; i <= max; i++)
+ {
+ CStdString name;
+ name.Format(path_template.c_str(), i);
+ if (!CFile::Exists(name))
+ return name;
+ }
+ return "";
+}
+
void CUtil::Tokenize(const CStdString& path, vector<CStdString>& tokens, const string& delimiters)
{
// Tokenize ripped from http://www.linuxselfhelp.com/HOWTO/C++Programming-HOWTO-7.html
static void ThumbCacheClear();
static void PlayDVD(const CStdString& strProtocol="dvd");
static CStdString GetNextFilename(const CStdString &fn_template, int max);
+ static CStdString GetNextPathname(const CStdString &path_template, int max);
static void TakeScreenshot();
static void TakeScreenshot(const CStdString &filename, bool sync);
static void Tokenize(const CStdString& path, std::vector<CStdString>& tokens, const std::string& delimiters);