GPAK  1.0.0
A general-purpose archive library

◆ filesystem_tree_file_path()

GPAK_API char* filesystem_tree_file_path ( filesystem_tree_node_t _node,
filesystem_tree_file_t _file 
)
Brief Description:\n Gets the path of a file node.

This function retrieves the path of the specified file node.

Parameters
_nodeA pointer to the filesystem_tree_node_t.
_fileA pointer to the filesystem_tree_file_t.
Returns
A string containing the path of the file.

Definition at line 236 of file filesystem_tree.c.

237 {
238  if (!_node || !_file)
239  return NULL;
240 
241  char* dir_path = filesystem_tree_directory_path(_node);
242  size_t path_length = strlen(dir_path) + strlen(_file->name_) + 1;
243  char* file_path = (char*)malloc(path_length * sizeof(char));
244 
245  snprintf(file_path, path_length, "%s%s", dir_path, _file->name_);
246 
247  free(dir_path);
248  return file_path;
249 }
GPAK_API char * filesystem_tree_directory_path(filesystem_tree_node_t *_node)

References filesystem_tree_directory_path(), and filesystem_tree_file::name_.

Referenced by gpak_fopen().