GPAK  1.0.0
A general-purpose archive library

◆ filesystem_iterator_next_file()

GPAK_API filesystem_tree_file_t* filesystem_iterator_next_file ( filesystem_tree_iterator_t _iterator)
Brief Description:\n Retrieves the next file in the filesystem tree.

This function returns the next file node in the filesystem tree using a depth-first search algorithm.

Parameters
_iteratorA pointer to the filesystem_tree_iterator_t.
Returns
A pointer to the next file node or NULL if there are no more files.

Definition at line 345 of file filesystem_tree.c.

346 {
347  if (_iterator->stack_size_ == 0)
348  return NULL;
349 
350  filesystem_iterator_state_t current_state = _iterator->stack_[_iterator->stack_size_ - 1];
351 
352  if (current_state.file_index_ < current_state.node_->num_files_)
353  {
354  filesystem_tree_file_t* next_file = current_state.node_->files_[current_state.file_index_];
355  current_state.file_index_++;
356  _iterator->stack_[_iterator->stack_size_ - 1] = current_state;
357  return next_file;
358  }
359 
360  return NULL;
361 }
filesystem_tree_node_t * node_
Definition: gpak_data.h:347
filesystem_iterator_state_t * stack_
Definition: gpak_data.h:367
filesystem_tree_file_t ** files_
Definition: gpak_data.h:328

References filesystem_iterator_state::file_index_, filesystem_tree_node::files_, filesystem_iterator_state::node_, filesystem_tree_node::num_files_, filesystem_tree_iterator::stack_, and filesystem_tree_iterator::stack_size_.

Referenced by _gpak_compressor_generate_dictionary().