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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!