GPAK  1.0.0
A general-purpose archive library

◆ filesystem_tree_directory_path()

GPAK_API char* filesystem_tree_directory_path ( filesystem_tree_node_t _node)
Brief Description:\n Gets the path of a directory node.

This function retrieves the path of the specified directory node.

Parameters
_nodeA pointer to the filesystem_tree_node_t.
Returns
A string containing the path of the directory.

Definition at line 221 of file filesystem_tree.c.

222 {
223  if (!_node || !_node->parent_)
224  return strdup("");
225 
226  char* parent_path = filesystem_tree_directory_path(_node->parent_);
227  size_t path_length = strlen(parent_path) + strlen(_node->name_) + 2;
228  char* path = (char*)malloc(path_length * sizeof(char));
229 
230  snprintf(path, path_length, "%s%s/", parent_path, _node->name_);
231 
232  free(parent_path);
233  return path;
234 }
GPAK_API char * filesystem_tree_directory_path(filesystem_tree_node_t *_node)
struct filesystem_tree_node * parent_
Definition: gpak_data.h:325

References filesystem_tree_node::name_, and filesystem_tree_node::parent_.

Referenced by filesystem_tree_file_path().