Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
1. Directory functions

Globally available directories related functions
Used to perform typical operations with it. More...

Functions

bool ATTR_DLL_LOCAL kodi::vfs::CreateDirectory (const std::string &path)
 Make a directory.
 
bool ATTR_DLL_LOCAL kodi::vfs::DirectoryExists (const std::string &path)
 Verifying the Existence of a Directory.
 
bool ATTR_DLL_LOCAL kodi::vfs::RemoveDirectory (const std::string &path, bool recursive=false)
 Removes a directory.
 
bool ATTR_DLL_LOCAL kodi::vfs::GetDirectory (const std::string &path, const std::string &mask, std::vector< kodi::vfs::CDirEntry > &items)
 Lists a directory.
 

Detailed Description

Globally available directories related functions
Used to perform typical operations with it.

Function Documentation

◆ CreateDirectory()

bool ATTR_DLL_LOCAL 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]pathPath to the directory.
Returns
Upon successful completion, CreateDirectory() shall return true. Otherwise false shall be returned, no directory shall be created.

Example:

...
std::string directory = "C:\\my_dir";
bool ret = kodi::vfs::CreateDirectory(directory);
fprintf(stderr, "Directory '%s' successfully created: %s\n", directory.c_str(), ret ? "yes" : "no");
...
bool ATTR_DLL_LOCAL CreateDirectory(const std::string &path)
Make a directory.
Definition addons/kodi-dev-kit/include/kodi/Filesystem.h:778

◆ DirectoryExists()

bool ATTR_DLL_LOCAL 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]pathPath to the directory.
Returns
True when it exists, false otherwise.

Example:

...
std::string directory = "C:\\my_dir";
bool ret = kodi::vfs::DirectoryExists(directory);
fprintf(stderr, "Directory '%s' present: %s\n", directory.c_str(), ret ? "yes" : "no");
...
bool ATTR_DLL_LOCAL DirectoryExists(const std::string &path)
Verifying the Existence of a Directory.
Definition addons/kodi-dev-kit/include/kodi/Filesystem.h:810

◆ GetDirectory()

bool ATTR_DLL_LOCAL 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]pathThe path in which the files and directories are located.
[in]maskMask to filter out requested files, e.g. "*.avi|*.mpg" to files with this ending.
[out]itemsThe returned list directory entries.
Returns
True if listing was successful, false otherwise.

Example:

std::vector<kodi::vfs::CDirEntry> items;
kodi::vfs::GetDirectory("special://temp", "", 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());
}
bool ATTR_DLL_LOCAL GetDirectory(const std::string &path, const std::string &mask, std::vector< kodi::vfs::CDirEntry > &items)
Lists a directory.
Definition addons/kodi-dev-kit/include/kodi/Filesystem.h:893

◆ RemoveDirectory()

bool ATTR_DLL_LOCAL 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]pathPath 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:

...
bool ret = kodi::vfs::RemoveDirectory("C:\\my_dir");
...
bool ATTR_DLL_LOCAL RemoveDirectory(const std::string &path, bool recursive=false)
Removes a directory.
Definition addons/kodi-dev-kit/include/kodi/Filesystem.h:844