Results 1 to 2 of 2

Thread: Merging files (*.001, *.002 etc.)

  1. #1
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Merging files (*.001, *.002 etc.)

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Merging files (*.001, *.002 etc.)

    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:
    Qt Code:
    1. int filecount = someFunctionToCalculateTheFileCount();
    2. QFile assembled(fileName);
    3. assembled.open(writeonly); //Check for errors too
    4.  
    5. if the file is open proceed:
    6.  
    7. for (int i = 0; i < filecount; ++i) {
    8. QFile file(fileNameBasedOnIteration);
    9. file.open(readonly) //Do some error checking too
    10.  
    11. 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!!!
    12.  
    13. file.close();
    14. }
    15. assembled.close();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Merging cells in QTableWidget
    By lyucs in forum Newbie
    Replies: 1
    Last Post: 22nd January 2010, 19:15
  2. Replies: 12
    Last Post: 17th June 2009, 05:34
  3. Merging to different QBrushPattern?
    By ashukla in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2008, 04:32
  4. Menubar Merging
    By elcuco in forum Qt Programming
    Replies: 3
    Last Post: 7th April 2007, 15:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.