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 #pragma once
10 
11 #include "IDirectory.h"
12 #include "MediaSource.h"
13 
14 #include <memory>
15 #include <string>
16 
17 namespace XFILE
18 {
19 
20   /*!
21   \ingroup windows
22   \brief Get access to shares and it's directories.
23   */
24   class CVirtualDirectory : public IDirectory
25   {
26   public:
27     CVirtualDirectory(void);
28     ~CVirtualDirectory(void) override;
29     bool GetDirectory(const CURL& url, CFileItemList &items) override;
30     void CancelDirectory() override;
31     bool GetDirectory(const CURL& url, CFileItemList &items, bool bUseFileDirectories, bool keepImpl);
32     void SetSources(const VECSOURCES& vecSources);
GetNumberOfSources()33     inline unsigned int GetNumberOfSources()
34     {
35       return static_cast<uint32_t>(m_vecSources.size());
36     }
37 
38     bool IsSource(const std::string& strPath, VECSOURCES *sources = NULL, std::string *name = NULL) const;
39     bool IsInSource(const std::string& strPath) const;
40 
41     inline const CMediaSource& operator [](const int index) const
42     {
43       return m_vecSources[index];
44     }
45 
46     inline CMediaSource& operator[](const int index)
47     {
48       return m_vecSources[index];
49     }
50 
51     void GetSources(VECSOURCES &sources) const;
52 
AllowNonLocalSources(bool allow)53     void AllowNonLocalSources(bool allow) { m_allowNonLocalSources = allow; };
54 
GetDirImpl()55     std::shared_ptr<IDirectory> GetDirImpl() { return m_pDir; }
ReleaseDirImpl()56     void ReleaseDirImpl() { m_pDir.reset(); }
57 
58   protected:
59     void CacheThumbs(CFileItemList &items);
60 
61     VECSOURCES m_vecSources;
62     bool m_allowNonLocalSources;
63     std::shared_ptr<IDirectory> m_pDir;
64   };
65 }
66