Results 1 to 3 of 3

Thread: Using quazip for extracting multiple files.

  1. #1
    Join Date
    Jul 2013
    Posts
    27
    Thanks
    11
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Using quazip for extracting multiple files.

    Hello friends,
    I am using QuaZip for extracting multiple files from a archive. I just need help on one small thing. As per the documentation of quazip says, amongst, JICompress, there is a method which can be used to extract multiple files at a given time. Link:- http://quazip.sourceforge.net/classJ...a28f837fab73ae

    QStringList JlCompress::extractFiles(QString fileCompressed,QSringList files,QString dir=QString() )[static]
    Parameters:
    fileCompressed The name of the archive.
    files The file list to extract.
    dir The directory to put the files to, the current directory if left empty.
    Returns:
    The list of the full paths of the files extracted, empty on failure.

    My apologies for the redundancy. As of now, i have the object and all of JICompress. I want to extract all files from the archive. I dont understand 2 parameters here. The return parameter, I dont understand why its necessary, as we are specifying the path of extraction. And what should i put for the 2nd parameter where is says the file list to extract. How can i say all, there are a lot of files, i cant just go on specifying names for each, as their names might change. Sorry for the long thread. Thank you for your time.

  2. #2
    Join Date
    Nov 2007
    Posts
    55
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using quazip for extracting multiple files.

    here a snippet from a library I wrote for my own purpose:

    Qt Code:
    1. void extractAll( QuaZip& archive )
    2. {
    3. // extracts all files from the archive and saves
    4. // them onto disk
    5. //
    6. // just a simple implementation for evaluation.
    7. // error handling has not been implemented yet!
    8.  
    9. for( bool f = archive.goToFirstFile(); f; f = archive.goToNextFile() )
    10. {
    11. // set source file in archive
    12. QString filePath = archive.getCurrentFileName();
    13. QuaZipFile zFile( archive.getZipName(), filePath );
    14. // open the source file
    15. zFile.open( QIODevice::ReadOnly );
    16. // create a bytes array and write the file data into it
    17. QByteArray ba = zFile.readAll();
    18. // close the source file
    19. zFile.close();
    20. // set destination file
    21. QFile dstFile( filePath );
    22. // open the destination file
    23. dstFile.open( QIODevice::WriteOnly | QIODevice::Text );
    24. // write the data from the bytes array into the destination file
    25. dstFile.write( ba.data() );
    26. //close the destination file
    27. dstFile.close();
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to alainstgt for this useful post:

    akshaysulakhe (27th July 2013)

  4. #3
    Join Date
    Jul 2013
    Posts
    27
    Thanks
    11
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Using quazip for extracting multiple files.

    Thanks, i mainly wanted extractDir, which i got from elsewhere.

Similar Threads

  1. Multiple UI files
    By Diblye in forum Newbie
    Replies: 5
    Last Post: 29th June 2012, 00:24
  2. Qt Multiple Ui files.....
    By Rajeshsan in forum Qt Programming
    Replies: 4
    Last Post: 19th January 2010, 04:14
  3. Extracting files from a zip file
    By Althor in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2009, 10:39
  4. Extracting text from files (AKA I'm a newbie!)
    By mike phillips in forum Newbie
    Replies: 16
    Last Post: 30th January 2009, 17:27
  5. Extracting strings in files
    By ComaWhite in forum Qt Programming
    Replies: 2
    Last Post: 7th October 2008, 00:01

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.