fixed: Handling setting of video files basepath causing eg. video information not...
authorarnova <arnova@void.org>
Sun, 4 Sep 2011 15:21:37 +0000 (17:21 +0200)
committerarnova <arnova@void.org>
Sun, 4 Sep 2011 15:21:37 +0000 (17:21 +0200)
xbmc/FileItem.cpp
xbmc/FileItem.h

index 38d0194..7aa77d2 100644 (file)
@@ -2684,6 +2684,9 @@ CStdString CFileItem::GetMovieName(bool bUseFolderNames /* = false */) const
 
   CStdString strMovieName = GetBaseMoviePath(bUseFolderNames);
 
+  if (URIUtils::IsStack(strMovieName))
+    strMovieName = CStackDirectory::GetStackedTitlePath(strMovieName);
+
   URIUtils::RemoveSlashAtEnd(strMovieName);
   strMovieName = URIUtils::GetFileName(strMovieName);
   CURL::Decode(strMovieName);
@@ -2698,9 +2701,6 @@ CStdString CFileItem::GetBaseMoviePath(bool bUseFolderNames) const
   if (IsMultiPath())
     strMovieName = CMultiPathDirectory::GetFirstPath(m_strPath);
 
-  if (URIUtils::IsStack(strMovieName))
-    strMovieName = CStackDirectory::GetStackedTitlePath(strMovieName);
-
   int pos;
   if ((pos=strMovieName.Find("BDMV/")) != -1 ||
       (pos=strMovieName.Find("BDMV\\")) != -1)
@@ -2721,6 +2721,47 @@ CStdString CFileItem::GetBaseMoviePath(bool bUseFolderNames) const
   return strMovieName;
 }
 
+#ifdef UNIT_TESTING
+bool CFileItem::testGetBaseMoviePath()
+{
+  CFileItem item;
+  CStdString path;
+  bool result = true;
+  
+  item.SetPath("c:\\dir\\filename.avi");
+  path = item.GetBaseMoviePath(false);
+  if (path != "c:\\dir\\filename.avi")
+    result = false;
+
+  item.SetPath("ftp://somepath/file.avi");
+  path = item.GetBaseMoviePath(false);
+  if (path != "ftp://somepath/file.avi")
+    result = false;
+  
+  item.SetPath("stack:///path/to/movie_name/cd1/some_file1.avi , /path/to/movie_name/cd2/some_file2.avi");
+  path = item.GetBaseMoviePath(false);
+  if (path != "stack:///path/to/movie_name/cd1/some_file1.avi , /path/to/movie_name/cd2/some_file2.avi")
+    result = false;
+
+  item.SetPath("stack:///path/to/movie_name/cd1/some_file1.avi , /path/to/movie_name/cd2/some_file2.avi");
+  path = item.GetBaseMoviePath(true);
+  if (path != "/path/to/movie_name/")
+    result = false;
+
+  item.SetPath("/home/user/TV Shows/Dexter/S1/1x01.avi");
+  path = item.GetBaseMoviePath(true);
+  if (path != "/home/user/TV Shows/Dexter/S1/")
+    result = false;
+  
+  item.SetPath("rar://g%3a%5cmultimedia%5cmovies%5cSphere%2erar/Sphere.avi");
+  path = item.GetBaseMoviePath(true);
+  if (path != "g:\\multimedia\\movies\\")
+    result = false;
+
+  return result;
+}
+#endif
+
 void CFileItem::SetVideoThumb()
 {
   if (HasThumbnail()) return;
index 99e4e4c..6c1bffe 100644 (file)
@@ -244,6 +244,10 @@ public:
    */
   CStdString GetBaseMoviePath(bool useFolderNames) const;
 
+#ifdef UNIT_TESTING
+  static bool testGetBaseMoviePath();
+#endif
+
   // Gets the user thumb, if it exists
   CStdString GetUserVideoThumb() const;
   CStdString GetUserMusicThumb(bool alwaysCheckRemote = false) const;