Hi,

I'm using QuaZip to archive my files like the following;

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. foreach(QFileInfo file, files)
  24. {
  25. if(!file.isFile())
  26. continue;
  27.  
  28. inFileTmp.setFileName(file.fileName());
  29. inFile.setFileName(file.filePath());
  30.  
  31. if(!inFile.open(QIODevice::ReadOnly))
  32. {
  33. qWarning("testCreate(): inFile.open(): %s", inFile.errorString().toLocal8Bit().constData());
  34. return NULL;
  35. }
  36.  
  37. if(!outFile.open(QIODevice::WriteOnly, QuaZipNewInfo(inFileTmp.fileName(), inFile.fileName())))
  38. {
  39.  
  40. qWarning("testCreate(): outFile.open(): %d", outFile.getZipError());
  41. return NULL;
  42. }
  43.  
  44. while(inFile.getChar(&c)&&outFile.putChar(c));
  45.  
  46. if(outFile.getZipError()!=UNZ_OK)
  47. {
  48. qWarning("testCreate(): outFile.putChar(): %d", outFile.getZipError());
  49. return NULL;
  50. }
  51.  
  52. compressedData = outFile.readAll();
  53.  
  54. outFile.close();
  55.  
  56. if(outFile.getZipError()!=UNZ_OK)
  57. {
  58. qWarning("testCreate(): outFile.close(): %d", outFile.getZipError());
  59. return NULL;
  60. }
  61.  
  62. inFile.close();
  63. }
  64.  
  65. zip.close();
  66.  
  67. if(zip.getZipError()!=0)
  68. {
  69. qWarning("testCreate(): zip.close(): %d", zip.getZipError());
  70. return NULL;
  71. }
  72.  
  73. return compressedData;
  74. }
To copy to clipboard, switch view to plain text mode 

The problem is; I want to send this zipped content to an HTTP server. But

Qt Code:
  1. compressedData = outFile.readAll();
To copy to clipboard, switch view to plain text mode 

is non-sense since outFile is writeOnly which makes compressedData empty string.

I try the following to overcome this situation;

Qt Code:
  1. QFile reader(p_name);
  2. if(QFile::exists(reader.fileName()))
  3. {
  4. if(reader.open(QIODevice::ReadOnly))
  5. {
  6. compressedData.append(reader.readAll());
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 

But it didn't work either..

Any ideas?