Permalink
Browse files

Merge pull request #3560 from arnova/path_subst_getdir_fix

fixed: Path substitution didn't work for files (only library items)
  • Loading branch information...
jmarshallnz committed Nov 7, 2013
2 parents 46c8e7d + d88e5dd commit 813525bc627079c37f5cbea19b71baea27e597b4
Showing with 36 additions and 12 deletions.
  1. +16 −5 xbmc/filesystem/Directory.cpp
  2. +19 −6 xbmc/utils/URIUtils.cpp
  3. +1 −1 xbmc/utils/URIUtils.h
@@ -46,10 +46,11 @@ class CGetDirectory
struct CResult
{
- CResult(const CStdString& dir) : m_event(true), m_dir(dir), m_result(false) {}
+ CResult(const CStdString& dir, const CStdString& listDir) : m_event(true), m_dir(dir), m_listDir(listDir), m_result(false) {}
CEvent m_event;
CFileItemList m_list;
CStdString m_dir;
+ CStdString m_listDir;
bool m_result;
};
@@ -64,7 +65,7 @@ class CGetDirectory
public:
virtual bool DoWork()
{
- m_result->m_list.SetPath(m_result->m_dir);
+ m_result->m_list.SetPath(m_result->m_listDir);
m_result->m_result = m_imp->GetDirectory(m_result->m_dir, m_result->m_list);
m_result->m_event.Set();
return m_result->m_result;
@@ -76,8 +77,8 @@ class CGetDirectory
public:
- CGetDirectory(boost::shared_ptr<IDirectory>& imp, const CStdString& dir)
- : m_result(new CResult(dir))
+ CGetDirectory(boost::shared_ptr<IDirectory>& imp, const CStdString& dir, const CStdString& listDir)
+ : m_result(new CResult(dir, listDir))
{
m_id = CJobManager::GetInstance().AddJob(new CGetJob(imp, m_result)
, NULL
@@ -152,7 +153,7 @@ bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, c
{
CSingleExit ex(g_graphicsContext);
- CGetDirectory get(pDirectory, realPath);
+ CGetDirectory get(pDirectory, realPath, strPath);
if(!get.Wait(TIME_TO_BUSY_DIALOG))
{
CGUIDialogBusy* dialog = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY);
@@ -222,6 +223,16 @@ bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, c
if (!(hints.flags & DIR_FLAG_NO_FILE_DIRS) && !items.IsMusicDb() && !items.IsVideoDb() && !items.IsSmartPlayList())
FilterFileDirectories(items, hints.mask);
+ // Correct items for path substitution
+ if (strPath != realPath)
+ {
+ for (int i = 0; i < items.Size(); ++i)
+ {
+ CFileItemPtr item = items[i];
+ item->SetPath(URIUtils::SubstitutePath(item->GetPath(), true));
+ }
+ }
+
return true;
}
XBMCCOMMONS_HANDLE_UNCHECKED
View
@@ -405,17 +405,30 @@ bool URIUtils::GetParentPath(const CStdString& strPath, CStdString& strParent)
return true;
}
-CStdString URIUtils::SubstitutePath(const CStdString& strPath)
+CStdString URIUtils::SubstitutePath(const CStdString& strPath, bool reverse /* = false */)
{
for (CAdvancedSettings::StringMapping::iterator i = g_advancedSettings.m_pathSubstitutions.begin();
i != g_advancedSettings.m_pathSubstitutions.end(); i++)
{
- if (strncmp(strPath.c_str(), i->first.c_str(), HasSlashAtEnd(i->first.c_str()) ? i->first.size()-1 : i->first.size()) == 0)
+ if (!reverse)
{
- if (strPath.size() > i->first.size())
- return URIUtils::AddFileToFolder(i->second, strPath.Mid(i->first.size()));
- else
- return i->second;
+ if (strncmp(strPath.c_str(), i->first.c_str(), HasSlashAtEnd(i->first.c_str()) ? i->first.size()-1 : i->first.size()) == 0)
+ {
+ if (strPath.size() > i->first.size())
+ return URIUtils::AddFileToFolder(i->second, strPath.Mid(i->first.size()));
+ else
+ return i->second;
+ }
+ }
+ else
+ {
+ if (strncmp(strPath.c_str(), i->second.c_str(), HasSlashAtEnd(i->second.c_str()) ? i->second.size()-1 : i->second.size()) == 0)
+ {
+ if (strPath.size() > i->second.size())
+ return URIUtils::AddFileToFolder(i->first, strPath.Mid(i->second.size()));
+ else
+ return i->second;
+ }
}
}
return strPath;
View
@@ -68,7 +68,7 @@ class URIUtils
static void GetCommonPath(CStdString& strPath, const CStdString& strPath2);
static CStdString GetParentPath(const CStdString& strPath);
static bool GetParentPath(const CStdString& strPath, CStdString& strParent);
- static CStdString SubstitutePath(const CStdString& strPath);
+ static CStdString SubstitutePath(const CStdString& strPath, bool reverse = false);
static bool IsAddonsPath(const CStdString& strFile);
static bool IsSourcesPath(const CStdString& strFile);

0 comments on commit 813525b

Please sign in to comment.