Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions