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

Virtual file server directory entry
This class is used as an entry for files and folders in kodi::vfs::GetDirectory(). More...

Classes

class  kodi::vfs::CDirEntry
 

Functions

 kodi::vfs::CDirEntry::CDirEntry (const std::string &label="", const std::string &path="", bool folder=false, int64_t size=-1, time_t dateTime=0)
 Constructor for VFS directory entry.
 
const std::string & kodi::vfs::CDirEntry::Label (void) const
 Get the directory entry name.
 
const std::string & kodi::vfs::CDirEntry::Title (void) const
 Get the optional title of entry.
 
const std::string & kodi::vfs::CDirEntry::Path (void) const
 Get the path of the entry.
 
bool kodi::vfs::CDirEntry::IsFolder (void) const
 Used to check entry is folder.
 
int64_t kodi::vfs::CDirEntry::Size (void) const
 If file, the size of the file.
 
time_t kodi::vfs::CDirEntry::DateTime ()
 Get file time and date for a new entry.
 
void kodi::vfs::CDirEntry::SetLabel (const std::string &label)
 Set the label name.
 
void kodi::vfs::CDirEntry::SetTitle (const std::string &title)
 Set the title name.
 
void kodi::vfs::CDirEntry::SetPath (const std::string &path)
 Set the path of the entry.
 
void kodi::vfs::CDirEntry::SetFolder (bool folder)
 Set the entry defined as folder.
 
void kodi::vfs::CDirEntry::SetSize (int64_t size)
 Set a file size for a new entry.
 
void kodi::vfs::CDirEntry::SetDateTime (time_t dateTime)
 Set file time and date for a new entry.
 
void kodi::vfs::CDirEntry::AddProperty (const std::string &id, const std::string &value)
 Add a by string defined property entry to directory entry.
 
void kodi::vfs::CDirEntry::ClearProperties ()
 Clear all present properties.
 
const std::map< std::string, std::string > & kodi::vfs::CDirEntry::GetProperties () const
 Get the present properties list on directory entry.
 

Detailed Description

Virtual file server directory entry
This class is used as an entry for files and folders in kodi::vfs::GetDirectory().


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++)
{
char buff[20];
time_t now = items[i].DateTime();
strftime(buff, 20, "%Y-%m-%d %H:%M:%S", gmtime(&now));
fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s -- Time: %s\n",
i+1,
items[i].IsFolder() ? "yes" : "no ",
items[i].Label().c_str(),
items[i].Path().c_str(),
buff);
}
Definition addons/kodi-dev-kit/include/kodi/Filesystem.h:548
const std::string & Label(void) const
Get the directory entry name.
Definition addons/kodi-dev-kit/include/kodi/Filesystem.h:614
bool IsFolder(void) const
Used to check entry is folder.
Definition addons/kodi-dev-kit/include/kodi/Filesystem.h:638
time_t DateTime()
Get file time and date for a new entry.
Definition addons/kodi-dev-kit/include/kodi/Filesystem.h:654
const std::string & Path(void) const
Get the path of the entry.
Definition addons/kodi-dev-kit/include/kodi/Filesystem.h:630
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

It has the header #include <kodi/Filesystem.h> be included to enjoy it.

@ingroup cpp_kodi_vfs_CDirEntry

The following table contains values that can be set with class CDirEntry :

Name Type Set call Get call Clear call
Directory entry name std::string SetLabel Label
Title of entry std::string SetTitle Title
Path of the entry std::string SetPath Path
Entry is folder bool SetFolder IsFolder
The size of the file int64_t SetSize Size
File time and date time_t SetDateTime DateTime
Property entries std::string, std::string AddProperty GetProperties ClearProperties

Function Documentation

◆ AddProperty()

void kodi::vfs::CDirEntry::AddProperty ( const std::string & id,
const std::string & value )
inline

Add a by string defined property entry to directory entry.

Note
A property can be used to add some special information about a file or directory entry, this can be used on other places to do the right work of them.
Parameters
[in]idIdentification name of property
[in]valueThe property value to add by given id

◆ CDirEntry()

kodi::vfs::CDirEntry::CDirEntry ( const std::string & label = "",
const std::string & path = "",
bool folder = false,
int64_t size = -1,
time_t dateTime = 0 )
inline

Constructor for VFS directory entry.

Parameters
[in]label[opt] Name to use for entry
[in]path[opt] Used path of the entry
[in]folder[opt] If set entry used as folder
[in]size[opt] If used as file, his size defined there
[in]dateTime[opt] Date time of the entry

◆ ClearProperties()

void kodi::vfs::CDirEntry::ClearProperties ( )
inline

Clear all present properties.

◆ DateTime()

time_t kodi::vfs::CDirEntry::DateTime ( )
inline

Get file time and date for a new entry.

Returns
The with time_t defined date and time of file

◆ GetProperties()

const std::map< std::string, std::string > & kodi::vfs::CDirEntry::GetProperties ( ) const
inline

Get the present properties list on directory entry.

Returns
map with all present properties

◆ IsFolder()

bool kodi::vfs::CDirEntry::IsFolder ( void ) const
inline

Used to check entry is folder.

Returns
true if entry is a folder

◆ Label()

const std::string & kodi::vfs::CDirEntry::Label ( void ) const
inline

Get the directory entry name.

Returns
Name of the entry

◆ Path()

const std::string & kodi::vfs::CDirEntry::Path ( void ) const
inline

Get the path of the entry.

Returns
File system path of the entry

◆ SetDateTime()

void kodi::vfs::CDirEntry::SetDateTime ( time_t dateTime)
inline

Set file time and date for a new entry.

Parameters
[in]dateTimeThe with time_t defined date and time of file

◆ SetFolder()

void kodi::vfs::CDirEntry::SetFolder ( bool folder)
inline

Set the entry defined as folder.

Parameters
[in]folderIf true becomes entry defined as folder

◆ SetLabel()

void kodi::vfs::CDirEntry::SetLabel ( const std::string & label)
inline

Set the label name.

Parameters
[in]labelname of entry

◆ SetPath()

void kodi::vfs::CDirEntry::SetPath ( const std::string & path)
inline

Set the path of the entry.

Parameters
[in]pathpath of entry

◆ SetSize()

void kodi::vfs::CDirEntry::SetSize ( int64_t size)
inline

Set a file size for a new entry.

Parameters
[in]sizeSize to set for dir entry

◆ SetTitle()

void kodi::vfs::CDirEntry::SetTitle ( const std::string & title)
inline

Set the title name.

Parameters
[in]titletitle name of entry

◆ Size()

int64_t kodi::vfs::CDirEntry::Size ( void ) const
inline

If file, the size of the file.

Returns
Defined file size

◆ Title()

const std::string & kodi::vfs::CDirEntry::Title ( void ) const
inline

Get the optional title of entry.

Returns
Title of the entry, if exists