[cstdstring] demise Format, replacing with StringUtils::Format
[vuplus_xbmc] / xbmc / filesystem / MusicFileDirectory.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "MusicFileDirectory.h"
22 #include "FileItem.h"
23 #include "guilib/LocalizeStrings.h"
24 #include "utils/URIUtils.h"
25 #include "utils/StringUtils.h"
26
27 using namespace MUSIC_INFO;
28 using namespace XFILE;
29
30 CMusicFileDirectory::CMusicFileDirectory(void)
31 {
32 }
33
34 CMusicFileDirectory::~CMusicFileDirectory(void)
35 {
36 }
37
38 bool CMusicFileDirectory::GetDirectory(const CStdString& strPath1, CFileItemList &items)
39 {
40   CStdString strPath=strPath1;
41
42   CStdString strFileName;
43   strFileName = URIUtils::GetFileName(strPath);
44   URIUtils::RemoveExtension(strFileName);
45
46   int iStreams = GetTrackCount(strPath1);
47
48   URIUtils::AddSlashAtEnd(strPath);
49
50   for (int i=0; i<iStreams; ++i)
51   {
52     CStdString strLabel = StringUtils::Format("%s - %s %02.2i", strFileName.c_str(), g_localizeStrings.Get(554).c_str(), i+1);
53     CFileItemPtr pItem(new CFileItem(strLabel));
54     strLabel = StringUtils::Format("%s%s-%i.%s", strPath.c_str(), strFileName.c_str(), i+1, m_strExt.c_str());
55     pItem->SetPath(strLabel);
56
57     if (m_tag.Loaded())
58       *pItem->GetMusicInfoTag() = m_tag;
59
60     pItem->GetMusicInfoTag()->SetTrackNumber(i+1);
61     items.Add(pItem);
62   }
63
64   return true;
65 }
66
67 bool CMusicFileDirectory::Exists(const char* strPath)
68 {
69   return true;
70 }
71
72 bool CMusicFileDirectory::ContainsFiles(const CStdString& strPath)
73 {
74   if (GetTrackCount(strPath) > 1)
75     return true;
76
77   return false;
78 }