diff options
author | filip <“filip.rabiega@gmail.com”> | 2023-02-02 21:53:03 +0200 |
---|---|---|
committer | filip <“filip.rabiega@gmail.com”> | 2023-02-02 21:53:03 +0200 |
commit | d2a6dafcf6dcffdd0f94655444f3570ce149ad01 (patch) | |
tree | c79eccef19c7e8d00e701776594483be389d76e3 /filesystem-datastructure.h | |
download | chadunix-fs-d2a6dafcf6dcffdd0f94655444f3570ce149ad01.tar.gz chadunix-fs-d2a6dafcf6dcffdd0f94655444f3570ce149ad01.tar.bz2 chadunix-fs-d2a6dafcf6dcffdd0f94655444f3570ce149ad01.zip |
Diffstat (limited to 'filesystem-datastructure.h')
-rw-r--r-- | filesystem-datastructure.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/filesystem-datastructure.h b/filesystem-datastructure.h new file mode 100644 index 0000000..9f8a330 --- /dev/null +++ b/filesystem-datastructure.h @@ -0,0 +1,80 @@ +/* + * File: filesystem-datastructure.h + * + * This file contains the structure declarations necessary to create the file + * system representation. + * + * It takes advantage of the Linked List Data Structure model to create a list + * of directories and files that would be assembeled together to create a + * Tree-like structure as the whole file system. + * + * Author: Filip Rabiega + */ + +/* + * These nodes are used to create a Linked List of Files + */ +typedef struct file_node { + + /* The file's name */ + char *name; + + /* The timestamp of the file */ + int timestamp; + + /* A pointer to the next file in the list */ + struct file_node *next_file; + +} File_node; + +/* + * These nodes are used to create a Linked List of Directories + */ +typedef struct dir_node { + + /* The name of directory */ + char *name; + + /* String of the directory path */ + char *path; + + /* Head node of the file list */ + File_node *file_list; + + /* Head node of the subdirectory list */ + struct dir_node *subdir_list; + + /* A pointer to the next directory in the list */ + struct dir_node *next_dir; + + /* A pointer to the parent directory */ + struct dir_node *par_dir; + +} Dir_node; + +/* + * These structures are used to create instances of a file system + */ +typedef struct FileSystem { + + /* A pointer to keep a reference to the root of the filesystem */ + Dir_node *root; + + /* A pointer to keep a reference to the current directory */ + Dir_node *cur_dir; + +} FileSystem; + +/* + * These structures are used to create linked lists of names. + * Used for the purpose of sorting the names of files and subdirectories + * of a directory for printing. + */ +typedef struct name_node { + /* The name to be stored in the node */ + char *name; + + /* The next node in the list */ + struct name_node *next_name; + +} Name_node; |