本文整理汇总了C++中CCodecs::FindFormatForArchiveType方法的典型用法代码示例。如果您正苦于以下问题:C++ CCodecs::FindFormatForArchiveType方法的具体用法?C++ CCodecs::FindFormatForArchiveType怎么用?C++ CCodecs::FindFormatForArchiveType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCodecs
的用法示例。
在下文中一共展示了CCodecs::FindFormatForArchiveType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Main2
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
//.........这里部分代码省略.........
示例2: DoExtractArchive
int DoExtractArchive(UString archive, UString targetDir, bool overwrite, bool extractPaths, ExtractProgressHandler epc)
{
CCodecs *codecs = new CCodecs;
CMyComPtr<IUnknown> compressCodecsInfo = codecs;
HRESULT result = codecs->Load();
if (result != S_OK)
throw CSystemException(result);
if (codecs->Formats.Size() == 0) throw -1;
CIntVector formatIndices;
if (!codecs->FindFormatForArchiveType(L"7z", formatIndices))
{
throw -1;
}
BOOL bApisAreAnsi = AreFileApisANSI();
#ifdef _WIN32
if (bApisAreAnsi)
SwitchFileAPIEncoding(bApisAreAnsi);
#endif
CExtractCallbackConsole *ecs = new CExtractCallbackConsole();
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
ecs->ProgressHandler = epc;
wcsncpy(ecs->destDir, targetDir, MAX_PATH);
ecs->Init();
COpenCallbackConsole openCallback;
CExtractOptions eo;
eo.StdOutMode = false;
eo.PathMode = extractPaths?NExtract::NPathMode::kCurPaths:NExtract::NPathMode::kNoPaths;
eo.TestMode = false;
eo.OverwriteMode = overwrite?NExtract::NOverwriteMode::kOverwrite:NExtract::NOverwriteMode::kSkip;
eo.OutputDir = targetDir;
eo.YesToAll = true;
#ifdef COMPRESS_MT
CObjectVector<CProperty> prp;
eo.Properties = prp;
#endif
UString errorMessage;
CDecompressStat stat;
NWildcard::CCensor wildcardCensor;
wildcardCensor.AddItem(NWildcard::ECensorPathMode::k_FullPath, true, L"*", true, true);
UStringVector ArchivePathsSorted;
UStringVector ArchivePathsFullSorted;
ArchivePathsSorted.Add(archive);
UString fullPath;
NFile::NDir::MyGetFullPathName(archive, fullPath);
ArchivePathsFullSorted.Add(fullPath);
UStringVector v1, v2;
v1.Add(fs2us(archive));
v2.Add(fs2us(archive));
const NWildcard::CCensorNode &wildcardCensorHead =
wildcardCensor.Pairs.Front().Head;
result = Extract(
codecs, CObjectVector<COpenType>(), CIntVector(),
v1, v2,
wildcardCensorHead,
eo, ecs, ecs,
NULL, // hash
errorMessage, stat);
#ifdef _WIN32
if (bApisAreAnsi)
SwitchFileAPIEncoding(!bApisAreAnsi);
#endif
if (!errorMessage.IsEmpty())
{
if (result == S_OK)
result = E_FAIL;
}
if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
{
if (result != S_OK)
throw CSystemException(result);
return NExitCode::kFatalError;
}
if (result != S_OK)
throw CSystemException(result);
return 0;
}