# Single-LevelDirectory
- Used to provide a logical grouping of files
- Used to keep track of files
The files exist in one high-level directory, under which all the files lie under that. This means that there are no duplicate file names as there is no way to distinguish between them.
Tree-Structure
This allows for recursive embedding of directories into another: resulting in the natural formation of a tree structure.
This means that now there are two ways to refer to a file:
Absolute Pathname
The pathname followed from the root of the tree to the final file.
root/Users/document.out
Relative Pathname
The pathname from the current working directory.
document.out
fromroot/Users
, andUsers/document.out
fromroot
.
Directed Acyclic Graph
This allows sharing of files (without actually replicating the content). Thus, the file “appears” in multiple directories.
Implementations:
Hard Link
Limited to file only.
Unix implements this hard link, ln
. Given two directories A
and B
, if B
wants to share a file F
stored in A
,
A
andB
have separate pointers to point to F on disk
Low overhead
Only pointers are added in directory.
Deletion problems
What happens if the file is deleted?
Symbolic Link
Can be file or directory.
Unix also implements the symbolic link with ln -s
. Given the same scenario,
B
creates a link fileG
that contains the path name ofF
.- Access to
G
findsF
and accesses it.
Simple deletion
Deletion from the original directory results in expected behaviour, as while
G
remains, it will not be able to accessF
.Similarly, deletion of
G
inB
does not affectF
.
Larger overhead
Special link takes up actual disk space, as compared to the pointer.
General Graph
Allows for cycles within the file directory, allowing for creation of link to directory.
In Unix, a symbolic link is allowed to link to directory, allowing for creation of a general graph.
Hard to traverse
Infinite loop
Hard to delete
Difficult to determine when to remove file or directory.