blob: 9f8a330ae49a3e4127030706b199d75c5ac90573 (
plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;
|