- A file is the most important and basic entity for data storage. In this article we will get some basic knowledge about concept of a file, different attributes of file, types of file and how a file is useful for the operating system.
A file is a collection of related information stored on a peripheral device
- File is a logical storage unit.
- Computer store information on different storage area such as magnetic disk, tap drives etc.
- These storage devices are usually of non-volatile type that means contents are stored despite of power failure.
- It is a named collection of related information that is recorded on secondary storage. It is the smallest allotment of logical secondary storage as per the user’s point of view.
- File may represent programs or data.
- Data files may be numeric, alphabetic, alphanumeric or binary.
- In general a file is a sequence of bits, bytes, lines or records whose meaning is defined by the file creator.
- A file can store different information such as source program, object program, executable program, numeric data/text, database records, Graphic Image etc.
- Each file has certain structure according to its type.
- A text file is represented as a sequence of characters organized into lines.
- A source file is a sequence of sub routines and functions.
- An object file is a sequence of bytes organized into block which is understandable by system linker. Usually it has the .obj extension.
- Executable file is a series of binary code that can be executed by the CPU. It has the .exe extension.
Types of File
- To perform an operation on the file, the O/S must recognize its types.
- Normally file type is implemented by including it as a part of file name.
- The type of file represents the contents of that file.
- File name is divided into two parts:
- By this way user and O/S can easily identify type of the file.
- In Dos the name can be of 8 characters long followed by a period and extension up to 3 characters.
- The system uses the extension to identify the file type and allow operations that can be perform on that file.
- For example only file with .com, .exe or .bat extension are used for executing a file. .com and .exe are two forms of binary executable file whereas .bat file is a batch files.
- DOS supports only a few extensions but application program also uses extension to indicate file types.
|Executable||.exe, .com, bin, none.||Need to run m/c lang .prg|
|Object||.o, .obj||Compile, m/c Lang; non linked|
|Source code||.c, .cc, .java, .asm, .a, .pas||Source code in various Lang|
|Batch file||.bat, .sh||Commands used for interpreting by o/s|
|Text||.txt, .rtf, .doc||Textual data documents|
|Word file||.wp, .tex, .ry, .doc||Various word processor formats|
|Library||.lib, .a, .so, .dll, .mpeg, .mov, .rm||Libraries routine for programs|
|Archive||.arc, .zip, rar||Related files|
|Multimedia||.mpeg, .mov, .rm, mp4, mkv||Binary file with audio, video information|
- UNIX uses a magic number to represent file type.
- This number is stored at the beginning of a file at the time of creation.
- Not all files have magic numbers so systems features cannot be based on this type of information.
- It is roughly allocate to indicate some of the file types such as program file and scripting file
- UNIX also does not record the name of the creative program.
- File attributes specifies properties of the file
- It also defines behavior of any file.
- A file can be referred by its name.
- A name is usually a string of characters such as example.c
- Some system treats upper and lower case character names differently while other systems consider them to be equivalent.
- A file has certain attributes that vary from the o/s to o/s.
- Some common file attributes are as follow:
- Name: Symbolic file name is the only information which is in human readable form.
- Type: It indicates the type of the file such as text, binary, object etc.
- Location: It is a pointer to the location of the file where a file is stored.
- Size: It determines the current size of the file. (bytes, blocks)
- Protection: It provides access control information to a user who can read write and execute it.
- Date, Time and User Identifier: It provides the information about the file creation date/time, last modification and last used date/time. It is helpful for security and usage monitoring.
- All information about each file is kept in the directory structure which resides on secondary storage.
- Normally the directory entry consists of files name and identifier.
- The identifier locates all the attributes of the files.
- Files and directories are non volatile storage they must be store on the device and brought into memory as needed.