void CExtractDialog::OnOK() { #ifndef _SFX NExtract::NPathMode::EEnum pathMode2 = (NExtract::NPathMode::EEnum)kPathModeButtonsVals[_pathMode.GetItemData(_pathMode.GetCurSel())]; if (PathMode != NExtract::NPathMode::kCurrentPathnames || pathMode2 != NExtract::NPathMode::kFullPathnames) PathMode = pathMode2; OverwriteMode = (NExtract::NOverwriteMode::EEnum)kOverwriteButtonsVals[_overwriteMode.GetItemData(_overwriteMode.GetCurSel())]; // _filesMode = (NExtractionDialog::NFilesMode::EEnum)GetFilesMode(); _passwordControl.GetText(Password); #endif NExtract::CInfo info; info.PathMode = PathMode; info.OverwriteMode = OverwriteMode; info.ShowPassword = (IsButtonCheckedBool(IDC_EXTRACT_CHECK_SHOW_PASSWORD)); UString s; #ifdef NO_REGISTRY _path.GetText(s); #else int currentItem = _path.GetCurSel(); if (currentItem == CB_ERR) { _path.GetText(s); if (_path.GetCount() >= kHistorySize) currentItem = _path.GetCount() - 1; } else _path.GetLBText(currentItem, s); #endif s.Trim(); #ifndef _SFX AddUniqueString(info.Paths, s); #endif DirectoryPath = s; #ifndef NO_REGISTRY for (int i = 0; i < _path.GetCount(); i++) if (i != currentItem) { UString sTemp; _path.GetLBText(i, sTemp); sTemp.Trim(); AddUniqueString(info.Paths, sTemp); } info.Save(); #endif CModalDialog::OnOK(); }
NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *panelItems, int itemsNumber, int move, const char *destPathLoc, int opMode, bool showBox) { if (move != 0) { g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported); return NFileOperationReturnCode::kError; } AString destPath = destPathLoc; UString destPathU = GetUnicodeString(destPath, CP_OEMCP); NFile::NName::NormalizeDirPathPrefix(destPathU); destPath = UnicodeStringToMultiByte(destPathU, CP_OEMCP); bool extractSelectedFiles = true; NExtract::CInfo extractionInfo; extractionInfo.PathMode = NExtract::NPathMode::kCurrentPathnames; extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt; bool silent = (opMode & OPM_SILENT) != 0; bool decompressAllItems = false; UString password = Password; bool passwordIsDefined = PasswordIsDefined; if (!silent) { const int kPathIndex = 2; extractionInfo.Load(); const int kPathModeRadioIndex = 4; const int kOverwriteModeRadioIndex = kPathModeRadioIndex + 4; const int kNumOverwriteOptions = 6; const int kFilesModeIndex = kOverwriteModeRadioIndex + kNumOverwriteOptions; const int kXSize = 76; const int kYSize = 19; const int kPasswordYPos = 12; const int kXMid = kXSize / 2; AString oemPassword = UnicodeStringToMultiByte(password, CP_OEMCP); struct CInitDialogItem initItems[]={ { DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, NMessageID::kExtractTitle, NULL, NULL }, { DI_TEXT, 5, 2, 0, 0, false, false, 0, false, NMessageID::kExtractTo, NULL, NULL }, { DI_EDIT, 5, 3, kXSize - 6, 3, true, false, DIF_HISTORY, false, -1, destPath, kExractPathHistoryName}, // { DI_EDIT, 5, 3, kXSize - 6, 3, true, false, 0, false, -1, destPath, NULL}, { DI_SINGLEBOX, 4, 5, kXMid - 2, 5 + 4, false, false, 0, false, NMessageID::kExtractPathMode, NULL, NULL }, { DI_RADIOBUTTON, 6, 6, 0, 0, false, extractionInfo.PathMode == NExtract::NPathMode::kFullPathnames, DIF_GROUP, false, NMessageID::kExtractPathFull, NULL, NULL }, { DI_RADIOBUTTON, 6, 7, 0, 0, false, extractionInfo.PathMode == NExtract::NPathMode::kCurrentPathnames, 0, false, NMessageID::kExtractPathCurrent, NULL, NULL }, { DI_RADIOBUTTON, 6, 8, 0, 0, false, extractionInfo.PathMode == NExtract::NPathMode::kNoPathnames, false, 0, NMessageID::kExtractPathNo, NULL, NULL }, { DI_SINGLEBOX, kXMid, 5, kXSize - 6, 5 + kNumOverwriteOptions, false, false, 0, false, NMessageID::kExtractOwerwriteMode, NULL, NULL }, { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAskBefore, DIF_GROUP, false, NMessageID::kExtractOwerwriteAsk, NULL, NULL }, { DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false, extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kWithoutPrompt, 0, false, NMessageID::kExtractOwerwritePrompt, NULL, NULL }, { DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false, extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kSkipExisting, 0, false, NMessageID::kExtractOwerwriteSkip, NULL, NULL }, { DI_RADIOBUTTON, kXMid + 2, 9, 0, 0, false, extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRename, 0, false, NMessageID::kExtractOwerwriteAutoRename, NULL, NULL }, { DI_RADIOBUTTON, kXMid + 2, 10, 0, 0, false, extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting, 0, false, NMessageID::kExtractOwerwriteAutoRenameExisting, NULL, NULL }, { DI_SINGLEBOX, 4, 10, kXMid- 2, 10 + 3, false, false, 0, false, NMessageID::kExtractFilesMode, NULL, NULL }, { DI_RADIOBUTTON, 6, 11, 0, 0, false, true, DIF_GROUP, false, NMessageID::kExtractFilesSelected, NULL, NULL }, { DI_RADIOBUTTON, 6, 12, 0, 0, false, false, 0, false, NMessageID::kExtractFilesAll, NULL, NULL }, { DI_SINGLEBOX, kXMid, kPasswordYPos, kXSize - 6, kPasswordYPos + 2, false, false, 0, false, NMessageID::kExtractPassword, NULL, NULL }, { DI_PSWEDIT, kXMid + 2, kPasswordYPos + 1, kXSize - 8, 12, false, false, 0, false, -1, oemPassword, NULL}, { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, { DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kExtractExtract, NULL, NULL }, { DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kExtractCancel, NULL, NULL } }; const int kNumDialogItems = sizeof(initItems) / sizeof(initItems[0]); const int kOkButtonIndex = kNumDialogItems - 2; const int kPasswordIndex = kNumDialogItems - 4; FarDialogItem dialogItems[kNumDialogItems]; g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems); for (;;) { int askCode = g_StartupInfo.ShowDialog(kXSize, kYSize, kHelpTopicExtrFromSevenZip, dialogItems, kNumDialogItems); if (askCode != kOkButtonIndex) return NFileOperationReturnCode::kInterruptedByUser; destPath = dialogItems[kPathIndex].Data; destPathU = GetUnicodeString(destPath, CP_OEMCP); destPathU.Trim(); if (destPathU.IsEmpty()) { #ifdef UNDER_CE destPathU = L"\\"; #else if (!NFile::NDirectory::MyGetCurrentDirectory(destPathU)) throw 318016; NFile::NName::NormalizeDirPathPrefix(destPathU); #endif break; } else { if (destPathU.Back() == kDirDelimiter) break; } g_StartupInfo.ShowMessage("You must specify directory path"); } if (dialogItems[kPathModeRadioIndex].Selected) extractionInfo.PathMode = NExtract::NPathMode::kFullPathnames; else if (dialogItems[kPathModeRadioIndex + 1].Selected) extractionInfo.PathMode = NExtract::NPathMode::kCurrentPathnames; else if (dialogItems[kPathModeRadioIndex + 2].Selected) extractionInfo.PathMode = NExtract::NPathMode::kNoPathnames; else throw 31806; if (dialogItems[kOverwriteModeRadioIndex].Selected) extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kAskBefore; else if (dialogItems[kOverwriteModeRadioIndex + 1].Selected) extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt; else if (dialogItems[kOverwriteModeRadioIndex + 2].Selected) extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kSkipExisting; else if (dialogItems[kOverwriteModeRadioIndex + 3].Selected) extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kAutoRename; else if (dialogItems[kOverwriteModeRadioIndex + 4].Selected) extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kAutoRenameExisting; else throw 31806; if (dialogItems[kFilesModeIndex].Selected) decompressAllItems = false; else if (dialogItems[kFilesModeIndex + 1].Selected) decompressAllItems = true; else throw 31806; extractionInfo.Save(); if (dialogItems[kFilesModeIndex].Selected) extractSelectedFiles = true; else if (dialogItems[kFilesModeIndex + 1].Selected) extractSelectedFiles = false; else throw 31806; oemPassword = dialogItems[kPasswordIndex].Data; password = MultiByteToUnicodeString(oemPassword, CP_OEMCP); passwordIsDefined = !password.IsEmpty(); } NFile::NDirectory::CreateComplexDirectory(destPathU); /* vector<int> realIndices; if (!decompressAllItems) GetRealIndexes(panelItems, itemsNumber, realIndices); */ CRecordVector<UINT32> indices; indices.Reserve(itemsNumber); for (int i = 0; i < itemsNumber; i++) indices.Add((UINT32)panelItems[i].UserData); HRESULT result = ExtractFiles(decompressAllItems, &indices.Front(), itemsNumber, !showBox, extractionInfo.PathMode, extractionInfo.OverwriteMode, destPathU, passwordIsDefined, password); // HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox, // extractionInfo, destPath, passwordIsDefined, password); if (result != S_OK) { if (result == E_ABORT) return NFileOperationReturnCode::kInterruptedByUser; ShowErrorMessage(result); return NFileOperationReturnCode::kError; } // if (move != 0) // { // if (DeleteFiles(panelItems, itemsNumber, opMode) == FALSE) // return NFileOperationReturnCode::kError; // } return NFileOperationReturnCode::kSuccess; }
bool CExtractDialog::OnInit() { #ifdef LANG LangSetWindowText(HWND(*this), 0x02000800); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif #ifndef _SFX _passwordControl.Attach(GetItem(IDC_EXTRACT_EDIT_PASSWORD)); _passwordControl.SetText(Password); _passwordControl.SetPasswordChar(TEXT('*')); #endif NExtract::CInfo info; #ifdef NO_REGISTRY PathMode = NExtract::NPathMode::kFullPathnames; OverwriteMode = NExtract::NOverwriteMode::kAskBefore; // info.Paths = NExtract::NPathMode::kFullPathnames; #else info.Load(); CheckButton(IDC_EXTRACT_CHECK_SHOW_PASSWORD, info.ShowPassword); UpdatePasswordControl(); PathMode = info.PathMode; OverwriteMode = info.OverwriteMode; #endif _path.Attach(GetItem(IDC_EXTRACT_COMBO_PATH)); _path.SetText(DirectoryPath); #ifndef NO_REGISTRY for (int i = 0; i < info.Paths.Size() && i < kHistorySize; i++) _path.AddString(info.Paths[i]); #endif /* if (info.Paths.Size() > 0) _path.SetCurSel(0); else _path.SetCurSel(-1); */ #ifndef _SFX _pathMode.Attach(GetItem(IDC_EXTRACT_COMBO_PATH_MODE)); AddComboItems(_pathMode, kPathMode_Pairs, sizeof(kPathMode_Pairs) / sizeof(kPathMode_Pairs[0]), kPathModeButtonsVals, PathMode); _overwriteMode.Attach(GetItem(IDC_EXTRACT_COMBO_OVERWRITE_MODE)); AddComboItems(_overwriteMode, kOverwriteMode_Pairs, sizeof(kOverwriteMode_Pairs) / sizeof(kOverwriteMode_Pairs[0]), kOverwriteButtonsVals, OverwriteMode); /* CheckRadioButton(kFilesButtons[0], kFilesButtons[kNumFilesButtons - 1], kFilesButtons[_filesMode]); */ // CWindow selectedFilesWindow = GetItem(IDC_EXTRACT_RADIO_SELECTED_FILES); // selectedFilesWindow.Enable(_enableSelectedFilesButton); #endif HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON)); SetIcon(ICON_BIG, icon); // CWindow filesWindow = GetItem(IDC_EXTRACT_RADIO_FILES); // filesWindow.Enable(_enableFilesButton); // UpdateWildCardState(); NormalizePosition(); return CModalDialog::OnInit(); }