Hello friends, In this blog post I am going to explain to you about file operations, as you all know that files are used to store the data information and this information can be retrieved with allowed permission when needed.
Each operating system has a system calls to make basic operations on files like the creation of the file, reading from a file, writing to file, etc. The following are some basic operations on the file.
Creating file operations: this operation is used to create a file. It requires two basic steps. first is to find the space for file in file system and next is to make an entry in the directory for this file. This entry includes the name, size, location of the file.
Reading from file operations: The system call that performs read operation requires two attributes – one is the file name and the other is block, where information is kept after reading.
Writing to file operations: The system call that performs write operation into a file, requires two attributes – one is file name in which data is to be written and other is information that is to be written.
Repositioning within file operations: A file is repositioned from one location to a new location by just reading file entry in directory and modifying location attribute with a new value. This operation does not require actual I/O.
Deleting file operations: In this operation, file entry is erased from the directory and all the space allocated to file is also released.
Truncating file operations: In this operation, only the contents of files are erased and all other attributes of the file remain unchanged except file size.
Open file operations: Before performing operation on a file , a process must open it. The purpose of the open file is to permit the system to read the attributes and list of disk addresses into the main memory for rapid access on later calls.
Close file operations: To free the internal table space, when all the accesses have finished, the file should be closed.
Append file operations: This operation is used to add data to the end of the file. Some system that provides a minimal set of system call do not generally have append, but some other systems provide multiple ways of doing the same thing, and this system sometimes have append.
Seek operations: Seek file operations are used to locate a location where to take the data. One common approach is a system call, which is used to seek the file pointer from a specific place in the file.
Rename operations: Rename operation is used to change the name of the existing file.
Set attributes operations: Some attributes of files are user-settable and can be changed after the file has been created. This system call makes that possible.
Get attributes operations: Get attributes operations are used to return the current value of attributes to the caller program or user.
In the case of any queries, you can write to us at firstname.lastname@example.org we will get back to you ASAP.
Hope! you would have enjoyed this post about types of file operations.
Please feel free to give your important feedbacks in the comment section below.
Have a great time! Sayonara!