我有 2 个结构来实现一个文件系统,除了 TODO 部分(在我的作业中要求)我不能修改它
目录结构:
typedef struct Directory {
char *name;
// TODO: The list of files of the current directory
File *fileList;
// TODO: The list of directories of the current directory
Directory *dirList;
// The parent directory of the current directory (NULL for the root directory)
struct Directory *parentDir;
} Directory;
一个用于文件:
typedef struct File {
// The name of the file
char *name;
// The size of the file
int size;
// The content of the file
char *data;
// The directory in which the file is located
Directory *dir;
} File;
我的问题是如何保持对我的文件和目录的引用以保持它们的链接,因为我的File/Directory *next结构中没有指针?我是否定义了不同的结构来保存我的参考资料?如果这是一个愚蠢的问题,我深表歉意,但我在这里严重遗漏了一些东西。