[S5] File copy

Estimated time: 30 minutes

Given a file containing arbitrary bytes, you must write a function that copies the file. Obviously, your function cannot modify the content of the original file. Beware that the copied file should have the same permissions as the original file.

Use only open(2), read(2), write(2), stat(2) and close(2).


Write here the body of the function

/*
 * @pre file_name != NULL, name of the original file
 *      new_file_name != NULL, name of the new file (the copy)
 *
 * @post copy the contents of {file_name} to {new_file_name}.
 *       return 0 if the function terminates with success, -1 in case of errors.
 */
int copy(char *file_name, char *new_file_name) {

Information

Author(s) Olivier Martin
Deadline No deadline
Submission limit No limitation
Category Tags File, S5

Tags

Close Permission Copy Open

Sign in