libDwm-0.9.45
Dwm::DirectoryEntry Class Reference

Encapsulates a directory entry (file, directory, FIFO, et. al.). More...

#include <DwmDirectoryEntry.hh>

Collaboration diagram for Dwm::DirectoryEntry:

Public Types

enum  TypeEnum {
  e_typeUnknown = 0x00 , e_typeFifo = 0x01 , e_typeCharacterSpecial = 0x02 , e_typeDirectory = 0x04 ,
  e_typeBlockSpecial = 0x08 , e_typeRegular = 0x10 , e_typeSymbolicLink = 0x20 , e_typeSocket = 0x40
}
 The types of DirectoryEntry objects.
 

Public Member Functions

 DirectoryEntry (const std::string &path)
 Construct from a path.
 
 DirectoryEntry (const std::string &path, const DirectoryEntry *parent)
 Construct from a path and a parent.
 
TypeEnum Type () const
 Returns the DirectoryEntry's type.
 
const std::string & Path () const
 Returns the DirectoryEntry's path.
 
std::string RelativePath () const
 
std::string BaseName () const
 Returns the final component of the DirectoryEntry's path.
 
std::string DirName () const
 Returns the name of the directory in which DirectoryEntry resides.
 
std::string RealPath () const
 If the DirectoryEntry exists in the filesystem, returns its path with all symlinks, extra '/' characters and references to '/.
 
std::string Extension () const
 If the DirectoryEntry has dots ('.
 
const DirectoryEntryParent () const
 If the DirectoryEntry has a parent, returns a pointer to it.
 
bool Exists () const
 Returns true if the DirectoryEntry exists in the filesystem.
 
bool IsDirectory () const
 Returns true if the DirectoryEntry is a directory.
 
bool GetChildren (std::vector< DirectoryEntry > &children, uint8_t typeMask=0xFF) const
 If the DirectoryEntry is a directory and has children, fills children with its direct children and returns true.
 
bool GetChildren (std::vector< DirectoryEntry > &children, DirectoryEntryFunctor &dirEntryFunc) const
 
uint32_t Recurse (DirectoryEntryFunctor &dirEntryFunc, bool depthFirst=false, int maxDepth=-1)
 

Protected Member Functions

uint32_t Recurse (DirectoryEntry &de, DirectoryEntryFunctor &dirEntryFunc, int depth, bool depthFirst, int maxDepth)
 

Static Protected Member Functions

static TypeEnum GetType (const struct stat &statStruct)
 
static TypeEnum GetType (const struct dirent &dirEntry)
 

Protected Attributes

std::string _path
 
const DirectoryEntry_parent
 
TypeEnum _type
 

Static Protected Attributes

static std::mutex _readdirMtx
 

Detailed Description

Encapsulates a directory entry (file, directory, FIFO, et. al.).

Member Function Documentation

◆ Extension()

std::string Dwm::DirectoryEntry::Extension ( ) const

If the DirectoryEntry has dots ('.

') followed by other characters in its BaseName(), returns the string of characters beyond the last dot ('.'). Else returns an empty string.

◆ GetChildren()

bool Dwm::DirectoryEntry::GetChildren ( std::vector< DirectoryEntry > & children,
uint8_t typeMask = 0xFF ) const

If the DirectoryEntry is a directory and has children, fills children with its direct children and returns true.

Else clears children and returns false.

◆ Parent()

const DirectoryEntry * Dwm::DirectoryEntry::Parent ( ) const

If the DirectoryEntry has a parent, returns a pointer to it.

Else returns (DirectoryEntry *)0.

◆ RealPath()

std::string Dwm::DirectoryEntry::RealPath ( ) const

If the DirectoryEntry exists in the filesystem, returns its path with all symlinks, extra '/' characters and references to '/.

/' and '/../' resolved. Else returns an empty string.


The documentation for this class was generated from the following file: