سؤال

I'm basically trying to extract a Mac application from a zip file using QuaZip. The code I'm using is:

QuaZip zip("file.zip");
qDebug() << zip.open(QuaZip::mdUnzip);

QuaZipFile file(&zip);
QFile out("application.app");
out.open(QIODevice::WriteOnly);

for(bool f=zip.goToFirstFile(); f; f=zip.goToNextFile()) {
    file.open(QIODevice::ReadOnly);
    //same functionality as QIODevice::readData() -- data is a char*, maxSize is qint64
    char c;
    while (file.getChar(&c)) out.putChar(c);      

    file.close();
}

out.flush();
out.close();

zip.close();

If I try to start the extracted app, I get an error message saying I "can't open the Application, because the Classic-Environment is no longer supported." I tried to make the .app executable but it still didn't work. I don't know any other easy way to extract an application using Qt.

I extracted it with the normal archiver and the application worked.

هل كانت مفيدة؟

المحلول

I'm not super familiar with QuaZip, but it almost looks like you're trying to extract the whole archive to a single file called "application.app", which is pretty seriously wrong. Applications are actually folders, not files -- the Finder just displays the folder (which has a name ending in ".app") as if it were a single file.

If you can dig up an example of using QuaZip to extract a ZIP file, you should just be able to use that code largely unmodified (other than the __MACOSX metadata, possibly).

نصائح أخرى

It may be easier to just call unzip from your app using QProcess or system().

unzip -q <path-to-zip> -d <path-to-destionation>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top