View Full Version : Merging files (*.001, *.002 etc.)
Altertwin
11th July 2010, 11:09
I've got a problem with merging files. I don't know how to join files like: *.001, *.002 etc. from (for example) Total Commander using C++. Have you hot any ideas or suggestions?
tbscope
11th July 2010, 11:15
These files should just be cuts of a larger file. In other words, begin with file 001 and write its contents to a new file called "assembledfile" for example. Then read the 002 file and append its contents to the "assembledfile" file.
In pseudocode:
int filecount = someFunctionToCalculateTheFileCount();
QFile assembled(fileName);
assembled.open(writeonly); //Check for errors too
if the file is open proceed:
for (int i = 0; i < filecount; ++i) {
QFile file(fileNameBasedOnIteration);
file.open(readonly) //Do some error checking too
if the file is open read all its contents and write it to the assembled file. You might want to use a data stream if the files are binary!!!
file.close();
}
assembled.close();
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.