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.
11 #include "IDirectory.h"
23 \brief Wrappers for \e IDirectory
29 virtual ~CDirectory(void);
35 int flags
= DIR_FLAG_DEFAULTS
;
38 static bool GetDirectory(const CURL
& url
39 , CFileItemList
&items
40 , const std::string
&strMask
43 static bool GetDirectory(const CURL
& url
,
44 const std::shared_ptr
<IDirectory
>& pDirectory
,
48 static bool GetDirectory(const CURL
& url
49 , CFileItemList
&items
50 , const CHints
&hints
);
52 static bool Create(const CURL
& url
);
53 static bool Exists(const CURL
& url
, bool bUseCache
= true);
54 static bool Remove(const CURL
& url
);
55 static bool RemoveRecursive(const CURL
& url
);
57 static bool GetDirectory(const std::string
& strPath
58 , CFileItemList
&items
59 , const std::string
&strMask
62 static bool GetDirectory(const std::string
& strPath
,
63 const std::shared_ptr
<IDirectory
>& pDirectory
,
65 const std::string
& strMask
,
68 static bool GetDirectory(const std::string
& strPath
69 , CFileItemList
&items
70 , const CHints
&hints
);
72 using DirectoryEnumerationCallback
= std::function
<void(const std::shared_ptr
<CFileItem
>& item
)>;
73 using DirectoryFilter
= std::function
<bool(const std::shared_ptr
<CFileItem
>& folder
)>;
76 * \brief Enumerates files and folders in and below a directory. Every applicable gets passed to the callback.
78 * \param path Directory to enumerate
79 * \param callback Files and folders matching the criteria are passed to this function
80 * \param filter Only folders are passed to this function. If it return false the folder and everything below it will skipped from the enumeration
81 * \param fileOnly If true only files are passed to \p callback. Doesn't affect \p filter
82 * \param mask Only files matching this mask are passed to \p callback
83 * \param flags See \ref DIR_FLAG enum
85 static bool EnumerateDirectory(
86 const std::string
& path
,
87 const DirectoryEnumerationCallback
& callback
,
88 const DirectoryFilter
& filter
= [](const std::shared_ptr
<CFileItem
>&) { return true; },
89 bool fileOnly
= false,
90 const std::string
& mask
= "",
91 int flags
= DIR_FLAG_DEFAULTS
);
93 static bool Create(const std::string
& strPath
);
94 static bool Exists(const std::string
& strPath
, bool bUseCache
= true);
95 static bool Remove(const std::string
& strPath
);
96 static bool RemoveRecursive(const std::string
& strPath
);
98 /*! \brief Filter files that act like directories from the list, replacing them with their directory counterparts
99 \param items The item list to filter
100 \param mask The mask to apply when filtering files
101 \param expandImages True to include disc images in file directory expansion
103 static void FilterFileDirectories(CFileItemList
&items
, const std::string
&mask
,
104 bool expandImages
=false);