4.59 beta

This commit is contained in:
Igor Pavlov
2008-08-13 00:00:00 +00:00
committed by Kornel Lesiński
parent 3901bf0ab8
commit 173c07e166
781 changed files with 22124 additions and 13650 deletions
+56 -23
View File
@@ -40,8 +40,8 @@
#include "../../MyVersion.h"
#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES)
extern "C"
{
extern "C"
{
#include "../../../../C/Alloc.h"
}
#endif
@@ -64,7 +64,7 @@ static const char *kCopyrightString = "\n7-Zip"
" " MY_VERSION_COPYRIGHT_DATE "\n";
static const char *kHelpString =
static const char *kHelpString =
"\nUsage: 7z"
#ifdef _NO_CRYPTO
"r"
@@ -96,7 +96,9 @@ static const char *kHelpString =
" -i[r[-|0]]{@listfile|!wildcard}: Include filenames\n"
" -m{Parameters}: set compression Method\n"
" -o{Directory}: set Output directory\n"
#ifndef _NO_CRYPTO
" -p{Password}: set Password\n"
#endif
" -r[-|0]: Recurse subdirectories\n"
" -scs{UTF-8 | WIN | DOS}: set charset for list files\n"
" -sfx[{name}]: Create SFX archive\n"
@@ -117,6 +119,7 @@ static const char *kHelpString =
static const char *kEverythingIsOk = "Everything is Ok";
static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode::kUserError
static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
static const wchar_t *kDefaultSfxModule = L"7zCon.sfx";
@@ -148,7 +151,7 @@ static void ShowCopyrightAndHelp(CStdOutStream &s, bool needHelp)
{
s << kCopyrightString;
// s << "# CPUs: " << (UInt64)NWindows::NSystem::GetNumberOfProcessors() << "\n";
if (needHelp)
if (needHelp)
s << kHelpString;
}
@@ -175,18 +178,20 @@ static inline char GetHex(Byte value)
return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
}
const char *kUnsupportedArcTypeMessage = "Unsupported archive type";
int Main2(
#ifndef _WIN32
#ifndef _WIN32
int numArguments, const char *arguments[]
#endif
)
{
#ifdef _WIN32
#ifdef _WIN32
SetFileApisToOEM();
#endif
UStringVector commandStrings;
#ifdef _WIN32
#ifdef _WIN32
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
#else
GetArguments(numArguments, arguments, commandStrings);
@@ -240,6 +245,17 @@ int Main2(
throw CSystemException(result);
bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
if (codecs->Formats.Size() == 0 &&
(isExtractGroupCommand ||
options.Command.CommandType == NCommandType::kList ||
options.Command.IsFromUpdateGroup()))
throw kNoFormats;
CIntVector formatIndices;
if (!codecs->FindFormatForArchiveType(options.ArcType, formatIndices))
throw kUnsupportedArcTypeMessage;
if (options.Command.CommandType == NCommandType::kInfo)
{
stdStream << endl << "Formats:" << endl;
@@ -373,14 +389,21 @@ int Main2(
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
ecs->OutStream = &stdStream;
#ifndef _NO_CRYPTO
ecs->PasswordIsDefined = options.PasswordEnabled;
ecs->Password = options.Password;
#endif
ecs->Init();
COpenCallbackConsole openCallback;
openCallback.OutStream = &stdStream;
#ifndef _NO_CRYPTO
openCallback.PasswordIsDefined = options.PasswordEnabled;
openCallback.Password = options.Password;
#endif
CExtractOptions eo;
eo.StdOutMode = options.StdOutMode;
@@ -396,9 +419,10 @@ int Main2(
CDecompressStat stat;
HRESULT result = DecompressArchives(
codecs,
options.ArchivePathsSorted,
formatIndices,
options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
options.WildcardCensor.Pairs.Front().Head,
options.WildcardCensor.Pairs.Front().Head,
eo, &openCallback, ecs, errorMessage, stat);
if (!errorMessage.IsEmpty())
{
@@ -430,7 +454,7 @@ int Main2(
stdStream << "Folders: " << stat.NumFolders << endl;
if (stat.NumFiles != 1 || stat.NumFolders != 0)
stdStream << "Files: " << stat.NumFiles << endl;
stdStream
stdStream
<< "Size: " << stat.UnpackSize << endl
<< "Compressed: " << stat.PackSize << endl;
}
@@ -439,13 +463,17 @@ int Main2(
UInt64 numErrors = 0;
HRESULT result = ListArchives(
codecs,
options.ArchivePathsSorted,
formatIndices,
options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
options.WildcardCensor.Pairs.Front().Head,
options.EnableHeaders,
options.WildcardCensor.Pairs.Front().Head,
options.EnableHeaders,
options.TechMode,
options.PasswordEnabled,
options.Password, numErrors);
#ifndef _NO_CRYPTO
options.PasswordEnabled,
options.Password,
#endif
numErrors);
if (numErrors > 0)
{
g_StdOut << endl << "Errors: " << numErrors;
@@ -463,28 +491,33 @@ int Main2(
if (uo.SfxMode && uo.SfxModule.IsEmpty())
uo.SfxModule = kDefaultSfxModule;
bool passwordIsDefined =
options.PasswordEnabled && !options.Password.IsEmpty();
COpenCallbackConsole openCallback;
openCallback.OutStream = &stdStream;
#ifndef _NO_CRYPTO
bool passwordIsDefined =
options.PasswordEnabled && !options.Password.IsEmpty();
openCallback.PasswordIsDefined = passwordIsDefined;
openCallback.Password = options.Password;
#endif
CUpdateCallbackConsole 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 = 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,
if (!uo.Init(codecs, formatIndices, options.ArchiveName))
throw kUnsupportedArcTypeMessage;
HRESULT result = UpdateArchive(codecs,
options.WildcardCensor, uo,
errorInfo, &openCallback, &callback);
int exitCode = NExitCode::kSuccess;
@@ -557,7 +590,7 @@ int Main2(
}
return exitCode;
}
else
else
PrintHelpAndExit(stdStream);
return 0;
}