void CZipFileDecompressor::DecompressNextMemberL(CZipFileMember& aMember)
    {
    __ASSERT_ALWAYS(!iUncompressedFile.SubSessionHandle(), 
                    User::Invariant());
    __ASSERT_ALWAYS(!iUncompressedData, User::Invariant());
    
    
    //Ignore entries that has zero uncompressed size.
    //(This includes e.g. directories) 
    if (aMember.UncompressedSize() > 0)
        {
        const TChar KDirectorySeparator('\\');
        
        TUint32 uncompressedSize = aMember.UncompressedSize();
        HBufC8* uncompressedData = HBufC8::NewLC(uncompressedSize);
        
        RZipFileMemberReaderStream* readerStream;
        User::LeaveIfError(iZipFile->GetInputStreamL(&aMember, readerStream));
        CleanupStack::PushL(readerStream);
        
        TPtr8 uncompressedDataPtr = uncompressedData->Des();
        User::LeaveIfError(readerStream->Read(uncompressedDataPtr, 
                                              uncompressedDataPtr.MaxLength()));
        
        CleanupStack::PopAndDestroy(readerStream);
        
        HBufC* fileName = aMember.Name()->AllocLC();
        TPtr fileNamePtr= fileName->Des();
        TInt lastDirectorySeparator = fileName->LocateReverse(KDirectorySeparator);
        if (lastDirectorySeparator >= 0)
            {
            fileNamePtr = fileName->Mid(lastDirectorySeparator+1);
            }
        
        TParsePtr fileNameParser(fileNamePtr);
        
        User::LeaveIfError(iUncompressedFile.Replace(iFileServer, 
                                                     fileNameParser.NameAndExt(), 
                                                     EFileWrite));            
        CleanupStack::PopAndDestroy(fileName);
        
        CleanupStack::Pop(uncompressedData);
        iUncompressedData = uncompressedData;
        
        iUncompressedFile.Write(*iUncompressedData, iStatus);
        SetActive();
        }
    else
        {
        iStatus = KRequestPending;
        SetActive();
        TRequestStatus* ownStatus = &iStatus;
        User::RequestComplete(ownStatus, KErrNone);
        }
    }
// static
QString WidgetUnzipUtilityS60::fileContentsL(const QString& aZipFileName, const QString& aFileName, 
const Qt::CaseSensitivity& cs)
{
    QString zipFileName = QDir::toNativeSeparators(aZipFileName);
    QString contents;

    TPtrC16 zName(reinterpret_cast<const TUint16*>(zipFileName.utf16()));

    RFs iFs;

    User::LeaveIfError(iFs.Connect());
    CZipFile *zipfile = CZipFile::NewL(iFs, zName);
    CleanupStack::PushL(zipfile);

    CZipFileMemberIterator *members = zipfile->GetMembersL();
    CZipFileMember* member;
    while ((member = members->NextL()) != 0) {
        QString filename = QString::fromUtf16(member->Name()->Ptr(), member->Name()->Length());

        // If the member is the desired file, extract it
        if (!filename.compare(aFileName, cs)) {
            RZipFileMemberReaderStream *stream;
            zipfile->GetInputStreamL(member, stream);
            CleanupStack::PushL(stream);

            HBufC8 *buffer = HBufC8::NewLC(member->UncompressedSize());
            TPtr8 bufferPtr(buffer->Des());
            User::LeaveIfError(stream->Read(bufferPtr, member->UncompressedSize()));

            QByteArray data(reinterpret_cast<const char*>(buffer->Ptr()), buffer->Length());
            QString ret(data);

            CleanupStack::PopAndDestroy(3); // zipfile, stream, buffer
            return ret;
        }
    }

    CleanupStack::PopAndDestroy();
    return contents;
}
TBool WidgetUnzipUtilityS60::RunUnzipL()
    {
    CZipFileMember* member = iMembers->NextL();
    if (member)
        {
        CleanupStack::PushL(member);
        RZipFileMemberReaderStream* stream;
        User::LeaveIfError(iZipFile->GetInputStreamL(member, stream));
        CleanupStack::PushL(stream);

        HBufC8* buffer = HBufC8::NewLC(member->UncompressedSize());
        TPtr8 bufferPtr(buffer->Des());
        User::LeaveIfError(stream->Read(bufferPtr, member->UncompressedSize()));

        TFileName text;
        text.Copy(*iTempZipPath);
        text.Append(_L('\\'));
        text.Append(*member->Name());

        HBufC* zipedFileNameAndPath = text.AllocLC();

        TInt index = zipedFileNameAndPath->LocateReverse('\\');

        if (index >= 0)
            {
            TPtrC path = zipedFileNameAndPath->Left(index + 1);
            iFs.MkDirAll(path); // errors are ok
            }

        if (zipedFileNameAndPath->Right(1).Compare(_L('\\')) != 0)
            {
            RFile file;
            CleanupClosePushL(file);
            file.Replace(iFs,*zipedFileNameAndPath,EFileWrite);
            User::LeaveIfError(file.Write(*buffer));
            CleanupStack::PopAndDestroy(); // file
            }
        iUncompressedSize += member->UncompressedSize();
        CleanupStack::PopAndDestroy(4);
        return ETrue;
        }
    else
        {
        return EFalse;
        }
    }