2 * Directory tree build/traverse routines
4 * Kern Sibbald, June MMII
8 Copyright (C) 2002 Kern Sibbald and John Walker
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of
13 the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public
21 License along with this program; if not, write to the Free
22 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 char *fname; /* file name */
29 uint32_t FileIndex; /* file index */
30 int type; /* node type */
31 struct s_tree_node *parent;
32 struct s_tree_node *sibling;
33 struct s_tree_node *child;
34 struct s_tree_node *next; /* next hash of FileIndex */
36 typedef struct s_tree_node TREE_NODE;
39 char *fname; /* file name */
40 uint32_t FileIndex; /* file index */
41 int type; /* node type */
42 struct s_tree_node *parent;
43 struct s_tree_node *sibling;
44 struct s_tree_node *child;
45 struct s_tree_node *next; /* next hash of FileIndex */
47 /* The above ^^^ must be identical to a TREE_NODE structure */
48 struct s_tree_node *first; /* first entry in the tree */
49 struct s_tree_node *last; /* last entry in tree */
51 typedef struct s_tree_root TREE_ROOT;
54 #define TN_ROOT 1 /* root node */
55 #define TN_NEWDIR 2 /* created directory to fill path */
56 #define TN_DIR 3 /* directory entry */
57 #define TN_FILE 4 /* file entry */
59 TREE_NODE *new_tree_node(int type);
60 TREE_NODE *insert_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent);
61 TREE_NODE *make_tree_path(char *path, TREE_ROOT *root);
62 TREE_NODE *first_tree_node(TREE_ROOT *root);
63 TREE_NODE *next_tree_node(TREE_NODE *node);
64 TREE_NODE *tree_cwd(char *path, TREE_ROOT *root, TREE_NODE *node);
65 TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node);
66 void append_tree_node(char *fname, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent);
67 void print_tree(char *path, TREE_NODE *root);
68 void free_tree(TREE_NODE *node);
69 int tree_getpath(TREE_NODE *node, char *buf, int buf_size);