Update to 7-Zip 17.01 Beta from Igor Pavlov

- Minor speed optimization for LZMA2 (xz and 7z) multi-threading compression.
  7-Zip now uses additional memory buffers for multi-block LZMA2 compression.
  CPU utilization was slightly improved.
- 7-zip now creates multi-block xz archives by default. Block size can be
  specified with -ms[Size]{m|g} switch.
- xz decoder now can unpack random block from multi-block xz archives.  7-Zip
  File Manager now can open nested multi-block xz archives (for example,
  image.iso.xz) without full unpacking of xz archive.
- 7-Zip now can create zip archives from stdin to stdout.
- 7-Zip command line: @listfile now doesn't work after -- switch.  Use
  -i@listfile before -- switch instead.

fixed bugs:
- 7-Zip could add unrequired alternate file streams to WIM archives, for
  commands that contain filename wildcards and -sns switch.
- 7-Zip 17.00 beta crashed for commands that write anti-item to 7z archive.
- 7-Zip 17.00 beta ignored "Use large memory pages" option.
This commit is contained in:
Tino Reichardt
2017-08-28 16:34:04 +02:00
parent 7c1f566312
commit ef790b5209
112 changed files with 4712 additions and 1705 deletions

View File

@@ -1453,7 +1453,12 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
pathMode = NExtract::NPathMode::kNoPathnames;
*/
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
extractCallbackSpec->InitForMulti(
false, // multiArchives
pathMode,
overwriteMode,
true // keepEmptyDirPrefixes
);
if (extractCallback2)
extractCallback2->SetTotal(_agentSpec->GetArc().GetEstmatedPhySize());
@@ -1717,7 +1722,12 @@ STDMETHODIMP CAgent::Extract(
COM_TRY_BEGIN
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
extractCallbackSpec->InitForMulti(
false, // multiArchives
pathMode,
overwriteMode,
true // keepEmptyDirPrefixes
);
CExtractNtOptions extractNtOptions;
extractNtOptions.AltStreams.Val = true; // change it!!!

View File

@@ -479,7 +479,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
}
_outFileStream.Release();
if (_extractMode && _processedFileInfo.AttribDefined)
SetFileAttrib(_diskFilePath, _processedFileInfo.Attrib);
SetFileAttrib_PosixHighDetect(_diskFilePath, _processedFileInfo.Attrib);
PrintNewLine();
return S_OK;
}

View File

@@ -988,7 +988,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|| !pathParts.IsEmpty()
|| !(_removePartsForAltStreams || _pathMode == NExtract::NPathMode::kNoPathsAlt))
#endif
Correct_FsPath(_pathMode == NExtract::NPathMode::kAbsPaths, pathParts, _item.MainIsDir);
Correct_FsPath(_pathMode == NExtract::NPathMode::kAbsPaths, _keepAndReplaceEmptyDirPrefixes, pathParts, _item.MainIsDir);
#ifdef SUPPORT_ALT_STREAMS
@@ -1542,7 +1542,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes)
NumFiles++;
if (!_stdOutMode && _extractMode && _fi.AttribDefined)
SetFileAttrib(_diskFilePath, _fi.Attrib);
SetFileAttrib_PosixHighDetect(_diskFilePath, _fi.Attrib);
RINOK(_extractCallback2->SetOperationResult(opRes, BoolToInt(_encrypted)));

View File

@@ -172,6 +172,7 @@ class CArchiveExtractCallback:
FString _dirPathPrefix_Full;
NExtract::NPathMode::EEnum _pathMode;
NExtract::NOverwriteMode::EEnum _overwriteMode;
bool _keepAndReplaceEmptyDirPrefixes; // replace them to "_";
#ifndef _SFX
@@ -278,11 +279,13 @@ public:
void InitForMulti(bool multiArchives,
NExtract::NPathMode::EEnum pathMode,
NExtract::NOverwriteMode::EEnum overwriteMode)
NExtract::NOverwriteMode::EEnum overwriteMode,
bool keepAndReplaceEmptyDirPrefixes)
{
_multiArchives = multiArchives;
_pathMode = pathMode;
_overwriteMode = overwriteMode;
_keepAndReplaceEmptyDirPrefixes = keepAndReplaceEmptyDirPrefixes;
NumFolders = NumFiles = NumAltStreams = UnpackSize = AltStreams_UnpackSize = 0;
}

View File

@@ -2376,15 +2376,7 @@ static UInt32 GetNumThreadsNext(unsigned i, UInt32 numThreads)
static bool AreSameMethodNames(const char *fullName, const char *shortName)
{
for (;;)
{
char c2 = *shortName++;
if (c2 == 0)
return true;
char c1 = *fullName++;
if (MyCharLower_Ascii(c1) != MyCharLower_Ascii(c2))
return false;
}
return StringsAreEqualNoCase_Ascii(fullName, shortName);
}
@@ -2545,27 +2537,24 @@ static const char * const k_PF[] =
#endif
static void PrintSize(AString &s, UInt64 ptr)
static void PrintSize(AString &s, UInt64 v)
{
UInt64 v = ptr;
UInt64 t = v >> 40;
UInt64 g = v >> 30;
UInt64 m = v >> 20;
UInt64 k = v >> 10;
UInt32 d = (UInt32)v;
char c = 0;
if (t >= 1000) { d = (UInt32)t; c = 'T'; }
else if (g >= 1000) { d = (UInt32)g; c = 'G'; }
else if (m >= 1000) { d = (UInt32)m; c = 'M'; }
else if (k >= 10) { d = (UInt32)k; c = 'K'; }
s.Add_UInt32(d);
// s += ' ';
if ((v & 0x3FF) == 0) { v >>= 10; c = 'K';
if ((v & 0x3FF) == 0) { v >>= 10; c = 'M';
if ((v & 0x3FF) == 0) { v >>= 10; c = 'G';
if ((v & 0x3FF) == 0) { v >>= 10; c = 'T';
}}}}
else
{
PrintHex(s, v);
return;
}
char temp[32];
ConvertUInt64ToString(v, temp);
s += temp;
if (c)
s += c;
// PrintHex(s, (DWORD_PTR)v);
}
@@ -2631,12 +2620,19 @@ static void SysInfo_To_String(AString &s, const SYSTEM_INFO &si)
s += " ";
DWORD_PTR minAdd = (DWORD_PTR)si.lpMinimumApplicationAddress;
if (minAdd != (1 << 16))
UInt64 maxSize = (UInt64)(DWORD_PTR)si.lpMaximumApplicationAddress + 1;
const UInt32 kReserveSize = ((UInt32)1 << 16);
if (minAdd != kReserveSize)
{
PrintSize(s, minAdd);
s += "-";
}
PrintSize(s, (UInt64)(DWORD_PTR)si.lpMaximumApplicationAddress + 1);
else
{
if ((maxSize & (kReserveSize - 1)) == 0)
maxSize += kReserveSize;
}
PrintSize(s, maxSize);
}
#ifndef _WIN64
@@ -3006,26 +3002,34 @@ HRESULT Bench(
UInt32 complexity = 10000;
const UInt32 *checkSum = NULL;
{
for (unsigned i = 0; i < ARRAY_SIZE(g_Hash); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(g_Hash); i++)
{
const CBenchHash &h = g_Hash[i];
AString s (h.Name);
AString hProp;
int propPos = s.Find(':');
AString benchMethod (h.Name);
AString benchProps;
int propPos = benchMethod.Find(':');
if (propPos >= 0)
{
hProp = s.Ptr(propPos + 1);
s.DeleteFrom(propPos);
benchProps = benchMethod.Ptr(propPos + 1);
benchMethod.DeleteFrom(propPos);
}
if (AreSameMethodNames(s, methodName))
if (AreSameMethodNames(benchMethod, methodName))
{
complexity = h.Complex;
checkSum = &h.CheckSum;
if (method.PropsString.IsEqualTo_Ascii_NoCase(hProp))
break;
if (benchProps.IsEmpty()
|| benchMethod.IsEqualTo_Ascii_NoCase("crc32") && benchProps == "8" && method.PropsString.IsEmpty()
|| method.PropsString.IsPrefixedBy_Ascii_NoCase(benchProps))
{
complexity = h.Complex;
checkSum = &h.CheckSum;
if (method.PropsString.IsEqualTo_Ascii_NoCase(benchProps))
break;
}
}
}
if (i == ARRAY_SIZE(g_Hash))
return E_NOTIMPL;
}
f.NewLine();
@@ -3316,18 +3320,35 @@ HRESULT Bench(
bool needSetComplexity = true;
if (!methodName.IsEqualTo_Ascii_NoCase("LZMA"))
{
for (unsigned i = 0; i < ARRAY_SIZE(g_Bench); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(g_Bench); i++)
{
const CBenchMethod &h = g_Bench[i];
if (AreSameMethodNames(h.Name, methodName))
AString benchMethod (h.Name);
AString benchProps;
int propPos = benchMethod.Find(':');
if (propPos >= 0)
{
callback.BenchProps.EncComplex = h.EncComplex;
callback.BenchProps.DecComplexCompr = h.DecComplexCompr;
callback.BenchProps.DecComplexUnc = h.DecComplexUnc;;
needSetComplexity = false;
break;
benchProps = benchMethod.Ptr(propPos + 1);
benchMethod.DeleteFrom(propPos);
}
if (AreSameMethodNames(benchMethod, methodName))
{
if (benchProps.IsEmpty()
|| benchProps == "x5" && method.PropsString.IsEmpty()
|| method.PropsString.IsPrefixedBy_Ascii_NoCase(benchProps))
{
callback.BenchProps.EncComplex = h.EncComplex;
callback.BenchProps.DecComplexCompr = h.DecComplexCompr;
callback.BenchProps.DecComplexUnc = h.DecComplexUnc;;
needSetComplexity = false;
break;
}
}
}
if (i == ARRAY_SIZE(g_Bench))
return E_NOTIMPL;
}
if (needSetComplexity)
callback.BenchProps.SetLzmaCompexity();

View File

@@ -40,7 +40,6 @@ using namespace NWindows;
#define kArcIncludeSwitches " -an -ai"
#define kHashIncludeSwitches " -i"
#define kStopSwitchParsing " --"
#define kLargePagesDisable " -slp-"
static NCompression::CInfo m_RegistryInfo;
extern HWND g_HWND;
@@ -96,8 +95,8 @@ static HRESULT Call7zGui(const UString &params,
static void AddLagePagesSwitch(UString &params)
{
if (!ReadLockMemoryEnable())
params += kLargePagesDisable;
if (ReadLockMemoryEnable())
params += " -slp";
}
class CRandNameGenerator
@@ -338,6 +337,7 @@ void Benchmark(bool totalMode)
UString params ('b');
if (totalMode)
params += " -mm=*";
AddLagePagesSwitch(params);
HRESULT result = Call7zGui(params, false, NULL);
if (result != S_OK)
ErrorMessageHRESULT(result);

View File

@@ -21,7 +21,7 @@ struct CDirItemsStat
UInt64 NumErrors;
UInt64 Get_NumItems() const { return NumDirs + NumFiles + NumAltStreams; }
// UInt64 Get_NumItems() const { return NumDirs + NumFiles + NumAltStreams; }
UInt64 Get_NumDataItems() const { return NumFiles + NumAltStreams; }
UInt64 GetTotalBytes() const { return FilesSize + AltStreamsSize; }
@@ -43,6 +43,30 @@ struct CDirItemsStat
{}
};
struct CDirItemsStat2: public CDirItemsStat
{
UInt64 Anti_NumDirs;
UInt64 Anti_NumFiles;
UInt64 Anti_NumAltStreams;
// UInt64 Get_NumItems() const { return Anti_NumDirs + Anti_NumFiles + Anti_NumAltStreams + CDirItemsStat::Get_NumItems(); }
UInt64 Get_NumDataItems2() const { return Anti_NumFiles + Anti_NumAltStreams + CDirItemsStat::Get_NumDataItems(); }
bool IsEmpty() const { return CDirItemsStat::IsEmpty()
&& 0 == Anti_NumDirs
&& 0 == Anti_NumFiles
&& 0 == Anti_NumAltStreams; }
CDirItemsStat2():
Anti_NumDirs(0),
Anti_NumFiles(0),
Anti_NumAltStreams(0)
{}
};
#define INTERFACE_IDirItemsCallback(x) \
virtual HRESULT ScanError(const FString &path, DWORD systemError) x; \
virtual HRESULT ScanProgress(const CDirItemsStat &st, const FString &path, bool isDir) x; \

View File

@@ -343,6 +343,7 @@ static HRESULT EnumerateAltStreams(
const NWildcard::CCensorNode &curNode,
int phyParent, int logParent, const FString &fullPath,
const UStringVector &addArchivePrefix, // prefix from curNode
bool addAllItems,
CDirItems &dirItems)
{
NFind::CStreamEnumerator enumerator(fullPath);
@@ -363,6 +364,10 @@ static HRESULT EnumerateAltStreams(
addArchivePrefixNew.Back() += reducedName;
if (curNode.CheckPathToRoot(false, addArchivePrefixNew, true))
continue;
if (!addAllItems)
if (!curNode.CheckPathToRoot(true, addArchivePrefixNew, true))
continue;
NFind::CFileInfo fi2 = fi;
fi2.Name += us2fs(reducedName);
fi2.Size = si.Size;
@@ -413,6 +418,8 @@ static HRESULT EnumerateForItem(
}
int dirItemIndex = -1;
bool addAllSubStreams = false;
if (curNode.CheckPathToRoot(true, addArchivePrefixNew, !fi.IsDir()))
{
int secureIndex = -1;
@@ -427,6 +434,8 @@ static HRESULT EnumerateForItem(
dirItems.AddDirFileInfo(phyParent, logParent, secureIndex, fi);
if (fi.IsDir())
enterToSubFolders2 = true;
addAllSubStreams = true;
}
#ifndef UNDER_CE
@@ -434,7 +443,9 @@ static HRESULT EnumerateForItem(
{
RINOK(EnumerateAltStreams(fi, curNode, phyParent, logParent,
phyPrefix + fi.Name,
addArchivePrefixNew, dirItems));
addArchivePrefixNew,
addAllSubStreams,
dirItems));
}
if (dirItemIndex >= 0)
@@ -643,7 +654,9 @@ static HRESULT EnumerateDirItems(
UStringVector pathParts;
pathParts.Add(fs2us(fi.Name));
RINOK(EnumerateAltStreams(fi, curNode, phyParent, logParent,
fullPath, pathParts, dirItems));
fullPath, pathParts,
true, /* addAllSubStreams */
dirItems));
}
#endif

View File

@@ -279,7 +279,9 @@ HRESULT Extract(
CArchiveExtractCallback *ecs = new CArchiveExtractCallback;
CMyComPtr<IArchiveExtractCallback> ec(ecs);
bool multi = (numArcs > 1);
ecs->InitForMulti(multi, options.PathMode, options.OverwriteMode);
ecs->InitForMulti(multi, options.PathMode, options.OverwriteMode,
false // keepEmptyDirParts
);
#ifndef _SFX
ecs->SetHashMethods(hash);
#endif

View File

@@ -146,6 +146,9 @@ static void CorrectUnsupportedName(UString &name)
static void Correct_PathPart(UString &s)
{
// "." and ".."
if (s.IsEmpty())
return;
if (s[0] == '.' && (s[1] == 0 || s[1] == '.' && s[2] == 0))
s.Empty();
#ifdef _WIN32
@@ -172,7 +175,7 @@ UString Get_Correct_FsFile_Name(const UString &name)
}
void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir)
void Correct_FsPath(bool absIsAllowed, bool keepAndReplaceEmptyPrefixes, UStringVector &parts, bool isDir)
{
unsigned i = 0;
@@ -181,6 +184,7 @@ void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir)
#if defined(_WIN32) && !defined(UNDER_CE)
bool isDrive = false;
#endif
if (parts[0].IsEmpty())
{
i = 1;
@@ -191,7 +195,7 @@ void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir)
if (parts.Size() > 2 && parts[2] == L"?")
{
i = 3;
if (parts.Size() > 3 && NWindows::NFile::NName::IsDrivePath2(parts[3]))
if (parts.Size() > 3 && NWindows::NFile::NName::IsDrivePath2(parts[3]))
{
isDrive = true;
i = 4;
@@ -220,6 +224,9 @@ void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir)
#endif
}
if (i != 0)
keepAndReplaceEmptyPrefixes = false;
for (; i < parts.Size();)
{
UString &s = parts[i];
@@ -228,15 +235,17 @@ void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir)
if (s.IsEmpty())
{
if (isDir || i != parts.Size() - 1)
{
parts.Delete(i);
continue;
}
if (!keepAndReplaceEmptyPrefixes)
if (isDir || i != parts.Size() - 1)
{
parts.Delete(i);
continue;
}
s = k_EmptyReplaceName;
}
else
{
keepAndReplaceEmptyPrefixes = false;
#ifdef _WIN32
CorrectUnsupportedName(s);
#endif

View File

@@ -12,7 +12,19 @@ void Correct_AltStream_Name(UString &s);
// replaces unsuported characters, and replaces "." , ".." and "" to "[]"
UString Get_Correct_FsFile_Name(const UString &name);
void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir);
/*
Correct_FsPath() corrects path parts to prepare it for File System operations.
It also corrects empty path parts like "\\\\":
- frontal empty path parts : it removes them or changes them to "_"
- another empty path parts : it removes them
if (absIsAllowed && path is absolute) : it removes empty path parts after start absolute path prefix marker
else
{
if (!keepAndReplaceEmptyPrefixes) : it removes empty path parts
if ( keepAndReplaceEmptyPrefixes) : it changes each empty frontal path part to "_"
}
*/
void Correct_FsPath(bool absIsAllowed, bool keepAndReplaceEmptyPrefixes, UStringVector &parts, bool isDir);
UString MakePathFromParts(const UStringVector &parts);

View File

@@ -19,12 +19,16 @@
using namespace NWindows;
static const char g_WinAttribChars[16 + 1] = "RHS8DAdNTsLCOnE_";
static const unsigned kNumWinAtrribFlags = 21;
static const char g_WinAttribChars[kNumWinAtrribFlags + 1] = "RHS8DAdNTsLCOIEV.X.PU";
/*
FILE_ATTRIBUTE_
0 READONLY
1 HIDDEN
2 SYSTEM
3 (Volume label - obsolete)
4 DIRECTORY
5 ARCHIVE
6 DEVICE
@@ -34,12 +38,19 @@ static const char g_WinAttribChars[16 + 1] = "RHS8DAdNTsLCOnE_";
10 REPARSE_POINT
11 COMPRESSED
12 OFFLINE
13 NOT_CONTENT_INDEXED
13 NOT_CONTENT_INDEXED (I - Win10 attrib/Explorer)
14 ENCRYPTED
16 VIRTUAL
15 INTEGRITY_STREAM (V - ReFS Win8/Win2012)
16 VIRTUAL (reserved)
17 NO_SCRUB_DATA (X - ReFS Win8/Win2012 attrib)
18 RECALL_ON_OPEN or EA
19 PINNED
20 UNPINNED
21 STRICTLY_SEQUENTIAL
22 RECALL_ON_DATA_ACCESS
*/
static const char kPosixTypes[16] = { '0', 'p', 'c', '3', 'd', '5', 'b', '7', '-', '9', 'l', 'B', 's', 'D', 'E', 'F' };
#define MY_ATTR_CHAR(a, n, c) ((a) & (1 << (n))) ? c : '-';
@@ -65,24 +76,57 @@ static void ConvertPosixAttribToString(char *s, UInt32 a) throw()
}
}
void ConvertWinAttribToString(char *s, UInt32 wa) throw()
{
for (int i = 0; i < 16; i++)
if ((wa & (1 << i)) && i != 7)
*s++ = g_WinAttribChars[i];
*s = 0;
// we support p7zip trick that stores posix attributes in high 16 bits, and 0x8000 flag
// we also support ZIP archives created in Unix, that store posix attributes in high 16 bits without 0x8000 flag
/*
some programs store posix attributes in high 16 bits.
p7zip - stores additional 0x8000 flag marker.
macos - stores additional 0x4000 flag marker.
info-zip - no additional marker.
*/
// if (wa & 0x8000)
if ((wa >> 16) != 0)
bool isPosix = ((wa & 0xF0000000) != 0);
UInt32 posix = 0;
if (isPosix)
{
posix = wa >> 16;
wa &= (UInt32)0x3FFF;
}
for (unsigned i = 0; i < kNumWinAtrribFlags; i++)
{
UInt32 flag = (1 << i);
if ((wa & flag) != 0)
{
char c = g_WinAttribChars[i];
if (c != '.')
{
wa &= ~flag;
// if (i != 7) // we can disable N (NORMAL) printing
*s++ = c;
}
}
}
if (wa != 0)
{
*s++ = ' ';
ConvertPosixAttribToString(s, wa >> 16);
ConvertUInt32ToHex8Digits(wa, s);
s += strlen(s);
}
*s = 0;
if (isPosix)
{
*s++ = ' ';
ConvertPosixAttribToString(s, posix);
}
}
void ConvertPropertyToShortString2(char *dest, const PROPVARIANT &prop, PROPID propID, int level) throw()
{
*dest = 0;

View File

@@ -657,38 +657,74 @@ static HRESULT Compress(
FOR_VECTOR (i, updatePairs2)
{
const CUpdatePair2 &up = updatePairs2[i];
if (up.NewData)
// 17.01: anti-item is (up.NewData && (p.UseArcProps in most cases))
if (up.NewData && !up.UseArcProps)
{
CDirItemsStat &stat = stat2.NewData;
const CDirItem &di = dirItems.Items[up.DirIndex];
if (di.IsDir())
stat.NumDirs++;
else if (di.IsAltStream)
if (up.ExistOnDisk())
{
stat.NumAltStreams++;
stat.AltStreamsSize += di.Size;
}
else
{
stat.NumFiles++;
stat.FilesSize += di.Size;
CDirItemsStat2 &stat = stat2.NewData;
const CDirItem &di = dirItems.Items[up.DirIndex];
if (di.IsDir())
{
if (up.IsAnti)
stat.Anti_NumDirs++;
else
stat.NumDirs++;
}
else if (di.IsAltStream)
{
if (up.IsAnti)
stat.Anti_NumAltStreams++;
else
{
stat.NumAltStreams++;
stat.AltStreamsSize += di.Size;
}
}
else
{
if (up.IsAnti)
stat.Anti_NumFiles++;
else
{
stat.NumFiles++;
stat.FilesSize += di.Size;
}
}
}
}
else if (up.ArcIndex >= 0)
{
CDirItemsStat &stat = stat2.OldData;
CDirItemsStat2 &stat = *(up.NewData ? &stat2.NewData : &stat2.OldData);
const CArcItem &ai = arcItems[up.ArcIndex];
if (ai.IsDir)
stat.NumDirs++;
{
if (up.IsAnti)
stat.Anti_NumDirs++;
else
stat.NumDirs++;
}
else if (ai.IsAltStream)
{
stat.NumAltStreams++;
stat.AltStreamsSize += ai.Size;
if (up.IsAnti)
stat.Anti_NumAltStreams++;
else
{
stat.NumAltStreams++;
stat.AltStreamsSize += ai.Size;
}
}
else
{
stat.NumFiles++;
stat.FilesSize += ai.Size;
if (up.IsAnti)
stat.Anti_NumFiles++;
else
{
stat.NumFiles++;
stat.FilesSize += ai.Size;
}
}
}
}
@@ -1592,8 +1628,18 @@ HRESULT UpdateArchive(
{
if (processedItems[i] != 0 || dirItem.Size == 0)
{
RINOK(callback->DeletingAfterArchiving(phyPath, false));
DeleteFileAlways(phyPath);
NFind::CFileInfo fileInfo;
if (fileInfo.Find(phyPath))
{
// maybe we must exclude also files with archive name: "a a.7z * -sdel"
if (fileInfo.Size == dirItem.Size
&& CompareFileTime(&fileInfo.MTime, &dirItem.MTime) == 0
&& CompareFileTime(&fileInfo.CTime, &dirItem.CTime) == 0)
{
RINOK(callback->DeletingAfterArchiving(phyPath, false));
DeleteFileAlways(phyPath);
}
}
}
else
{

View File

@@ -17,13 +17,13 @@
struct CArcToDoStat
{
CDirItemsStat NewData;
CDirItemsStat OldData;
CDirItemsStat DeleteData;
CDirItemsStat2 NewData;
CDirItemsStat2 OldData;
CDirItemsStat2 DeleteData;
UInt64 Get_NumDataItems_Total() const
{
return NewData.Get_NumDataItems() + OldData.Get_NumDataItems();
return NewData.Get_NumDataItems2() + OldData.Get_NumDataItems2();
}
};

View File

@@ -48,9 +48,14 @@ namespace NCompression
UString Options;
UString EncryptionMethod;
void Reset_BlockLogSize()
{
BlockLogSize = (UInt32)(Int32)-1;
}
void ResetForLevelChange()
{
BlockLogSize = NumThreads = Level = Dictionary = Order = UInt32(-1);
BlockLogSize = NumThreads = Level = Dictionary = Order = (UInt32)(Int32)-1;
Method.Empty();
// Options.Empty();
// EncryptionMethod.Empty();

View File

@@ -114,6 +114,39 @@ void Print_DirItemsStat(AString &s, const CDirItemsStat &st)
}
}
void Print_DirItemsStat2(AString &s, const CDirItemsStat2 &st)
{
Print_DirItemsStat(s, (CDirItemsStat &)st);
bool needLF = true;
if (st.Anti_NumDirs != 0)
{
if (needLF)
s.Add_LF();
needLF = false;
Print_UInt64_and_String(s, st.Anti_NumDirs, st.Anti_NumDirs == 1 ? "anti-folder" : "anti-folders");
}
if (st.Anti_NumFiles != 0)
{
if (needLF)
s.Add_LF();
else
s += ", ";
needLF = false;
Print_UInt64_and_String(s, st.Anti_NumFiles, st.Anti_NumFiles == 1 ? "anti-file" : "anti-files");
}
if (st.Anti_NumAltStreams != 0)
{
if (needLF)
s.Add_LF();
else
s += ", ";
needLF = false;
Print_UInt64_and_String(s, st.Anti_NumAltStreams, "anti-alternate-streams");
}
}
void CExtractScanConsole::PrintStat(const CDirItemsStat &st)
{
if (_so)

View File

@@ -97,7 +97,6 @@ static const char * const kHelpString =
#endif
#endif
" <command> [<switches>...] <archive_name> [<file_names>...]\n"
" [<@listfiles...>]\n"
"\n"
"<Commands>\n"
" a : Add files to archive\n"
@@ -114,6 +113,7 @@ static const char * const kHelpString =
"\n"
"<Switches>\n"
" -- : Stop switches parsing\n"
" @listfile : set path to listfile that contains file names\n"
" -ai[r[-|0]]{@listfile|!wildcard} : Include archives\n"
" -ax[r[-|0]]{@listfile|!wildcard} : eXclude archives\n"
" -ao{a|s|t|u} : set Overwrite mode\n"
@@ -548,6 +548,7 @@ int Main2(
if (options.LargePages)
{
SetLargePageSize();
// note: this process also can inherit that Privilege from parent process
g_LargePagesMode =
#if defined(_WIN32) && !defined(UNDER_CE)
NSecurity::EnablePrivilege_LockMemory();

View File

@@ -241,6 +241,7 @@ static void PrintPropPair(AString &s, const char *name, UInt64 val)
void PrintSize_bytes_Smart(AString &s, UInt64 val);
void Print_DirItemsStat(AString &s, const CDirItemsStat &st);
void Print_DirItemsStat2(AString &s, const CDirItemsStat2 &st);
HRESULT CUpdateCallbackConsole::FinishScanning(const CDirItemsStat &st)
{
@@ -399,10 +400,10 @@ HRESULT CUpdateCallbackConsole::Finalize()
*/
void static PrintToDoStat(CStdOutStream *_so, const CDirItemsStat &stat, const char *name)
void static PrintToDoStat(CStdOutStream *_so, const CDirItemsStat2 &stat, const char *name)
{
AString s;
Print_DirItemsStat(s, stat);
Print_DirItemsStat2(s, stat);
*_so << name << ": " << s << endl;
}

View File

@@ -7,7 +7,7 @@
namespace NMessageID {
const unsigned k_Last_PropId_supported_by_plugin = kpidStreamId;
const unsigned k_Last_PropId_supported_by_plugin = kpidCopyLink;
enum EEnum
{

View File

@@ -574,7 +574,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
}
else if (!srcPanel.DoesItSupportOperations())
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
@@ -608,6 +608,8 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
UStringVector copyFolders;
ReadCopyHistory(copyFolders);
bool useFullItemPaths = srcPanel.Is_IO_FS_Folder(); // maybe we need flat also here ??
{
CCopyDialog copyDialog;
@@ -626,14 +628,14 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
if (destPath.IsEmpty())
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
UString correctName;
if (!srcPanel.CorrectFsPath(destPath, correctName))
{
srcPanel.MessageBoxError(E_INVALIDARG);
srcPanel.MessageBox_Error_HRESULT(E_INVALIDARG);
return;
}
@@ -647,7 +649,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
if (destPath.Len() > 0 && destPath[0] == '\\')
if (destPath.Len() == 1 || destPath[1] != '\\')
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
#endif
@@ -658,7 +660,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
if (NumPanels == 1 || CompareFileNames(destPath, srcPanel.GetFsPath()) == 0)
{
srcPanel.MessageBoxMyError(L"Can not copy files onto itself");
srcPanel.MessageBox_Error(L"Can not copy files onto itself");
return;
}
@@ -674,7 +676,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
destIsFsPath = true;
else if (destPanel.IsFSDrivesFolder() || destPanel.IsRootFolder())
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
}
@@ -683,7 +685,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
if (IsAltPathPrefix(us2fs(destPath)))
{
// we allow alt streams dest only to alt stream folder in second panel
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
/*
FString basePath = us2fs(destPath);
@@ -704,7 +706,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
int pos = destPath.ReverseFind_PathSepar();
if (pos < 0)
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
{
@@ -713,7 +715,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
UString name = destPath.Ptr(pos + 1);
if (name.Find(L':') >= 0)
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
#endif
@@ -721,7 +723,8 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
UString prefix = destPath.Left(pos + 1);
if (!CreateComplexDir(us2fs(prefix)))
{
srcPanel.MessageBoxError2Lines(prefix, GetLastError());
DWORD lastError = ::GetLastError();
srcPanel.MessageBox_Error_2Lines_Message_HRESULT(prefix, lastError);
return;
}
}
@@ -732,7 +735,8 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
NName::NormalizeDirPathPrefix(destPath);
if (!CreateComplexDir(us2fs(destPath)))
{
srcPanel.MessageBoxError2Lines(destPath, GetLastError());
DWORD lastError = ::GetLastError();
srcPanel.MessageBox_Error_2Lines_Message_HRESULT(destPath, lastError);
return;
}
}
@@ -754,7 +758,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
bool useTemp = useSrcPanel && useDestPanel;
if (useTemp && NumPanels == 1)
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
@@ -793,13 +797,25 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
UStringVector filePaths;
UString folderPrefix;
if (useTemp)
folderPrefix = fs2us(tempDirPrefix);
else
folderPrefix = srcPanel.GetFsPath();
filePaths.ClearAndReserve(indices.Size());
FOR_VECTOR (i, indices)
filePaths.AddInReserved(srcPanel.GetItemRelPath2(indices[i]));
{
UInt32 index = indices[i];
UString s;
if (useFullItemPaths)
s = srcPanel.GetItemRelPath2(index);
else
s = srcPanel.GetItemName_for_Copy(index);
filePaths.AddInReserved(s);
}
result = destPanel.CopyFrom(move, folderPrefix, filePaths, true, 0);
}
@@ -812,7 +828,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
// srcPanel.InvalidateList(NULL, true);
if (result != E_ABORT)
srcPanel.MessageBoxError(result);
srcPanel.MessageBox_Error_HRESULT(result);
// return;
}

View File

@@ -1025,7 +1025,7 @@ HRESULT CVirtFileSystem::FlushToDisk(bool closeLast)
_numFlushed++;
_fileIsOpen = false;
if (file.AttribDefined)
NDir::SetFileAttrib(path, file.Attrib);
NDir::SetFileAttrib_PosixHighDetect(path, file.Attrib);
}
return S_OK;
}

View File

@@ -383,7 +383,10 @@ static void SetMemoryLock()
NSecurity::AddLockMemoryPrivilege();
if (ReadLockMemoryEnable())
{
// note: child processes can inherit that Privilege
g_LargePagesMode = NSecurity::EnablePrivilege_LockMemory();
}
}
bool g_SymLink_Supported = false;

View File

@@ -205,7 +205,7 @@ struct CCopyStateIO
CCopyStateIO(): DeleteSrcFile(false), TotalSize(0), StartPos(0) {}
HRESULT MyCopyFile(CFSTR inPath, CFSTR outPath);
HRESULT MyCopyFile(CFSTR inPath, CFSTR outPath, DWORD attrib = INVALID_FILE_ATTRIBUTES);
};
HRESULT SendLastErrorMessage(IFolderOperationsExtractCallback *callback, const FString &fileName);

View File

@@ -31,7 +31,7 @@ extern bool g_IsNT;
namespace NFsFolder {
HRESULT CCopyStateIO::MyCopyFile(CFSTR inPath, CFSTR outPath)
HRESULT CCopyStateIO::MyCopyFile(CFSTR inPath, CFSTR outPath, DWORD attrib)
{
ErrorFileIndex = -1;
ErrorMessage.Empty();
@@ -87,6 +87,9 @@ HRESULT CCopyStateIO::MyCopyFile(CFSTR inPath, CFSTR outPath)
}
}
if (attrib != INVALID_FILE_ATTRIBUTES)
SetFileAttrib(outPath, attrib);
if (DeleteSrcFile)
{
if (!DeleteFileAlways(inPath))
@@ -424,7 +427,9 @@ static HRESULT CopyFile_Ask(
state2.DeleteSrcFile = state.MoveMode;
state2.TotalSize = state.ProgressInfo.TotalSize;
state2.StartPos = state.ProgressInfo.StartPos;
RINOK(state2.MyCopyFile(srcPath, destPathNew));
RINOK(state2.MyCopyFile(srcPath, destPathNew, srcFileInfo.Attrib));
if (state2.ErrorFileIndex >= 0)
{
if (state2.ErrorMessage.IsEmpty())

View File

@@ -314,7 +314,7 @@ void CApp::Link()
CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder())
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
CRecordVector<UInt32> indices;
@@ -323,7 +323,7 @@ void CApp::Link()
return;
if (indices.Size() != 1)
{
srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE);
srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE);
return;
}
int index = indices[0];

View File

@@ -697,43 +697,57 @@ bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result)
return CWindow2::OnCommand(code, itemID, lParam, result);
}
void CPanel::MessageBoxInfo(LPCWSTR message, LPCWSTR caption)
/*
void CPanel::MessageBox_Info(LPCWSTR message, LPCWSTR caption) const
{ ::MessageBoxW((HWND)*this, message, caption, MB_OK); }
void CPanel::MessageBox(LPCWSTR message, LPCWSTR caption)
void CPanel::MessageBox_Warning(LPCWSTR message) const
{ ::MessageBoxW((HWND)*this, message, L"7-Zip", MB_OK | MB_ICONWARNING); }
*/
void CPanel::MessageBox_Error_Caption(LPCWSTR message, LPCWSTR caption) const
{ ::MessageBoxW((HWND)*this, message, caption, MB_OK | MB_ICONSTOP); }
void CPanel::MessageBox(LPCWSTR message)
{ MessageBox(message, L"7-Zip"); }
void CPanel::MessageBoxWarning(LPCWSTR message)
{ ::MessageBoxW(NULL, message, L"7-Zip", MB_OK | MB_ICONWARNING); }
void CPanel::MessageBoxMyError(LPCWSTR message)
{ MessageBox(message, L"7-Zip"); }
void CPanel::MessageBox_Error(LPCWSTR message) const
{ MessageBox_Error_Caption(message, L"7-Zip"); }
void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption)
static UString ErrorHResult_To_Message(HRESULT errorCode)
{
MessageBox(HResultToMessage(errorCode), caption);
if (errorCode == 0)
errorCode = E_FAIL;
return HResultToMessage(errorCode);
}
void CPanel::MessageBoxError2Lines(LPCWSTR message, HRESULT errorCode)
void CPanel::MessageBox_Error_HRESULT_Caption(HRESULT errorCode, LPCWSTR caption) const
{
MessageBox_Error_Caption(ErrorHResult_To_Message(errorCode), caption);
}
void CPanel::MessageBox_Error_HRESULT(HRESULT errorCode) const
{ MessageBox_Error_HRESULT_Caption(errorCode, L"7-Zip"); }
void CPanel::MessageBox_Error_2Lines_Message_HRESULT(LPCWSTR message, HRESULT errorCode) const
{
UString m = message;
if (errorCode != 0)
{
m.Add_LF();
m += HResultToMessage(errorCode);
}
MessageBoxMyError(m);
m.Add_LF();
m += ErrorHResult_To_Message(errorCode);
MessageBox_Error(m);
}
void CPanel::MessageBoxError(HRESULT errorCode)
{ MessageBoxError(errorCode, L"7-Zip"); }
void CPanel::MessageBoxLastError(LPCWSTR caption)
{ MessageBoxError(::GetLastError(), caption); }
void CPanel::MessageBoxLastError()
{ MessageBoxLastError(L"7-Zip"); }
void CPanel::MessageBox_LastError(LPCWSTR caption) const
{ MessageBox_Error_HRESULT_Caption(::GetLastError(), caption); }
void CPanel::MessageBox_LastError() const
{ MessageBox_LastError(L"7-Zip"); }
void CPanel::MessageBox_Error_LangID(UINT resourceID) const
{ MessageBox_Error(LangString(resourceID)); }
void CPanel::MessageBox_Error_UnsupportOperation() const
{ MessageBox_Error_LangID(IDS_OPERATION_IS_NOT_SUPPORTED); }
void CPanel::MessageBoxErrorLang(UINT resourceID)
{ MessageBox(LangString(resourceID)); }
void CPanel::SetFocusToList()
@@ -821,7 +835,7 @@ void CPanel::ChangeFlatMode()
_flatModeForArc = _flatMode;
else
_flatModeForDisk = _flatMode;
RefreshListCtrlSaveFocused();
RefreshListCtrl_SaveFocused();
}
/*
@@ -848,12 +862,12 @@ void CPanel::AddToArchive()
GetOperatedItemIndices(indices);
if (!Is_IO_FS_Folder())
{
MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
MessageBox_Error_UnsupportOperation();
return;
}
if (indices.Size() == 0)
{
MessageBoxErrorLang(IDS_SELECT_FILES);
MessageBox_Error_LangID(IDS_SELECT_FILES);
return;
}
UStringVector names;
@@ -873,7 +887,7 @@ void CPanel::AddToArchive()
if (res != S_OK)
{
if (destCurDirPrefix.Len() >= MAX_PATH)
MessageBoxErrorLang(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER);
MessageBox_Error_LangID(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER);
}
// KillSelection();
}
@@ -910,7 +924,7 @@ void CPanel::GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &p
}
if (paths.Size() == 0)
{
MessageBoxErrorLang(IDS_SELECT_FILES);
MessageBox_Error_LangID(IDS_SELECT_FILES);
return;
}
}
@@ -1026,7 +1040,7 @@ void CPanel::TestArchives()
if (res != S_OK)
{
if (res != E_ABORT)
MessageBoxError(res);
MessageBox_Error_HRESULT(res);
}
return;
@@ -1071,7 +1085,7 @@ void CPanel::TestArchives()
if (!IsFSFolder())
{
MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
MessageBox_Error_UnsupportOperation();
return;
}
UStringVector paths;

View File

@@ -220,11 +220,12 @@ public:
struct CSelectedState
{
int FocusedItem;
UString FocusedName;
bool SelectFocused;
bool FocusedName_Defined;
UString FocusedName;
UStringVector SelectedNames;
CSelectedState(): FocusedItem(-1), SelectFocused(false) {}
CSelectedState(): FocusedItem(-1), FocusedName_Defined(false), SelectFocused(true) {}
};
#ifdef UNDER_CE
@@ -326,9 +327,7 @@ private:
void AddColumn(const CPropColumn &prop);
void SetFocusedSelectedItem(int index, bool select);
HRESULT RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames);
void OnShiftSelectMessage();
void OnArrowWithShift();
@@ -463,7 +462,7 @@ public:
void GetSelectedNames(UStringVector &selectedNames);
void SaveSelectedState(CSelectedState &s);
HRESULT RefreshListCtrl(const CSelectedState &s);
HRESULT RefreshListCtrlSaveFocused();
HRESULT RefreshListCtrl_SaveFocused();
bool GetItem_BoolProp(UInt32 itemIndex, PROPID propID) const;
bool IsItem_Deleted(int itemIndex) const;
@@ -745,20 +744,20 @@ public:
HRESULT RefreshListCtrl();
void MessageBoxInfo(LPCWSTR message, LPCWSTR caption);
void MessageBox(LPCWSTR message);
void MessageBoxWarning(LPCWSTR message);
void MessageBox(LPCWSTR message, LPCWSTR caption);
void MessageBoxMyError(LPCWSTR message);
void MessageBoxError(HRESULT errorCode, LPCWSTR caption);
void MessageBoxError(HRESULT errorCode);
void MessageBoxError2Lines(LPCWSTR message, HRESULT errorCode);
void MessageBoxLastError(LPCWSTR caption);
void MessageBoxLastError();
// void MessageBox_Info(LPCWSTR message, LPCWSTR caption) const;
// void MessageBox_Warning(LPCWSTR message) const;
void MessageBox_Error_Caption(LPCWSTR message, LPCWSTR caption) const;
void MessageBox_Error(LPCWSTR message) const;
void MessageBox_Error_HRESULT_Caption(HRESULT errorCode, LPCWSTR caption) const;
void MessageBox_Error_HRESULT(HRESULT errorCode) const;
void MessageBox_Error_2Lines_Message_HRESULT(LPCWSTR message, HRESULT errorCode) const;
void MessageBox_LastError(LPCWSTR caption) const;
void MessageBox_LastError() const;
void MessageBox_Error_LangID(UINT resourceID) const;
void MessageBox_Error_UnsupportOperation() const;
// void MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID);
void MessageBoxErrorLang(UINT resourceID);
void OpenAltStreams();

View File

@@ -101,7 +101,7 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
{
UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED);
if (options.showErrorMessages)
MessageBox(errorMessage);
MessageBox_Error(errorMessage);
else if (messages != 0)
messages->Add(errorMessage);
return E_FAIL;
@@ -307,7 +307,7 @@ HRESULT CPanel::CopyFrom(bool moveMode, const UString &folderPrefix, const UStri
{
UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED);
if (showErrorMessages)
MessageBox(errorMessage);
MessageBox_Error(errorMessage);
else if (messages != 0)
messages->Add(errorMessage);
return E_ABORT;
@@ -334,7 +334,7 @@ void CPanel::CopyFromNoAsk(const UStringVector &filePaths)
// For Password:
SetFocusToList();
if (result != E_ABORT)
MessageBoxError(result);
MessageBox_Error_HRESULT(result);
return;
}

View File

@@ -382,6 +382,6 @@ void CApp::CalculateCrc(const char *methodName)
{
unsigned srcPanelIndex = GetFocusedPanelIndex();
CPanel &srcPanel = Panels[srcPanelIndex];
srcPanel.MessageBoxError(res);
srcPanel.MessageBox_Error_HRESULT(res);
}
}

View File

@@ -327,6 +327,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
// CSelectedState selState;
// SaveSelectedState(selState);
// FString dirPrefix2;
FString dirPrefix;
CTempDir tempDirectory;
@@ -337,6 +338,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
{
tempDirectory.Create(kTempDirPrefix);
dirPrefix = tempDirectory.GetPath();
// dirPrefix2 = dirPrefix;
NFile::NName::NormalizeDirPathPrefix(dirPrefix);
}
@@ -345,6 +347,10 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
{
UStringVector names;
// names variable is USED for drag and drop from 7-zip to Explorer or to 7-zip archive folder.
// names variable is NOT USED for drag and drop from 7-zip to 7-zip File System folder.
FOR_VECTOR (i, indices)
{
UInt32 index = indices[i];
@@ -354,6 +360,23 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
else
{
s = GetItemName(index);
/*
// We use (keepAndReplaceEmptyPrefixes = true) in CAgentFolder::Extract
// So the following code is not required.
// Maybe we also can change IFolder interface and send some flag also.
if (s.IsEmpty())
{
// Correct_FsFile_Name("") returns "_".
// If extracting code removes empty folder prefixes from path (as it was in old version),
// Explorer can't find "_" folder in temp folder.
// We can ask Explorer to copy parent temp folder "7zE" instead.
names.Clear();
names.Add(dirPrefix2);
break;
}
*/
s = Get_Correct_FsFile_Name(s);
}
names.Add(fs2us(dirPrefix) + s);
@@ -408,7 +431,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
// we ignore E_UNEXPECTED that is returned if we drag file to printer
if (res != DRAGDROP_S_CANCEL && res != S_OK
&& res != E_UNEXPECTED)
MessageBoxError(res);
MessageBox_Error_HRESULT(res);
res = dropSourceSpec->Result;
}
@@ -422,10 +445,10 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
if (res != S_OK && res != E_ABORT)
{
// we restore Notify before MessageBoxError. So we will se files selection
// we restore Notify before MessageBox_Error_HRESULT. So we will se files selection
disableNotify.Restore();
// SetFocusToList();
MessageBoxError(res);
MessageBox_Error_HRESULT(res);
}
if (res == S_OK && dropSourceSpec->Messages.IsEmpty() && !canceled)
KillSelection();

View File

@@ -298,7 +298,7 @@ HRESULT CPanel::BindToPathAndRefresh(const UString &path)
#endif
HRESULT res = BindToPath(s, UString(), archiveIsOpened, encrypted);
RefreshListCtrl(UString(), -1, true, UStringVector());
RefreshListCtrl();
return res;
}
@@ -740,17 +740,20 @@ void CPanel::OpenParentFolder()
}
}
UStringVector selectedItems;
CSelectedState state;
state.FocusedName = focusedName;
state.FocusedName_Defined = true;
/*
if (!focusedName.IsEmpty())
selectedItems.Add(focusedName);
state.SelectedNames.Add(focusedName);
*/
LoadFullPath();
// ::SetCurrentDirectory(::_currentFolderPrefix);
RefreshListCtrl(focusedName, -1, true, selectedItems);
RefreshListCtrl(state);
// _listView.EnsureVisible(_listView.GetFocusedItem(), false);
}
void CPanel::CloseOneLevel()
{
ReleaseFolder();
@@ -783,7 +786,7 @@ void CPanel::OpenRootFolder()
CDisableNotify disableNotify(*this);
_parentFolders.Clear();
SetToRootFolder();
RefreshListCtrl(UString(), -1, true, UStringVector());
RefreshListCtrl();
// ::SetCurrentDirectory(::_currentFolderPrefix);
/*
BeforeChangeFolder();
@@ -847,7 +850,7 @@ void CPanel::OpenAltStreams()
CDisableTimerProcessing disableTimerProcessing(*this);
CDisableNotify disableNotify(*this);
SetNewFolder(newFolder);
RefreshListCtrl(UString(), -1, true, UStringVector());
RefreshListCtrl();
return;
}
return;

View File

@@ -559,11 +559,11 @@ HRESULT CPanel::OpenAsArc(IInStream *inStream,
*/
/*
if (!s.IsEmpty())
MessageBoxWarning(s);
MessageBox_Warning(s);
else
*/
// after MessageBoxWarning it throws exception in nested archives in Debug Mode. why ?.
// MessageBoxWarning(L"test error");
// after MessageBox_Warning it throws exception in nested archives in Debug Mode. why ?.
// MessageBox_Warning(L"test error");
}
}
@@ -585,9 +585,10 @@ HRESULT CPanel::OpenAsArc_Msg(IInStream *inStream,
if (res == E_ABORT)
return res;
if (showErrorMessage && encrypted)
if (showErrorMessage)
if (encrypted || res != S_FALSE) // 17.01 : we show message also for (res != S_FALSE)
{
UString message("Error");
UString message;
if (res == S_FALSE)
{
message = MyFormatNew(
@@ -598,7 +599,7 @@ HRESULT CPanel::OpenAsArc_Msg(IInStream *inStream,
}
else
message = HResultToMessage(res);
MessageBoxMyError(message);
MessageBox_Error(message);
}
return res;
@@ -799,6 +800,12 @@ void CApp::DiffFiles()
{
const CPanel &panel = GetFocusedPanel();
if (!panel.Is_IO_FS_Folder())
{
panel.MessageBox_Error_UnsupportOperation();
return;
}
CRecordVector<UInt32> indices;
panel.GetSelectedItemsIndices(indices);
@@ -811,6 +818,13 @@ void CApp::DiffFiles()
else if (indices.Size() == 1 && NumPanels >= 2)
{
const CPanel &destPanel = Panels[1 - LastFocusedPanel];
if (!destPanel.Is_IO_FS_Folder())
{
panel.MessageBox_Error_UnsupportOperation();
return;
}
path1 = panel.GetItemFullPath(indices[0]);
CRecordVector<UInt32> indices2;
destPanel.GetSelectedItemsIndices(indices2);
@@ -1061,7 +1075,7 @@ bool CPanel::IsVirus_Message(const UString &name)
s.Add_LF(); s += name2;
s.Add_LF(); s += name3;
MessageBoxMyError(s);
MessageBox_Error(s);
return true;
}
@@ -1095,7 +1109,7 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar
return;
if (res != S_FALSE)
{
MessageBoxError(res);
MessageBox_Error_HRESULT(res);
return;
}
}
@@ -1130,7 +1144,7 @@ HRESULT CPanel::OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath,
{
if (!_folderOperations)
{
MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
MessageBox_Error_UnsupportOperation();
return E_FAIL;
}
@@ -1589,7 +1603,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
if (!_folderOperations)
{
MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
MessageBox_Error_UnsupportOperation();
return;
}
@@ -1600,7 +1614,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
CTempDir tempDirectory;
if (!tempDirectory.Create(kTempDirPrefix))
{
MessageBoxLastError();
MessageBox_LastError();
return;
}
@@ -1729,7 +1743,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
if (result != S_OK)
{
if (result != E_ABORT)
MessageBoxError(result);
MessageBox_Error_HRESULT(result);
return;
}

View File

@@ -11,6 +11,8 @@
#include "../../PropID.h"
#include "../Common/ExtractingFilePath.h"
#include "resource.h"
#include "LangUtils.h"
@@ -317,7 +319,8 @@ void CPanel::AddColumn(const CPropColumn &prop)
HRESULT CPanel::RefreshListCtrl()
{
return RefreshListCtrl(UString(), -1, true, UStringVector());
CSelectedState state;
return RefreshListCtrl(state);
}
int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
@@ -356,7 +359,9 @@ void CPanel::GetSelectedNames(UStringVector &selectedNames)
void CPanel::SaveSelectedState(CSelectedState &s)
{
s.FocusedName_Defined = false;
s.FocusedName.Empty();
s.SelectFocused = true; // false;
s.SelectedNames.Clear();
s.FocusedItem = _listView.GetFocusedItem();
{
@@ -364,7 +369,12 @@ void CPanel::SaveSelectedState(CSelectedState &s)
{
int realIndex = GetRealItemIndex(s.FocusedItem);
if (realIndex != kParentIndex)
{
s.FocusedName = GetItemRelPath(realIndex);
s.FocusedName_Defined = true;
s.SelectFocused = _listView.IsItemSelected(s.FocusedItem);
/*
const int kSize = 1024;
WCHAR name[kSize + 1];
@@ -376,21 +386,26 @@ void CPanel::SaveSelectedState(CSelectedState &s)
item.mask = LVIF_TEXT;
if (_listView.GetItem(&item))
focusedName = item.pszText;
*/
*/
}
}
}
GetSelectedNames(s.SelectedNames);
}
/*
HRESULT CPanel::RefreshListCtrl(const CSelectedState &s)
{
bool selectFocused = s.SelectFocused;
if (_mySelectMode)
selectFocused = true;
return RefreshListCtrl(s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
return RefreshListCtrl2(
s.FocusedItem >= 0, // allowEmptyFocusedName
s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
}
*/
HRESULT CPanel::RefreshListCtrlSaveFocused()
HRESULT CPanel::RefreshListCtrl_SaveFocused()
{
CSelectedState state;
SaveSelectedState(state);
@@ -420,8 +435,7 @@ void CPanel::SetFocusedSelectedItem(int index, bool select)
#endif
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames)
HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
{
if (!_folder)
return S_OK;
@@ -433,6 +447,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
CDisableTimerProcessing timerProcessing(*this);
CDisableNotify disableNotify(*this);
int focusedPos = state.FocusedItem;
if (focusedPos < 0)
focusedPos = 0;
@@ -534,8 +549,8 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
{
UString itemName ("..");
item.iItem = listViewItemCount;
if (itemName == focusedName)
cursorIndex = item.iItem;
if (itemName == state.FocusedName)
cursorIndex = listViewItemCount;
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
int subItem = 0;
item.iSubItem = subItem++;
@@ -573,7 +588,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
bool selected = false;
if (!focusedName.IsEmpty() || !selectedNames.IsEmpty())
if (state.FocusedName_Defined || !state.SelectedNames.IsEmpty())
{
relPath.Empty();
@@ -599,9 +614,9 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
}
}
relPath += name;
if (relPath == focusedName)
if (relPath == state.FocusedName)
cursorIndex = listViewItemCount;
if (selectedNames.FindInSorted(relPath) >= 0)
if (state.SelectedNames.FindInSorted(relPath) >= 0)
selected = true;
}
@@ -724,7 +739,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
disableNotify.Restore();
if (_listView.GetItemCount() > 0 && cursorIndex >= 0)
SetFocusedSelectedItem(cursorIndex, selectFocused);
SetFocusedSelectedItem(cursorIndex, state.SelectFocused);
Print_OnNotify("after SetFocusedSelectedItem");
@@ -738,7 +753,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
if (focusedPos >= _listView.GetItemCount())
focusedPos = _listView.GetItemCount() - 1;
// we select item only in showDots mode.
SetFocusedSelectedItem(focusedPos, showDots);
SetFocusedSelectedItem(focusedPos, showDots && (focusedPos == 0));
}
// m_RedrawEnabled = true;
@@ -789,6 +804,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
return S_OK;
}
void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
{
indices.Clear();
@@ -800,13 +816,16 @@ void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
if (_listView.GetItemParam(itemIndex, param))
indices.Add(param);
}
HeapSort(&indices.Front(), indices.Size());
*/
FOR_VECTOR (i, _selectedStatusVector)
if (_selectedStatusVector[i])
const bool *v = &_selectedStatusVector.Front();
unsigned size = _selectedStatusVector.Size();
for (unsigned i = 0; i < size; i++)
if (v[i])
indices.Add(i);
// HeapSort(&indices.Front(), indices.Size());
}
void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
{
GetSelectedItemsIndices(indices);
@@ -922,7 +941,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
GetOperatedItemIndices(indices);
if (indices.Size() > 20)
{
MessageBoxErrorLang(IDS_TOO_MANY_ITEMS);
MessageBox_Error_LangID(IDS_TOO_MANY_ITEMS);
return;
}
@@ -974,17 +993,20 @@ UString CPanel::GetItemName_for_Copy(int itemIndex) const
{
if (itemIndex == kParentIndex)
return L"..";
UString s;
{
NCOM::CPropVariant prop;
if (_folder->GetProperty(itemIndex, kpidOutName, &prop) == S_OK)
{
if (prop.vt == VT_BSTR)
return prop.bstrVal;
if (prop.vt != VT_EMPTY)
s = prop.bstrVal;
else if (prop.vt != VT_EMPTY)
throw 2723401;
}
if (s.IsEmpty())
s = GetItemName(itemIndex);
}
return GetItemName(itemIndex);
return Get_Correct_FsFile_Name(s);
}
void CPanel::GetItemName(int itemIndex, UString &s) const
@@ -1224,9 +1246,9 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
void CPanel::OnReload()
{
HRESULT res = RefreshListCtrlSaveFocused();
HRESULT res = RefreshListCtrl_SaveFocused();
if (res != S_OK)
MessageBoxError(res);
MessageBox_Error_HRESULT(res);
}
void CPanel::OnTimer()

View File

@@ -661,7 +661,7 @@ bool CPanel::CheckBeforeUpdate(UINT resourceID)
{
if (!_folderOperations)
{
MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
MessageBox_Error_UnsupportOperation();
// resourceID = resourceID;
// MessageBoxErrorForUpdate(E_NOINTERFACE, resourceID);
return false;
@@ -689,7 +689,7 @@ bool CPanel::CheckBeforeUpdate(UINT resourceID)
s += _parentFolders[i - 1].VirtualPath;
s.Add_LF();
AddLangString(s, IDS_PROP_READ_ONLY);
MessageBoxMyError(s);
MessageBox_Error(s);
return false;
}

View File

@@ -111,9 +111,9 @@ typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp);
void CPanel::MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID)
{
if (errorCode == E_NOINTERFACE)
MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
MessageBox_Error_UnsupportOperation();
else
MessageBoxError(errorCode, LangString(resourceID));
MessageBox_Error_HRESULT_Caption(errorCode, LangString(resourceID));
}
*/
@@ -178,7 +178,7 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
{
if (toRecycleBin)
{
MessageBoxErrorLang(IDS_ERROR_LONG_PATH_TO_RECYCLE);
MessageBox_Error_LangID(IDS_ERROR_LONG_PATH_TO_RECYCLE);
return;
}
useInternalDelete = true;
@@ -210,7 +210,7 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
}
/*
if (fo.fAnyOperationsAborted)
MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
MessageBox_Error_HRESULT_Caption(result, LangString(IDS_ERROR_DELETING));
*/
if (!useInternalDelete)
{
@@ -301,7 +301,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
UString newName = lpnmh->item.pszText;
if (!IsCorrectFsName(newName))
{
MessageBoxError(E_INVALIDARG);
MessageBox_Error_HRESULT(E_INVALIDARG);
return FALSE;
}
@@ -310,7 +310,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
UString correctName;
if (!CorrectFsPath(newName, correctName))
{
MessageBoxError(E_INVALIDARG);
MessageBox_Error_HRESULT(E_INVALIDARG);
return FALSE;
}
newName = correctName;
@@ -344,6 +344,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
// Can't use RefreshListCtrl here.
// RefreshListCtrlSaveFocused();
_selectedState.FocusedName = prefix + newName;
_selectedState.FocusedName_Defined = true;
_selectedState.SelectFocused = true;
// We need clear all items to disable GetText before Reload:
@@ -375,7 +376,7 @@ void CPanel::CreateFolder()
if (!IsCorrectFsName(newName))
{
MessageBoxError(E_INVALIDARG);
MessageBox_Error_HRESULT(E_INVALIDARG);
return;
}
@@ -384,7 +385,7 @@ void CPanel::CreateFolder()
UString correctName;
if (!CorrectFsPath(newName, correctName))
{
MessageBoxError(E_INVALIDARG);
MessageBox_Error_HRESULT(E_INVALIDARG);
return;
}
newName = correctName;
@@ -413,6 +414,7 @@ void CPanel::CreateFolder()
if (!_mySelectMode)
state.SelectedNames.Clear();
state.FocusedName = newName;
state.FocusedName_Defined = true;
state.SelectFocused = true;
}
RefreshTitleAlways();
@@ -444,7 +446,7 @@ void CPanel::CreateFile()
UString correctName;
if (!CorrectFsPath(newName, correctName))
{
MessageBoxError(E_INVALIDARG);
MessageBox_Error_HRESULT(E_INVALIDARG);
return;
}
newName = correctName;
@@ -453,7 +455,7 @@ void CPanel::CreateFile()
HRESULT result = _folderOperations->CreateFile(newName, 0);
if (result != S_OK)
{
MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR));
MessageBox_Error_HRESULT_Caption(result, LangString(IDS_CREATE_FILE_ERROR));
// MessageBoxErrorForUpdate(result, IDS_CREATE_FILE_ERROR);
return;
}
@@ -463,6 +465,7 @@ void CPanel::CreateFile()
if (!_mySelectMode)
state.SelectedNames.Clear();
state.FocusedName = newName;
state.FocusedName_Defined = true;
state.SelectFocused = true;
RefreshListCtrl(state);
}
@@ -515,9 +518,9 @@ void CPanel::ChangeComment()
if (result != S_OK)
{
if (result == E_NOINTERFACE)
MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
MessageBox_Error_UnsupportOperation();
else
MessageBoxError(result, L"Set Comment Error");
MessageBox_Error_HRESULT_Caption(result, L"Set Comment Error");
}
RefreshListCtrl(state);
}

View File

@@ -167,7 +167,7 @@ void CApp::Split()
CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.Is_IO_FS_Folder())
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
CRecordVector<UInt32> indices;
@@ -176,13 +176,13 @@ void CApp::Split()
return;
if (indices.Size() != 1)
{
srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE);
srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE);
return;
}
int index = indices[0];
if (srcPanel.IsItem_Folder(index))
{
srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE);
srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE);
return;
}
const UString itemName = srcPanel.GetItemName(index);
@@ -203,12 +203,12 @@ void CApp::Split()
NFind::CFileInfo fileInfo;
if (!fileInfo.Find(us2fs(srcPath + itemName)))
{
srcPanel.MessageBoxMyError(L"Can not find file");
srcPanel.MessageBox_Error(L"Can not find file");
return;
}
if (fileInfo.Size <= splitDialog.VolumeSizes.Front())
{
srcPanel.MessageBoxErrorLang(IDS_SPLIT_VOL_MUST_BE_SMALLER);
srcPanel.MessageBox_Error_LangID(IDS_SPLIT_VOL_MUST_BE_SMALLER);
return;
}
const UInt64 numVolumes = GetNumberOfVolumes(fileInfo.Size, splitDialog.VolumeSizes);
@@ -226,7 +226,8 @@ void CApp::Split()
NName::NormalizeDirPathPrefix(path);
if (!CreateComplexDir(us2fs(path)))
{
srcPanel.MessageBoxError2Lines(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), ::GetLastError());
DWORD lastError = ::GetLastError();
srcPanel.MessageBox_Error_2Lines_Message_HRESULT(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), lastError);
return;
}
@@ -350,7 +351,7 @@ void CApp::Combine()
CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder())
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
srcPanel.MessageBox_Error_LangID(IDS_OPERATION_IS_NOT_SUPPORTED);
return;
}
CRecordVector<UInt32> indices;
@@ -360,7 +361,7 @@ void CApp::Combine()
int index = indices[0];
if (indices.Size() != 1 || srcPanel.IsItem_Folder(index))
{
srcPanel.MessageBoxErrorLang(IDS_COMBINE_SELECT_ONE_FILE);
srcPanel.MessageBox_Error_LangID(IDS_COMBINE_SELECT_ONE_FILE);
return;
}
const UString itemName = srcPanel.GetItemName(index);
@@ -376,7 +377,7 @@ void CApp::Combine()
CVolSeqName volSeqName;
if (!volSeqName.ParseName(itemName))
{
srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_DETECT_SPLIT_FILE);
srcPanel.MessageBox_Error_LangID(IDS_COMBINE_CANT_DETECT_SPLIT_FILE);
return;
}
@@ -396,13 +397,13 @@ void CApp::Combine()
}
if (combiner.Names.Size() == 1)
{
srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART);
srcPanel.MessageBox_Error_LangID(IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART);
return;
}
if (combiner.TotalSize == 0)
{
srcPanel.MessageBoxMyError(L"No data");
srcPanel.MessageBox_Error(L"No data");
return;
}
@@ -438,7 +439,8 @@ void CApp::Combine()
NName::NormalizeDirPathPrefix(path);
if (!CreateComplexDir(us2fs(path)))
{
srcPanel.MessageBoxError2Lines(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), ::GetLastError());
DWORD lastError = ::GetLastError();
srcPanel.MessageBox_Error_2Lines_Message_HRESULT(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), lastError);
return;
}
@@ -457,7 +459,7 @@ void CApp::Combine()
combiner.OutputPath = us2fs(destFilePath);
if (fileInfo.Find(combiner.OutputPath))
{
srcPanel.MessageBoxMyError(MyFormatNew(IDS_FILE_EXIST, destFilePath));
srcPanel.MessageBox_Error(MyFormatNew(IDS_FILE_EXIST, destFilePath));
return;
}

View File

@@ -80,6 +80,9 @@ using namespace NDir;
static const unsigned kHistorySize = 20;
static const UInt32 kNoSolidBlockSize = 0;
static const UInt32 kSolidBlockSize = 64;
static LPCSTR const kExeExt = ".exe";
#define k7zFormat "7z"
@@ -292,7 +295,7 @@ static const CFormatInfo g_Formats[] =
"xz",
(1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
METHODS_PAIR(g_XzMethods),
false, false, true, false, false, false
false, true, true, false, false, false
},
{
"zstd", /* 6 */
@@ -838,10 +841,17 @@ void CCompressDialog::OnOK()
Info.OrderMode = GetOrderMode();
Info.NumThreads = GetNumThreadsSpec();
UInt32 solidLogSize = GetBlockSizeSpec();
Info.SolidBlockSize = 0;
if (solidLogSize > 0 && solidLogSize != (UInt32)(Int32)-1)
Info.SolidBlockSize = (solidLogSize >= 64) ? (UInt64)(Int64)-1 : ((UInt64)1 << solidLogSize);
{
// Info.SolidIsSpecified = g_Formats[GetStaticFormatIndex()].Solid;
UInt32 solidLogSize = GetBlockSizeSpec();
Info.SolidBlockSize = 0;
if (solidLogSize == (UInt32)(Int32)-1)
Info.SolidIsSpecified = false;
else if (solidLogSize > 0)
Info.SolidBlockSize = (solidLogSize >= 64) ?
(UInt64)(Int64)-1 :
((UInt64)1 << solidLogSize);
}
Info.Method = GetMethodSpec();
Info.EncryptionMethod = GetEncryptionMethodSpec();
@@ -949,6 +959,7 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
*/
return true;
}
case IDC_COMPRESS_FORMAT:
{
bool isSFX = IsSFX();
@@ -963,6 +974,7 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
SetMemoryUsage();
return true;
}
case IDC_COMPRESS_LEVEL:
{
SetMethod(GetMethodID());
@@ -972,6 +984,7 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
SetMemoryUsage();
return true;
}
case IDC_COMPRESS_METHOD:
{
SetLevel();
@@ -983,13 +996,34 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
SetMemoryUsage();
return true;
}
case IDC_COMPRESS_DICTIONARY:
case IDC_COMPRESS_ORDER:
{
SetSolidBlockSize();
UInt32 blockSizeLog = GetBlockSizeSpec();
if (blockSizeLog != (UInt32)(Int32)-1
&& blockSizeLog != kNoSolidBlockSize
&& blockSizeLog != kSolidBlockSize)
{
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormatAlways(ai.Name);
NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
fo.Reset_BlockLogSize();
SetSolidBlockSize(true);
}
SetMemoryUsage();
return true;
}
case IDC_COMPRESS_ORDER:
return true;
case IDC_COMPRESS_SOLID:
{
SetMemoryUsage();
return true;
}
case IDC_COMPRESS_THREADS:
{
SetMemoryUsage();
@@ -1282,6 +1316,12 @@ bool CCompressDialog::IsZipFormat()
return ai.Name.IsEqualTo_Ascii_NoCase("zip");
}
bool CCompressDialog::IsXzFormat()
{
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
return ai.Name.IsEqualTo_Ascii_NoCase("xz");
}
void CCompressDialog::SetEncryptionMethod()
{
_encryptionMethod.ResetContent();
@@ -1647,10 +1687,8 @@ bool CCompressDialog::GetOrderMode()
return false;
}
static const UInt32 kNoSolidBlockSize = 0;
static const UInt32 kSolidBlockSize = 64;
void CCompressDialog::SetSolidBlockSize()
void CCompressDialog::SetSolidBlockSize(bool useDictionary)
{
m_Solid.ResetContent();
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
@@ -1668,6 +1706,10 @@ void CCompressDialog::SetSolidBlockSize()
UInt32 defaultBlockSize = (UInt32)(Int32)-1;
const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
if (useDictionary)
defaultBlockSize = GetBlockSizeSpec();
else
{
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
@@ -1678,23 +1720,54 @@ void CCompressDialog::SetSolidBlockSize()
}
}
bool is7z = ai.Name.IsEqualTo_Ascii_NoCase("7z");
{
int index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_NON_SOLID));
UString s ('-');
if (is7z)
LangString(IDS_COMPRESS_NON_SOLID, s);
int index = (int)m_Solid.AddString(s);
m_Solid.SetItemData(index, (UInt32)kNoSolidBlockSize);
m_Solid.SetCurSel(0);
if (defaultBlockSize == kNoSolidBlockSize)
m_Solid.SetCurSel(0);
}
UInt64 blockSize;
bool needSet = (defaultBlockSize == (UInt32)(Int32)-1);
if (is7z)
{
blockSize = (UInt64)dict << 7;
const UInt32 kMinSize = (UInt32)1 << 24;
const UInt64 kMaxSize = (UInt64)1 << 32;
if (blockSize < kMinSize) blockSize = kMinSize;
if (blockSize > kMaxSize) blockSize = kMaxSize;
}
else
{
blockSize = (UInt64)dict << 2;
const UInt32 kMinSize = (UInt32)1 << 20;
const UInt32 kMaxSize = (UInt32)1 << 28;
if (blockSize < kMinSize) blockSize = kMinSize;
if (blockSize > kMaxSize) blockSize = kMaxSize;
if (blockSize < dict) blockSize = dict;
}
for (unsigned i = 20; i <= 36; i++)
{
if (needSet && dict >= (((UInt64)1 << (i - 7))) && i <= 32)
if (defaultBlockSize == (UInt32)(Int32)-1 && ((UInt64)1 << i) >= blockSize)
defaultBlockSize = i;
TCHAR s[40];
char post;
ConvertUInt32ToString(1 << (i % 10), s);
if (i < 30) lstrcat(s, TEXT(" M"));
else lstrcat(s, TEXT(" G"));
lstrcat(s, TEXT("B"));
if (i < 20) post = 'K';
else if (i < 30) post = 'M';
else post = 'G';
unsigned pos = (unsigned)lstrlen(s);
s[pos++] = ' ';
s[pos++] = post;
s[pos++] = 'B';
s[pos] = 0;
int index = (int)m_Solid.AddString(s);
m_Solid.SetItemData(index, (UInt32)i);
}
@@ -1815,20 +1888,42 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory)
size1 += (2 << 20) + (4 << 20);
numThreads1 = 2;
}
UInt32 numBlockThreads = numThreads / numThreads1;
UInt64 chunkSize = 0;
if (methidId == kLZMA || numBlockThreads == 1)
size1 += (UInt64)dict * 3 / 2;
else
if (methidId != kLZMA && numBlockThreads != 1)
{
UInt64 chunkSize = (UInt64)dict << 2;
chunkSize = (UInt64)dict << 2;
chunkSize = MyMax(chunkSize, (UInt64)(1 << 20));
chunkSize = MyMin(chunkSize, (UInt64)(1 << 28));
chunkSize = MyMax(chunkSize, (UInt64)dict);
size1 += chunkSize * 2;
if (IsXzFormat())
{
UInt32 blockSizeLog = GetBlockSizeSpec();
if (blockSizeLog != (UInt32)(Int32)-1)
{
if (blockSizeLog == kSolidBlockSize)
{
numBlockThreads = 1;
chunkSize = 0;
}
else if (blockSizeLog != kNoSolidBlockSize)
chunkSize = (UInt64)1 << blockSizeLog;
}
}
}
if (chunkSize == 0)
size += numBlockThreads * (size1 + (UInt64)dict * 3 / 2);
else
{
size += numBlockThreads * (size1 + chunkSize);
UInt64 numPackChunks = numBlockThreads + (numBlockThreads / 4) + 2;
size += numPackChunks * chunkSize;
}
size += size1 * numBlockThreads;
decompressMemory = dict + (2 << 20);
return size;
@@ -1843,9 +1938,11 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory)
case kDeflate:
case kDeflate64:
{
/*
UInt32 order = GetOrder();
if (order == (UInt32)(Int32)-1)
order = 32;
*/
if (level >= 7)
size += (1 << 20);
size += 3 << 20;

View File

@@ -137,6 +137,7 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
UString GetEncryptionMethodSpec();
bool IsZipFormat();
bool IsXzFormat();
void SetEncryptionMethod();
@@ -161,7 +162,7 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void SetOrder();
bool GetOrderMode();
void SetSolidBlockSize();
void SetSolidBlockSize(bool useDictionary = false);
void SetNumThreads();
UInt64 GetMemoryUsage(UInt32 dict, UInt64 &decompressMemory);

View File

@@ -128,14 +128,21 @@ static int Main2()
#if defined(_WIN32) && !defined(UNDER_CE)
NSecurity::EnablePrivilege_SymLink();
#endif
#ifdef _7ZIP_LARGE_PAGES
if (options.LargePages)
{
SetLargePageSize();
g_LargePagesMode = NSecurity::EnablePrivilege_LockMemory();
// note: this process also can inherit that Privilege from parent process
g_LargePagesMode =
#if defined(_WIN32) && !defined(UNDER_CE)
NSecurity::EnablePrivilege_LockMemory();
#else
true;
#endif
}
#endif
#endif
CREATE_CODECS_OBJECT

View File

@@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /FAcs /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "_7ZIP_LARGE_PAGES" /FAcs /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -72,7 +72,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /Gr /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /Gr /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "_7ZIP_LARGE_PAGES" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -99,7 +99,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "_7ZIP_LARGE_PAGES" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -127,7 +127,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /Gr /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /Gr /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "_7ZIP_LARGE_PAGES" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"