File: gtree.h

package info (click to toggle)
rdiff-backup-fs 1.0.0-8
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 952 kB
  • sloc: sh: 3,800; ansic: 2,944; makefile: 23
file content (62 lines) | stat: -rw-r--r-- 1,295 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef _SUPPORT_TREE_H_
#define _SUPPORT_TREE_H_

#include "../headers.h"
#include "gstats.h"
#include "gstring.h"
#include "gpath.h"

// #define TREE_DEBUG

struct node {

    struct stats *stats;
    int size;
    int capacity;
    struct node **children;
    char *name;
    
};

typedef struct node node_t;
typedef node_t * tree_t;

/*
 * creates a new directory tree with the root directory;
 * 
 * @1: pointer to the location, where the tree will be stored;
 * 
 * returns: 0 on success, -1 otherwise
 */
int gtreenew(struct node **);

/*
 * adds a new file, or rather its path and information about it, to the 
 * directory tree;
 * 
 * @1: pointer to the directory tree;
 * @2: pointer to the information about the file;
 * @3: path used to position element in the tree
 * 
 * returns: 0 on sucess, -1 otherwise
 */
int gtreeadd(tree_t, struct stats *, char *);

/*
 * finds and returns array of names of all children of a given
 * directory;
 * 
 * @1: pointer to the directory tree;
 * @2: path of a directory;
 * 
 * returns: array of strings on success or NULL otherwise;
 */
char** gtreecld(struct node *tree, const char *path);

int gtreeget(struct node *, const char *, struct stats **);

int gtreedel(struct node *, const char *);

int gtreesave(struct node *, char *);

#endif