Question
I need help with the following assignment in C in the most basic code nothing too advances if possible. It is required to include all
I need help with the following assignment in C in the most basic code nothing too advances if possible.
It is required to include all necessary error checking for the file copy assignment. The following is an outline of the programs structure:
Take source file name and destination file name from command line
test whether the source file exists // system call
if source file does not exist
display error message based on the error number //using strerror(errno)
exit
else if it is not readable
display error message based on the error number
exit
open the source file for read //system call
if failed to open the source file
display error message based on the error number
exit
test whether the destination file exists // system call
if the destination file exists
prompt user whether to overwrite the destination file
if user enters 0 for no
prompt user whether to append to the destination file
if user enters 0 for no
display a message
exit
else
open the destination for append //system call
else
open the destination for overwrite //system call
else
get the source file status using stat system call //stat() system call
open/create the destination file using the same st_mode as the source file //system call
copy file as shown in cpUnix.c
close both files //close() system call
The following system calls are useful: (http://linux.die.net/man/2/syscalls)
open read write close access stat
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started