Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/CPP/7zip/UI
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2015-11-19 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:57 +0300
commite24f7fba53cc8f28d74b5039f7279d9bf945ff25 (patch)
tree52cf49d97bf4436151ec824ec7fbbf9d567578ff /CPP/7zip/UI
parent7c8a265a15125b64808e695882acd2a0298ebce4 (diff)
15.1115.11
Diffstat (limited to 'CPP/7zip/UI')
-rw-r--r--CPP/7zip/UI/Agent/AgentProxy.cpp3
-rw-r--r--CPP/7zip/UI/Common/ArchiveCommandLine.cpp38
-rw-r--r--CPP/7zip/UI/Common/ArchiveExtractCallback.cpp22
-rw-r--r--CPP/7zip/UI/Common/ArchiveOpenCallback.cpp33
-rw-r--r--CPP/7zip/UI/Common/Bench.cpp21
-rw-r--r--CPP/7zip/UI/Common/PropIDUtils.cpp18
-rw-r--r--CPP/7zip/UI/Common/SortUtils.cpp4
-rw-r--r--CPP/7zip/UI/Common/TempFiles.cpp2
-rw-r--r--CPP/7zip/UI/Common/UpdateCallback.cpp1
-rw-r--r--CPP/7zip/UI/Common/UpdatePair.cpp1
-rw-r--r--CPP/7zip/UI/Common/WorkDir.cpp2
-rw-r--r--CPP/7zip/UI/Console/Main.cpp6
-rw-r--r--CPP/7zip/UI/Console/MainAr.cpp4
-rw-r--r--CPP/7zip/UI/Far/StdAfx.h5
-rw-r--r--CPP/7zip/UI/FileManager/FM.cpp3
-rw-r--r--CPP/7zip/UI/FileManager/Panel.h58
-rw-r--r--CPP/7zip/UI/FileManager/PanelItemOpen.cpp6
-rw-r--r--CPP/7zip/UI/FileManager/PanelItems.cpp214
-rw-r--r--CPP/7zip/UI/FileManager/PanelListNotify.cpp2
-rw-r--r--CPP/7zip/UI/FileManager/PanelSort.cpp16
-rw-r--r--CPP/7zip/UI/FileManager/RegistryUtils.cpp2
-rw-r--r--CPP/7zip/UI/FileManager/SysIconUtils.cpp2
-rw-r--r--CPP/7zip/UI/FileManager/ViewSettings.cpp2
-rw-r--r--CPP/7zip/UI/FileManager/ViewSettings.h8
-rw-r--r--CPP/7zip/UI/GUI/BenchmarkDialog.cpp14
-rw-r--r--CPP/7zip/UI/GUI/CompressDialog.cpp34
26 files changed, 367 insertions, 154 deletions
diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp
index 9a977c70..803a327a 100644
--- a/CPP/7zip/UI/Agent/AgentProxy.cpp
+++ b/CPP/7zip/UI/Agent/AgentProxy.cpp
@@ -248,7 +248,8 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
unsigned len = 0;
bool isPtrName = false;
- #ifdef MY_CPU_LE
+ #if defined(MY_CPU_LE) && defined(_WIN32)
+ // it works only if (sizeof(wchar_t) == 2)
if (arc.GetRawProps)
{
const void *p;
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
index 067b32f3..f39cf162 100644
--- a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
@@ -271,7 +271,7 @@ static const unsigned kCommandIndex = 0;
static const char *kCannotFindListFile = "Cannot find listfile";
static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
static const char *kTerminalOutError = "I won't write compressed data to a terminal";
-static const char *kSameTerminalError = "I won't write data and program's messages to same terminal";
+static const char *kSameTerminalError = "I won't write data and program's messages to same stream";
static const char *kEmptyFilePath = "Empty file path";
static const char *kCannotFindArchive = "Cannot find archive";
@@ -1219,8 +1219,26 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
if (isExtractGroupCommand)
{
- if (options.StdOutMode && options.IsStdOutTerminal && options.IsStdErrTerminal)
- throw CArcCmdLineException(kSameTerminalError);
+ if (options.StdOutMode)
+ {
+ if (
+ options.Number_for_Percents == k_OutStream_stdout
+ // || options.Number_for_Out == k_OutStream_stdout
+ // || options.Number_for_Errors == k_OutStream_stdout
+ ||
+ (
+ (options.IsStdOutTerminal && options.IsStdErrTerminal)
+ &&
+ (
+ options.Number_for_Percents != k_OutStream_disabled
+ // || options.Number_for_Out != k_OutStream_disabled
+ // || options.Number_for_Errors != k_OutStream_disabled
+ )
+ )
+ )
+ throw CArcCmdLineException(kSameTerminalError);
+ }
+
if (parser[NKey::kOutputDir].ThereIs)
{
eo.OutputDir = us2fs(parser[NKey::kOutputDir].PostStrings[0]);
@@ -1293,8 +1311,18 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
if (updateOptions.StdOutMode && updateOptions.EMailMode)
throw CArcCmdLineException("stdout mode and email mode cannot be combined");
- if (updateOptions.StdOutMode && options.IsStdOutTerminal)
- throw CArcCmdLineException(kTerminalOutError);
+
+ if (updateOptions.StdOutMode)
+ {
+ if (options.IsStdOutTerminal)
+ throw CArcCmdLineException(kTerminalOutError);
+
+ if (options.Number_for_Percents == k_OutStream_stdout
+ || options.Number_for_Out == k_OutStream_stdout
+ || options.Number_for_Errors == k_OutStream_stdout)
+ throw CArcCmdLineException(kSameTerminalError);
+ }
+
if (updateOptions.StdInMode)
updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
index 877326b8..fe9c3366 100644
--- a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
@@ -451,32 +451,42 @@ static UString GetDirPrefixOf(const UString &src)
return s;
}
-static bool IsSafePath(const UString &path)
+#endif
+
+
+bool IsSafePath(const UString &path)
{
+ if (NName::IsAbsolutePath(path))
+ return false;
+
UStringVector parts;
SplitPathToParts(path, parts);
- int level = 0;
- FOR_VECTOR(i, parts)
+ unsigned level = 0;
+
+ FOR_VECTOR (i, parts)
{
const UString &s = parts[i];
if (s.IsEmpty())
+ {
+ if (i == 0)
+ return false;
continue;
+ }
if (s == L".")
continue;
if (s == L"..")
{
- if (level <= 0)
+ if (level == 0)
return false;
level--;
}
else
level++;
}
+
return level > 0;
}
-#endif
-
bool CensorNode_CheckPath2(const NWildcard::CCensorNode &node, const CReadArcItem &item, bool &include)
{
diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
index 47af7251..359835d3 100644
--- a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
+++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
@@ -73,18 +73,40 @@ struct CInFileStreamVol: public CInFileStream
}
};
+
+// from ArchiveExtractCallback.cpp
+bool IsSafePath(const UString &path);
+
STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStream)
{
COM_TRY_BEGIN
*inStream = NULL;
+
if (_subArchiveMode)
return S_FALSE;
if (Callback)
{
RINOK(Callback->Open_CheckBreak());
}
+
+ UString name2 = name;
+
+
+ #ifndef _SFX
+
+ #ifdef _WIN32
+ name2.Replace(L'/', WCHAR_PATH_SEPARATOR);
+ #endif
+
+ // if (!allowAbsVolPaths)
+ if (!IsSafePath(name2))
+ return S_FALSE;
+
+ #endif
+
+
FString fullPath;
- if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name), fullPath))
+ if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name2), fullPath))
return S_FALSE;
if (!_fileInfo.Find(fullPath))
return S_FALSE;
@@ -93,10 +115,15 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre
CInFileStreamVol *inFile = new CInFileStreamVol;
CMyComPtr<IInStream> inStreamTemp = inFile;
if (!inFile->Open(fullPath))
- return ::GetLastError();
+ {
+ DWORD lastError = ::GetLastError();
+ if (lastError == 0)
+ return E_FAIL;
+ return HRESULT_FROM_WIN32(lastError);
+ }
FileSizes.Add(_fileInfo.Size);
- FileNames.Add(name);
+ FileNames.Add(name2);
inFile->FileNameIndex = FileNames_WasUsed.Add(true);
inFile->OpenCallbackImp = this;
inFile->OpenCallbackRef = this;
diff --git a/CPP/7zip/UI/Common/Bench.cpp b/CPP/7zip/UI/Common/Bench.cpp
index 3833f07f..f861f503 100644
--- a/CPP/7zip/UI/Common/Bench.cpp
+++ b/CPP/7zip/UI/Common/Bench.cpp
@@ -32,9 +32,7 @@
#include "../../../../C/Alloc.h"
#include "../../../../C/CpuArch.h"
-#if defined(_WIN32)
#include "../../../Windows/System.h"
-#endif
#ifndef _7ZIP_ST
#include "../../../Windows/Synchronization.h"
@@ -1860,11 +1858,15 @@ static void PrintTotals(IBenchPrintCallback &f, bool showFreq, UInt64 cpuFreq, c
PrintResults(f, res.Usage / numIterations2, res.RPU / numIterations2, res.Rating / numIterations2, showFreq, cpuFreq);
}
-static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
+static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString,
+ bool size_Defined, UInt64 size, const char *threadsString, UInt32 numThreads)
{
f.Print("RAM ");
f.Print(sizeString);
- PrintNumber(f, (size >> 20), 6);
+ if (size_Defined)
+ PrintNumber(f, (size >> 20), 6);
+ else
+ f.Print(" ?");
f.Print(" MB, # ");
f.Print(threadsString);
PrintNumber(f, numThreads, 3);
@@ -2450,15 +2452,13 @@ HRESULT Bench(
return S_FALSE;
UInt32 numCPUs = 1;
- UInt64 ramSize = (UInt64)512 << 20;
+ UInt64 ramSize = (UInt64)(sizeof(size_t)) << 29;
#ifndef _7ZIP_ST
numCPUs = NSystem::GetNumberOfProcessors();
#endif
- #if defined(_WIN32)
- ramSize = NSystem::GetRamSize();
- #endif
+ bool ramSize_Defined = NSystem::GetRamSize(ramSize);
UInt32 numThreadsSpecified = numCPUs;
@@ -2640,7 +2640,7 @@ HRESULT Bench(
{
printCallback->NewLine();
printCallback->NewLine();
- PrintRequirements(*printCallback, "size: ", ramSize, "CPU hardware threads:", numCPUs);
+ PrintRequirements(*printCallback, "size: ", ramSize_Defined, ramSize, "CPU hardware threads:", numCPUs);
}
if (numThreadsSpecified < 1 || numThreadsSpecified > kNumThreadsMax)
@@ -2834,6 +2834,7 @@ HRESULT Bench(
dicSizeLog = (UInt64)1 << 20;
#endif
+ if (ramSize_Defined)
for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog), totalBenchMode) + (8 << 20) <= ramSize)
break;
@@ -2848,7 +2849,7 @@ HRESULT Bench(
}
}
- PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dict, totalBenchMode), "Benchmark threads: ", numThreads);
+ PrintRequirements(f, "usage:", true, GetBenchMemoryUsage(numThreads, dict, totalBenchMode), "Benchmark threads: ", numThreads);
f.NewLine();
diff --git a/CPP/7zip/UI/Common/PropIDUtils.cpp b/CPP/7zip/UI/Common/PropIDUtils.cpp
index 32001624..dccc08b1 100644
--- a/CPP/7zip/UI/Common/PropIDUtils.cpp
+++ b/CPP/7zip/UI/Common/PropIDUtils.cpp
@@ -142,14 +142,16 @@ void ConvertPropertyToShortString(char *dest, const PROPVARIANT &prop, PROPID pr
case kpidVa:
{
UInt64 v = 0;
- if (ConvertPropVariantToUInt64(prop, v))
- {
- dest[0] = '0';
- dest[1] = 'x';
- ConvertUInt64ToHex(prop.ulVal, dest + 2);
- return;
- }
- break;
+ if (prop.vt == VT_UI4)
+ v = prop.ulVal;
+ else if (prop.vt == VT_UI8)
+ v = (UInt64)prop.uhVal.QuadPart;
+ else
+ break;
+ dest[0] = '0';
+ dest[1] = 'x';
+ ConvertUInt64ToHex(v, dest + 2);
+ return;
}
}
diff --git a/CPP/7zip/UI/Common/SortUtils.cpp b/CPP/7zip/UI/Common/SortUtils.cpp
index b7e422a2..5f29249b 100644
--- a/CPP/7zip/UI/Common/SortUtils.cpp
+++ b/CPP/7zip/UI/Common/SortUtils.cpp
@@ -14,8 +14,10 @@ static int CompareStrings(const unsigned *p1, const unsigned *p2, void *param)
void SortFileNames(const UStringVector &strings, CUIntVector &indices)
{
- unsigned numItems = strings.Size();
+ const unsigned numItems = strings.Size();
indices.ClearAndSetSize(numItems);
+ if (numItems == 0)
+ return;
unsigned *vals = &indices[0];
for (unsigned i = 0; i < numItems; i++)
vals[i] = i;
diff --git a/CPP/7zip/UI/Common/TempFiles.cpp b/CPP/7zip/UI/Common/TempFiles.cpp
index 0c13ae15..2f868381 100644
--- a/CPP/7zip/UI/Common/TempFiles.cpp
+++ b/CPP/7zip/UI/Common/TempFiles.cpp
@@ -17,5 +17,3 @@ void CTempFiles::Clear()
Paths.DeleteBack();
}
}
-
-
diff --git a/CPP/7zip/UI/Common/UpdateCallback.cpp b/CPP/7zip/UI/Common/UpdateCallback.cpp
index ea8f47e1..6c439cfd 100644
--- a/CPP/7zip/UI/Common/UpdateCallback.cpp
+++ b/CPP/7zip/UI/Common/UpdateCallback.cpp
@@ -757,4 +757,3 @@ void CArchiveUpdateCallback::InFileStream_On_Destroy(UINT_PTR val)
}
throw 20141125;
}
-
diff --git a/CPP/7zip/UI/Common/UpdatePair.cpp b/CPP/7zip/UI/Common/UpdatePair.cpp
index 68701400..e2115197 100644
--- a/CPP/7zip/UI/Common/UpdatePair.cpp
+++ b/CPP/7zip/UI/Common/UpdatePair.cpp
@@ -92,6 +92,7 @@ void GetUpdatePairInfoList(
{
arcIndices.ClearAndSetSize(numArcItems);
+ if (numArcItems != 0)
{
unsigned *vals = &arcIndices[0];
for (unsigned i = 0; i < numArcItems; i++)
diff --git a/CPP/7zip/UI/Common/WorkDir.cpp b/CPP/7zip/UI/Common/WorkDir.cpp
index 735cdda4..284eaa16 100644
--- a/CPP/7zip/UI/Common/WorkDir.cpp
+++ b/CPP/7zip/UI/Common/WorkDir.cpp
@@ -17,7 +17,7 @@ FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FStr
{
NWorkDir::NMode::EEnum mode = workDirInfo.Mode;
- #ifndef UNDER_CE
+ #if defined(_WIN32) && !defined(UNDER_CE)
if (workDirInfo.ForRemovableOnly)
{
mode = NWorkDir::NMode::kCurrent;
diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp
index 652b30f7..50652555 100644
--- a/CPP/7zip/UI/Console/Main.cpp
+++ b/CPP/7zip/UI/Console/Main.cpp
@@ -4,11 +4,13 @@
#include "../../../Common/MyWindows.h"
+#ifdef _WIN32
#include <Psapi.h>
+#endif
#include "../../../../C/CpuArch.h"
-#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES)
+#if defined( _7ZIP_LARGE_PAGES)
#include "../../../../C/Alloc.h"
#endif
@@ -470,7 +472,7 @@ static void PrintHexId(CStdOutStream &so, UInt64 id)
int Main2(
#ifndef _WIN32
- int numArgs, const char *args[]
+ int numArgs, char *args[]
#endif
)
{
diff --git a/CPP/7zip/UI/Console/MainAr.cpp b/CPP/7zip/UI/Console/MainAr.cpp
index f3f977f5..d30a96e4 100644
--- a/CPP/7zip/UI/Console/MainAr.cpp
+++ b/CPP/7zip/UI/Console/MainAr.cpp
@@ -20,7 +20,7 @@ CStdOutStream *g_ErrStream = NULL;
extern int Main2(
#ifndef _WIN32
- int numArgs, const char *args[]
+ int numArgs, char *args[]
#endif
);
@@ -49,7 +49,7 @@ static void PrintError(const char *message)
int MY_CDECL main
(
#ifndef _WIN32
- int numArgs, const char *args[]
+ int numArgs, char *args[]
#endif
)
{
diff --git a/CPP/7zip/UI/Far/StdAfx.h b/CPP/7zip/UI/Far/StdAfx.h
index 3bff655e..2854ff3e 100644
--- a/CPP/7zip/UI/Far/StdAfx.h
+++ b/CPP/7zip/UI/Far/StdAfx.h
@@ -3,11 +3,6 @@
#ifndef __STDAFX_H
#define __STDAFX_H
-// #define _CRT_SECURE_NO_DEPRECATE
-// #include <windows.h>
-// #include <stdio.h>
-
#include "../../../Common/Common.h"
#endif
-
diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp
index 1a7ed060..a320c016 100644
--- a/CPP/7zip/UI/FileManager/FM.cpp
+++ b/CPP/7zip/UI/FileManager/FM.cpp
@@ -42,6 +42,7 @@ using namespace NFind;
#define MENU_HEIGHT 26
+bool g_RAM_Size_Defined;
UInt64 g_RAM_Size;
#ifdef _WIN32
@@ -425,7 +426,7 @@ static void ErrorMessage(const wchar_t *s)
static int WINAPI WinMain2(int nCmdShow)
{
- g_RAM_Size = NSystem::GetRamSize();
+ g_RAM_Size_Defined = NSystem::GetRamSize(g_RAM_Size);
#ifdef _WIN32
diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h
index bb579947..709ef0f5 100644
--- a/CPP/7zip/UI/FileManager/Panel.h
+++ b/CPP/7zip/UI/FileManager/Panel.h
@@ -69,31 +69,67 @@ struct CPanelCallback
void PanelCopyItems();
-struct CItemProperty
+
+struct CPropColumn
{
- UString Name;
+ int Order;
PROPID ID;
VARTYPE Type;
- int Order;
bool IsVisible;
bool IsRawProp;
UInt32 Width;
+ UString Name;
- int Compare(const CItemProperty &a) const { return MyCompare(Order, a.Order); }
+ bool IsEqualTo(const CPropColumn &a) const
+ {
+ return Order == a.Order
+ && ID == a.ID
+ && Type == a.Type
+ && IsVisible == a.IsVisible
+ && IsRawProp == a.IsRawProp
+ && Width == a.Width
+ && Name == a.Name;
+ }
+
+ int Compare(const CPropColumn &a) const { return MyCompare(Order, a.Order); }
+
+ int Compare_NameFirst(const CPropColumn &a) const
+ {
+ if (ID == kpidName)
+ {
+ if (a.ID != kpidName)
+ return -1;
+ }
+ else if (a.ID == kpidName)
+ return 1;
+ return MyCompare(Order, a.Order);
+ }
};
-class CItemProperties: public CObjectVector<CItemProperty>
+
+class CPropColumns: public CObjectVector<CPropColumn>
{
public:
- int FindItemWithID(PROPID id)
+ int FindItem_for_PropID(PROPID id) const
{
FOR_VECTOR (i, (*this))
if ((*this)[i].ID == id)
return i;
return -1;
}
+
+ bool IsEqualTo(const CPropColumns &props) const
+ {
+ if (Size() != props.Size())
+ return false;
+ FOR_VECTOR (i, (*this))
+ if (!(*this)[i].IsEqualTo(props[i]))
+ return false;
+ return true;
+ }
};
+
struct CTempFileInfo
{
UInt32 FileIndex; // index of file in folder
@@ -284,8 +320,8 @@ private:
void ChangeWindowSize(int xSize, int ySize);
HRESULT InitColumns();
- // void InitColumns2(PROPID sortID);
- void InsertColumn(unsigned index);
+ void DeleteColumn(unsigned index);
+ void AddColumn(const CPropColumn &prop);
void SetFocusedSelectedItem(int index, bool select);
HRESULT RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
@@ -446,7 +482,6 @@ public:
void SetFocusToLastRememberedItem();
- void ReadListViewInfo();
void SaveListViewInfo();
CPanel() :
@@ -484,8 +519,9 @@ public:
bool _needSaveInfo;
UString _typeIDString;
CListViewInfo _listViewInfo;
- CItemProperties _properties;
- CItemProperties _visibleProperties;
+
+ CPropColumns _columns;
+ CPropColumns _visibleColumns;
PROPID _sortID;
// int _sortIndex;
diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
index a4ab254d..c37ac64f 100644
--- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
@@ -36,6 +36,7 @@ using namespace NSynchronization;
using namespace NFile;
using namespace NDir;
+extern bool g_RAM_Size_Defined;
extern UInt64 g_RAM_Size;
#ifndef _UNICODE
@@ -1173,7 +1174,10 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
{
NCOM::CPropVariant prop;
_folder->GetProperty(index, kpidSize, &prop);
- UInt64 fileLimit = g_RAM_Size / 4;
+ UInt64 fileLimit = 1 << 22;
+ if (g_RAM_Size_Defined)
+ fileLimit = g_RAM_Size / 4;
+
UInt64 fileSize = 0;
if (!ConvertPropVariantToUInt64(prop, fileSize))
fileSize = fileLimit;
diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp
index e6b89cbe..e72d1bb6 100644
--- a/CPP/7zip/UI/FileManager/PanelItems.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItems.cpp
@@ -82,15 +82,33 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType)
}
}
+
+static int ItemProperty_Compare_NameFirst(void *const *a1, void *const *a2, void * /* param */)
+{
+ return (*(*((const CPropColumn **)a1))).Compare_NameFirst(*(*((const CPropColumn **)a2)));
+}
+
HRESULT CPanel::InitColumns()
{
- if (_needSaveInfo)
- SaveListViewInfo();
+ SaveListViewInfo();
_listView.DeleteAllItems();
_selectedStatusVector.Clear();
- ReadListViewInfo();
+ {
+ // ReadListViewInfo();
+ const UString oldType = _typeIDString;
+ _typeIDString = GetFolderTypeID();
+ // an empty _typeIDString is allowed.
+
+ // we read registry only for new FolderTypeID
+ if (!_needSaveInfo || _typeIDString != oldType)
+ _listViewInfo.Read(_typeIDString);
+
+ // folders with same FolderTypeID can have different columns
+ // so we still read columns for that case.
+ // if (_needSaveInfo && _typeIDString == oldType) return S_OK;
+ }
// PROPID sortID;
/*
@@ -101,9 +119,8 @@ HRESULT CPanel::InitColumns()
_ascending = _listViewInfo.Ascending;
- _properties.Clear();
+ _columns.Clear();
- _needSaveInfo = true;
bool isFsFolder = IsFSFolder() || IsAltStreamsFolder();
{
@@ -125,7 +142,7 @@ HRESULT CPanel::InitColumns()
}
if (propID == kpidIsDir)
continue;
- CItemProperty prop;
+ CPropColumn prop;
prop.Type = varType;
prop.ID = propID;
prop.Name = GetNameOfProperty(propID, name);
@@ -133,7 +150,7 @@ HRESULT CPanel::InitColumns()
prop.IsVisible = GetColumnVisible(propID, isFsFolder);
prop.Width = GetColumnWidth(propID, varType);
prop.IsRawProp = false;
- _properties.Add(prop);
+ _columns.Add(prop);
}
}
@@ -141,13 +158,15 @@ HRESULT CPanel::InitColumns()
{
UInt32 numProps;
_folderRawProps->GetNumRawProps(&numProps);
+
for (UInt32 i = 0; i < numProps; i++)
{
CMyComBSTR name;
PROPID propID;
- RINOK(_folderRawProps->GetRawPropInfo(i, &name, &propID));
-
- CItemProperty prop;
+ HRESULT res = _folderRawProps->GetRawPropInfo(i, &name, &propID);
+ if (res != S_OK)
+ continue;
+ CPropColumn prop;
prop.Type = VT_EMPTY;
prop.ID = propID;
prop.Name = GetNameOfProperty(propID, name);
@@ -155,83 +174,147 @@ HRESULT CPanel::InitColumns()
prop.IsVisible = GetColumnVisible(propID, isFsFolder);
prop.Width = GetColumnWidth(propID, VT_BSTR);;
prop.IsRawProp = true;
- _properties.Add(prop);
+ _columns.Add(prop);
}
}
- // InitColumns2(sortID);
-
- for (;;)
- if (!_listView.DeleteColumn(0))
- break;
-
unsigned order = 0;
unsigned i;
for (i = 0; i < _listViewInfo.Columns.Size(); i++)
{
const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
- int index = _properties.FindItemWithID(columnInfo.PropID);
+ int index = _columns.FindItem_for_PropID(columnInfo.PropID);
if (index >= 0)
{
- CItemProperty &item = _properties[index];
- item.IsVisible = columnInfo.IsVisible;
+ CPropColumn &item = _columns[index];
+ if (item.Order >= 0)
+ continue; // we ignore duplicated items
+ bool isVisible = columnInfo.IsVisible;
+ // we enable kpidName, if it was disabled by some incorrect code
+ if (columnInfo.PropID == kpidName)
+ isVisible = true;
+ item.IsVisible = isVisible;
item.Width = columnInfo.Width;
- if (columnInfo.IsVisible)
+ if (isVisible)
item.Order = order++;
continue;
}
}
+
+ for (i = 0; i < _columns.Size(); i++)
+ {
+ CPropColumn &item = _columns[i];
+ if (item.IsVisible && item.Order < 0)
+ item.Order = order++;
+ }
- for (i = 0; i < _properties.Size(); i++)
+ for (i = 0; i < _columns.Size(); i++)
{
- CItemProperty &item = _properties[i];
+ CPropColumn &item = _columns[i];
if (item.Order < 0)
item.Order = order++;
}
- _visibleProperties.Clear();
- for (i = 0; i < _properties.Size(); i++)
+ CPropColumns newColumns;
+
+ for (i = 0; i < _columns.Size(); i++)
{
- const CItemProperty &prop = _properties[i];
+ const CPropColumn &prop = _columns[i];
if (prop.IsVisible)
- _visibleProperties.Add(prop);
+ newColumns.Add(prop);
}
- // _sortIndex = 0;
- _sortID = kpidName;
+
/*
+ _sortIndex = 0;
if (_listViewInfo.SortIndex >= 0)
{
- int sortIndex = _properties.FindItemWithID(sortID);
+ int sortIndex = _columns.FindItem_for_PropID(sortID);
if (sortIndex >= 0)
_sortIndex = sortIndex;
}
*/
- _sortID = _listViewInfo.SortID;
- _visibleProperties.Sort();
+ if (_listViewInfo.IsLoaded)
+ _sortID = _listViewInfo.SortID;
+ else
+ {
+ _sortID = 0;
+ if (IsFSFolder() || IsAltStreamsFolder() || IsArcFolder())
+ _sortID = kpidName;
+ }
+
+ /* There are restrictions in ListView control:
+ 1) main column (kpidName) must have (LV_COLUMNW::iSubItem = 0)
+ So we need special sorting for columns.
+ 2) when we add new column, LV_COLUMNW::iOrder can not be larger than already inserted columns)
+ So we set column order after all columns are added.
+ */
+ newColumns.Sort(ItemProperty_Compare_NameFirst, NULL);
+
+ if (newColumns.IsEqualTo(_visibleColumns))
+ return S_OK;
+
+ CIntArr columns(newColumns.Size());
+ for (i = 0; i < newColumns.Size(); i++)
+ columns[i] = -1;
+
+ bool orderError = false;
+
+ for (i = 0; i < newColumns.Size(); i++)
+ {
+ const CPropColumn &prop = newColumns[i];
+ if (prop.Order < (int)newColumns.Size() && columns[prop.Order] == -1)
+ columns[prop.Order] = i;
+ else
+ orderError = true;
+ }
+
+ for (;;)
+ {
+ unsigned numColumns = _visibleColumns.Size();
+ if (numColumns == 0)
+ break;
+ DeleteColumn(numColumns - 1);
+ }
+
+ for (i = 0; i < newColumns.Size(); i++)
+ AddColumn(newColumns[i]);
+
+ // columns[0], columns[1], .... should be displayed from left to right:
+ if (!orderError)
+ _listView.SetColumnOrderArray(_visibleColumns.Size(), columns);
- for (i = 0; i < _visibleProperties.Size(); i++)
- InsertColumn(i);
+ _needSaveInfo = true;
return S_OK;
}
-void CPanel::InsertColumn(unsigned index)
+
+void CPanel::DeleteColumn(unsigned index)
{
- const CItemProperty &prop = _visibleProperties[index];
+ _visibleColumns.Delete(index);
+ _listView.DeleteColumn(index);
+}
+
+void CPanel::AddColumn(const CPropColumn &prop)
+{
+ const int index = _visibleColumns.Size();
+
LV_COLUMNW column;
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
column.cx = prop.Width;
column.fmt = GetColumnAlign(prop.ID, prop.Type);
- column.iOrder = prop.Order;
- // iOrder must be <= _listView.ItemCount
- column.iSubItem = index;
+ column.iOrder = index; // must be <= _listView.ItemCount
+ column.iSubItem = index; // must be <= _listView.ItemCount
column.pszText = const_cast<wchar_t *>((const wchar_t *)prop.Name);
+
+ _visibleColumns.Add(prop);
_listView.InsertColumn(index, &column);
}
+
HRESULT CPanel::RefreshListCtrl()
{
return RefreshListCtrl(UString(), -1, true, UStringVector());
@@ -959,20 +1042,17 @@ UInt64 CPanel::GetItemSize(int itemIndex) const
return 0;
}
-void CPanel::ReadListViewInfo()
-{
- _typeIDString = GetFolderTypeID();
- if (!_typeIDString.IsEmpty())
- _listViewInfo.Read(_typeIDString);
-}
void CPanel::SaveListViewInfo()
{
+ if (!_needSaveInfo)
+ return;
+
unsigned i;
- for (i = 0; i < _visibleProperties.Size(); i++)
+ for (i = 0; i < _visibleColumns.Size(); i++)
{
- CItemProperty &prop = _visibleProperties[i];
+ CPropColumn &prop = _visibleColumns[i];
LVCOLUMN winColumnInfo;
winColumnInfo.mask = LVCF_ORDER | LVCF_WIDTH;
if (!_listView.GetColumn(i, &winColumnInfo))
@@ -983,14 +1063,18 @@ void CPanel::SaveListViewInfo()
CListViewInfo viewInfo;
- // PROPID sortPropID = _properties[_sortIndex].ID;
+ // PROPID sortPropID = _columns[_sortIndex].ID;
PROPID sortPropID = _sortID;
- _visibleProperties.Sort();
+ // we save columns as "sorted by order" to registry
+
+ CPropColumns sortedProperties = _visibleColumns;
+
+ sortedProperties.Sort();
- for (i = 0; i < _visibleProperties.Size(); i++)
+ for (i = 0; i < sortedProperties.Size(); i++)
{
- const CItemProperty &prop = _visibleProperties[i];
+ const CPropColumn &prop = sortedProperties[i];
CColumnInfo columnInfo;
columnInfo.IsVisible = prop.IsVisible;
columnInfo.PropID = prop.ID;
@@ -998,13 +1082,13 @@ void CPanel::SaveListViewInfo()
viewInfo.Columns.Add(columnInfo);
}
- for (i = 0; i < _properties.Size(); i++)
+ for (i = 0; i < _columns.Size(); i++)
{
- const CItemProperty &prop = _properties[i];
- if (!prop.IsVisible)
+ const CPropColumn &prop = _columns[i];
+ if (sortedProperties.FindItem_for_PropID(prop.ID) < 0)
{
CColumnInfo columnInfo;
- columnInfo.IsVisible = prop.IsVisible;
+ columnInfo.IsVisible = false;
columnInfo.PropID = prop.ID;
columnInfo.Width = prop.Width;
viewInfo.Columns.Add(columnInfo);
@@ -1040,9 +1124,9 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
menu.CreatePopup();
const int kCommandStart = 100;
- FOR_VECTOR (i, _properties)
+ FOR_VECTOR (i, _columns)
{
- const CItemProperty &prop = _properties[i];
+ const CPropColumn &prop = _columns[i];
UINT flags = MF_STRING;
if (prop.IsVisible)
flags |= MF_CHECKED;
@@ -1053,25 +1137,22 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView);
- if (menuResult >= kCommandStart && menuResult <= kCommandStart + (int)_properties.Size())
+ if (menuResult >= kCommandStart && menuResult <= kCommandStart + (int)_columns.Size())
{
int index = menuResult - kCommandStart;
- CItemProperty &prop = _properties[index];
+ CPropColumn &prop = _columns[index];
prop.IsVisible = !prop.IsVisible;
if (prop.IsVisible)
{
- unsigned num = _visibleProperties.Size();
- prop.Order = num;
- _visibleProperties.Add(prop);
- InsertColumn(num);
+ prop.Order = _visibleColumns.Size();
+ AddColumn(prop);
}
else
{
- int visibleIndex = _visibleProperties.FindItemWithID(prop.ID);
+ int visibleIndex = _visibleColumns.FindItem_for_PropID(prop.ID);
if (visibleIndex >= 0)
{
- _visibleProperties.Delete(visibleIndex);
/*
if (_sortIndex == index)
{
@@ -1084,8 +1165,7 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
_sortID = kpidName;
_ascending = true;
}
-
- _listView.DeleteColumn(visibleIndex);
+ DeleteColumn(visibleIndex);
}
}
}
diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
index 408ffae1..39c29681 100644
--- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp
+++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
@@ -175,7 +175,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
if (item.cchTextMax <= 1)
return 0;
- const CItemProperty &property = _visibleProperties[item.iSubItem];
+ const CPropColumn &property = _visibleColumns[item.iSubItem];
PROPID propID = property.ID;
if (realIndex == kParentIndex)
diff --git a/CPP/7zip/UI/FileManager/PanelSort.cpp b/CPP/7zip/UI/FileManager/PanelSort.cpp
index 82d6756e..59b785b8 100644
--- a/CPP/7zip/UI/FileManager/PanelSort.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSort.cpp
@@ -83,9 +83,9 @@ static inline const wchar_t *GetExtensionPtr(const UString &name)
void CPanel::SetSortRawStatus()
{
_isRawSortProp = false;
- FOR_VECTOR (i, _properties)
+ FOR_VECTOR (i, _columns)
{
- const CItemProperty &prop = _properties[i];
+ const CPropColumn &prop = _columns[i];
if (prop.ID == _sortID)
{
_isRawSortProp = prop.IsRawProp ? 1 : 0;
@@ -169,7 +169,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
return ::CompareFileTime(&file1.MTime, &file2.MTime);
*/
- // PROPID propID = panel->_properties[panel->_sortIndex].ID;
+ // PROPID propID = panel->_columns[panel->_sortIndex].ID;
NCOM::CPropVariant prop1, prop2;
// Name must be first property
@@ -215,7 +215,7 @@ void CPanel::SortItems(int index)
{
_sortIndex = index;
_ascending = true;
- switch (_properties[_sortIndex].ID)
+ switch (_columns[_sortIndex].ID)
{
case kpidSize:
case kpidPackedSize:
@@ -229,13 +229,15 @@ void CPanel::SortItems(int index)
_listView.SortItems(CompareItems, (LPARAM)this);
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
}
+
void CPanel::SortItemsWithPropID(PROPID propID)
{
- int index = _properties.FindItemWithID(propID);
+ int index = _columns.FindItem_for_PropID(propID);
if (index >= 0)
SortItems(index);
}
*/
+
void CPanel::SortItemsWithPropID(PROPID propID)
{
if (propID == _sortID)
@@ -264,8 +266,8 @@ void CPanel::SortItemsWithPropID(PROPID propID)
void CPanel::OnColumnClick(LPNMLISTVIEW info)
{
/*
- int index = _properties.FindItemWithID(_visibleProperties[info->iSubItem].ID);
+ int index = _columns.FindItem_for_PropID(_visibleColumns[info->iSubItem].ID);
SortItems(index);
*/
- SortItemsWithPropID(_visibleProperties[info->iSubItem].ID);
+ SortItemsWithPropID(_visibleColumns[info->iSubItem].ID);
}
diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.cpp b/CPP/7zip/UI/FileManager/RegistryUtils.cpp
index ffcb5555..84dada2b 100644
--- a/CPP/7zip/UI/FileManager/RegistryUtils.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryUtils.cpp
@@ -164,4 +164,4 @@ bool ReadFlatView(UInt32 panelIndex) { return ReadOption(GetFlatViewName(panelIn
/*
void Save_ShowDeleted(bool enable) { SaveOption(kShowDeletedFiles, enable); }
bool Read_ShowDeleted() { return ReadOption(kShowDeletedFiles, false); }
-*/ \ No newline at end of file
+*/
diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
index c400bc29..c8ea8b95 100644
--- a/CPP/7zip/UI/FileManager/SysIconUtils.cpp
+++ b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
@@ -252,4 +252,4 @@ int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName)
{
return GetIconIndex(attrib, fileName, NULL);
}
-*/ \ No newline at end of file
+*/
diff --git a/CPP/7zip/UI/FileManager/ViewSettings.cpp b/CPP/7zip/UI/FileManager/ViewSettings.cpp
index 2818d0f3..9292d120 100644
--- a/CPP/7zip/UI/FileManager/ViewSettings.cpp
+++ b/CPP/7zip/UI/FileManager/ViewSettings.cpp
@@ -97,6 +97,8 @@ void CListViewInfo::Read(const UString &id)
Get32(buf + 4, SortID);
GetBool(buf + 8, Ascending);
+ IsLoaded = true;
+
size -= kListViewHeaderSize;
if (size % kColumnInfoSize != 0)
return;
diff --git a/CPP/7zip/UI/FileManager/ViewSettings.h b/CPP/7zip/UI/FileManager/ViewSettings.h
index dbb98dc6..aeb68979 100644
--- a/CPP/7zip/UI/FileManager/ViewSettings.h
+++ b/CPP/7zip/UI/FileManager/ViewSettings.h
@@ -23,14 +23,22 @@ struct CListViewInfo
CRecordVector<CColumnInfo> Columns;
PROPID SortID;
bool Ascending;
+ bool IsLoaded;
void Clear()
{
SortID = 0;
Ascending = true;
+ IsLoaded = false;
Columns.Clear();
}
+ CListViewInfo():
+ SortID(0),
+ Ascending(true),
+ IsLoaded(false)
+ {}
+
/*
int FindColumnWithID(PROPID propID) const
{
diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
index e210f0d1..b7c95950 100644
--- a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
+++ b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
@@ -177,7 +177,9 @@ bool CBenchmarkDialog::OnInit()
m_Dictionary.Attach(GetItem(IDC_BENCH_DICTIONARY));
cur = 0;
- UInt64 ramSize = NSystem::GetRamSize();
+
+ UInt64 ramSize = (UInt64)(sizeof(size_t)) << 29;
+ bool ramSize_Defined = NSystem::GetRamSize(ramSize);
#ifdef UNDER_CE
const UInt32 kNormalizedCeSize = (16 << 20);
@@ -187,8 +189,14 @@ bool CBenchmarkDialog::OnInit()
if (Sync.DictionarySize == (UInt32)(Int32)-1)
{
- unsigned dicSizeLog;
- for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
+ unsigned dicSizeLog = 25;
+
+ #ifdef UNDER_CE
+ dicSizeLog = 20;
+ #endif
+
+ if (ramSize_Defined)
+ for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
if (GetBenchMemoryUsage(Sync.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
break;
Sync.DictionarySize = (1 << dicSizeLog);
diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp
index 23b6f52f..45d3c59a 100644
--- a/CPP/7zip/UI/GUI/CompressDialog.cpp
+++ b/CPP/7zip/UI/GUI/CompressDialog.cpp
@@ -250,9 +250,10 @@ static bool IsMethodSupportedBySfx(int methodID)
return false;
}
-static UInt64 GetMaxRamSizeForProgram()
+static bool GetMaxRamSizeForProgram(UInt64 &physSize)
{
- UInt64 physSize = NSystem::GetRamSize();
+ physSize = (UInt64)(sizeof(size_t)) << 29;
+ bool ramSize_Defined = NSystem::GetRamSize(physSize);
const UInt64 kMinSysSize = (1 << 24);
if (physSize <= kMinSysSize)
physSize = 0;
@@ -261,7 +262,7 @@ static UInt64 GetMaxRamSizeForProgram()
const UInt64 kMinUseSize = (1 << 24);
if (physSize < kMinUseSize)
physSize = kMinUseSize;
- return physSize;
+ return ramSize_Defined;
}
@@ -1170,7 +1171,8 @@ void CCompressDialog::SetDictionary()
UInt32 level = GetLevel2();
if (methodID < 0)
return;
- const UInt64 maxRamSize = GetMaxRamSizeForProgram();
+ UInt64 maxRamSize;
+ bool maxRamSize_Defined = GetMaxRamSizeForProgram(maxRamSize);
switch (methodID)
{
@@ -1196,18 +1198,20 @@ void CCompressDialog::SetDictionary()
if (i == 20 && j > 0)
continue;
UInt32 dict = ((UInt32)(2 + j) << (i - 1));
+
if (dict >
- #ifdef MY_CPU_64BIT
- (3 << 29)
- #else
- (1 << 26)
- #endif
+ #ifdef MY_CPU_64BIT
+ (3 << 29)
+ #else
+ (1 << 26)
+ #endif
)
continue;
+
AddDictionarySize(dict);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
- if (dict <= defaultDict && requiredComprSize <= maxRamSize)
+ if (dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
@@ -1242,11 +1246,12 @@ void CCompressDialog::SetDictionary()
AddDictionarySize(dict);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
- if (dict <= defaultDict && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
+ if ((dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
+ || m_Dictionary.GetCount() == 1)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
- SetNearestSelectComboBox(m_Dictionary, defaultDict);
+ // SetNearestSelectComboBox(m_Dictionary, defaultDict);
break;
}
@@ -1295,11 +1300,12 @@ void CCompressDialog::SetDictionary()
AddDictionarySize(dict);
UInt64 decomprSize;
UInt64 requiredComprSize = GetMemoryUsage(dict, decomprSize);
- if (dict <= defaultDict && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
+ if ((dict <= defaultDict && (!maxRamSize_Defined || requiredComprSize <= maxRamSize))
+ || m_Dictionary.GetCount() == 1)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
- SetNearestSelectComboBox(m_Dictionary, defaultDict);
+ // SetNearestSelectComboBox(m_Dictionary, defaultDict);
break;
}
}