[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / filesystem / MultiPathFile.cpp
blob1f1bf96c867623b63defa4bc1a2eb589f9fcbeae
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "MultiPathFile.h"
11 #include "MultiPathDirectory.h"
12 #include "URL.h"
13 #include "utils/URIUtils.h"
15 using namespace XFILE;
17 CMultiPathFile::CMultiPathFile(void)
18 : COverrideFile(false)
19 { }
21 CMultiPathFile::~CMultiPathFile(void) = default;
23 bool CMultiPathFile::Open(const CURL& url)
25 // grab the filename off the url
26 std::string path, fileName;
27 URIUtils::Split(url.Get(), path, fileName);
28 std::vector<std::string> vecPaths;
29 if (!CMultiPathDirectory::GetPaths(path, vecPaths))
30 return false;
32 for (unsigned int i = 0; i < vecPaths.size(); i++)
34 std::string filePath = vecPaths[i];
35 filePath = URIUtils::AddFileToFolder(filePath, fileName);
36 if (m_file.Open(filePath))
37 return true;
39 return false;
42 bool CMultiPathFile::Exists(const CURL& url)
44 // grab the filename off the url
45 std::string path, fileName;
46 URIUtils::Split(url.Get(), path, fileName);
47 std::vector<std::string> vecPaths;
48 if (!CMultiPathDirectory::GetPaths(path, vecPaths))
49 return false;
51 for (unsigned int i = 0; i < vecPaths.size(); i++)
53 std::string filePath = vecPaths[i];
54 filePath = URIUtils::AddFileToFolder(filePath, fileName);
55 if (CFile::Exists(filePath))
56 return true;
58 return false;
61 int CMultiPathFile::Stat(const CURL& url, struct __stat64* buffer)
63 // grab the filename off the url
64 std::string path, fileName;
65 URIUtils::Split(url.Get(), path, fileName);
66 std::vector<std::string> vecPaths;
67 if (!CMultiPathDirectory::GetPaths(path, vecPaths))
68 return false;
70 for (unsigned int i = 0; i < vecPaths.size(); i++)
72 std::string filePath = vecPaths[i];
73 filePath = URIUtils::AddFileToFolder(filePath, fileName);
74 int ret = CFile::Stat(filePath, buffer);
75 if (ret == 0)
76 return ret;
78 return -1;
81 std::string CMultiPathFile::TranslatePath(const CURL& url)
83 return url.Get();