Debian Codegraph @

xbmc/playlists/PlayListURL.cpp

raw
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #include "PlayListURL.h"
10
11 #include "FileItem.h"
12 #include "filesystem/File.h"
13 #include "utils/StringUtils.h"
14 #include "utils/URIUtils.h"
15
16 using namespace PLAYLIST;
17 using namespace XFILE;
18
19 // example url file
20 //[DEFAULT]
21 //BASEURL=http://msdn2.microsoft.com/en-us/library/ms812698.aspx
22 //[InternetShortcut]
23 //URL=http://msdn2.microsoft.com/en-us/library/ms812698.aspx
24
25 CPlayListURL::CPlayListURL(void) = default;
26
27 CPlayListURL::~CPlayListURL(void) = default;
28
29 bool CPlayListURL::Load(const std::string& strFileName)
30 {
31 char szLine[4096];
32 std::string strLine;
33
34 Clear();
35
36 m_strPlayListName = URIUtils::GetFileName(strFileName);
37 URIUtils::GetParentPath(strFileName, m_strBasePath);
38
39 CFile file;
40 if (!file.Open(strFileName) )
41 {
42 file.Close();
43 return false;
44 }
45
46 while (file.ReadString(szLine, 1024))
47 {
48 strLine = szLine;
49 StringUtils::RemoveCRLF(strLine);
50
51 if (StringUtils::StartsWith(strLine, "[InternetShortcut]"))
52 {
53 if (file.ReadString(szLine,1024))
54 {
55 strLine = szLine;
56 StringUtils::RemoveCRLF(strLine);
57 if (StringUtils::StartsWith(strLine, "URL="))
58 {
59 CFileItemPtr newItem(new CFileItem(strLine.substr(4), false));
60 Add(newItem);
61 }
62 }
63 }
64 }
65
66 file.Close();
67 return true;
68 }
69