Permalink
Browse files

A patch to support relative playlists.. That means that

the path to be played when a playlist is played is
created by combining the path to the playlist file and
the path written in the playlist.

Ex.
If you have a playlist in smb://server/share/playlist.pls
playlist.pls contains�
Alicia Keys\Songs in a minor.mp3
Alicia Keys\Intro.mp3

Then this patch makes sure that each file will be added
with full path like
smb://server/share/Alicia Keys/Songs in a minor.mp3
smb://server/share/Alicia Keys/Intro.mp3


git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk/XBMC@554 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
1 parent 48a9468 commit b1074a07fd7ff5f48147f1ff1f60fff08cab9f1b yamp committed Jan 17, 2004
Showing with 53 additions and 1 deletion.
  1. +4 −0 xbmc/PlayListB4S.cpp
  2. +12 −0 xbmc/PlayListM3U.cpp
  3. +4 −1 xbmc/PlayListPLS.cpp
  4. +32 −0 xbmc/Util.cpp
  5. +1 −0 xbmc/Util.h
View
@@ -29,6 +29,9 @@ CPlayListB4S::~CPlayListB4S(void)
bool CPlayListB4S::Load(const CStdString& strFileName)
{
+ CStdString strBasePath;
+ CUtil::GetParentPath(strFileName,strBasePath);
+
Clear();
TiXmlDocument xmlDoc;
@@ -66,6 +69,7 @@ bool CPlayListB4S::Load(const CStdString& strFileName)
if (pNodeInfo)
{
CStdString strInfo = pNodeInfo->FirstChild()->Value();
+ CUtil::GetQualifiedFilename(strBasePath,strFileName);
CPlayListItem newItem(strInfo,strFileName,lDuration);
Add(newItem);
}
View
@@ -28,8 +28,10 @@ CPlayListM3U::~CPlayListM3U(void)
bool CPlayListM3U::Load(const CStdString& strFileName)
{
+ CStdString strBasePath;
Clear();
m_strPlayListName=CUtil::GetFileName(strFileName);
+ CUtil::GetParentPath(strFileName,strBasePath);
CFile file;
if (!file.Open(strFileName,false) )
{
@@ -73,6 +75,7 @@ bool CPlayListM3U::Load(const CStdString& strFileName)
{
CStdString strFileName=szLine;
CUtil::RemoveCRLF(strFileName);
+ CUtil::GetQualifiedFilename(strBasePath,strFileName);
CPlayListItem newItem(strInfo,strFileName,lDuration);
Add(newItem);
}
@@ -83,6 +86,15 @@ bool CPlayListM3U::Load(const CStdString& strFileName)
}
}
}
+ else
+ {
+ CStdString strFileName=szLine;
+ CUtil::RemoveCRLF(strFileName);
+ CUtil::GetQualifiedFilename(strBasePath,strFileName);
+ CUtil::GetFileName(
+ CPlayListItem newItem(strFileName, strFileName, 0);
+ Add(newItem);
+ }
}
file.Close();
View
@@ -28,8 +28,10 @@ CPlayListPLS::~CPlayListPLS(void)
bool CPlayListPLS::Load(const CStdString& strFileName)
{
-Clear();
+ CStdString strBasePath;
+ Clear();
m_strPlayListName=CUtil::GetFileName(strFileName);
+ CUtil::GetParentPath(strFileName,strBasePath);
CFile file;
if (!file.Open(strFileName,false) )
{
@@ -86,6 +88,7 @@ Clear();
long lDuration=atol(strDuration.c_str());
lDuration*=1000;
strFilename.Replace("http:","shout:");
+ CUtil::GetQualifiedFilename(strBasePath,strFilename);
CPlayListItem newItem(strInfo,strFilename,lDuration);
Add(newItem);
strFilename="";
View
@@ -112,6 +112,38 @@ bool CUtil::GetParentPath(const CStdString& strPath, CStdString& strParent)
return true;
}
+//Make sure you have a full path in the filename, otherwise adds the base path before.
+void CUtil::GetQualifiedFilename(const CStdString &strBasePath, CStdString &strFilename)
+{
+ CURL plItemUrl(strFilename);
+ CURL plBaseUrl(strBasePath);
+
+ if(plBaseUrl.GetProtocol().length()==0) //Base in local directory
+ {
+ if(plItemUrl.GetProtocol().length()==0 ) //Filename is local or not qualified
+ {
+ if (!( isalpha(strFilename.c_str()[0]) && strFilename.c_str()[1] == ':')) //Filename not fully qualified
+ {
+ if (strFilename.c_str()[0] == '\\')
+ strFilename = strBasePath + strFilename.Replace('/','\\');
+ else
+ strFilename = strBasePath + '\\' + strFilename.Replace('/','\\');
+ }
+ }
+ }
+ else //Base is remote
+ {
+ if(plItemUrl.GetProtocol().length()==0 ) //Filename is local
+ {
+ if (strFilename.c_str()[0] == '/') //Begins with a slash.. not good.. but we try to make the best of it..
+ strFilename = strBasePath + strFilename.Replace('\\','/');
+ else
+ strFilename = strBasePath + '/' + strFilename;
+ }
+ }
+}
+
+
//*********************************************************************************************
void CUtil::LaunchXbe(char* szPath, char* szXbe, char* szParameters)
{
View
@@ -17,6 +17,7 @@ class CUtil
static bool IsShortCut(const CStdString& strFileName);
static int cmpnocase(const char* str1,const char* str2);
static bool GetParentPath(const CStdString& strPath, CStdString& strParent);
+ static void GetQualifiedFilename(const CStdString &strBasePath, CStdString &strFilename);
static void LaunchXbe(char* szPath, char* szXbe, char* szParameters);
static bool FileExists(const CStdString& strFileName);
static void GetThumbnail(const CStdString& strFileName, CStdString& strThumb);

0 comments on commit b1074a0

Please sign in to comment.