A problem regarding QuaZip
Hi,
I'm using QuaZip to archive my files like the following;
Code:
QByteArray LoggerManager
::packFiles(const QString
& p_name,
const QByteArray
& p_BytesToBrCompressed
) {
QuaZip zip(testZip);
zip.setFileNameCodec("IBM866"); /* or Windows-1250 */
if(!zip.open(QuaZip::mdCreate))
{
qWarning("testCreate(): zip.open(): %d", zip.getZipError());
return NULL;
}
QString loc
= qApp
->applicationDirPath
() + "/logs/error_log/";
QFileInfoList files
=QDir(loc
).
entryInfoList();
QuaZipFile outFile(&zip);
char c;
{
if(!file.isFile())
continue;
inFileTmp.setFileName(file.fileName());
inFile.setFileName(file.filePath());
{
qWarning("testCreate(): inFile.open(): %s", inFile.errorString().toLocal8Bit().constData());
return NULL;
}
if(!outFile.
open(QIODevice::WriteOnly, QuaZipNewInfo
(inFileTmp.
fileName(), inFile.
fileName()))) {
qWarning("testCreate(): outFile.open(): %d", outFile.getZipError());
return NULL;
}
while(inFile.getChar(&c)&&outFile.putChar(c));
if(outFile.getZipError()!=UNZ_OK)
{
qWarning("testCreate(): outFile.putChar(): %d", outFile.getZipError());
return NULL;
}
compressedData = outFile.readAll();
outFile.close();
if(outFile.getZipError()!=UNZ_OK)
{
qWarning("testCreate(): outFile.close(): %d", outFile.getZipError());
return NULL;
}
inFile.close();
}
zip.close();
if(zip.getZipError()!=0)
{
qWarning("testCreate(): zip.close(): %d", zip.getZipError());
return NULL;
}
return compressedData;
}
The problem is; I want to send this zipped content to an HTTP server. But
Code:
compressedData = outFile.readAll();
is non-sense since outFile is writeOnly which makes compressedData empty string.
I try the following to overcome this situation;
Code:
if(QFile::exists(reader.
fileName())) {
{
compressedData.append(reader.readAll());
}
}
But it didn't work either..
Any ideas?
Re: A problem regarding QuaZip
Does the server support only HTTP? FTP would be better.
Is the archive read-only file (in the file system) or do you mean its only the attribute with which you open the QFile object, but the file it self is not read-only?
Quote:
But it didn't work either..
By "not working" do you mean compressData is empty?
Re: A problem regarding QuaZip
Quote:
Does the server support only HTTP? FTP would be better.
Yepp!
Quote:
Is the archive read-only file (in the file system) or do you mean its only the attribute with which you open the QFile object, but the file it self is not read-only?
arcihive is opened write-only by default. That's why I can't read it. And I opened QFile object ad read-only by myself.
Quote:
By "not working" do you mean compressData is empty?
Sorry..Yes.
Re: A problem regarding QuaZip
and you are sure (by means of stepping trough or debug message) that:
compressedData.append(reader.readAll());
is being called?
Re: A problem regarding QuaZip
Re: A problem regarding QuaZip
What is the size of the file when you look it up with a file manager?
What is the size of the file when you do reader.size()?
Re: A problem regarding QuaZip
it's size seems completely logical to me. About 20000 bytes.
Re: A problem regarding QuaZip
And you can't reopen it in read only mode after you're done creating the archive?
Re: A problem regarding QuaZip
Hi,
I'm very sorry to take your time but my problem caused by VS 2010 debugger. I was actually reading the file contents properly but the debugger doesn't show me. When I did qDebug, I saw all the contents of the file that i'm reading.
thanks for your care.