STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) { COM_TRY_BEGIN NCOM::CPropVariant prop; switch(propID) { case kpidMethod: { UString resString; CRecordVector<UInt64> ids; int i; for (i = 0; i < _db.Folders.Size(); i++) { const CFolder &f = _db.Folders[i]; for (int j = f.Coders.Size() - 1; j >= 0; j--) ids.AddToUniqueSorted(f.Coders[j].MethodID); } for (i = 0; i < ids.Size(); i++) { UInt64 id = ids[i]; UString methodName; /* bool methodIsKnown = */ FindMethod(EXTERNAL_CODECS_VARS id, methodName); if (methodName.IsEmpty()) methodName = ConvertMethodIdToString(id); if (!resString.IsEmpty()) resString += L' '; resString += methodName; } prop = resString; break; } case kpidSolid: prop = _db.IsSolid(); break; case kpidNumBlocks: prop = (UInt32)_db.Folders.Size(); break; case kpidHeadersSize: prop = _db.HeadersSize; break; case kpidPhySize: prop = _db.PhySize; break; case kpidOffset: if (_db.ArchiveInfo.StartPosition != 0) prop = _db.ArchiveInfo.StartPosition; break; } prop.Detach(value); return S_OK; COM_TRY_END }
HRESULT CHashBundle::SetMethods(DECL_EXTERNAL_CODECS_LOC_VARS const UStringVector &hashMethods) { UStringVector names = hashMethods; if (names.IsEmpty()) { UString s; s.SetFromAscii(k_DefaultHashMethod); names.Add(s); } CRecordVector<CMethodId> ids; CObjectVector<COneMethodInfo> methods; unsigned i; for (i = 0; i < names.Size(); i++) { COneMethodInfo m; RINOK(m.ParseMethodFromString(names[i])); if (m.MethodName.IsEmpty()) m.MethodName = k_DefaultHashMethod; if (m.MethodName == "*") { CRecordVector<CMethodId> tempMethods; GetHashMethods(EXTERNAL_CODECS_LOC_VARS tempMethods); methods.Clear(); ids.Clear(); FOR_VECTOR (t, tempMethods) { unsigned index = ids.AddToUniqueSorted(tempMethods[t]); if (ids.Size() != methods.Size()) methods.Insert(index, m); } break; }