File Management
File Management
File
• A file is collection of specific information
stored in the memory of computer system.
• File management is defined as the process of
manipulating files in computer system,
it management includes the process of
creating, modifying and deleting the files.
• The file may have attributes like name, creator,
date, type, permissions etc.
File Structure
• A File Structure should be according to a required
format that the operating system can understand.
• A file has a certain defined structure according to
its type.
• A text file is a sequence of characters organized
into lines.
• A source file is a sequence of procedures and
functions.
• An object file is a sequence of bytes organized
into blocks that are understandable by the
machine.
• When operating system defines different file
structures, it also contains the code to support
these file structure.
Attributes of a File
• Following are some of the attributes of a file :
• Name . It is the only information which is in human-readable
form.
• Identifier. The file is identified by a unique tag(number)
within file system.
• Type. It is needed for systems that support different types of
files.
• Location. Pointer to file location on device.
• Size. The current size of the file.
• Protection. This controls and assigns the power of reading,
writing, executing.
• Time, date, and user identification. This is the data for
protection, security, and usage monitoring.
File Access Methods
• The way that files are accessed and read into
memory is determined by Access methods.
• Usually a single access method is supported by
systems while there are OS's that support
multiple access methods.
• There are three access methods:
• 1. Sequential Access
• 2.Direct Access
• 3.Index Access
1.Sequential Access
• Data is accessed one record right after another
is an order.
• Read command cause a pointer to be moved
ahead by one.
• Such a method is reasonable for tape.
• It is the simplest access method.
• Information in the file is processed in order,
one record after the other.
• This mode of access is by far the most
common;
• 2. Direct Access
• Direct access method also known as relative
access method.
• It is a logical record that allows the program to
read and write record rapidly in no particular
order.
• The direct access is based on the disk model of a
file since disk allows random access to any file
block.
• For direct access, the file is viewed as a numbered
sequence of block or record
• Thus, we may read block 14 then block 59 and
then we can write block 17.
• There is no restriction on the order of reading and
writing for a direct access file.
• 3. Indexed Sequential Access
• It is built on top of Sequential access.
• It uses an Index to control the pointer while
accessing files.
• These methods construct an index for the file.
• The index, like an index in the back of a book,
contains the pointer to the various blocks.
• To find a record in the file, we first search the
index and then by the help of pointer we
access the file directly.
What is a Directory?
• Information about files is maintained by
Directories.
• A directory can contain multiple files.
• It can even have directories inside of them.
• In Windows we also call these directories as
folders.
• Following is the information maintained in a
directory :
• Name : The name visible to user.
• Location : Device and location on the device
where the file header is located.
• Size : Number of bytes/words/blocks in the file.
• Usage : Time of creation, access, modification
etc.
Directory Structure:
• There are several logical structures of a directory,
these are given below.
• 1. Single-level directory –
The single-level directory is the simplest directory
structure.
• In it, all files are contained in the same directory
which makes it easy to support and understand.
• A single level directory has a significant
limitation, however, when the number of files
increases or when the system has more than one
user.
• Since all the files are in the same directory, they
must have a unique name
1.Single level directory:
2.Two level Directory structure: