Implementation of "cp -I" linux command
Goals/Tasks
The goal of this project is to copy directories/files quicker than the simple cp command.
Summary
The programm has two arguments: the source (A) file/directory and the destination (T) file/directory. The programm traverses through A, reads the info of the i-nodes and for every a i-node in A it searces the corresponding t i-node in T.
We distinguish 4 cases:
- The
tdoesn't exist in T: in this case thethas to be created in the right place inside T and theato be copied in thet. If the i-node refers to a file, we also have to copy the data of the file. - The
texists in T and is the same as theain A: in this case we do nothing. This is the case where the quick incremental copy "wins" the simplecp. - The
texists in T, but there is no corresponding inain A: in this case the file from A was deleted and we have to update the T. - The
texists in T and it's not the same as theain A: in this case we have to copy the content of thea i-nodetot i-node.
When 2 files are not the same:
- obviously, we don't read the content of the files, because this is time-consuming.
- if a refers to a file and t refers to a directory
- if a and t refer to directories, we check their content recursively
- if a and t refer to files with different size
- if a and t refer to files with the same size but the t is older than a
If the i-nodes a and t are referring to directories, we have to recursively do the above steps.
Compilation
./quic -v -d origindir destdir
origindiris the source directorydestdiris the destination directoryvis a flag and prints info about choices/actions of the programm regarding to copying/deleting files.dis a flag that defines that the files that were deleted from the source directory must not exist in the destination folder.