libsqsh v1.5.1
|
A walker over the contents of a file. More...
#include <sqsh_tree_private.h>
Public Member Functions | |
struct SqshTreeTraversal * | sqsh_tree_traversal_new (const struct SqshFile *file, int *err) |
Creates a new SqshTreeTraversal object rooted at the specified inode. | |
void | sqsh_tree_traversal_set_max_depth (struct SqshTreeTraversal *traversal, size_t max_depth) |
Sets the maximum depth of the traversal. | |
SQSH_NO_UNUSED bool | sqsh_tree_traversal_next (struct SqshTreeTraversal *traversal, int *err) |
Moves the traversal to the next entry int the current directory. | |
enum SqshFileType | sqsh_tree_traversal_type (const struct SqshTreeTraversal *traversal) |
Returns the inode type of the current entry. | |
enum SqshTreeTraversalState | sqsh_tree_traversal_state (const struct SqshTreeTraversal *traversal) |
returns the state of the traversal. | |
const char * | sqsh_tree_traversal_name (const struct SqshTreeTraversal *traversal, size_t *len) |
Returns the name of the current entry. | |
char * | sqsh_tree_traversal_path_dup (const struct SqshTreeTraversal *traversal) |
Creates a heap allocated copy of the path to the current entry. | |
SQSH_NO_UNUSED char * | sqsh_tree_traversal_name_dup (const struct SqshTreeTraversal *traversal) |
creates a heap allocated copy of the name of the current entry. | |
size_t | sqsh_tree_traversal_depth (const struct SqshTreeTraversal *traversal) |
Returns the path segment at a given index. | |
const char * | sqsh_tree_traversal_path_segment (const struct SqshTreeTraversal *traversal, size_t *len, sqsh_index_t index) |
Get a segment of the path of the current entry. | |
SQSH_NO_UNUSED struct SqshFile * | sqsh_tree_traversal_open_file (const struct SqshTreeTraversal *traversal, int *err) |
Returns the inode of the current entry. | |
int | sqsh_tree_traversal_free (struct SqshTreeTraversal *traversal) |
A walker over the contents of a file.
Definition at line 110 of file sqsh_tree_private.h.
size_t sqsh_tree_traversal_depth | ( | const struct SqshTreeTraversal * | traversal | ) |
Returns the path segment at a given index.
[in,out] | traversal | The traversal to use |
int sqsh_tree_traversal_free | ( | struct SqshTreeTraversal * | traversal | ) |
[in,out] | traversal | The file traversal struct to clean up. |
const char * sqsh_tree_traversal_name | ( | const struct SqshTreeTraversal * | traversal, |
size_t * | len ) |
Returns the name of the current entry.
This entry is not zero terminated. The function will return an empty string for the uppermost object.
[in] | traversal | The traversal to use |
[out] | len | Pointer to a size_t where the length of the name will be stored. |
SQSH_NO_UNUSED char * sqsh_tree_traversal_name_dup | ( | const struct SqshTreeTraversal * | traversal | ) |
creates a heap allocated copy of the name of the current entry.
The caller is responsible for calling free() on the returned pointer.
The returned string is 0 terminated.
[in] | traversal | The traversal to use |
struct SqshTreeTraversal * sqsh_tree_traversal_new | ( | const struct SqshFile * | file, |
int * | err ) |
Creates a new SqshTreeTraversal object rooted at the specified inode.
The returned traversal iterator object borrows the passed file object. The returned traversal iterator object will visit all entries recursively located below the passed inode (which can be limited with sqsh_tree_traversal_set_max_depth
). If the passed inode is not a directory, only the passed inode itself will be visited.
[in] | file | the base inode to start from. |
[out] | err | Pointer to an int where the error code will be stored. |
SQSH_NO_UNUSED bool sqsh_tree_traversal_next | ( | struct SqshTreeTraversal * | traversal, |
int * | err ) |
Moves the traversal to the next entry int the current directory.
[in,out] | traversal | The traversal to use |
[out] | err | Pointer to an int where the error code will be stored. |
SQSH_NO_UNUSED struct SqshFile * sqsh_tree_traversal_open_file | ( | const struct SqshTreeTraversal * | traversal, |
int * | err ) |
Returns the inode of the current entry.
[in,out] | traversal | The traversal to use |
[out] | err | Pointer to an int where the error code will be |
char * sqsh_tree_traversal_path_dup | ( | const struct SqshTreeTraversal * | traversal | ) |
Creates a heap allocated copy of the path to the current entry.
The caller is responsible for calling free() on the returned pointer.
The returned string is 0 terminated.
[in] | traversal | The traversal to use |
const char * sqsh_tree_traversal_path_segment | ( | const struct SqshTreeTraversal * | traversal, |
size_t * | len, | ||
sqsh_index_t | index ) |
Get a segment of the path of the current entry.
A path segment is a part of the path that is separated by a path separator (/
). The segments are indexed starting at 0, and there are depth
segments in total (0 <= index < depth). The last segment is the name of the current entry.
The root of the traversal is considered at depth 0, and so has no path segments (or name).
If the traversal is rooted at /a/b
, and the traversal iterator is pointing at /a/b/c/d.txt
, the path segments will be [c
, d.txt
].
The returned pointer is not zero terminated.
[in,out] | traversal | The traversal to use |
[out] | len | Pointer to a size_t where the length of the name will be stored. |
[in] | index | The index of the path segment. |
void sqsh_tree_traversal_set_max_depth | ( | struct SqshTreeTraversal * | traversal, |
size_t | max_depth ) |
Sets the maximum depth of the traversal.
[in] | traversal | The traversal to use |
[in] | max_depth | The maximum depth to traverse. |
enum SqshTreeTraversalState sqsh_tree_traversal_state | ( | const struct SqshTreeTraversal * | traversal | ) |
returns the state of the traversal.
[in] | traversal | The traversal to use |
enum SqshFileType sqsh_tree_traversal_type | ( | const struct SqshTreeTraversal * | traversal | ) |
Returns the inode type of the current entry.
[in] | traversal | The traversal to use |