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

#include <directory.h>

Inherits object.

Public Member Functions

 directory ()
 
 ~directory ()
 
bool open (const char *path)
 
bool close ()
 
bool skip ()
 
charread ()
 
void rewind ()
 
uint64_t getChildCount ()
 
chargetChildName (uint64_t index)
 
int64_t getMaxFileNameLength ()
 
int64_t getMaxPathLength ()
 
bool getCanExceedMaxFileNameLength ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Static Public Member Functions

static bool create (const char *path, mode_t perms)
 
static bool createTemporaryDirectory (char *templatedirname, mode_t perms)
 
static bool remove (const char *path)
 
static bool removeTree (const char *path)
 
static chargetCurrentWorkingDirectory ()
 
static bool changeDirectory (const char *path)
 
static bool changeRoot (const char *path)
 
static int64_t getMaxFileNameLength (const char *pathname)
 
static int64_t getMaxPathLength (const char *pathname)
 
static bool getCanExceedMaxFileNameLength (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

◆ 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".

◆ createTemporaryDirectory()

static bool directory::createTemporaryDirectory ( char * templatedirname,
mode_t perms )
static

Creates a (presumably) temporary directory using "templatedirname" as a template. The permissions of the directory will be set to "perms".

The last 6 characters of "templatedirname" must be XXXXXX and "templatedirname" will be modified to contain the name of the directory that was actually created.

Returns true on success and false on failure.

◆ getCanExceedMaxFileNameLength() [1/2]

bool directory::getCanExceedMaxFileNameLength ( )

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

◆ getCanExceedMaxFileNameLength() [2/2]

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

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

◆ 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.

◆ getMaxFileNameLength() [1/2]

int64_t directory::getMaxFileNameLength ( )

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

◆ getMaxFileNameLength() [2/2]

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

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

◆ getMaxPathLength() [1/2]

int64_t directory::getMaxPathLength ( )

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

◆ getMaxPathLength() [2/2]

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

Returns the character 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.

◆ removeTree()

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

Removes the directory "path", and its contents.

◆ 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.