Suppose I have two .dat files; one on my computer and the other one on the other side of the earth - with data constantly being serialized into them through a QDataStream
.
The data is parsed the same way – first some sort of ID and then an object associated with that particular ID.
QFile file("data.dat");
QDataStream stream(&file);
file.open("QIODevice::ReadWrite");
stream << *id*; // ID goes in.
stream << *data_object*; // Object with interesting data is serialized into the file.
file.close();
After a while – the first one might look something like this (illustratory, not syntactically correct):
//-------------------------------------DATA.DAT------------------------------------//
ID:873482025
dataObject
ID:129845379
dataObject
ID:836482455
dataObject
ID:224964811
dataObject
ID:625444876
dataObject
ID:215548669
dataObject
//-------------------------------------DATA.DAT------------------------------------//
But the second one hasn't caught up quite yet.
//-------------------------------------DATA.DAT------------------------------------//
ID:873482025
dataObject
ID:129845379
dataObject
ID:836482455
dataObject
//-------------------------------------DATA.DAT------------------------------------//
Is it possible to take both files – detect the differences between them and then "fuse" in the ones that are missing from the second but are present in the first?
Obviously this could be achieved by writing a function extracts the innards of the files, categorizes the contents individually, compares them and so forth – but is there a way to do this by just handling the files themselves, without having to parse the contents individually?