- Year not given
Directory, file path, access methods
Short answer
A directory maps file names to files (i-node pointers), organized hierarchically. File paths (absolute from root, relative from working directory) locate files. Access methods: sequential (simple, whole-file processing but slow random), direct (fast random access for fixed-size records), and indexed sequential (fast keyed lookup with index overhead).
Define directory and file path. Discuss various access methods with advantages and disadvantages of each.
Directory
A directory is a special file that contains information about other files, normally entries of (file name, attributes or pointer to the i-node). It maps file names to files, and is organised as single-level, two-level or hierarchical (tree) structures.
File path
A path name specifies a file's location in the directory tree.
- Absolute path: starts from the root:
/usr/ram/notes.txt(UNIX) orC:\Users\Ram\notes.txt. - Relative path: relative to the current working directory:
ram/notes.txtor../ram/notes.txt(.is the current and..the parent directory).
Access methods
- Sequential access: bytes/records are processed in order from the beginning (read next, write next). Advantages: simple, efficient for processing whole files, suits tapes. Disadvantages: slow to reach an arbitrary record, cannot jump.
- Direct (random) access: the file is viewed as numbered fixed-length blocks, any of which can be read or written immediately (
read(n)). Advantages: fast access to any record, ideal for databases and large files. Disadvantages: requires random-access media and fixed-size records or an offset; more complex. - Indexed sequential access: an index of keys points to records. A lookup in the index finds the block, which is then read directly. Advantages: fast keyed access and also sequential scanning. Disadvantages: index uses extra space, needs maintenance when records change, and large index may need multiple levels.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- File attributes; directory systems; free blocks · Operating System, chapter 5
- File allocation and access methods · Operating System, chapter 5
- Random access file transaction processing · Object Oriented Programming, chapter 8
- File I/O operations, errors, random access · Computer Programming, chapter 10