GPAK  1.0.0
A general-purpose archive library

◆ filesystem_iterator_next_subling_directory()

GPAK_API filesystem_tree_node_t* filesystem_iterator_next_subling_directory ( filesystem_tree_iterator_t _iterator)
Brief Description:\n Retrieves the next sibling directory in the filesystem tree.

This function returns the next sibling directory node in the filesystem tree without traversing its children.

Parameters
_iteratorA pointer to the filesystem_tree_iterator_t.
Returns
A pointer to the next sibling directory node or NULL if there are no more sibling directories.

Definition at line 324 of file filesystem_tree.c.

325 {
326  if (_iterator->stack_size_ == 0)
327  return NULL;
328 
329  filesystem_iterator_state_t current_state = _iterator->stack_[_iterator->stack_size_ - 1];
330 
331  if (current_state.child_index_ < current_state.node_->num_children_)
332  {
333  filesystem_tree_node_t* next_directory = current_state.node_->children_[current_state.child_index_];
334 
335  // Update the current state's child_index
336  current_state.child_index_++;
337  _iterator->stack_[_iterator->stack_size_ - 1] = current_state;
338 
339  return next_directory;
340  }
341 
342  return NULL;
343 }
filesystem_tree_node_t * node_
Definition: gpak_data.h:347
filesystem_iterator_state_t * stack_
Definition: gpak_data.h:367
struct filesystem_tree_node ** children_
Definition: gpak_data.h:326

References filesystem_iterator_state::child_index_, filesystem_tree_node::children_, filesystem_iterator_state::node_, filesystem_tree_node::num_children_, filesystem_tree_iterator::stack_, and filesystem_tree_iterator::stack_size_.