Permalink
Browse files

CFavourites: replace Paramify() implementation with StringUtils::Para…

…mify()
  • Loading branch information...
1 parent 1146ff9 commit a02630c1f2f75cd1350019d922e36b529b289ce8 @Montellese Montellese committed Feb 26, 2013
Showing with 5 additions and 26 deletions.
  1. +5 −21 xbmc/Favourites.cpp
  2. +0 −5 xbmc/Favourites.h
View
@@ -25,6 +25,7 @@
#include "FileItem.h"
#include "utils/XBMCTinyXML.h"
#include "utils/log.h"
+#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "settings/AdvancedSettings.h"
#include "video/VideoInfoTag.h"
@@ -148,37 +149,20 @@ bool CFavourites::IsFavourite(CFileItem *item, int contextWindow)
return items.Contains(GetExecutePath(item, contextWindow));
}
-static CStdString Paramify(const CStdString& param)
-{
- CStdString result(param);
- result.Replace("\\", "\\\\");
- result.Replace("\"", "\\\"");
- return "\"" + result + "\"";
-}
-
-#ifdef UNIT_TESTING
-bool CFavourites::TestParamify()
-{
- return (Paramify("test") == "\"test\"" &&
- Paramify("test\"foo\"test") == "\"test\\\"foo\\\"test\"" &&
- Paramify("C:\\foo\\bar\\") == "\"C:\\\\foo\\\\bar\\\\\"");
-}
-#endif
-
CStdString CFavourites::GetExecutePath(const CFileItem *item, int contextWindow)
{
CStdString execute;
if (item->m_bIsFolder && (g_advancedSettings.m_playlistAsFolders ||
!(item->IsSmartPlayList() || item->IsPlayList())))
- execute.Format("ActivateWindow(%i,%s)", contextWindow, Paramify(item->GetPath()));
+ execute.Format("ActivateWindow(%i,%s)", contextWindow, StringUtils::Paramify(item->GetPath()).c_str());
else if (item->IsScript())
- execute.Format("RunScript(%s)", Paramify(item->GetPath().Mid(9)));
+ execute.Format("RunScript(%s)", StringUtils::Paramify(item->GetPath().Mid(9)).c_str());
else // assume a media file
{
if (item->IsVideoDb() && item->HasVideoInfoTag())
- execute.Format("PlayMedia(%s)", Paramify(item->GetVideoInfoTag()->m_strFileNameAndPath));
+ execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetVideoInfoTag()->m_strFileNameAndPath).c_str());
else
- execute.Format("PlayMedia(%s)", Paramify(item->GetPath()));
+ execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetPath()).c_str());
}
return execute;
}
View
@@ -33,11 +33,6 @@ class CFavourites
static bool AddOrRemove(CFileItem *item, int contextWindow);
static bool Save(const CFileItemList& items);
static bool IsFavourite(CFileItem *item, int contextWindow);
-
-#ifdef UNIT_TESTING
- static bool TestParamify();
-#endif
-
private:
static CStdString GetExecutePath(const CFileItem *item, int contextWindow);
};

0 comments on commit a02630c

Please sign in to comment.