---
title: "Directory, file path, access methods"
subject: "Operating System"
chapter: 5
key: "semester_6/operating_system:directory-file-path-access-methods"
source: https://www.bctengineer.com/q/semester_6/operating_system/directory-file-path-access-methods
site: BCT Engineering
---

# Directory, file path, access methods

Operating System · Chapter 5: File Systems

- Asked in: year not given
- Video: [Access Methods | File Access Methods | operating systems | Sequential | Direct | Indexed | File Syst](https://www.youtube.com/watch?v=0vno0Ra0wEg) — Sudhakar Atchala
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/directory-file-path-access-methods
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-5

## Question

Define directory and file path. Discuss various access methods with advantages and disadvantages of each.

## 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).

## Answer

#### 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) or `C:\Users\Ram\notes.txt`.
- **Relative path:** relative to the current working directory: `ram/notes.txt` or `../ram/notes.txt` (`.` is the current and `..` the parent directory).

#### Access methods
1. **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.
2. **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.
3. **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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is a directory?
   A. A table of free disk blocks
   B. A special file that maps file names to files (name plus attributes or i-node pointer)
   C. The data portion of a file
   D. A device driver
   Answer: B. A directory holds entries for other files. (Key point: Directory)

2. Which is a relative path?
   A. /usr/ram/notes.txt
   B. C:\Users\Ram\notes.txt
   C. ../ram/notes.txt
   D. /notes.txt
   Answer: C. Relative paths start from the current working directory; .. is the parent. (Key point: Relative path)

3. What does direct access require?
   A. Reading all earlier records first
   B. A tape device
   C. An index of keys
   D. Fixed-size records/blocks so any one can be read by number
   Answer: D. Direct access views the file as numbered fixed-length blocks. (Key point: Direct access)

4. What is a disadvantage of indexed sequential access?
   A. The index uses extra space and needs maintenance when records change
   B. Slow keyed lookup
   C. It cannot scan sequentially
   D. It cannot be used on disks
   Answer: A. The index gives fast keyed access at the cost of space and upkeep. (Key point: Indexed sequential drawback)

## Related in Operating System

- [File attributes; directory systems; free blocks](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afile-attribute-directory-free-blocks) — Operating System, chapter 5
- [File allocation and access methods](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afile-allocation-access-methods) — Operating System, chapter 5

## Related in other subjects

- [Random access file transaction processing](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Arandom-access-transaction) — Object Oriented Programming, chapter 8
- [File I/O operations, errors, random access](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afile-io-errors-random-access) — Computer Programming, chapter 10
