void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins) { plugins.Clear(); UString baseFolderPrefix; GetProgramFolderPath(baseFolderPrefix); { CPluginInfo pluginInfo; pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll"; if (::ReadPluginInfo(pluginInfo, false)) plugins.Add(pluginInfo); } UString folderPath = baseFolderPrefix + L"Plugins" WSTRING_PATH_SEPARATOR; NFind::CEnumeratorW enumerator(folderPath + L"*"); NFind::CFileInfoW fileInfo; while (enumerator.Next(fileInfo)) { if (fileInfo.IsDir()) continue; CPluginInfo pluginInfo; pluginInfo.FilePath = folderPath + fileInfo.Name; if (::ReadPluginInfo(pluginInfo, true)) plugins.Add(pluginInfo); } }
HRESULT CHandler::SetMainMethod( CCompressionMethodMode &methodMode #ifndef _7ZIP_ST , UInt32 numThreads #endif ) { methodMode.Bonds = _bonds; CObjectVector<COneMethodInfo> methods = _methods; { FOR_VECTOR (i, methods) { AString &methodName = methods[i].MethodName; if (methodName.IsEmpty()) methodName = kDefaultMethodName; } if (methods.IsEmpty()) { COneMethodInfo &m = methods.AddNew(); m.MethodName = (GetLevel() == 0 ? k_Copy_Name : kDefaultMethodName); methodMode.DefaultMethod_was_Inserted = true; } }
bool CLangPage::OnInit() { LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); _langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG)); UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH) + NativeLangString(NWindows::MyLoadStringW(IDS_LANG_NATIVE)); int index = (int)_langCombo.AddString(s); _langCombo.SetItemData(index, _paths.Size()); _paths.Add(L"-"); _langCombo.SetCurSel(0); CObjectVector<CLangEx> langs; LoadLangs(langs); for (int i = 0; i < langs.Size(); i++) { const CLangEx &lang = langs[i]; UString name, nationalName; if (!lang.Lang.GetMessage(0, name)) name = lang.ShortName; if (lang.Lang.GetMessage(1, nationalName) && !nationalName.IsEmpty()) name += NativeLangString(nationalName); index = (int)_langCombo.AddString(name); _langCombo.SetItemData(index, _paths.Size()); _paths.Add(lang.ShortName); if (g_LangID.CompareNoCase(lang.ShortName) == 0) _langCombo.SetCurSel(index); } return CPropertyPage::OnInit(); }
void ReadInternalAssociations(CObjectVector<CExtInfo> &items) { items.Clear(); NSynchronization::CCriticalSectionLock lock(g_CriticalSection); CKey associationsKey; if (associationsKey.Open(HKEY_CURRENT_USER, kAssociationsPath, KEY_READ) != ERROR_SUCCESS) return; CSysStringVector extNames; associationsKey.EnumKeys(extNames); for(int i = 0; i < extNames.Size(); i++) { const CSysString extName = extNames[i]; CExtInfo extInfo; // extInfo.Enabled = false; extInfo.Ext = GetUnicodeString(extName); CKey key; if (key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS) return; UString pluginsString; key.QueryValue(kExtPlugins, pluginsString); SplitString(pluginsString, extInfo.Plugins); /* if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS) extInfo.Enabled = false; */ items.Add(extInfo); } }
static bool GetTextPairs(const UString &srcString, CObjectVector<CTextPair> &pairs) { pairs.Clear(); unsigned pos = 0; if (srcString.Len() > 0) { if (srcString[0] == kBOM) pos++; } while (pos < srcString.Len()) { unsigned finishPos; UString id = GetIDString((const wchar_t *)srcString + pos, finishPos); pos += finishPos; if (id.IsEmpty()) continue; UString value = GetValueString((const wchar_t *)srcString + pos, finishPos); pos += finishPos; if (!id.IsEmpty()) { CTextPair pair; pair.ID = id; pair.Value = value; pairs.Add(pair); } } return true; }
void CExtDatabase::Read() { CObjectVector<CExtInfo> extItems; ReadInternalAssociations(extItems); ReadFileFolderPluginInfoList(Plugins); for (int i = 0; i < extItems.Size(); i++) { const CExtInfo &extInfo = extItems[i]; CExtInfoBig extInfoBig; extInfoBig.Ext = extInfo.Ext; extInfoBig.Associated = false; for (int p = 0; p < extInfo.Plugins.Size(); p++) { int pluginIndex = FindPlugin(extInfo.Plugins[p]); if (pluginIndex >= 0) extInfoBig.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, true)); } ExtBigItems.Add(extInfoBig); } for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++) { const CPluginInfo &pluginInfo = Plugins[pluginIndex]; CPluginLibrary pluginLibrary; CMyComPtr<IFolderManager> folderManager; if (pluginInfo.FilePath.IsEmpty()) folderManager = new CArchiveFolderManager; else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath, pluginInfo.ClassID, &folderManager) != S_OK) continue; CMyComBSTR extBSTR; if (folderManager->GetExtensions(&extBSTR) != S_OK) return; const UString ext2 = (const wchar_t *)extBSTR; UStringVector exts; SplitString(ext2, exts); for (int i = 0; i < exts.Size(); i++) { const UString &ext = exts[i]; int index = FindExtInfoBig(ext); if (index < 0) { CExtInfoBig extInfo; extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false)); extInfo.Associated = false; extInfo.Ext = ext; ExtBigItems.Add(extInfo); } else { CExtInfoBig &extInfo = ExtBigItems[index]; int pluginIndexIndex = extInfo.FindPlugin(pluginIndex); if (pluginIndexIndex < 0) extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false)); } } } }
HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &resPath) { filled = false; for (;;) { if (Enumerators.IsEmpty()) { if (Index >= FileNames.Size()) return S_OK; const FString &path = FileNames[Index]; int pos = path.ReverseFind(FCHAR_PATH_SEPARATOR); resPath.Empty(); if (pos >= 0) resPath = path.Left(pos + 1); #ifdef _WIN32 // it's for "c:" paths/ if (BasePrefix.IsEmpty() && path.Length() == 2 && path[1] == ':') { fileInfo.Name = path; fileInfo.Attrib = FILE_ATTRIBUTE_DIRECTORY; fileInfo.Size = 0; } else #endif if (!fileInfo.Find(BasePrefix + path)) { WRes errorCode = GetNormalizedError(); resPath = path; return errorCode; } Index++; break; } bool found; if (!Enumerators.Back().Next(fileInfo, found)) { HRESULT errorCode = GetNormalizedError(); resPath = Prefixes.Back(); return errorCode; } if (found) { resPath = Prefixes.Back(); break; } Enumerators.DeleteBack(); Prefixes.DeleteBack(); } resPath += fileInfo.Name; if (!FlatMode && fileInfo.IsDir()) { FString prefix = resPath + FCHAR_PATH_SEPARATOR; Enumerators.Add(NFind::CEnumerator(BasePrefix + prefix + FCHAR_ANY_MASK)); Prefixes.Add(prefix); } filled = true; return S_OK; }
bool GetTextConfig(const AString &s, CObjectVector<CTextConfigPair> &pairs) { pairs.Clear(); unsigned pos = 0; ///////////////////// // read strings for (;;) { if (!SkipSpaces(s, pos)) break; CTextConfigPair pair; unsigned finishPos; AString temp = GetIDString(((const char *)s) + pos, finishPos); if (!ConvertUTF8ToUnicode(temp, pair.ID)) return false; if (finishPos == 0) return false; pos += finishPos; if (!SkipSpaces(s, pos)) return false; if (s[pos] != '=') return false; pos++; if (!SkipSpaces(s, pos)) return false; if (s[pos] != '\"') return false; pos++; AString message; for (;;) { if (pos >= s.Len()) return false; char c = s[pos++]; if (c == '\"') break; if (c == '\\') { c = s[pos++]; switch (c) { case 'n': message += '\n'; break; case 't': message += '\t'; break; case '\\': message += '\\'; break; case '\"': message += '\"'; break; default: message += '\\'; message += c; break; } } else message += c; } if (!ConvertUTF8ToUnicode(message, pair.String)) return false; pairs.Add(pair); } return true; }
void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */) { CSystemPage systemPage; CMenuPage menuPage; CFoldersPage foldersPage; CEditPage editPage; CSettingsPage settingsPage; CLangPage langPage; CObjectVector<NControl::CPageInfo> pages; BIG_DIALOG_SIZE(200, 200); const UINT pageIDs[] = { SIZED_DIALOG(IDD_SYSTEM), SIZED_DIALOG(IDD_MENU), SIZED_DIALOG(IDD_FOLDERS), SIZED_DIALOG(IDD_EDIT), SIZED_DIALOG(IDD_SETTINGS), SIZED_DIALOG(IDD_LANG) }; NControl::CPropertyPage *pagePointers[] = { &systemPage, &menuPage, &foldersPage, &editPage, &settingsPage, &langPage }; for (unsigned i = 0; i < ARRAY_SIZE(pageIDs); i++) { NControl::CPageInfo &page = pages.AddNew(); page.ID = pageIDs[i]; LangString_OnlyFromLangFile(page.ID, page.Title); page.Page = pagePointers[i]; } INT_PTR res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS)); if (res != -1 && res != 0) { if (langPage.LangWasChanged) { // g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000)); MyLoadMenu(); g_App.ReloadToolbars(); g_App.MoveSubWindows(); // we need it to change list window aafter _toolBar.AutoSize(); g_App.ReloadLang(); } /* if (systemPage.WasChanged) { // probably it doesn't work, since image list is locked? g_App.SysIconsWereChanged(); } */ g_App.SetListSettings(); g_App.RefreshAllPanels(); // ::PostMessage(hwndOwner, kLangWasChangedMessage, 0 , 0); } }
void UpdateProduce( const CObjectVector<CDirItem> &dirItems, const CObjectVector<CArchiveItem> &archiveItems, const CObjectVector<CUpdatePair> &updatePairs, const NUpdateArchive::CActionSet &actionSet, CObjectVector<CUpdatePair2> &operationChain) { for(int i = 0; i < updatePairs.Size(); i++) { // CUpdateArchiveRange aRange; const CUpdatePair &pair = updatePairs[i]; CUpdatePair2 pair2; pair2.IsAnti = false; pair2.ArchiveItemIndex = pair.ArchiveItemIndex; pair2.DirItemIndex = pair.DirItemIndex; pair2.ExistInArchive = (pair.State != NPairState::kOnlyOnDisk); pair2.ExistOnDisk = (pair.State != NPairState::kOnlyInArchive); switch(actionSet.StateActions[pair.State]) { case NPairAction::kIgnore: /* if (pair.State != NPairState::kOnlyOnDisk) IgnoreArchiveItem(m_ArchiveItems[pair.ArchiveItemIndex]); // cout << "deleting"; */ break; case NPairAction::kCopy: { if (pair.State == NPairState::kOnlyOnDisk) throw kUpdateActionSetCollision; pair2.NewData = pair2.NewProperties = false; operationChain.Add(pair2); break; } case NPairAction::kCompress: { if (pair.State == NPairState::kOnlyInArchive || pair.State == NPairState::kNotMasked) throw kUpdateActionSetCollision; pair2.NewData = pair2.NewProperties = true; operationChain.Add(pair2); break; } case NPairAction::kCompressAsAnti: { pair2.IsAnti = true; pair2.NewData = pair2.NewProperties = true; operationChain.Add(pair2); break; } } } }
HRESULT CHandler::SetCompressionMethod( CCompressionMethodMode &methodMode, CCompressionMethodMode &headerMethod) { HRESULT res = SetCompressionMethod(methodMode, _methods #ifdef COMPRESS_MT , _numThreads #endif ); RINOK(res); methodMode.Binds = _binds; if (_compressHeaders) { // headerMethod.Methods.Add(methodMode.Methods.Back()); CObjectVector<COneMethodInfo> headerMethodInfoVector; COneMethodInfo oneMethodInfo; oneMethodInfo.MethodName = kLZMAMethodName; { CProp prop; prop.Id = NCoderPropID::kMatchFinder; prop.Value = kLzmaMatchFinderForHeaders; oneMethodInfo.Props.Add(prop); } { CProp prop; prop.Id = NCoderPropID::kAlgorithm; prop.Value = kAlgorithmForHeaders; oneMethodInfo.Props.Add(prop); } { CProp prop; prop.Id = NCoderPropID::kNumFastBytes; prop.Value = (UInt32)kNumFastBytesForHeaders; oneMethodInfo.Props.Add(prop); } { CProp prop; prop.Id = NCoderPropID::kDictionarySize; prop.Value = (UInt32)kDictionaryForHeaders; oneMethodInfo.Props.Add(prop); } headerMethodInfoVector.Add(oneMethodInfo); HRESULT res = SetCompressionMethod(headerMethod, headerMethodInfoVector #ifdef COMPRESS_MT ,1 #endif ); RINOK(res); } return S_OK; }
void CInArchive::ReadUnpackInfo( const CObjectVector<CByteBuffer> *dataVector, CObjectVector<CFolder> &folders) { WaitAttribute(NID::kFolder); CNum numFolders = ReadNum(); { CStreamSwitch streamSwitch; streamSwitch.Set(this, dataVector); folders.Clear(); folders.Reserve(numFolders); for (CNum i = 0; i < numFolders; i++) { folders.Add(CFolder()); GetNextFolderItem(folders.Back()); } } WaitAttribute(NID::kCodersUnpackSize); CNum i; for (i = 0; i < numFolders; i++) { CFolder &folder = folders[i]; CNum numOutStreams = folder.GetNumOutStreams(); folder.UnpackSizes.Reserve(numOutStreams); for (CNum j = 0; j < numOutStreams; j++) folder.UnpackSizes.Add(ReadNumber()); } for (;;) { UInt64 type = ReadID(); if (type == NID::kEnd) return; if (type == NID::kCRC) { CBoolVector crcsDefined; CRecordVector<UInt32> crcs; ReadHashDigests(numFolders, crcsDefined, crcs); for (i = 0; i < numFolders; i++) { CFolder &folder = folders[i]; folder.UnpackCRCDefined = crcsDefined[i]; folder.UnpackCRC = crcs[i]; } continue; } SkipData(); } }
HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &properties) { if (properties.IsEmpty()) return S_OK; CMyComPtr<ISetProperties> setProperties; unknown->QueryInterface(IID_ISetProperties, (void **)&setProperties); if (!setProperties) return S_OK; UStringVector realNames; CPropVariant *values = new CPropVariant[properties.Size()]; try { int i; for(i = 0; i < properties.Size(); i++) { const CProperty &property = properties[i]; NCOM::CPropVariant propVariant; UString name = property.Name; if (property.Value.IsEmpty()) { if (!name.IsEmpty()) { wchar_t c = name.Back(); if (c == L'-') propVariant = false; else if (c == L'+') propVariant = true; if (propVariant.vt != VT_EMPTY) name.DeleteBack(); } } else ParseNumberString(property.Value, propVariant); realNames.Add(name); values[i] = propVariant; } CRecordVector<const wchar_t *> names; for(i = 0; i < realNames.Size(); i++) names.Add((const wchar_t *)realNames[i]); RINOK(setProperties->SetProperties(&names.Front(), values, names.Size())); } catch(...) { delete []values; throw; } delete []values; return S_OK; }
bool MyGetLogicalDriveStrings(CObjectVector<FString> &driveStrings) { driveStrings.Clear(); #ifndef _UNICODE if (!g_IsNT) { driveStrings.Clear(); UINT32 size = GetLogicalDriveStrings(0, NULL); if (size == 0) return false; CObjArray<char> buf(size); UINT32 newSize = GetLogicalDriveStrings(size, buf); if (newSize == 0 || newSize > size) return false; AString s; UINT32 prev = 0; for (UINT32 i = 0; i < newSize; i++) { if (buf[i] == 0) { s = buf + prev; prev = i + 1; driveStrings.Add(fas2fs(s)); } } return prev == newSize; } else #endif { UINT32 size = GetLogicalDriveStringsW(0, NULL); if (size == 0) return false; CObjArray<wchar_t> buf(size); UINT32 newSize = GetLogicalDriveStringsW(size, buf); if (newSize == 0 || newSize > size) return false; UString s; UINT32 prev = 0; for (UINT32 i = 0; i < newSize; i++) { if (buf[i] == 0) { s = buf + prev; prev = i + 1; driveStrings.Add(us2fs(s)); } } return prev == newSize; } }
bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath, DWORD &errorCode) { filled = false; for (;;) { if (Enumerators.IsEmpty()) { if (Index >= FileNames.Size()) return true; const UString &path = FileNames[Index]; int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); resPath.Empty(); if (pos >= 0) resPath = path.Left(pos + 1); if (!NFind::FindFile(BasePrefix + path, fileInfo)) { errorCode = ::GetLastError(); resPath = path; return false; } Index++; break; } bool found; if (!Enumerators.Back().Next(fileInfo, found)) { errorCode = ::GetLastError(); resPath = Prefixes.Back(); return false; } if (found) { resPath = Prefixes.Back(); break; } Enumerators.DeleteBack(); Prefixes.DeleteBack(); } resPath += fileInfo.Name; if (!FlatMode && fileInfo.IsDir()) { UString prefix = resPath + (UString)(wchar_t)kDirDelimiter; Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)kAnyStringWildcard)); Prefixes.Add(prefix); } filled = true; return true; }
HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs, const UInt64 *size, const UInt64 *compressedSize) { for (int i = 0; i < _fields.Size(); i++) { const CFieldInfo &fieldInfo = _fields[i]; PrintSpaces(fieldInfo.PrefixSpacesWidth); NCOM::CPropVariant prop; if (fieldInfo.PropID == kpidSize) PrintNumberString(fieldInfo.TextAdjustment, fieldInfo.Width, size); else if (fieldInfo.PropID == kpidPackSize) PrintNumberString(fieldInfo.TextAdjustment, fieldInfo.Width, compressedSize); else if (fieldInfo.PropID == kpidPath) { wchar_t textString[32]; ConvertUInt64ToString(numFiles, textString); UString temp = textString; temp += L" "; temp += kFilesMessage; temp += L", "; ConvertUInt64ToString(numDirs, textString); temp += textString; temp += L" "; temp += kDirsMessage; PrintString(fieldInfo.TextAdjustment, 0, temp); } else PrintString(fieldInfo.TextAdjustment, fieldInfo.Width, L""); } return S_OK; }
bool CStartupInfo::ControlGetActivePanelSelectedOrCurrentItems( CObjectVector<PluginPanelItem> &pluginPanelItems) { pluginPanelItems.Clear(); PanelInfo panelInfo; if(!ControlGetActivePanelInfo(panelInfo)) return false; if(panelInfo.ItemsNumber <= 0) throw "There are no items"; if (panelInfo.SelectedItemsNumber == 0) pluginPanelItems.Add(panelInfo.PanelItems[panelInfo.CurrentItem]); else for (int i = 0; i < panelInfo.SelectedItemsNumber; i++) pluginPanelItems.Add(panelInfo.SelectedItems[i]); return true; }
static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value) { CProperty prop; prop.Name = name; prop.Value = value; properties.Add(prop); }
void Clear() { CID.Empty(); parentCID.Empty(); createType.Empty(); Extents.Clear(); }
void CFieldPrinter::AddProp(const wchar_t *name, PROPID propID, bool isRawProp) { CFieldInfo f; f.PropID = propID; f.IsRawProp = isRawProp; GetPropName(propID, name, f.NameA, f.NameU); f.NameU.AddAscii(" = "); if (!f.NameA.IsEmpty()) f.NameA += " = "; else { const UString &s = f.NameU; AString sA; unsigned i; for (i = 0; i < s.Len(); i++) { wchar_t c = s[i]; if (c >= 0x80) break; sA += (char)c; } if (i == s.Len()) f.NameA = sA; } _fields.Add(f); }
HRESULT LoadExternalCodecs(ICompressCodecsInfo *codecsInfo, CObjectVector<CCodecInfoEx> &externalCodecs) { UInt32 num; RINOK(codecsInfo->GetNumberOfMethods(&num)); for (UInt32 i = 0; i < num; i++) { CCodecInfoEx info; NWindows::NCOM::CPropVariant prop; RINOK(codecsInfo->GetProperty(i, NMethodPropID::kID, &prop)); // if (prop.vt != VT_BSTR) // info.Id.IDSize = (Byte)SysStringByteLen(prop.bstrVal); // memmove(info.Id.ID, prop.bstrVal, info.Id.IDSize); if (prop.vt != VT_UI8) { continue; // old Interface // return E_INVALIDARG; } info.Id = prop.uhVal.QuadPart; prop.Clear(); RINOK(codecsInfo->GetProperty(i, NMethodPropID::kName, &prop)); if (prop.vt == VT_BSTR) info.Name = prop.bstrVal; else if (prop.vt != VT_EMPTY) return E_INVALIDARG;; RINOK(ReadNumberOfStreams(codecsInfo, i, NMethodPropID::kInStreams, info.NumInStreams)); RINOK(ReadNumberOfStreams(codecsInfo, i, NMethodPropID::kOutStreams, info.NumOutStreams)); RINOK(ReadIsAssignedProp(codecsInfo, i, NMethodPropID::kEncoderIsAssigned, info.EncoderIsAssigned)); RINOK(ReadIsAssignedProp(codecsInfo, i, NMethodPropID::kDecoderIsAssigned, info.DecoderIsAssigned)); externalCodecs.Add(info); } return S_OK; }
static void SplitFilesToGroups( const CCompressionMethodMode &method, bool useFilters, bool maxFilter, const CObjectVector<CUpdateItem> &updateItems, CObjectVector<CSolidGroup> &groups) { if (method.Methods.Size() != 1 || method.Binds.Size() != 0) useFilters = false; groups.Clear(); groups.Add(CSolidGroup()); groups.Add(CSolidGroup()); CSolidGroup &generalGroup = groups[0]; CSolidGroup &exeGroup = groups[1]; generalGroup.Method = method; int i; for (i = 0; i < updateItems.Size(); i++) { const CUpdateItem &updateItem = updateItems[i]; if (!updateItem.NewData) continue; if (!updateItem.HasStream()) continue; if (useFilters) { const UString name = updateItem.Name; int dotPos = name.ReverseFind(L'.'); if (dotPos >= 0) { UString ext = name.Mid(dotPos + 1); if (IsExeFile(ext)) { exeGroup.Indices.Add(i); continue; } } } generalGroup.Indices.Add(i); } if (exeGroup.Indices.Size() > 0) if (!MakeExeMethod(method, maxFilter, exeGroup.Method)) exeGroup.Method = method; for (i = 0; i < groups.Size();) if (groups[i].Indices.Size() == 0) groups.Delete(i); else i++; }
static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &pluginName) { for (int i = 0; i < plugins.Size(); i++) if (plugins[i].Name.CompareNoCase(pluginName) == 0) return i; return -1; }
void COutArchive::WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer *comment) { SeekTo(m_BasePosition); UInt64 cdOffset = GetCurrentPosition(); for(int i = 0; i < items.Size(); i++) WriteCentralHeader(items[i]); UInt64 cd64EndOffset = GetCurrentPosition(); UInt64 cdSize = cd64EndOffset - cdOffset; bool cdOffset64 = cdOffset >= 0xFFFFFFFF; bool cdSize64 = cdSize >= 0xFFFFFFFF; bool items64 = items.Size() >= 0xFFFF; bool isZip64 = (cdOffset64 || cdSize64 || items64); if (isZip64) { WriteUInt32(NSignature::kZip64EndOfCentralDir); WriteUInt64(kZip64EcdSize); // ThisDiskNumber = 0; WriteUInt16(45); // version WriteUInt16(45); // version WriteUInt32(0); // ThisDiskNumber = 0; WriteUInt32(0); // StartCentralDirectoryDiskNumber;; WriteUInt64((UInt64)items.Size()); WriteUInt64((UInt64)items.Size()); WriteUInt64((UInt64)cdSize); WriteUInt64((UInt64)cdOffset); WriteUInt32(NSignature::kZip64EndOfCentralDirLocator); WriteUInt32(0); // number of the disk with the start of the zip64 end of central directory WriteUInt64(cd64EndOffset); WriteUInt32(1); // total number of disks } WriteUInt32(NSignature::kEndOfCentralDir); WriteUInt16(0); // ThisDiskNumber = 0; WriteUInt16(0); // StartCentralDirectoryDiskNumber; WriteUInt16((UInt16)(items64 ? 0xFFFF: items.Size())); WriteUInt16((UInt16)(items64 ? 0xFFFF: items.Size())); WriteUInt32(cdSize64 ? 0xFFFFFFFF: (UInt32)cdSize); WriteUInt32(cdOffset64 ? 0xFFFFFFFF: (UInt32)cdOffset); UInt32 commentSize = (UInt32)(comment ? comment->GetCapacity() : 0); WriteUInt16((UInt16)commentSize); if (commentSize > 0) WriteBytes((const Byte *)*comment, commentSize); m_OutBuffer.FlushWithCheck(); }
void CFieldPrinter::PrintTitle() { for (int i = 0; i < _fields.Size(); i++) { const CFieldInfo &fieldInfo = _fields[i]; PrintSpaces(fieldInfo.PrefixSpacesWidth); PrintString(fieldInfo.TitleAdjustment, ((fieldInfo.PropID == kpidPath) ? 0: fieldInfo.Width), fieldInfo.Name); } }
void CExtDatabase::Save() { CObjectVector<CExtInfo> extItems; for (int i = 0; i < ExtBigItems.Size(); i++) { const CExtInfoBig &extInfoBig = ExtBigItems[i]; CExtInfo extInfo; // extInfo.Enabled = extInfoBig.Associated; extInfo.Ext = extInfoBig.Ext; for (int p = 0; p < extInfoBig.PluginsPairs.Size(); p++) { CPluginEnabledPair pluginPair = extInfoBig.PluginsPairs[p]; if (pluginPair.Enabled) extInfo.Plugins.Add(Plugins[pluginPair.Index].Name); } extItems.Add(extInfo); } WriteInternalAssociations(extItems); }
static void ConvertToLongNames(const UString &prefix, CObjectVector<NWildcard::CItem> &items) { for (int i = 0; i < items.Size(); i++) { NWildcard::CItem &item = items[i]; if (item.Recursive || item.PathParts.Size() != 1) continue; ConvertToLongName(prefix, item.PathParts.Front()); } }
static HRESULT EnumerateArchiveItems(CAgent *agent, const CProxyFolder &item, const UString &prefix, CObjectVector<CArcItem> &arcItems) { int i; for (i = 0; i < item.Files.Size(); i++) { const CProxyFile &fileItem = item.Files[i]; CArcItem ai; RINOK(::GetFileTime(agent, fileItem.Index, ai.MTime)); CPropVariant property; agent->GetArchive()->GetProperty(fileItem.Index, kpidSize, &property); ai.SizeDefined = (property.vt != VT_EMPTY); if (ai.SizeDefined) ai.Size = ConvertPropVariantToUInt64(property); ai.IsDir = false; ai.Name = prefix + fileItem.Name; ai.Censored = true; // test it ai.IndexInServer = fileItem.Index; arcItems.Add(ai); } for (i = 0; i < item.Folders.Size(); i++) { const CProxyFolder &dirItem = item.Folders[i]; UString fullName = prefix + dirItem.Name; if(dirItem.IsLeaf) { CArcItem ai; RINOK(::GetFileTime(agent, dirItem.Index, ai.MTime)); ai.IsDir = true; ai.SizeDefined = false; ai.Name = fullName; ai.Censored = true; // test it ai.IndexInServer = dirItem.Index; arcItems.Add(ai); } RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(WCHAR_PATH_SEPARATOR), arcItems)); } return S_OK; }
void CFieldPrinter::PrintTitleLines() { for (int i = 0; i < _fields.Size(); i++) { const CFieldInfo &fieldInfo = _fields[i]; PrintSpaces(fieldInfo.PrefixSpacesWidth); for (int i = 0; i < fieldInfo.Width; i++) g_StdOut << '-'; } }
void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins) { ReadPluginInfoList(plugins); for (int i = 0; i < plugins.Size();) if (plugins[i].Type != kPluginTypeFF) plugins.Delete(i); else i++; { CPluginInfo p; // p.FilePath.Empty(); p.Type = kPluginTypeFF; p.Name = L"7-Zip"; // p.ClassID = CLSID_CAgentArchiveHandler; p.ClassIDDefined = true; // p.OptionsClassID; p.OptionsClassIDDefined = false; plugins.Add(p); } }