qUncompress Z_DATA_ERROR error
Solved
General and Desktop
-
Hello,
I am facing an issue which I cannot solve when I uncompress data with qUncompress. I need to open an XML file to be read by a QDomDocument.
When tesing this, it works perfectly.
QFile f1(filePath); f1.open(QIODevice::ReadOnly | QIODevice::Text); QByteArray b1 = f1.readAll(); QByteArray b2 = qCompress(b1); QByteArray b3 = qUncompress(b2); document.setContent(b3);
When doing the same through a QFile, it fails with error "qUncompress: Z_DATA_ERROR: Input data is corrupted"
QFile f1(filePath); f1.open(QIODevice::ReadOnly | QIODevice::Text); QByteArray b1 = f1.readAll(); QByteArray b2 = qCompress(b1); QFile f2(filePath + "c"); f2.open(QIODevice::WriteOnly | QIODevice::Text); f2.write(b2); QFile f3(filePath + "c"); f3.open(QIODevice::ReadOnly | QIODevice::Text); QByteArray b3 = qUncompress(f3.readAll()); document.setContent(b3);
I really do not understand the difference in terms of compression/decompression. Any idea ? Thanks !!