El dimarts, 3 de novembre de 2020, a les 17:41:28 CET, Gabriel Domínguez Camarero va escriure: > Hi, > > > > The first question " I have tried to do this but there some error that block > me to open a file. I dont know if i am using correctly the class > KCompressionDevice." is related with the code down bellow. > > > > > auto kgzip = KCompressionDevice(QUrl(where.toString() + “/” + fileName + > “.gz”).toLocalFile(), KCompressionDevice::GZip); > assert(kgzip.isOpen() == true); > > > > kgzip.write(QString("hello World").toUtf8()); > kgzip.close();
Well the code above doesn't compile; you can't assign KCompressionDevice around. Also if you don't open the device, it won't open itself. So #include <KCompressionDevice> #include <QDebug> int main(int argc, char *argv) { KCompressionDevice kgzip("hola.gz", KCompressionDevice::GZip); kgzip.open(QIODevice::WriteOnly); qDebug() << kgzip.isOpen(); kgzip.write(QString("hello World").toUtf8()); kgzip.close(); } This does compile and creates a hola.gz file with hello Worlds as its contents. Cheers, Albert > > > El 02/11/2020 22:34 Albert Astals Cid <aa...@kde.org> escribió: > > > > > El dilluns, 2 de novembre de 2020, a les 22:23:44 CET, Gabriel Domínguez > Camarero va escriure: > Hello I am gabridc, > Hello Gabriel, this KDE Frameworks devel is for discussion around development > *of* KDE Frameworks not *with* KDE Frameworks, your question belongs to > kde-devel@kde.org > > > > > > > > I am a developer for Index-fm and we are trying to integrate KArchive in the > file explorer, I have tried to do this but there some error that block me to > open a file. I dont know if i am using correctly the class KCompressionDevice. > Is this question related to the code down below? or different? > > > Also, I would to ask another question because I would like to write a file > inside my file.gz but in this case I dont have the function writeFile like > KTar or KZip classes. > You can't write a file *inside* a gz file, a gz is not multiple files, it's > just one file (a .tar.gz is still just one gz file, it's the tar part that > has multiple files). > > > Cheers, > Albert > > > > > > > auto kgzip = KCompressionDevice(QUrl(where.toString() + “/” + fileName + > “.gz”).toLocalFile(), KCompressionDevice::GZip); > assert(kgzip.isOpen() == true); > > > > > kgzip.write(QString("hello World").toUtf8()); > kgzip.close();