/* * This file implements the File System object, which is the namespace for a * task's file system. It tracks a task's root and current working directory. */ #include #include #include "namespace.h" static void file_system_new(Object *); static void file_system_delete(Object *); static void file_system_copy(Object *, Object *); /* File System object type */ ObjectType fsType = { .name = "FILE SYSTEM", .size = sizeof(FileSystem), .new = file_system_new, .delete = file_system_delete, .copy = file_system_copy, }; /* Create a new File System object */ static void file_system_new(Object *obj) { FileSystem *fs = (void *) obj; fs->cwdPath = create_list(&dirEntryType); } /* Destory a File System object */ static void file_system_delete(Object *obj) { FileSystem *fs = (void *) obj; put(fs->cwd); destroy_list(fs->cwdPath); put(fs->root); } /* Copy a File System object */ static void file_system_copy(Object *a, Object *b) { FileSystem *parent = (void *) a, *child = (void *) b; child->cwd = get(parent->cwd); child->cwdPath = copy_list(parent->cwdPath); child->root = get(parent->root); }