kodi
VirtualDirectory.h
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 
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);
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 
53  void AllowNonLocalSources(bool allow) { m_allowNonLocalSources = allow; }
54 
55  std::shared_ptr<IDirectory> GetDirImpl() { return m_pDir; }
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 }
void SetSources(const VECSOURCES &vecSources)
Add shares to the virtual directory.
Definition: VirtualDirectory.cpp:40
Interface to the directory on a file system.
Definition: IDirectory.h:51
Definition: Scraper.h:41
Represents a list of files.
Definition: FileItem.h:702
Definition: URL.h:21
Represents a share.
Definition: MediaSource.h:22
bool IsInSource(const std::string &strPath) const
Is the share path in the virtual directory.
Definition: VirtualDirectory.cpp:143
Get access to shares and it&#39;s directories.
Definition: VirtualDirectory.h:24
bool GetDirectory(const CURL &url, CFileItemList &items) override
Retrieve the shares or the content of a directory.
Definition: VirtualDirectory.cpp:54
void CancelDirectory() override
Cancel the current directory fetch (if possible).
Definition: VirtualDirectory.cpp:90
bool IsSource(const std::string &strPath, VECSOURCES *sources=NULL, std::string *name=NULL) const
Is the share strPath in the virtual directory.
Definition: VirtualDirectory.cpp:103