Rudiments
Public Member Functions | Static Public Member Functions | List of all members
directory Class Reference

Public Member Functions

 directory ()
 
 ~directory ()
 
bool open (const char *path)
 
bool close ()
 
bool skip ()
 
char * read ()
 
void rewind ()
 
uint64_t getChildCount ()
 
char * getChildName (uint64_t index)
 
int64_t maxFileNameLength ()
 
int64_t maxPathLength ()
 
bool canExceedMaxFileNameLength ()
 

Static Public Member Functions

static bool create (const char *path, mode_t perms)
 
static bool remove (const char *path)
 
static char * getCurrentWorkingDirectory ()
 
static bool changeDirectory (const char *path)
 
static bool changeRoot (const char *path)
 
static int64_t maxFileNameLength (const char *pathname)
 
static int64_t maxPathLength (const char *pathname)
 
static bool canExceedMaxFileNameLength (const char *pathname)
 

Detailed Description

The directory class provides methods for opening/closing a directory and traversing it's files and subdirectories.

Constructor & Destructor Documentation

◆ directory()

directory::directory ( )

Creates an instance of the directory class.

◆ ~directory()

directory::~directory ( )

Deletes this instance of the directory class.

Member Function Documentation

◆ canExceedMaxFileNameLength() [1/2]

bool directory::canExceedMaxFileNameLength ( )

Returns true if an attempt to access a file in directory "pathname" longer than the length returned by maxFileNameLength() will succeed and false if it will fail.

◆ canExceedMaxFileNameLength() [2/2]

static bool directory::canExceedMaxFileNameLength ( const char *  pathname)
static

Returns true if an attempt to access a file in directory "pathname" longer than the length returned by maxFileNameLength() will succeed and false if it will fail.

◆ changeDirectory()

static bool directory::changeDirectory ( const char *  path)
static

Sets the current working directory to "path".

◆ changeRoot()

static bool directory::changeRoot ( const char *  path)
static

Changes root to "path".

◆ close()

bool directory::close ( )

Closes the currently open directory.

◆ create()

static bool directory::create ( const char *  path,
mode_t  perms 
)
static

Creates a new directory "path" with permissions "perms".

◆ getChildCount()

uint64_t directory::getChildCount ( )

Returns the number of files/subdirectories inside the open directory.

◆ getChildName()

char* directory::getChildName ( uint64_t  index)

Returns the name of the file/subdirectory at "index".

This methods allocates a buffer internally and returns it. The calling program must deallocate the buffer.

◆ getCurrentWorkingDirectory()

static char* directory::getCurrentWorkingDirectory ( )
static

Returns the current working directory.

This methods allocates a buffer internally and returns it. The calling program must deallocate the buffer.

◆ maxFileNameLength() [1/2]

int64_t directory::maxFileNameLength ( )

Returns the length of the longest file name that can be created in the currently open directory .

◆ maxFileNameLength() [2/2]

static int64_t directory::maxFileNameLength ( const char *  pathname)
static

Returns the length of the longest file name that can be created in directory "pathname".

◆ maxPathLength() [1/2]

int64_t directory::maxPathLength ( )

Returns the length of the longest relative path name that can be created in the currently open directory .

◆ maxPathLength() [2/2]

static int64_t directory::maxPathLength ( const char *  pathname)
static

Returns the length of the longest relative path name that can be created under the directory "pathname".

◆ open()

bool directory::open ( const char *  path)

Opens directory "path".

◆ read()

char* directory::read ( )

Returns the name of the current file inside the open directory and moves on to the next one. If there was no file at the current position then this method returns NULL.

◆ remove()

static bool directory::remove ( const char *  path)
static

Removes the directory "path", if it is empty.

◆ rewind()

void directory::rewind ( )

Resets the current file/subdirectory inside the open directory to the first one.

◆ skip()

bool directory::skip ( )

Moves from the current file inside the open directory to the next one. Returns true if there was a next file and false otherwise.