// 커맨드라인 정보로 options 셋팅 void zmodifyer::OptionSetting(UStringVector& commandStrings, CArchiveCommandLineOptions & options) { CArchiveCommandLineParser parser; parser.Parse1(commandStrings, options); //if (options.HelpMode) //{ //ShowCopyrightAndHelp(g_StdOut, true); //return; //} parser.Parse2(options, zdb_); if( options.PasswordEnabled ) { CMyComPtr< ICryptoSetPassword > setPassword = new CCryptoSetPassword; setPassword->CryptoSetPassword( (const Byte*)(&options.Password[0]), options.Password.Length() * 2 ); } }
int Main2(int argc,TCHAR **argv) { UStringVector commandStrings; #ifdef _WIN32 NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings); #else extern void mySplitCommandLineW(int numArguments,TCHAR **arguments,UStringVector &parts); mySplitCommandLineW(argc,argv,commandStrings); #endif #ifndef UNDER_CE if (commandStrings.Size() > 0) commandStrings.Delete(0); #endif if (commandStrings.Size() == 0) { MessageBoxW(0, L"Specify command", L"7-Zip", 0); return 0; } /* { CSysString resultPath; NWindows::NFile::NDirectory::MyGetCurrentDirectory(resultPath); ::MessageBoxW(0, resultPath, L"7-Zip - curDir", 0); } */ CArchiveCommandLineOptions options; CArchiveCommandLineParser parser; parser.Parse1(commandStrings, options); parser.Parse2(options); #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES) if (options.LargePages) NSecurity::EnableLockMemoryPrivilege(); #endif CCodecs *codecs = new CCodecs; CMyComPtr<IUnknown> compressCodecsInfo = codecs; HRESULT result = codecs->Load(); if (result != S_OK) throw CSystemException(result); bool isExtractGroupCommand = options.Command.IsFromExtractGroup(); if (codecs->Formats.Size() == 0 && (isExtractGroupCommand || options.Command.IsFromUpdateGroup())) throw kNoFormats; CIntVector formatIndices; if (!codecs->FindFormatForArchiveType(options.ArcType, formatIndices)) { ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE, 0x0200060D); return NExitCode::kFatalError; } if (options.Command.CommandType == NCommandType::kBenchmark) { HRESULT res; #ifdef EXTERNAL_CODECS CObjectVector<CCodecInfoEx> externalCodecs; res = LoadExternalCodecs(codecs, externalCodecs); if (res != S_OK) throw CSystemException(res); #endif res = Benchmark( #ifdef EXTERNAL_CODECS codecs, &externalCodecs, #endif options.NumThreads, options.DictionarySize); if (res != S_OK) throw CSystemException(res); } else if (isExtractGroupCommand) { CExtractCallbackImp *ecs = new CExtractCallbackImp; CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs; #ifndef _NO_CRYPTO ecs->PasswordIsDefined = options.PasswordEnabled; ecs->Password = options.Password; #endif ecs->Init(); CExtractOptions eo; eo.StdOutMode = options.StdOutMode; eo.OutputDir = options.OutputDir; eo.YesToAll = options.YesToAll; eo.OverwriteMode = options.OverwriteMode; eo.PathMode = options.Command.GetPathMode(); eo.TestMode = options.Command.IsTestMode(); eo.CalcCrc = options.CalcCrc; #if !defined(_7ZIP_ST) && !defined(_SFX) eo.Properties = options.ExtractProperties; #endif bool messageWasDisplayed = false; HRESULT result = ExtractGUI(codecs, formatIndices, options.ArchivePathsSorted, options.ArchivePathsFullSorted, options.WildcardCensor.Pairs.Front().Head, eo, options.ShowDialog, messageWasDisplayed, ecs); if (result != S_OK) { if (result != E_ABORT && messageWasDisplayed) return NExitCode::kFatalError; throw CSystemException(result); } if (!ecs->IsOK()) return NExitCode::kFatalError; } else if (options.Command.IsFromUpdateGroup()) { #ifndef _NO_CRYPTO bool passwordIsDefined = options.PasswordEnabled && !options.Password.IsEmpty(); #endif CUpdateCallbackGUI callback; // callback.EnablePercents = options.EnablePercents; #ifndef _NO_CRYPTO callback.PasswordIsDefined = passwordIsDefined; callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty(); callback.Password = options.Password; #endif // callback.StdOutMode = options.UpdateOptions.StdOutMode; callback.Init(); if (!options.UpdateOptions.Init(codecs, formatIndices, options.ArchiveName)) { ErrorLangMessage(IDS_UPDATE_NOT_SUPPORTED, 0x02000601); return NExitCode::kFatalError; } bool messageWasDisplayed = false; HRESULT result = UpdateGUI( codecs, options.WildcardCensor, options.UpdateOptions, options.ShowDialog, messageWasDisplayed, &callback); if (result != S_OK) { if (result != E_ABORT && messageWasDisplayed) return NExitCode::kFatalError; throw CSystemException(result); } if (callback.FailedFiles.Size() > 0) { if (!messageWasDisplayed) throw CSystemException(E_FAIL); return NExitCode::kWarning; } } else { throw "Unsupported command"; } return 0; }