📄 main.cpp
字号:
{
Byte b = sig[j];
if (b > 0x20 && b < 0x80)
{
stdStream << (char)b;
}
else
{
stdStream << GetHex((Byte)((b >> 4) & 0xF));
stdStream << GetHex((Byte)(b & 0xF));
}
stdStream << ' ';
}
stdStream << endl;
}
stdStream << endl << "Codecs:" << endl;
#ifdef EXTERNAL_CODECS
UINT32 numMethods;
if (codecs->GetNumberOfMethods(&numMethods) == S_OK)
for (UInt32 j = 0; j < numMethods; j++)
{
int libIndex = codecs->GetCodecLibIndex(j);
if (libIndex >= 0)
{
char s[32];
ConvertUInt64ToString(libIndex, s);
PrintString(stdStream, s, 2);
}
else
stdStream << " ";
stdStream << ' ';
stdStream << (char)(codecs->GetCodecEncoderIsAssigned(j) ? 'C' : ' ');
UInt64 id;
stdStream << " ";
HRESULT res = codecs->GetCodecId(j, id);
if (res != S_OK)
id = (UInt64)(Int64)-1;
char s[32];
ConvertUInt64ToString(id, s, 16);
PrintString(stdStream, s, 8);
stdStream << " ";
PrintString(stdStream, codecs->GetCodecName(j), 11);
stdStream << endl;
/*
if (res != S_OK)
throw "incorrect Codec ID";
*/
}
#endif
return S_OK;
}
else if (options.Command.CommandType == NCommandType::kBenchmark)
{
if (options.Method.CompareNoCase(L"CRC") == 0)
{
HRESULT res = CrcBenchCon((FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
if (res != S_OK)
{
if (res == S_FALSE)
{
stdStream << "\nCRC Error\n";
return NExitCode::kFatalError;
}
throw CSystemException(res);
}
}
else
{
HRESULT res = LzmaBenchCon(
#ifdef EXTERNAL_LZMA
codecs,
#endif
(FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
if (res != S_OK)
{
if (res == S_FALSE)
{
stdStream << "\nDecoding Error\n";
return NExitCode::kFatalError;
}
throw CSystemException(res);
}
}
}
else if (isExtractGroupCommand || options.Command.CommandType == NCommandType::kList)
{
if(isExtractGroupCommand)
{
CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
ecs->OutStream = &stdStream;
ecs->PasswordIsDefined = options.PasswordEnabled;
ecs->Password = options.Password;
ecs->Init();
COpenCallbackConsole openCallback;
openCallback.OutStream = &stdStream;
openCallback.PasswordIsDefined = options.PasswordEnabled;
openCallback.Password = options.Password;
CExtractOptions eo;
eo.StdOutMode = options.StdOutMode;
eo.PathMode = options.Command.GetPathMode();
eo.TestMode = options.Command.IsTestMode();
eo.OverwriteMode = options.OverwriteMode;
eo.OutputDir = options.OutputDir;
eo.YesToAll = options.YesToAll;
#ifdef COMPRESS_MT
eo.Properties = options.ExtractProperties;
#endif
UString errorMessage;
CDecompressStat stat;
HRESULT result = DecompressArchives(
codecs,
options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
options.WildcardCensor.Pairs.Front().Head,
eo, &openCallback, ecs, errorMessage, stat);
if (!errorMessage.IsEmpty())
{
stdStream << endl << "Error: " << errorMessage;
if (result == S_OK)
result = E_FAIL;
}
stdStream << endl;
if (ecs->NumArchives > 1)
stdStream << "Archives: " << ecs->NumArchives << endl;
if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
{
if (ecs->NumArchives > 1)
{
stdStream << endl;
if (ecs->NumArchiveErrors != 0)
stdStream << "Archive Errors: " << ecs->NumArchiveErrors << endl;
if (ecs->NumFileErrors != 0)
stdStream << "Sub items Errors: " << ecs->NumFileErrors << endl;
}
if (result != S_OK)
throw CSystemException(result);
return NExitCode::kFatalError;
}
if (result != S_OK)
throw CSystemException(result);
if (stat.NumFolders != 0)
stdStream << "Folders: " << stat.NumFolders << endl;
if (stat.NumFiles != 1 || stat.NumFolders != 0)
stdStream << "Files: " << stat.NumFiles << endl;
stdStream
<< "Size: " << stat.UnpackSize << endl
<< "Compressed: " << stat.PackSize << endl;
}
else
{
UInt64 numErrors = 0;
HRESULT result = ListArchives(
codecs,
options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
options.WildcardCensor.Pairs.Front().Head,
options.EnableHeaders,
options.TechMode,
options.PasswordEnabled,
options.Password, numErrors);
if (numErrors > 0)
{
g_StdOut << endl << "Errors: " << numErrors;
return NExitCode::kFatalError;
}
if (result != S_OK)
throw CSystemException(result);
}
}
else if(options.Command.IsFromUpdateGroup())
{
UString workingDir;
CUpdateOptions &uo = options.UpdateOptions;
if (uo.SfxMode && uo.SfxModule.IsEmpty())
uo.SfxModule = kDefaultSfxModule;
bool passwordIsDefined =
options.PasswordEnabled && !options.Password.IsEmpty();
COpenCallbackConsole openCallback;
openCallback.OutStream = &stdStream;
openCallback.PasswordIsDefined = passwordIsDefined;
openCallback.Password = options.Password;
CUpdateCallbackConsole callback;
callback.EnablePercents = options.EnablePercents;
callback.PasswordIsDefined = passwordIsDefined;
callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
callback.Password = options.Password;
callback.StdOutMode = uo.StdOutMode;
callback.Init(&stdStream);
CUpdateErrorInfo errorInfo;
if (!uo.Init(codecs, options.ArchiveName, options.ArcType))
throw "Unsupported archive type";
HRESULT result = UpdateArchive(codecs,
options.WildcardCensor, uo,
errorInfo, &openCallback, &callback);
int exitCode = NExitCode::kSuccess;
if (callback.CantFindFiles.Size() > 0)
{
stdStream << endl;
stdStream << "WARNINGS for files:" << endl << endl;
int numErrors = callback.CantFindFiles.Size();
for (int i = 0; i < numErrors; i++)
{
stdStream << callback.CantFindFiles[i] << " : ";
stdStream << NError::MyFormatMessageW(callback.CantFindCodes[i]) << endl;
}
stdStream << "----------------" << endl;
stdStream << "WARNING: Cannot find " << numErrors << " file";
if (numErrors > 1)
stdStream << "s";
stdStream << endl;
exitCode = NExitCode::kWarning;
}
if (result != S_OK)
{
UString message;
if (!errorInfo.Message.IsEmpty())
{
message += errorInfo.Message;
message += L"\n";
}
if (!errorInfo.FileName.IsEmpty())
{
message += errorInfo.FileName;
message += L"\n";
}
if (!errorInfo.FileName2.IsEmpty())
{
message += errorInfo.FileName2;
message += L"\n";
}
if (errorInfo.SystemError != 0)
{
message += NError::MyFormatMessageW(errorInfo.SystemError);
message += L"\n";
}
if (!message.IsEmpty())
stdStream << L"\nError:\n" << message;
throw CSystemException(result);
}
int numErrors = callback.FailedFiles.Size();
if (numErrors == 0)
{
if (callback.CantFindFiles.Size() == 0)
stdStream << kEverythingIsOk << endl;
}
else
{
stdStream << endl;
stdStream << "WARNINGS for files:" << endl << endl;
for (int i = 0; i < numErrors; i++)
{
stdStream << callback.FailedFiles[i] << " : ";
stdStream << NError::MyFormatMessageW(callback.FailedCodes[i]) << endl;
}
stdStream << "----------------" << endl;
stdStream << "WARNING: Cannot open " << numErrors << " file";
if (numErrors > 1)
stdStream << "s";
stdStream << endl;
exitCode = NExitCode::kWarning;
}
return exitCode;
}
else
PrintHelpAndExit(stdStream);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -