Switch to the no_helpers branch, that branch has been made for users that want just the tree, because they wanna use it for something else. I get where those people are coming from, because initially even I didn't know what I wanted to do after writing the tree generation code for a while. That tree can be used for anything.
- NOTE: people switching to the no_helpers branch should read this README too. It has all the information you need to work with the tree.
-
struct dnode *init_tree(char *absolute_location_of_dir)- this creates the tree. -
struct fnode *find_fnode_abs(struct dnode *tree, char *absolute_location_of_file)- this will return the fnode corresponding to a file. -
int write_abs(struct dnode *tree, char *absolute_location_of_file, char *content)- this will write to a file, wont append. -
struct str_blk *read_abs(struct dnode *tree, char *absolute_location_of_file)- this will return the content of a file(str_blk explained below with all the structs).
struct fnode{
char *location;
struct str_blk *text;
struct stat st;
};- This is the structure in the tree that contains the file. Location is absolute.
struct dnode{
char *location;
struct stat st;
struct dnode *parent;
struct dnode_list *dlist;
struct fnode_list *flist;
};- This is the structure in the tree that contains the directory. Location is absolute. dnode_list, fnode_list explained below.
struct dnode_list{
struct dnode *val;
struct dnode_list *next;
};- This is just a linked list of sub-directories in a dnode
struct fnode_list{
struct fnode *val;
struct fnode_list *next;
};- This is just a linked list of files in a dnode
struct str_blk{
char *content;
struct str_blk *next;
};- This is how the tree stores text, Instead of one big buffer, the program creates a linked list of blocks of text, with predefined size (BLK_SIZE defined in
str_ll.h)