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
t
doesn't exist in T: in this case thet
has to be created in the right place inside T and thea
to be copied in thet
. If the i-node refers to a file, we also have to copy the data of the file. - The
t
exists in T and is the same as thea
in A: in this case we do nothing. This is the case where the quick incremental copy "wins" the simplecp
. - The
t
exists in T, but there is no corresponding ina
in A: in this case the file from A was deleted and we have to update the T. - The
t
exists in T and it's not the same as thea
in A: in this case we have to copy the content of thea i-node
tot 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
origindir
is the source directorydestdir
is the destination directoryv
is a flag and prints info about choices/actions of the programm regarding to copying/deleting files.d
is a flag that defines that the files that were deleted from the source directory must not exist in the destination folder.