cp command function using c program | os cs8461 | 4th sem of cse | operating system lab | QT

Опубликовано: 04 Ноябрь 2024
на канале: Quick Through
458
8

operating system laboratory for cse engineering playlist
   • Operating System  

Exp# 3c cp command
Date:
Aim
To simulate cp command using UNIX system call.
Algorithm
1. Get source and destination filename as command-line argument.
2. Declare a buffer of size 1KB
3. Open the source file in readonly mode using open system call.
4. If file does not exist, then stop.
5. Create the destination file using creat system call.
6. If file cannot be created, then stop.
7. File copy is achieved as follows:
a. Read 1KB data from source file and store onto buffer using read system call.
b. Write the buffer contents onto destination file using write system call.
c. If end-of-file then step 8 else step 7a.
8. Close source and destination file using close system call.
9. Stop.