GPAK  1.0.0
A general-purpose archive library

◆ filesystem_iterator_create()

GPAK_API filesystem_tree_iterator_t* filesystem_iterator_create ( filesystem_tree_node_t _root)
Brief Description:\n Creates a new filesystem tree iterator.

This function initializes and returns a new filesystem tree iterator for traversing the filesystem tree starting from the given _root node.

Parameters
_rootA pointer to the root filesystem_tree_node_t.
Returns
A pointer to the created filesystem_tree_iterator_t.

Definition at line 278 of file filesystem_tree.c.

279 {
280  if (!_root)
281  return NULL;
282 
284  iterator->stack_capacity_ = 16ull;
285  iterator->stack_size_ = 0ull;
286  iterator->stack_ = (filesystem_iterator_state_t*)malloc(sizeof(filesystem_iterator_state_t) * iterator->stack_capacity_);
287 
288  filesystem_iterator_state_t initial_state = { .node_ = _root, .child_index_ = 0ull, .file_index_ = 0ull };
289  iterator->stack_[iterator->stack_size_++] = initial_state;
290 
291  return iterator;
292 }
filesystem_tree_node_t * node_
Definition: gpak_data.h:347
filesystem_iterator_state_t * stack_
Definition: gpak_data.h:367

References filesystem_iterator_state::node_, filesystem_tree_iterator::stack_, filesystem_tree_iterator::stack_capacity_, and filesystem_tree_iterator::stack_size_.

Referenced by _gpak_compressor_generate_dictionary().