4.46 beta

This commit is contained in:
Igor Pavlov
2007-05-25 00:00:00 +00:00
committed by Kornel Lesiński
parent a145bfc7cf
commit c574fc0f4b
191 changed files with 1318 additions and 854 deletions

View File

@@ -8,8 +8,6 @@
#include "../Common/OpenArchive.h"
static const UInt64 kMaxCheckStartPosition = 1 << 20;
static inline UINT GetCurrentFileCodePage()
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }

View File

@@ -2,7 +2,9 @@
#include "StdAfx.h"
#ifdef _WIN32
#include <io.h>
#endif
#include <stdio.h>
#include "Common/ListFileUtils.h"
@@ -26,8 +28,6 @@ using namespace NCommandLineParser;
using namespace NWindows;
using namespace NFile;
static const int kNumSwitches = 28;
namespace NKey {
enum Enum
{
@@ -58,7 +58,8 @@ enum Enum
kShowDialog,
kLargePages,
kCharSet,
kTechMode
kTechMode,
kShareForWrite
};
}
@@ -92,7 +93,7 @@ NExtract::NOverwriteMode::EEnum k_OverwriteModes[] =
NExtract::NOverwriteMode::kAutoRenameExisting
};
static const CSwitchForm kSwitchForms[kNumSwitches] =
static const CSwitchForm kSwitchForms[] =
{
{ L"?", NSwitchType::kSimple, false },
{ L"H", NSwitchType::kSimple, false },
@@ -121,10 +122,10 @@ static const CSwitchForm kSwitchForms[kNumSwitches] =
{ L"AD", NSwitchType::kSimple, false },
{ L"SLP", NSwitchType::kUnLimitedPostString, false, 0},
{ L"SCS", NSwitchType::kUnLimitedPostString, false, 0},
{ L"SLT", NSwitchType::kSimple, false }
{ L"SLT", NSwitchType::kSimple, false },
{ L"SSW", NSwitchType::kSimple, false }
};
static const CCommandForm g_CommandForms[] =
{
{ L"A", false },
@@ -140,7 +141,6 @@ static const CCommandForm g_CommandForms[] =
static const int kNumCommandForms = sizeof(g_CommandForms) / sizeof(g_CommandForms[0]);
static const int kMaxCmdLineSize = 1000;
static const wchar_t *kUniversalWildcard = L"*";
static const int kMinNonSwitchWords = 1;
static const int kCommandIndex = 0;
@@ -250,7 +250,7 @@ static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
return true;
}
static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
static inline UINT GetCurrentCodePage() { return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
@@ -346,9 +346,9 @@ static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
}
{
NSynchronization::CEvent event;
event.Open(EVENT_MODIFY_STATE, false, GetSystemString(eventName));
event.Set();
NSynchronization::CManualResetEvent event;
if (event.Open(EVENT_MODIFY_STATE, false, GetSystemString(eventName)) == S_OK)
event.Set();
}
}
#endif
@@ -666,7 +666,8 @@ static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &pr
}
}
CArchiveCommandLineParser::CArchiveCommandLineParser(): parser(kNumSwitches) {}
CArchiveCommandLineParser::CArchiveCommandLineParser():
parser(sizeof(kSwitchForms) / sizeof(kSwitchForms[0])) {}
void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
CArchiveCommandLineOptions &options)
@@ -680,9 +681,9 @@ void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
ThrowUserErrorException();
}
options.IsInTerminal = (_isatty(_fileno(stdin)) != 0);
options.IsStdOutTerminal = (_isatty(_fileno(stdout)) != 0);
options.IsStdErrTerminal = (_isatty(_fileno(stderr)) != 0);
options.IsInTerminal = (isatty(fileno(stdin)) != 0);
options.IsStdOutTerminal = (isatty(fileno(stdout)) != 0);
options.IsStdErrTerminal = (isatty(fileno(stderr)) != 0);
options.StdOutMode = parser[NKey::kStdOut].ThereIs;
options.EnableHeaders = !parser[NKey::kDisableHeaders].ThereIs;
options.HelpMode = parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs || parser[NKey::kHelp3].ThereIs;
@@ -895,6 +896,9 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
SetMethodOptions(parser, updateOptions.MethodMode.Properties);
if (parser[NKey::kShareForWrite].ThereIs)
updateOptions.OpenShareForWrite = true;
options.EnablePercents = !parser[NKey::kDisablePercents].ThereIs;
if (options.EnablePercents)

View File

@@ -39,7 +39,7 @@ static void AddLagePagesSwitch(UString &params)
HRESULT MyCreateProcess(const UString &params,
LPCWSTR curDir, bool waitFinish,
NWindows::NSynchronization::CEvent *event)
NWindows::NSynchronization::CBaseEvent *event)
{
const UString params2 = params;
PROCESS_INFORMATION processInformation;
@@ -114,9 +114,28 @@ static UString Get7zGuiPath()
return GetQuotedString(path);
}
static HRESULT CreateTempEvent(const wchar_t *name,
NSynchronization::CManualResetEvent &event, UString &eventName)
{
CRandom random;
random.Init(GetTickCount());
for (;;)
{
int number = random.Generate();
wchar_t temp[32];
ConvertUInt64ToString((UInt32)number, temp);
eventName = name;
eventName += temp;
RINOK(event.CreateWithName(false, GetSystemString(eventName)));
if (::GetLastError() != ERROR_ALREADY_EXISTS)
return S_OK;
event.Close();
}
}
static HRESULT CreateMap(const UStringVector &names,
const UString &id,
CFileMapping &fileMapping, NSynchronization::CEvent &event,
CFileMapping &fileMapping, NSynchronization::CManualResetEvent &event,
UString &params)
{
UInt32 extraSize = 2;
@@ -126,7 +145,6 @@ static HRESULT CreateMap(const UStringVector &names,
UInt32 totalSize = extraSize + dataSize;
UString mappingName;
UString eventName;
CRandom random;
random.Init(GetTickCount());
@@ -146,20 +164,8 @@ static HRESULT CreateMap(const UStringVector &names,
fileMapping.Close();
}
for (;;)
{
int number = random.Generate();
wchar_t temp[32];
ConvertUInt64ToString(UInt32(number), temp);
eventName = id;
eventName += L"MappingEndEvent";
eventName += temp;
if (!event.Create(true, false, GetSystemString(eventName)))
return E_FAIL;
if (::GetLastError() != ERROR_ALREADY_EXISTS)
break;
event.Close();
}
UString eventName;
RINOK(CreateTempEvent(id + L"MappingEndEvent", event, eventName));
params += mappingName;
params += L":";
@@ -218,7 +224,6 @@ HRESULT CompressFiles(
UInt32 totalSize = extraSize + dataSize;
UString mappingName;
UString eventName;
CFileMapping fileMapping;
CRandom random;
@@ -241,23 +246,9 @@ HRESULT CompressFiles(
fileMapping.Close();
}
NSynchronization::CEvent event;
for (;;)
{
int number = random.Generate();
wchar_t temp[32];
ConvertUInt64ToString(UInt32(number), temp);
eventName = L"7zCompressMappingEndEvent";
eventName += temp;
if (!event.Create(true, false, GetSystemString(eventName)))
{
// MyMessageBox(IDS_ERROR, 0x02000605);
return E_FAIL;
}
if (::GetLastError() != ERROR_ALREADY_EXISTS)
break;
event.Close();
}
NSynchronization::CManualResetEvent event;
UString eventName;
RINOK(CreateTempEvent(L"7zCompressMappingEndEvent", event, eventName));
params += mappingName;
params += L":";
@@ -337,7 +328,7 @@ static HRESULT ExtractGroupCommand(const UStringVector &archivePaths,
params2 += kArchiveNoNameSwitch;
params2 += kArchiveMapSwitch;
CFileMapping fileMapping;
NSynchronization::CEvent event;
NSynchronization::CManualResetEvent event;
RINOK(CreateMap(archivePaths, L"7zExtract", fileMapping, event, params2));
return MyCreateProcess(params2, 0, false, &event);
}

View File

@@ -8,7 +8,7 @@
HRESULT MyCreateProcess(const UString &params,
LPCWSTR lpCurrentDirectory, bool waitFinish,
NWindows::NSynchronization::CEvent *event);
NWindows::NSynchronization::CBaseEvent *event);
HRESULT CompressFiles(
const UString &curDir,

View File

@@ -14,7 +14,7 @@ namespace NOverwriteAnswer
kNo,
kNoToAll,
kAutoRename,
kCancel,
kCancel
};
}

View File

@@ -58,6 +58,8 @@ static bool ReadPathFromRegistry(HKEY baseKey, CSysString &path)
return false;
}
#endif
CSysString GetBaseFolderPrefixFromRegistry()
{
CSysString moduleFolderPrefix = GetLibraryFolderPrefix();
@@ -71,8 +73,8 @@ CSysString GetBaseFolderPrefixFromRegistry()
if (NFind::FindFile(moduleFolderPrefix + kFormatsFolderName, fileInfo))
if (fileInfo.IsDirectory())
return moduleFolderPrefix;
CSysString path;
#ifdef _WIN32
CSysString path;
if (ReadPathFromRegistry(HKEY_CURRENT_USER, path))
return path;
if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
@@ -81,9 +83,6 @@ CSysString GetBaseFolderPrefixFromRegistry()
return moduleFolderPrefix;
}
#endif
typedef UInt32 (WINAPI *GetNumberOfMethodsFunc)(UInt32 *numMethods);
typedef UInt32 (WINAPI *GetNumberOfFormatsFunc)(UInt32 *numFormats);
typedef UInt32 (WINAPI *GetHandlerPropertyFunc)(PROPID propID, PROPVARIANT *value);

View File

@@ -97,7 +97,7 @@ struct CArchiveLink
IInArchive *GetArchive() { return Archive1 != 0 ? Archive1: Archive0; }
UString GetDefaultItemName() { return Archive1 != 0 ? DefaultItemName1: DefaultItemName0; }
const int GetArchiverIndex() const { return Archive1 != 0 ? FormatIndex1: FormatIndex0; }
int GetArchiverIndex() const { return Archive1 != 0 ? FormatIndex1: FormatIndex0; }
HRESULT Close();
void Release();
};

View File

@@ -67,6 +67,7 @@ void SortStringsToIndices(const UStringVector &strings, CIntVector &indices)
// TSort(&indices.Front(), indices.Size(), CompareStrings, (void *)&strings);
}
/*
void SortStrings(const UStringVector &src, UStringVector &dest)
{
CIntVector indices;
@@ -76,3 +77,4 @@ void SortStrings(const UStringVector &src, UStringVector &dest)
for (int i = 0; i < indices.Size(); i++)
dest.Add(src[indices[i]]);
}
*/

View File

@@ -6,6 +6,6 @@
#include "Common/String.h"
void SortStringsToIndices(const UStringVector &strings, CIntVector &indices);
void SortStrings(const UStringVector &src, UStringVector &dest);
// void SortStrings(const UStringVector &src, UStringVector &dest);
#endif

View File

@@ -46,11 +46,8 @@ using namespace NCOM;
using namespace NFile;
using namespace NName;
static const wchar_t *kTempArchiveFilePrefixString = L"7zi";
static const wchar_t *kTempFolderPrefix = L"7zE";
static const char *kIllegalFileNameMessage = "Illegal file name for temp archive";
using namespace NUpdateArchive;
static HRESULT CopyBlock(ISequentialInStream *inStream, ISequentialOutStream *outStream)
@@ -277,6 +274,7 @@ static HRESULT Compress(
const CCompressionMethodMode &compressionMethod,
CArchivePath &archivePath,
const CObjectVector<CArchiveItem> &archiveItems,
bool shareForWrite,
bool stdInMode,
/* const UString & stdInFileName, */
bool stdOutMode,
@@ -338,6 +336,7 @@ static HRESULT Compress(
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec );
updateCallbackSpec->ShareForWrite = shareForWrite;
updateCallbackSpec->StdInMode = stdInMode;
updateCallbackSpec->Callback = callback;
updateCallbackSpec->DirItems = &dirItems;
@@ -518,6 +517,7 @@ static HRESULT UpdateWithItemLists(
options.MethodMode,
command.ArchivePath,
archiveItems,
options.OpenShareForWrite,
options.StdInMode,
/* options.StdInFileName, */
options.StdOutMode,

View File

@@ -99,6 +99,8 @@ struct CUpdateOptions
bool SfxMode;
UString SfxModule;
bool OpenShareForWrite;
bool StdInMode;
UString StdInFileName;
bool StdOutMode;
@@ -117,7 +119,8 @@ struct CUpdateOptions
StdInMode(false),
StdOutMode(false),
EMailMode(false),
EMailRemoveAfter(false)
EMailRemoveAfter(false),
OpenShareForWrite(false)
{};
CRecordVector<UInt64> VolumesSizes;
};

View File

@@ -17,6 +17,7 @@ using namespace NWindows;
CArchiveUpdateCallback::CArchiveUpdateCallback():
Callback(0),
ShareForWrite(false),
StdInMode(false),
DirItems(0),
ArchiveItems(0),
@@ -202,7 +203,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
CInFileStream *inStreamSpec = new CInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
UString path = DirPrefix + dirItem.FullPath;
if(!inStreamSpec->Open(path))
if(!inStreamSpec->OpenShared(path, ShareForWrite))
{
return Callback->OpenFileError(path, ::GetLastError());
}

View File

@@ -58,6 +58,7 @@ public:
IUpdateCallbackUI *Callback;
UString DirPrefix;
bool ShareForWrite;
bool StdInMode;
const CObjectVector<CDirItem> *DirItems;
const CObjectVector<CArchiveItem> *ArchiveItems;

View File

@@ -126,8 +126,8 @@ static const TCHAR *kCompressionShowPasswordValueName = TEXT("ShowPassword");
static const TCHAR *kCompressionEncryptHeadersValueName = TEXT("EncryptHeaders");
static const TCHAR *kCompressionOptionsKeyName = TEXT("Options");
static const TCHAR *kSolid = TEXT("Solid");
static const TCHAR *kMultiThread = TEXT("Multithread");
// static const TCHAR *kSolid = TEXT("Solid");
// static const TCHAR *kMultiThread = TEXT("Multithread");
static const WCHAR *kCompressionOptions = L"Options";
static const TCHAR *kCompressionLevel = TEXT("Level");

View File

@@ -704,6 +704,15 @@ SOURCE=..\..\..\..\C\Alloc.c
SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.h
# End Source File
# End Group
# End Target
# End Project

View File

@@ -2,8 +2,6 @@
#include "StdAfx.h"
#include <stdio.h>
#include "ConsoleClose.h"
static int g_BreakCounter = 0;

View File

@@ -396,15 +396,15 @@ HRESULT ListArchives(
CCodecs *codecs,
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
bool enableHeaders, bool techMode, bool &passwordEnabled, UString &password)
bool enableHeaders, bool techMode, bool &passwordEnabled, UString &password, UInt64 &numErrors)
{
numErrors = 0;
CFieldPrinter fieldPrinter;
if (!techMode)
fieldPrinter.Init(kStandardFieldTable, sizeof(kStandardFieldTable) / sizeof(kStandardFieldTable[0]));
UInt64 numFiles2 = 0, totalPackSize2 = 0, totalUnPackSize2 = 0;
UInt64 *totalPackSizePointer2 = 0, *totalUnPackSizePointer2 = 0;
int numErrors = 0;
for (int i = 0; i < archivePaths.Size(); i++)
{
const UString &archiveName = archivePaths[i];
@@ -528,7 +528,5 @@ HRESULT ListArchives(
g_StdOut << endl;
g_StdOut << "Archives: " << archivePaths.Size() << endl;
}
if (numErrors > 0)
g_StdOut << endl << "Errors: " << numErrors;
return S_OK;
}

View File

@@ -10,7 +10,7 @@ HRESULT ListArchives(
CCodecs *codecs,
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
bool enableHeaders, bool techMode, bool &passwordEnabled, UString &password);
bool enableHeaders, bool techMode, bool &passwordEnabled, UString &password, UInt64 &errors);
#endif

View File

@@ -2,8 +2,6 @@
#include "StdAfx.h"
#include <io.h>
#include "Common/MyInitGuid.h"
#include "Common/CommandLineParser.h"
@@ -108,6 +106,7 @@ static const char *kHelpString =
" -si[{name}]: read data from stdin\n"
" -slt: show technical information for l (List) command\n"
" -so: write data to stdout\n"
" -ssw: compress shared files\n"
" -t{Type}: Set type of archive\n"
" -v{Size}[b|k|m|g]: Create volumes\n"
" -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options\n"
@@ -118,7 +117,6 @@ static const char *kHelpString =
// ---------------------------
// exception messages
static const char *kProcessArchiveMessage = " archive: ";
static const char *kEverythingIsOk = "Everything is Ok";
static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode::kUserError
@@ -151,13 +149,7 @@ static void GetArguments(int numArguments, const char *arguments[], UStringVecto
static void ShowCopyrightAndHelp(CStdOutStream &s, bool needHelp)
{
s << kCopyrightString;
/*
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
s << "System configuration: " << (UInt64)numCPUs << " CPU";
if (numCPUs > 1)
s << "s";
s << "\n";
*/
// s << "# CPUs: " << (UInt64)NWindows::NSystem::GetNumberOfProcessors() << "\n";
if (needHelp)
s << kHelpString;
}
@@ -439,6 +431,7 @@ int Main2(
}
else
{
UInt64 numErrors = 0;
HRESULT result = ListArchives(
codecs,
options.ArchivePathsSorted,
@@ -447,7 +440,12 @@ int Main2(
options.EnableHeaders,
options.TechMode,
options.PasswordEnabled,
options.Password);
options.Password, numErrors);
if (numErrors > 0)
{
g_StdOut << endl << "Errors: " << numErrors;
return NExitCode::kFatalError;
}
if (result != S_OK)
throw CSystemException(result);
}

View File

@@ -19,9 +19,21 @@ using namespace NWindows;
CStdOutStream *g_StdStream = 0;
#ifdef _WIN32
#ifndef _UNICODE
bool g_IsNT = false;
#endif
#if !defined(_UNICODE) || !defined(_WIN64)
static inline bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
#endif
#endif
extern int Main2(
#ifndef _WIN32
@@ -36,15 +48,6 @@ static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required
static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n";
static const char *kInternalExceptionMessage = "\n\nInternal Error #";
static inline bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
int
#ifdef _MSC_VER
__cdecl
@@ -57,15 +60,21 @@ int numArguments, const char *arguments[]
)
{
g_StdStream = &g_StdOut;
#ifdef _WIN32
#ifdef _UNICODE
#ifndef _WIN64
if (!IsItWindowsNT())
{
(*g_StdStream) << "This program requires Windows NT/2000/XP/2003";
(*g_StdStream) << "This program requires Windows NT/2000/XP/2003/Vista";
return NExitCode::kFatalError;
}
#endif
#else
g_IsNT = IsItWindowsNT();
#endif
#endif
// setlocale(LC_COLLATE, ".OCP");
NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;

View File

@@ -26,8 +26,6 @@ static const wchar_t *kEmptyFileAlias = L"[Content]";
static const char *kCreatingArchiveMessage = "Creating archive ";
static const char *kUpdatingArchiveMessage = "Updating archive ";
static const char *kScanningMessage = "Scanning";
static const char *kNoFilesScannedMessage = "No files scanned";
static const char *kTotalFilesAddedMessage = "Total files added to archive: ";
HRESULT CUpdateCallbackConsole::OpenResult(const wchar_t *name, HRESULT result)

View File

@@ -14,7 +14,7 @@ enum EEnum
kYesAll,
kNoAll,
kAutoRename,
kQuit,
kQuit
};
}

View File

@@ -79,6 +79,7 @@ LZMA_BENCH_OBJS = \
C_OBJS = \
$O\Alloc.obj \
$O\Threads.obj \
!include "../../Crc2.mak"

View File

@@ -42,8 +42,6 @@
using namespace NWindows;
static LPCTSTR kFileClassIDString = TEXT("SevenZip");
///////////////////////////////
// IShellExtInit

View File

@@ -534,6 +534,15 @@ SOURCE=..\..\..\..\C\Sort.c
SOURCE=..\..\..\..\C\Sort.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.h
# End Source File
# End Group
# Begin Group "Common"

View File

@@ -93,6 +93,7 @@ FM_COMMON_OBJS = \
C_OBJS = \
$O\Alloc.obj \
$O\Sort.obj \
$O\Threads.obj \
OBJS = \
$O\StdAfx.obj \

View File

@@ -147,8 +147,8 @@ STDMETHODIMP CExtractCallBackImp::SetOperationResult(INT32 operationResult, bool
return E_FAIL;
}
char buffer[512];
sprintf(buffer, g_StartupInfo.GetMsgString(idMessage),
GetSystemString(m_CurrentFilePath, m_CodePage));
const AString s = GetSystemString(m_CurrentFilePath, m_CodePage);
sprintf(buffer, g_StartupInfo.GetMsgString(idMessage), (const char *)s);
if (g_StartupInfo.ShowMessage(buffer) == -1)
return E_ABORT;
}

View File

@@ -570,6 +570,15 @@ SOURCE=..\..\..\..\C\Sort.c
SOURCE=..\..\..\..\C\Sort.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.h
# End Source File
# End Group
# End Target
# End Project

View File

@@ -33,8 +33,6 @@ using namespace NFar;
static const char *kCommandPrefix = "7-zip";
static const int kDescriptionMaxSize = 256;
static const char *kRegisrtryMainKeyName = "";
static const char *kRegisrtryValueNameEnabled = "UsedByDefault3";

View File

@@ -21,8 +21,6 @@ using namespace NFar;
namespace NOverwriteDialog {
static const char *kHelpTopic = "OverwriteDialog";
struct CFileInfoStrings
{
CSysString Size;

View File

@@ -421,8 +421,10 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
char updateAddToArchiveString[512];
const AString s = GetSystemString(arcInfo.Name, CP_OEMCP);
sprintf(updateAddToArchiveString,
g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), GetSystemString(arcInfo.Name), CP_OEMCP);
g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s);
int methodIndex = 0;
int i;
@@ -534,7 +536,6 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
if (archiveName.Right(prevExtensionLen).CompareNoCase(prevExtension) == 0)
{
int pos = archiveName.Length() - prevExtensionLen;
UString temp = archiveName.Left(pos);
if (pos > 1)
{
int dotPos = archiveName.ReverseFind('.');

View File

@@ -71,6 +71,7 @@ AGENT_OBJS = \
C_OBJS = \
$O\Alloc.obj \
$O\Sort.obj \
$O\Threads.obj \
OBJS = \
$O\StdAfx.obj \

View File

@@ -53,6 +53,7 @@ static CIDLangPair kIDLangPairs[] =
{ IDC_STATIC_COMPRESS_UPDATE_MODE, 0x02000D02 },
{ IDC_STATIC_COMPRESS_OPTIONS, 0x02000D07 },
{ IDC_COMPRESS_SFX, 0x02000D08 },
{ IDC_COMPRESS_SHARED, 0x02000D16 },
{ IDC_COMPRESS_ENCRYPTION, 0x02000D10 },
{ IDC_STATIC_COMPRESS_PASSWORD1, 0x02000B01 },
@@ -194,7 +195,7 @@ static const CFormatInfo g_Formats[] =
},
{
L"GZip",
(1 << 5) | (1 << 7) | (1 << 9),
(1 << 1) | (1 << 5) | (1 << 7) | (1 << 9),
g_GZipMethods, MY_SIZE_OF_ARRAY(g_GZipMethods),
false, false, false, false, false, false
},
@@ -301,6 +302,7 @@ bool CCompressDialog::OnInit()
SetItemText(IDC_COMPRESS_HARDWARE_THREADS, s);
CheckButton(IDC_COMPRESS_SFX, Info.SFXMode);
CheckButton(IDC_COMPRESS_SHARED, Info.OpenShareForWrite);
CheckControlsEnable();
@@ -539,6 +541,8 @@ void CCompressDialog::OnOK()
Info.EncryptionMethod = GetEncryptionMethodSpec();
Info.ArchiverInfoIndex = m_Format.GetCurSel();
Info.SFXMode = IsSFX();
Info.OpenShareForWrite = IsButtonCheckedBool(IDC_COMPRESS_SHARED);
m_RegistryInfo.EncryptHeaders = Info.EncryptHeaders = IsButtonCheckedBool(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES);
m_Params.GetText(Info.Options);

View File

@@ -43,6 +43,8 @@ namespace NCompressDialog
UString EncryptionMethod;
bool SFXMode;
bool OpenShareForWrite;
UString ArchiveName; // in: Relative for ; out: abs
UString CurrentDirPrefix;

View File

@@ -36,6 +36,8 @@ static const int kPathModeButtons[] =
IDC_EXTRACT_RADIO_NO_PATHNAMES
};
#ifndef _SFX
static const NExtract::NPathMode::EEnum kPathModeButtonsVals[] =
{
NExtract::NPathMode::kFullPathnames,
@@ -74,7 +76,6 @@ static const int kFilesButtons[] =
static const int kNumFilesButtons = sizeof(kFilesButtons) / sizeof(kFilesButtons[0]);
*/
#ifndef _SFX
void CExtractDialog::GetPathMode()
{
for (int i = 0; i < kNumPathnamesButtons; i++)
@@ -169,7 +170,9 @@ static CIDLangPair kIDLangPairs[] =
// static const int kWildcardsButtonIndex = 2;
#ifndef NO_REGISTRY
static const int kHistorySize = 8;
#endif
bool CExtractDialog::OnInit()
{

View File

@@ -72,7 +72,7 @@ struct CThreadExtracting
ExtractCallbackSpec->ProgressDialog.MyClose();
return 0;
}
static DWORD WINAPI MyThreadFunction(void *param)
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
return ((CThreadExtracting *)param)->Process();
}
@@ -154,9 +154,8 @@ HRESULT ExtractGUI(
extracter.Options = &options;
extracter.OpenCallback = openCallback;
CThread thread;
if (!thread.Create(CThreadExtracting::MyThreadFunction, &extracter))
throw 271824;
NWindows::CThread thread;
RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &extracter));
extracter.ExtractCallbackSpec->StartProgressDialog(title);
if (extracter.Result == S_OK && options.TestMode &&
extracter.ExtractCallbackSpec->Messages.IsEmpty() &&

View File

@@ -46,14 +46,13 @@ HINSTANCE g_hInstance;
bool g_IsNT = false;
#endif
static const wchar_t *kExceptionErrorMessage = L"Error:";
static const wchar_t *kUserBreak = L"Break signaled";
// static const wchar_t *kExceptionErrorMessage = L"Error:";
// static const wchar_t *kUserBreak = L"Break signaled";
static const wchar_t *kMemoryExceptionMessage = L"ERROR: Can't allocate required memory!";
static const wchar_t *kUnknownExceptionMessage = L"Unknown Error";
static const wchar_t *kInternalExceptionMessage = L"Internal Error #";
static const wchar_t *kIncorrectCommandMessage = L"Incorrect command";
// static const wchar_t *kInternalExceptionMessage = L"Internal Error #";
// static const wchar_t *kIncorrectCommandMessage = L"Incorrect command";
static void ErrorMessage(const wchar_t *message)
{

View File

@@ -684,6 +684,15 @@ SOURCE=..\..\..\..\C\Alloc.c
SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.h
# End Source File
# End Group
# Begin Group "Common"

View File

@@ -76,8 +76,6 @@ static const UInt32 kMaxDicSize =
(1 << 27);
#endif
static const int kDefaultDictionary = 22;
bool CBenchmarkDialog::OnInit()
{
#ifdef LANG
@@ -423,7 +421,7 @@ struct CThreadBenchmark
HRESULT Process();
HRESULT Result;
static DWORD WINAPI MyThreadFunction(void *param)
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
((CThreadBenchmark *)param)->Result = ((CThreadBenchmark *)param)->Process();
return 0;
@@ -465,8 +463,9 @@ HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
if (info2.NumIterations == 0)
info2.NumIterations = 1;
info2.GlobalTime /= info2.NumIterations;
info2.UserTime /= info2.NumIterations;
info2.UnpackSize *= info2.NumIterations;
info2.PackSize *= info2.NumIterations;
info2.NumIterations = 1;
if (final && SyncInfo->DecompressingInfo.GlobalTime == 0)
{
@@ -575,10 +574,8 @@ HRESULT Benchmark(
benchmarkDialog._syncInfo.NumThreads = numThreads;
benchmarker.SyncInfo = &benchmarkDialog._syncInfo;
CThread thread;
if (!thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker))
return E_FAIL;
NWindows::CThread thread;
RINOK(thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker));
benchmarkDialog.Create(0);
thread.Wait();
return S_OK;
return thread.Wait();
}

View File

@@ -39,6 +39,11 @@ public:
CBenchInfo2 DecompressingInfoTemp;
CBenchInfo2 DecompressingInfo;
CProgressSyncInfo()
{
if (_startEvent.Create() != S_OK)
throw 3986437;
}
void Init()
{
Changed = false;

View File

@@ -30,7 +30,7 @@
using namespace NWindows;
using namespace NFile;
static const wchar_t *kIncorrectOutDir = L"Incorrect output directory path";
// static const wchar_t *kIncorrectOutDir = L"Incorrect output directory path";
static const wchar_t *kDefaultSfxModule = L"7z.sfx";
static const wchar_t *kSFXExtension = L"exe";
@@ -76,7 +76,7 @@ struct CThreadUpdating
UpdateCallbackGUI->ProgressDialog.MyClose();
return 0;
}
static DWORD WINAPI MyThreadFunction(void *param)
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
return ((CThreadUpdating *)param)->Process();
}
@@ -273,6 +273,7 @@ static HRESULT ShowDialog(
di.CurrentDirPrefix = currentDirPrefix;
di.SFXMode = options.SfxMode;
di.OpenShareForWrite = options.OpenShareForWrite;
if (callback->PasswordIsDefined)
di.Password = callback->Password;
@@ -334,6 +335,7 @@ static HRESULT ShowDialog(
di.EncryptHeadersIsAllowed, di.EncryptHeaders,
di.SFXMode);
options.OpenShareForWrite = di.OpenShareForWrite;
ParseAndAddPropertires(options.MethodMode.Properties, di.Options);
if (di.SFXMode)
@@ -388,9 +390,8 @@ HRESULT UpdateGUI(
tu.OpenCallback = openCallback;
tu.ErrorInfo = &errorInfo;
CThread thread;
if (!thread.Create(CThreadUpdating::MyThreadFunction, &tu))
throw 271824;
NWindows::CThread thread;
RINOK(thread.Create(CThreadUpdating::MyThreadFunction, &tu))
tu.UpdateCallbackGUI->StartProgressDialog(LangString(IDS_PROGRESS_COMPRESSING, 0x02000DC0));
return tu.Result;
}

View File

@@ -100,6 +100,7 @@ FM_OBJS = \
C_OBJS = \
$O\Alloc.obj \
$O\Threads.obj \
!include "../../Crc2.mak"

View File

@@ -48,3 +48,5 @@
#define IDC_COMPRESS_COMBO_ENCRYPTION_METHOD 1121
#define IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES 1122
#define IDC_COMPRESS_SHARED 1130

View File

@@ -1,7 +1,7 @@
#include "resource.h"
#include "../../../GuiCommon.rc"
#define xSize2 380
#define xSize2 400
#define ySize2 305
#define xSize (xSize2 + marg + marg)
@@ -24,22 +24,25 @@
#undef bXPos3
#undef bYPos
#define gSize 180
#define gSize 190
#define gSpace 24
#define g0XSize 100
#define g1XSize 90
#define g0XSize (gSize - g1XSize)
#define g1XPos (marg + g0XSize)
#define g1XSize (gSize - g0XSize)
#define g2XSize 122
#define g3XSize 40
#define g2XSize (gSize - g3XSize)
#define g3XPos (marg + g2XSize)
#define g3XSize (gSize - g2XSize)
#define g4XPos (marg + gSize + gSpace)
#define g4XPos2 (g4XPos + 7)
#define g4XSize (xSize2 - gSize - gSpace)
#define g4XSize2 (g4XSize - 14)
#define OptYPos 73
#define PswYPos 128
#define bXPos1 (xSize - marg - bXSize)
#define bXPos2 (bXPos1 - 10 - bXSize)
#define bXPos3 (bXPos2 - 10 - bXSize)
@@ -93,25 +96,27 @@ BEGIN
LTEXT "&Update mode:",IDC_STATIC_COMPRESS_UPDATE_MODE, g4XPos, 39, g4XSize, 8
COMBOBOX IDC_COMPRESS_COMBO_UPDATE_MODE, g4XPos, 51, g4XSize, 80, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Options",IDC_STATIC_COMPRESS_OPTIONS, g4XPos, 73, g4XSize, 32
GROUPBOX "Options",IDC_STATIC_COMPRESS_OPTIONS, g4XPos, OptYPos, g4XSize, 48
CONTROL "Create SF&X archive",IDC_COMPRESS_SFX, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
g4XPos2, 87, g4XSize2, 10
g4XPos2, OptYPos + 14, g4XSize2, 10
CONTROL "Compress shared files",IDC_COMPRESS_SHARED, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
g4XPos2, OptYPos + 30, g4XSize2, 10
GROUPBOX "Encryption",IDC_COMPRESS_ENCRYPTION, g4XPos, 113, g4XSize, 127
GROUPBOX "Encryption",IDC_COMPRESS_ENCRYPTION, g4XPos, PswYPos, g4XSize, 127
LTEXT "Enter password:",IDC_STATIC_COMPRESS_PASSWORD1, g4XPos2, 127, g4XSize2, 8
EDITTEXT IDC_COMPRESS_EDIT_PASSWORD1, g4XPos2, 139, g4XSize2, 14, ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Reenter password:",IDC_STATIC_COMPRESS_PASSWORD2, g4XPos2, 159, g4XSize2, 8
EDITTEXT IDC_COMPRESS_EDIT_PASSWORD2, g4XPos2, 171, g4XSize2, 14, ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Enter password:",IDC_STATIC_COMPRESS_PASSWORD1, g4XPos2, PswYPos + 14, g4XSize2, 8
EDITTEXT IDC_COMPRESS_EDIT_PASSWORD1, g4XPos2, PswYPos + 26, g4XSize2, 14, ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Reenter password:",IDC_STATIC_COMPRESS_PASSWORD2, g4XPos2, PswYPos + 46, g4XSize2, 8
EDITTEXT IDC_COMPRESS_EDIT_PASSWORD2, g4XPos2, PswYPos + 58, g4XSize2, 14, ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Show Password",IDC_COMPRESS_CHECK_SHOW_PASSWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
g4XPos2, 192, g4XSize2, 10
g4XPos2, PswYPos + 79, g4XSize2, 10
LTEXT "&Encryption method:",IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, g4XPos2, 208, 80, 8
COMBOBOX IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, g4XPos2 + 90, 206, g4XSize2 - 90, 198, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Encryption method:",IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, g4XPos2, PswYPos + 95, 100, 8
COMBOBOX IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, g4XPos2 + 100, PswYPos + 93, g4XSize2 - 100, 198, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Encrypt file &names", IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
g4XPos2, 224, g4XSize2, 10
g4XPos2, PswYPos + 111, g4XSize2, 10
DEFPUSHBUTTON "OK", IDOK, bXPos3, bYPos, bXSize, bYSize, WS_GROUP
PUSHBUTTON "Cancel", IDCANCEL, bXPos2, bYPos, bXSize, bYSize