Rudiments: directory Class Reference

Rudiments

- Main Page
- Classes

- Class List
- Class Hierarchy
- Class Members

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 | ( |  | ) |

Creates an instance of the directory class.

directory::~directory | ( |  | ) |

Deletes this instance of the directory class.

## Member Function Documentation

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.

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.

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

Sets the current working directory to "path".

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

Changes root to "path".

bool directory::close | ( |  | ) |

Closes the currently open directory.

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

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

uint64_t directory::getChildCount | ( |  | ) |

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

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.

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.

int64_t directory::maxFileNameLength | ( |  | ) |

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

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

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

int64_t directory::maxPathLength | ( |  | ) |

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

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

bool directory::open | ( | const char * | path | ) |

Opens directory "path".

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.

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

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

void directory::rewind | ( |  | ) |

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

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.