Building a tree from a directory structure
Hello.
I'm designing (or trying) a program that will be command line on linux/unix that
checks for duplicate files. I'm coding a function that will take argv[1] - argv[n] and build
a linked list tree out of those directory arguments:
e.g.
$ checkdups /bin /home
this will check for duplicate files in the /bin and /home directories descending into their
subdirectories also. My question is with my implementation. I have a:
Code:
struct dir {
char name[256];
struct dir *subdirs;
struct file *files;
struct dir *next;
};
struct file {
char name[256];
off_t size;
struct file *next;
};
this gives the current directory name, followed by a pointer to a linked list of all its
sub-directories, followed by a pointer to another linked list with all the current
directories files, and a *next pointer if this directory happens to be on same level
with other directories. Using the two above structs I would be able to describe a
directory structure using linked lists and be able to traverse it to operate on all files
below a particular set of directories. Am I going about this in the right way?
thanks :)