Esempio n. 1
0
	SnapshotItem(const IFileContainer *container, const Location &fileName, const struct RARHeaderDataEx &info, SnapshotItem *parent) :
		::VFS::SnapshotItem(container, unpackedSize(info), parent)
	{
		m_data.path = QString::fromWCharArray(info.FileNameW);
		m_data.fileName = fileName;
		m_data.fileSize = totalSize();
		m_data.lastModified = fromDosTime(info.FileTime);
	}
Esempio n. 2
0
HRESULT CHandler::GetProperty(quint32 index, PROPID propID, QVariant *value)
{
    QVariant prop;
    const CItemEx &item = *m_Items[index];
    switch (propID) {
    case kpidPath:
        prop = NItemName::GetOSName2(item.Name);
        break;
    case kpidIsFolder:
        prop = item.IsDirectory();
        break;
    case kpidSize:
        prop = item.UnPackSize;
        break;
    case kpidPackedSize:
        prop = item.PackSize;
        break;
    case kpidLastWriteTime: {
        prop = fromDosTime(QByteArray((char *)&item.Time, 4));
        break;
    }
    case kpidAttributes:
        prop = item.GetWinAttributes();
        break;
    case kpidEncrypted:
        prop = item.IsEncrypted();
        break;
    case kpidComment: {
        prop = QString::fromLocal8Bit(bytearray(item.Comment)); // item.GetCodePage()
        break;
    }
    case kpidCRC:
        if (item.IsThereCrc())
            prop = item.FileCRC;
        break;
    case kpidMethod: {
        quint16 methodId = item.CompressionMethod;
        QString method;
        if (item.IsEncrypted()) {
            if (methodId == NFileHeader::NCompressionMethod::kWzAES) {
                method = kAESMethod;
                CWzAesExtraField aesField;
                if (item.CentralExtra.GetWzAesField(aesField)) {
                    method += "-";
                    method += QString::number((aesField.Strength + 1) * 64);
                    method += " ";
                    methodId = aesField.Method;
                }
            } else {
                if (item.IsStrongEncrypted()) {
                    CStrongCryptoField f;
                    bool finded = false;
                    if (item.CentralExtra.GetStrongCryptoField(f)) {
                        for (int i = 0; i < sizeof(g_StrongCryptoPairs) / sizeof(g_StrongCryptoPairs[0]); i++) {
                            const CStrongCryptoPair &pair = g_StrongCryptoPairs[i];
                            if (f.AlgId == pair.Id) {
                                method += pair.Name;
                                finded = true;
                                break;
                            }
                        }
                    }
                    if (!finded)
                        method += kStrongCryptoMethod;
                } else
                    method += kZipCryptoMethod;
                method += " ";
            }
        }
        if (methodId < kNumMethods)
            method += kMethods[methodId];
        else if (methodId == NFileHeader::NCompressionMethod::kWzPPMd)
            method += kPPMdMethod;
        else {
            method += QString::number(methodId);
        }
        prop = method;
        break;
    }
    case kpidHostOS:
        prop = QLatin1String((item.MadeByVersion.HostOS < kNumHostOSes) ?
               (kHostOS[item.MadeByVersion.HostOS]) : kUnknownOS);
        break;
    }
    *value = prop;
    return S_OK;
//    COM_TRY_END
}