A C program representing a directory tree structure which may be used concurrently.
'tis a task for a university course
Write a program that simulates a directory tree containing structure that may be used
concurrently by multiple threads. The implementation should provide the Tree.h
interface.
Required functions from Tree.h
:
Tree* tree_new()
returns a new heap-alloc'd treeint tree_create(const char* path)
likemkdir path
int tree_remove(const char* path)
likermdir path
int tree_move(const char* source, const char* target)
likemv source target
void tree_free(Tree*)
destroys a heap-alloc'd tree and frees all of the memory used by it
Note: functions return various error codes as per the tasks specification.
The implementation needs to support concurrent execution with multiple threads. It needs to be not only concurrent but paralell as well ie. if some actions on the tree may be performed at the same time they better be.
The HashMap
was given and not created by me, same with majority of
path_utils
and the simple err
utilities for terminating processes with
style. They were provided by the task authors.
Tree
and rw
modules are mine.
Tree
-- implementation of theTree.h
interfacerw
-- my implementation of a readers & writers style locking mechanism