1. • 1. Fundamental File Processing Operations
Physical files and Logical files Opening files
Closing files Reading and Writing Seeking
Special Characters in Files
• 2. Physical Files and Logical Files Physical
file A file that actually exists on secondary
storage. It is the file as known by the computer
operating system and that appears in its file
directory.
• 3. Logical Files The file as seen by the
program. The use of logical files allows a
program to describe operations to be
performed on a file without knowing what
actual physical file will be used. The program
may then be used to process any one of a
number of different files that share the same
structure. Physical Files and Logical Files
• 4. Opening Files 2 ways of manipulation of
files: Open an existing file Create a new file,
deleting any existing contents in the physical
file.
• 5. Closing Files Analogy Telephone line, like
hanging up the phone. When you hang up the
phone, the phone is available for taking or
placing another call; when you close a file, the
logical file name or file descriptor is available
for use with another file. Closing a file that has
been used for output also ensures that
everything has been written to the file.
2. • 6. Reading and Writing Fundamental to file
processing Actions that make file processing
an input/output (I/O) operation.
• 7. Seeking The action of moving directly to a
certain position in a file. Requires at least two
pieces of information, source file and offset.
Source file – the logical file name in which the
seek will occur Offset – the number of
positions in the file the pointer is to be moved
from the start of the file.
• 8. Special Characters in Files Creating a file
structures may encounter some difficulty with
extra, unexpected characters that turn up in the
files, with characters that disappear, and with
numeric counts that are inserted into the files.