8
Fundamental File Fundamental File Processing Processing Operations Operations Physical files and Logical files Physical files and Logical files Opening files Opening files Closing files Closing files Reading and Writing Reading and Writing Seeking Seeking Special Characters in Files Special Characters in Files

Fundamental File Processing Operations

  • Upload
    rico

  • View
    4.832

  • Download
    3

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Fundamental File Processing Operations

Fundamental File Fundamental File Processing OperationsProcessing Operations

Physical files and Logical filesPhysical files and Logical filesOpening filesOpening filesClosing filesClosing files

Reading and WritingReading and WritingSeekingSeeking

Special Characters in FilesSpecial Characters in Files

Page 2: Fundamental File Processing Operations

Physical Files and Logical Physical Files and Logical FilesFiles

Physical filePhysical file

A file that actually exists on A file that actually exists on secondary storage. It is the file secondary storage. It is the file as known by the computer as known by the computer operating system and that operating system and that appears in its file directory.appears in its file directory.

Page 3: Fundamental File Processing Operations

Logical FilesLogical Files

The file as seen by the program. The The file as seen by the program. The use of logical files allows a program use of logical files allows a program to describe operations to be to describe operations to be performed on a file without knowing performed on a file without knowing what actual physical file will be used. what actual physical file will be used. The program may then be used to The program may then be used to process any one of a number of process any one of a number of different files that share the same different files that share the same structure.structure.

Physical Files and Logical Physical Files and Logical FilesFiles

Page 4: Fundamental File Processing Operations

Opening FilesOpening Files

2 ways of manipulation of files:2 ways of manipulation of files:

1.1. Open an existing fileOpen an existing file

2.2. Create a new file, deleting Create a new file, deleting any existing contents in the any existing contents in the physical file.physical file.

Page 5: Fundamental File Processing Operations

Closing FilesClosing Files

AnalogyAnalogy Telephone line, like hanging up the Telephone line, like hanging up the

phone. When you hang up the phone. When you hang up the phone, the phone is available for phone, the phone is available for taking or placing another call; when taking or placing another call; when you close a file, the logical file name you close a file, the logical file name or file descriptor is available for use or file descriptor is available for use with another file. Closing a file that with another file. Closing a file that has been used for output also has been used for output also ensures that everything has been ensures that everything has been written to the file.written to the file.

Page 6: Fundamental File Processing Operations

Reading and WritingReading and Writing

Fundamental to file processingFundamental to file processing Actions that make file Actions that make file

processing an processing an input/outputinput/output (I/O) (I/O) operation.operation.

Page 7: Fundamental File Processing Operations

SeekingSeeking

The action of moving directly to a The action of moving directly to a certain position in a file.certain position in a file.

Requires at least two pieces of Requires at least two pieces of information, source file and offset.information, source file and offset.

1.1. Source file – the logical file name Source file – the logical file name in which the seek will occurin which the seek will occur

2.2. Offset – the number of positions in Offset – the number of positions in the file the pointer is to be moved the file the pointer is to be moved from the start of the file.from the start of the file.

Page 8: Fundamental File Processing Operations

Special Characters in FilesSpecial Characters in Files

Creating a file structures may Creating a file structures may encounter some difficulty with encounter some difficulty with extra, unexpected characters extra, unexpected characters that turn up in the files, with that turn up in the files, with characters that disappear, and characters that disappear, and with numeric counts that are with numeric counts that are inserted into the files.inserted into the files.