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.
9 #include "MultiPathFile.h"
11 #include "MultiPathDirectory.h"
13 #include "utils/URIUtils.h"
15 using namespace XFILE
;
17 CMultiPathFile::CMultiPathFile(void)
18 : COverrideFile(false)
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
))
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
))
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
))
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
))
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
))
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
);
81 std::string
CMultiPathFile::TranslatePath(const CURL
& url
)