<aside>
💡
Summary of Section 10.1: Files
</aside>
File Concept
- A file is a named collection of data stored on secondary storage.
- Managed by the file system (FS), which provides a high-level interface for users.
- File Access Methods:
- Sequential Access: Reads/writes in order (e.g., text files).
- Direct Access: Jumps to a specific record (used in databases).
- Byte-Oriented Access: Reads/writes a specific number of bytes.
- Record-Oriented Access: Reads/writes structured records.
🔹 Benefit: Users interact with files without worrying about hardware details.
File Types
- Data and Metadata:
- Data → Visible content of a file.
- Metadata → Stored in a file header (format, structure).
- Identifying File Types:
- Magic Number (hidden inside the file header).
- File Extension (e.g.,
.txt
, .exe
).
- Weak vs. Strong Typing:
- Weak Typing: OS guesses file type from extension (e.g., Windows).
- Strong Typing: OS uses magic numbers to enforce correct handling.
🔹 Example: Renaming a .docx
file to .txt
may still open in Word but could be unreadable in Notepad.
Exercises and Applications
- Comparing Access Methods:
- Determine which methods apply to different file types.
- File Type Recognition:
- Analyze how extensions and magic numbers affect file handling.
- Enforcing File Types:
- Compare weak vs. strong file typing.
This section explains file management, access methods, and file type identification, focusing on user interaction and OS enforcement.