I need to write a C program for finding the differences between two folders, folder1 and folder2.tar and update the contents of folder2.tar with folder1. So I have written using tar –diff utility command like below:
#include <unistd.h>
#include <stdio.h>
main()
{
system("tar df folder2.tar folder1 > file.patch");
system("tar uf folder2 folder1"); //Assume folder2 is the extracted version of folder2.tar
}
Here I have few questions:
- Firstly, I am not able to get the differences in contents of folders into the separate file. I am getting only the modified filename in the folder and time modified
- Secondly, as will be many files in the folders, and after modifying a random file in folder1, how do we specify the path to update only that specific file in folder2.tar?
- How do we write the code for the above scenario?
Any idea !!!!! Please help me if you have so !
Thanks
Try this:
You can then get the modified filenames from the output of diff and pass them to
tar -u. Feel free to wrap it in system() so you can call it a C program, but I’d advise you to make it a bash script: Smaller, faster and you don’t need to recompile when you make changes.