Results 1 to 1 of 1

Thread: Unable to open zipped file which is zipped with Quazip

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Unable to open zipped file which is zipped with Quazip

    Hi,

    After I zip my data using the code below, I can create the zip file and it's size is quite logical. But when I attempt to unzip it using WinZip, Winzip gives me an error.

    I'm working on Microsoft VS 2O1O and using Qt 4.8.

    Any ideas?

    Qt Code:
    1. QByteArray LoggerManager::packFiles(const QString& p_name, const QByteArray& p_BytesToBrCompressed)
    2. {
    3. QString testZip = p_name;
    4. QuaZip zip(testZip);
    5.  
    6. zip.setFileNameCodec("IBM866"); /* or Windows-1250 */
    7.  
    8. if(!zip.open(QuaZip::mdCreate))
    9. {
    10. qWarning("testCreate(): zip.open(): %d", zip.getZipError());
    11. return NULL;
    12. }
    13.  
    14. QString loc = qApp->applicationDirPath() + "/logs/error_log/";
    15.  
    16. QFileInfoList files=QDir(loc).entryInfoList();
    17. QFile inFile;
    18. QFile inFileTmp;
    19. QuaZipFile outFile(&zip);
    20. char c;
    21. QByteArray compressedData = "";
    22.  
    23. if(!outFile.open(QIODevice::WriteOnly, QuaZipNewInfo("", "")))
    24. {
    25.  
    26. qWarning("testCreate(): outFile.open(): %d", outFile.getZipError());
    27. return NULL;
    28. }
    29.  
    30. //while(inFile.getChar(&c)&&outFile.putChar(c));
    31.  
    32. for(int i=0; i < p_BytesToBrCompressed.size(); i++)
    33. {
    34. outFile.putChar(p_BytesToBrCompressed.at(i));
    35. }
    36.  
    37. if(outFile.getZipError()!=UNZ_OK)
    38. {
    39. qDebug() << "AQQQQQQQQQQQQQQQQ!!";
    40. qWarning("testCreate(): outFile.putChar(): %d", outFile.getZipError());
    41. return NULL;
    42. }
    43.  
    44. outFile.close();
    45.  
    46. if(outFile.getZipError()!=UNZ_OK)
    47. {
    48. qWarning("testCreate(): outFile.close(): %d", outFile.getZipError());
    49. return NULL;
    50. }
    51.  
    52. QFile reader(p_name);
    53. if(QFile::exists(p_name))
    54. {
    55. if(reader.open(QIODevice::ReadOnly))
    56. {
    57. compressedData.append(reader.readAll());
    58. }
    59. }
    60.  
    61. inFile.close();
    62.  
    63. zip.close();
    64.  
    65. if(zip.getZipError()!=0)
    66. {
    67. qWarning("testCreate(): zip.close(): %d", zip.getZipError());
    68. return NULL;
    69. }
    70.  
    71. qDebug() << "Compressed Data: " << compressedData;
    72.  
    73. return compressedData;
    74. }
    To copy to clipboard, switch view to plain text mode 


    Added after 1 24 minutes:


    Hi again,

    The problem was in;

    Qt Code:
    1. if(!outFile.open(QIODevice::WriteOnly, QuaZipNewInfo("", "")))
    To copy to clipboard, switch view to plain text mode 

    so replacing the above line with;

    Qt Code:
    1. if(!outFile.open(QIODevice::WriteOnly, QuaZipNewInfo("syd_barrett.txt")))
    To copy to clipboard, switch view to plain text mode 

    solved the problem.

    Unfortunately in Quazip, there is nothing to alert the user for this case at least.

    Anyway, the problem solved and thanks.
    Last edited by zgulser; 12th October 2012 at 18:14.

Similar Threads

  1. Unable to open Help option in Qt creator.
    By Channareddy in forum Qt Tools
    Replies: 2
    Last Post: 22nd July 2011, 10:48
  2. Replies: 1
    Last Post: 18th January 2011, 12:48
  3. Replies: 3
    Last Post: 1st November 2010, 16:33
  4. Replies: 9
    Last Post: 20th May 2010, 09:55
  5. [Solved] QuaZIP and getting a file out of an archiv
    By Lykurg in forum Qt Programming
    Replies: 0
    Last Post: 6th March 2008, 07:44

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.