Path
[Class_wrapper]
The path class facilitates the manipulation of paths using stack and iterator notations.
More...Data Structures | |
struct | dar_path |
Incomplete struct for use as path reference pointer. More... | |
Functions | |
NAMESPACE_LIBDAR_START dar_path * | dar_path_create (char *path) |
Creates a new path object from c string. | |
dar_path * | dar_path_copy (dar_path *ref) |
Copy constructor. | |
void | dar_path_destroy (dar_path *ref) |
Frees memory used by path object. | |
bool | dar_path_compare (dar_path *ref, dar_path *path) |
Returns true if paths are exactly alike. | |
bool | dar_path_is_relative (dar_path *ref) |
Returns true if the path is relative, false if absolute. | |
bool | dar_path_is_subdir_of (dar_path *ref, dar_path *path, bool case_sensit) |
Returns true if reference is a subdirectory of path . | |
char * | dar_path_iterate_next (dar_path *ref) |
Gets c string containing the name of the next child directory. | |
void | dar_path_iterate_reset (dar_path *ref) |
Resets iteration position at the root or shallowest child. | |
bool | dar_path_stack_push (dar_path *ref, dar_path *path) |
Adds another relative path to the end of the reference path. | |
bool | dar_path_stack_peek (dar_path *ref, char **name) |
Returns deepest child directory name without removing it from the stack. | |
bool | dar_path_stack_pop (dar_path *ref, char **name) |
Pops the deepest child directory off the stack, or returns false if there are no more children left (only one element on the stack). | |
bool | dar_path_stack_pop_front (dar_path *ref, char **name) |
Pops the root or topmost directory. | |
char * | dar_path_get_string (dar_path *ref) |
Returns full path name. | |
unsigned int | dar_path_get_depth (dar_path *ref) |
Returns the number of elements left in the path. |
Detailed Description
The path class facilitates the manipulation of paths using stack and iterator notations.While not specifically limited by the interface, the path class currently supports only Unix notation.
While used by the library, are available to you as an additional tool, not as an interface. If you choose to use them you must export any results to c strings before using them.
Unlike mask classes, a path class is fully mutable. The path class of functions are wrappers over the methods of the C++ object, a link to which will be returned from constructor or copy functions. When calling the methods, pass the as the first argument and additional arguments as required.
The path functions are organized starting with dar_path
. There are create, copy, destroy, and other functions there. For more continuity, the stack and iteration methods have been named dar_path_stack
and dar_path_iterate
respectively.
Like the mask functions, all functions that take another path object make a local copy of the object and leave the object pointed to by the passed in variable untouched. Therefore, the caller will have to remember to take care of destroying objects manually.
Function Documentation
|
Copy constructor. Creates a fresh path object. |
|
Creates a new path object from c string.
Returns |
|
Returns the number of elements left in the path. An absolute path adds one for the root directory itself.
foo/bar/directory 3 /foo/bar/directory 4 |
|
Returns full path name. String will represent either an absolute or relative path. |
|
Returns true if reference is a subdirectory of
For example, |
|
Returns deepest child directory name without removing it from the stack. Will always output a string, but will return false if the output is the last possible element (no more parent directories).
This method should be used whenever the deepest child is desired. This is equivalent to |
|
Pops the root or topmost directory. Returns false when only the deepest child is left or path is equal to the root directory. |
|
Adds another relative path to the end of the reference path. Returns false if pushed path is not relative (can't add an absolute path to another absolute path!) |