Globally available directories related functions
Used to perform typical operations with it.
◆ CreateDirectory()
bool ATTRIBUTE_HIDDEN kodi::vfs::CreateDirectory |
( |
const std::string & |
path | ) |
|
|
inline |
Make a directory.
The kodi::vfs::CreateDirectory() function shall create a new directory with name path.
The newly created directory shall be an empty directory.
- Parameters
-
[in] | path | Path to the directory. |
- Returns
- Upon successful completion, CreateDirectory() shall return true. Otherwise false shall be returned, no directory shall be created.
Example:
#include <kodi/Filesystem.h>
...
std::string directory = "C:\\my_dir";
fprintf(stderr, "Directory '%s' successfull created: %s\n", directory.c_str(), ret ? "yes" : "no");
...
◆ DirectoryExists()
bool ATTRIBUTE_HIDDEN kodi::vfs::DirectoryExists |
( |
const std::string & |
path | ) |
|
|
inline |
Verifying the Existence of a Directory.
The kodi::vfs::DirectoryExists() method determines whether a specified folder exists.
- Parameters
-
[in] | path | Path to the directory. |
- Returns
- True when it exists, false otherwise.
Example:
#include <kodi/Filesystem.h>
...
std::string directory = "C:\\my_dir";
fprintf(stderr, "Directory '%s' present: %s\n", directory.c_str(), ret ? "yes" : "no");
...
◆ RemoveDirectory()
bool ATTRIBUTE_HIDDEN kodi::vfs::RemoveDirectory |
( |
const std::string & |
path, |
|
|
bool |
recursive = false |
|
) |
| |
|
inline |
Removes a directory.
The kodi::vfs::RemoveDirectory() function shall remove a directory whose name is given by path.
- Parameters
-
[in] | path | Path to the directory. |
[in] | recursive | [opt] Remove directory recursive (default is false) |
- Returns
- Upon successful completion, the function RemoveDirectory() shall return true. Otherwise, false shall be returned, and errno set to indicate the error. If false is returned, the named directory shall not be changed.
Example:
#include <kodi/Filesystem.h>
...
...
◆ GetDirectory()
bool ATTRIBUTE_HIDDEN kodi::vfs::GetDirectory |
( |
const std::string & |
path, |
|
|
const std::string & |
mask, |
|
|
std::vector< kodi::vfs::CDirEntry > & |
items |
|
) |
| |
|
inline |
Lists a directory.
Return the list of files and directories which have been found in the specified directory and which respect the given constraint.
It can handle the normal OS dependent paths and also the special virtual filesystem from Kodi what starts with special://.
- Parameters
-
[in] | path | The path in which the files and directories are located. |
[in] | mask | Mask to filter out requested files, e.g. "*.avi|*.mpg" to files with this ending. |
[out] | items | The returned list directory entries. |
- Returns
- True if listing was successful, false otherwise.
Example:
#include <kodi/Filesystem.h>
std::vector<kodi::vfs::CDirEntry> items;
fprintf(stderr, "Directory have %lu entries\n", items.size());
for (unsigned long i = 0; i < items.size(); i++)
{
fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s\n",
i+1,
items[i].IsFolder() ? "yes" : "no ",
items[i].Label().c_str(),
items[i].Path().c_str());
}