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>2011-04-11 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:05 +0300
commit35596517f203f1c4970413b3b5b2e216b849e462 (patch)
tree93240df3eb4ddbd8eebbe6a5fc65e93f2ccb6495 /CPP/7zip/UI
parentde4f8c22fe4b9e59b60495b84db2e81de50999a9 (diff)
9.219.21
Diffstat (limited to 'CPP/7zip/UI')
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.cpp130
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.h60
-rwxr-xr-xCPP/7zip/UI/Agent/AgentOut.cpp226
-rwxr-xr-xCPP/7zip/UI/Agent/AgentProxy.cpp12
-rwxr-xr-xCPP/7zip/UI/Agent/AgentProxy.h10
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolder.cpp33
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOpen.cpp29
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOut.cpp115
-rwxr-xr-xCPP/7zip/UI/Agent/IFolderArchive.h10
-rwxr-xr-xCPP/7zip/UI/Agent/UpdateCallbackAgent.cpp2
-rwxr-xr-xCPP/7zip/UI/Client7z/Client7z.cpp108
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveCommandLine.cpp70
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveCommandLine.h8
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveExtractCallback.cpp54
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveExtractCallback.h10
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveName.cpp20
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveOpenCallback.cpp4
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveOpenCallback.h6
-rwxr-xr-xCPP/7zip/UI/Common/Bench.cpp845
-rwxr-xr-xCPP/7zip/UI/Common/Bench.h29
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall.cpp16
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall.h5
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall2.cpp16
-rwxr-xr-xCPP/7zip/UI/Common/DirItem.h10
-rwxr-xr-xCPP/7zip/UI/Common/EnumDirItems.cpp84
-rwxr-xr-xCPP/7zip/UI/Common/EnumDirItems.h4
-rwxr-xr-xCPP/7zip/UI/Common/Extract.cpp14
-rwxr-xr-xCPP/7zip/UI/Common/Extract.h2
-rwxr-xr-xCPP/7zip/UI/Common/ExtractingFilePath.cpp8
-rwxr-xr-xCPP/7zip/UI/Common/LoadCodecs.cpp83
-rwxr-xr-xCPP/7zip/UI/Common/LoadCodecs.h23
-rwxr-xr-xCPP/7zip/UI/Common/OpenArchive.cpp48
-rwxr-xr-xCPP/7zip/UI/Common/OpenArchive.h1
-rwxr-xr-xCPP/7zip/UI/Common/Property.h6
-rwxr-xr-xCPP/7zip/UI/Common/SetProperties.cpp4
-rwxr-xr-xCPP/7zip/UI/Common/TempFiles.cpp5
-rwxr-xr-xCPP/7zip/UI/Common/TempFiles.h6
-rwxr-xr-xCPP/7zip/UI/Common/Update.cpp121
-rwxr-xr-xCPP/7zip/UI/Common/Update.h20
-rwxr-xr-xCPP/7zip/UI/Common/UpdateCallback.cpp30
-rwxr-xr-xCPP/7zip/UI/Common/UpdateCallback.h5
-rwxr-xr-xCPP/7zip/UI/Common/WorkDir.cpp50
-rwxr-xr-xCPP/7zip/UI/Common/WorkDir.h22
-rwxr-xr-xCPP/7zip/UI/Common/ZipRegistry.cpp26
-rwxr-xr-xCPP/7zip/UI/Common/ZipRegistry.h4
-rwxr-xr-xCPP/7zip/UI/Console/BenchCon.cpp291
-rwxr-xr-xCPP/7zip/UI/Console/BenchCon.h8
-rwxr-xr-xCPP/7zip/UI/Console/Console.dsp16
-rwxr-xr-xCPP/7zip/UI/Console/ExtractCallbackConsole.cpp8
-rwxr-xr-xCPP/7zip/UI/Console/List.cpp6
-rwxr-xr-xCPP/7zip/UI/Console/Main.cpp30
-rwxr-xr-xCPP/7zip/UI/Console/MainAr.cpp5
-rwxr-xr-xCPP/7zip/UI/Console/PercentPrinter.cpp36
-rwxr-xr-xCPP/7zip/UI/Console/PercentPrinter.h9
-rwxr-xr-xCPP/7zip/UI/Console/makefile2
-rwxr-xr-xCPP/7zip/UI/Explorer/ContextMenu.cpp53
-rwxr-xr-xCPP/7zip/UI/Explorer/DllExports.cpp17
-rwxr-xr-xCPP/7zip/UI/Far/FarUtils.cpp3
-rwxr-xr-xCPP/7zip/UI/Far/Main.cpp29
-rwxr-xr-xCPP/7zip/UI/Far/Plugin.cpp17
-rwxr-xr-xCPP/7zip/UI/Far/Plugin.h9
-rwxr-xr-xCPP/7zip/UI/Far/PluginDelete.cpp67
-rwxr-xr-xCPP/7zip/UI/Far/PluginRead.cpp8
-rwxr-xr-xCPP/7zip/UI/Far/PluginWrite.cpp209
-rwxr-xr-xCPP/7zip/UI/FileManager/App.cpp27
-rwxr-xr-xCPP/7zip/UI/FileManager/App.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/BrowseDialog.cpp38
-rwxr-xr-xCPP/7zip/UI/FileManager/BrowseDialog.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/ExtractCallback.cpp45
-rwxr-xr-xCPP/7zip/UI/FileManager/ExtractCallback.h1
-rwxr-xr-xCPP/7zip/UI/FileManager/FM.cpp35
-rwxr-xr-xCPP/7zip/UI/FileManager/FSDrives.cpp48
-rwxr-xr-xCPP/7zip/UI/FileManager/FSDrives.h8
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolder.cpp88
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolder.h26
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolderCopy.cpp157
-rwxr-xr-xCPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp39
-rwxr-xr-xCPP/7zip/UI/FileManager/FileFolderPluginOpen.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/FilePlugins.cpp104
-rwxr-xr-xCPP/7zip/UI/FileManager/FilePlugins.h47
-rwxr-xr-xCPP/7zip/UI/FileManager/FoldersPage.cpp8
-rwxr-xr-xCPP/7zip/UI/FileManager/HelpUtils.cpp10
-rwxr-xr-xCPP/7zip/UI/FileManager/IFolder.h3
-rwxr-xr-xCPP/7zip/UI/FileManager/LangUtils.cpp51
-rwxr-xr-xCPP/7zip/UI/FileManager/LangUtils.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/ListViewDialog.cpp7
-rwxr-xr-xCPP/7zip/UI/FileManager/MenuPage.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/MessagesDialog.cpp5
-rwxr-xr-xCPP/7zip/UI/FileManager/MyLoadMenu.cpp31
-rwxr-xr-xCPP/7zip/UI/FileManager/NetFolder.cpp10
-rwxr-xr-xCPP/7zip/UI/FileManager/OpenCallback.cpp13
-rwxr-xr-xCPP/7zip/UI/FileManager/OpenCallback.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/OptionsDialog.cpp10
-rwxr-xr-xCPP/7zip/UI/FileManager/Panel.cpp67
-rwxr-xr-xCPP/7zip/UI/FileManager/Panel.h47
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelCrc.cpp44
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelDrag.cpp28
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelFolderChange.cpp68
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelItemOpen.cpp323
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelItems.cpp11
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelListNotify.cpp18
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelMenu.cpp3
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelOperations.cpp28
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelSelect.cpp14
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelSort.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelSplitFile.cpp68
-rwxr-xr-xCPP/7zip/UI/FileManager/PasswordDialog.cpp23
-rwxr-xr-xCPP/7zip/UI/FileManager/PasswordDialog.h8
-rwxr-xr-xCPP/7zip/UI/FileManager/PluginLoader.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgramLocation.cpp21
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgramLocation.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.cpp17
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.h7
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2Res.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryAssociations.cpp295
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryAssociations.h47
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryPlugins.cpp18
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryPlugins.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/RootFolder.cpp8
-rwxr-xr-xCPP/7zip/UI/FileManager/SettingsPage.cpp1
-rwxr-xr-xCPP/7zip/UI/FileManager/SysIconUtils.cpp38
-rwxr-xr-xCPP/7zip/UI/FileManager/SysIconUtils.h5
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPage.cpp591
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPage.h108
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPage.rc17
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPageRes.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/resource.h1
-rwxr-xr-xCPP/7zip/UI/FileManager/resource.rc3
-rwxr-xr-xCPP/7zip/UI/GUI/BenchmarkDialog.cpp188
-rwxr-xr-xCPP/7zip/UI/GUI/BenchmarkDialog.h34
-rwxr-xr-xCPP/7zip/UI/GUI/BenchmarkDialog.rc27
-rwxr-xr-xCPP/7zip/UI/GUI/BenchmarkDialogRes.h4
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.cpp6
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.h2
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.rc14
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractDialog.cpp1
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractDialog.rc13
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractGUI.cpp11
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.cpp5
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.dsp8
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateGUI.cpp27
-rwxr-xr-xCPP/7zip/UI/GUI/makefile3
142 files changed, 3390 insertions, 2960 deletions
diff --git a/CPP/7zip/UI/Agent/Agent.cpp b/CPP/7zip/UI/Agent/Agent.cpp
index 4a099308..c11bd490 100755
--- a/CPP/7zip/UI/Agent/Agent.cpp
+++ b/CPP/7zip/UI/Agent/Agent.cpp
@@ -18,7 +18,7 @@ STDMETHODIMP CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder)
return S_OK;
}
-void CAgentFolder::LoadFolder(CProxyFolder *folder)
+void CAgentFolder::LoadFolder(const CProxyFolder *folder)
{
int i;
CProxyItem item;
@@ -56,22 +56,15 @@ STDMETHODIMP CAgentFolder::GetNumberOfItems(UInt32 *numItems)
return S_OK;
}
+#define SET_realIndex_AND_folder \
+ UInt32 realIndex; const CProxyFolder *folder; \
+ if (_flatMode) { const CProxyItem &item = _items[index]; folder = item.Folder; realIndex = item.Index; } \
+ else { folder = _proxyFolderItem; realIndex = index; }
+
+
UString CAgentFolder::GetName(UInt32 index) const
{
- UInt32 realIndex;
- const CProxyFolder *folder;
- if (_flatMode)
- {
- const CProxyItem &item = _items[index];
- folder = item.Folder;
- realIndex = item.Index;
- }
- else
- {
- folder = _proxyFolderItem;
- realIndex = index;
- }
-
+ SET_realIndex_AND_folder
if (realIndex < (UInt32)folder->Folders.Size())
return folder->Folders[realIndex].Name;
return folder->Files[realIndex - folder->Folders.Size()].Name;
@@ -97,32 +90,17 @@ UString CAgentFolder::GetFullPathPrefixPlusPrefix(UInt32 index) const
return _proxyFolderItem->GetFullPathPrefix() + GetPrefix(index);
}
-void CAgentFolder::GetPrefixIfAny(UInt32 index, NCOM::CPropVariant &prop) const
-{
- if (!_flatMode)
- return;
- prop = GetPrefix(index);
-}
-
-
-STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
+STDMETHODIMP CAgentFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
+ COM_TRY_BEGIN
NCOM::CPropVariant prop;
- const CProxyFolder *folder;
- UInt32 realIndex;
- if (_flatMode)
+ SET_realIndex_AND_folder
+ if (propID == kpidPrefix)
{
- const CProxyItem &item = _items[itemIndex];
- folder = item.Folder;
- realIndex = item.Index;
+ if (_flatMode)
+ prop = GetPrefix(index);
}
- else
- {
- folder = _proxyFolderItem;
- realIndex = itemIndex;
- }
-
- if (realIndex < (UInt32)folder->Folders.Size())
+ else if (realIndex < (UInt32)folder->Folders.Size())
{
const CProxyFolder &item = folder->Folders[realIndex];
if (!_flatMode && propID == kpidSize)
@@ -130,12 +108,12 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI
else if (!_flatMode && propID == kpidPackSize)
prop = item.PackSize;
else
- switch(propID)
+ switch (propID)
{
- case kpidIsDir: prop = true; break;
+ case kpidIsDir: prop = true; break;
case kpidNumSubDirs: prop = item.NumSubFolders; break;
- case kpidNumSubFiles: prop = item.NumSubFiles; break;
- case kpidName: prop = item.Name; break;
+ case kpidNumSubFiles: prop = item.NumSubFiles; break;
+ case kpidName: prop = item.Name; break;
case kpidCRC:
{
if (item.IsLeaf)
@@ -146,8 +124,6 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI
prop = item.Crc;
break;
}
- case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
-
default:
if (item.IsLeaf)
return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
@@ -155,22 +131,21 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI
}
else
{
- realIndex -= folder->Folders.Size();
- const CProxyFile &item = folder->Files[realIndex];
- switch(propID)
+ const CProxyFile &item = folder->Files[realIndex - folder->Folders.Size()];
+ switch (propID)
{
case kpidIsDir: prop = false; break;
case kpidName: prop = item.Name; break;
- case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
default:
return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
}
}
prop.Detach(value);
return S_OK;
+ COM_TRY_END
}
-HRESULT CAgentFolder::BindToFolder(CProxyFolder *folder, IFolderFolder **resultFolder)
+HRESULT CAgentFolder::BindToFolder(const CProxyFolder *folder, IFolderFolder **resultFolder)
{
CMyComPtr<IFolderFolder> parentFolder;
if (folder->Parent != _proxyFolderItem)
@@ -189,20 +164,7 @@ HRESULT CAgentFolder::BindToFolder(CProxyFolder *folder, IFolderFolder **resultF
STDMETHODIMP CAgentFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
{
COM_TRY_BEGIN
-
- CProxyFolder *folder;
- UInt32 realIndex;
- if (_flatMode)
- {
- const CProxyItem &item = _items[index];
- folder = item.Folder;
- realIndex = item.Index;
- }
- else
- {
- folder = _proxyFolderItem;
- realIndex = index;
- }
+ SET_realIndex_AND_folder
if (realIndex >= (UInt32)folder->Folders.Size())
return E_INVALIDARG;
return BindToFolder(&folder->Folders[realIndex], resultFolder);
@@ -235,19 +197,7 @@ STDMETHODIMP CAgentFolder::GetStream(UInt32 index, ISequentialInStream **stream)
if (!getStream)
return S_OK;
- const CProxyFolder *folder;
- UInt32 realIndex;
- if (_flatMode)
- {
- const CProxyItem &item = _items[index];
- folder = item.Folder;
- realIndex = item.Index;
- }
- else
- {
- folder = _proxyFolderItem;
- realIndex = index;
- }
+ SET_realIndex_AND_folder
UInt32 indexInArchive;
if (realIndex < (UInt32)folder->Folders.Size())
@@ -262,7 +212,7 @@ STDMETHODIMP CAgentFolder::GetStream(UInt32 index, ISequentialInStream **stream)
return getStream->GetStream(indexInArchive, stream);
}
-STATPROPSTG kProperties[] =
+static const STATPROPSTG kProperties[] =
{
{ NULL, kpidNumSubDirs, VT_UI4},
{ NULL, kpidNumSubFiles, VT_UI4},
@@ -325,7 +275,7 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro
COM_TRY_END
}
-STATPROPSTG kFolderProps[] =
+static const STATPROPSTG kFolderProps[] =
{
{ NULL, kpidSize, VT_UI8},
{ NULL, kpidPackSize, VT_UI8},
@@ -340,7 +290,7 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant prop;
- switch(propID)
+ switch (propID)
{
case kpidSize: prop = _proxyFolderItem->Size; break;
case kpidPackSize: prop = _proxyFolderItem->PackSize; break;
@@ -399,7 +349,7 @@ void CAgentFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntV
return;
}
realIndices.Clear();
- for(UInt32 i = 0; i < numItems; i++)
+ for (UInt32 i = 0; i < numItems; i++)
{
const CProxyItem &item = _items[indices[i]];
const CProxyFolder *folder = item.Folder;
@@ -423,13 +373,8 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
UStringVector pathParts;
- CProxyFolder *currentProxyFolder = _proxyFolderItem;
- while (currentProxyFolder->Parent)
- {
- pathParts.Insert(0, currentProxyFolder->Name);
- currentProxyFolder = currentProxyFolder->Parent;
- }
-
+ _proxyFolderItem->GetPathParts(pathParts);
+
/*
if (_flatMode)
pathMode = NExtract::NPathMode::kNoPathnames;
@@ -437,10 +382,13 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
+ FString pathU;
+ if (path)
+ pathU = us2fs(path);
extractCallbackSpec->Init(NULL, &_agentSpec->GetArc(),
extractCallback2,
false, testMode ? true : false, false,
- (path ? path : L""),
+ path ? pathU : FTEXT(""),
pathParts,
(UInt64)(Int64)-1);
CUIntVector realIndices;
@@ -474,10 +422,10 @@ STDMETHODIMP CAgent::Open(
{
COM_TRY_BEGIN
_archiveFilePath = filePath;
- NFile::NFind::CFileInfoW fi;
+ NFile::NFind::CFileInfo fi;
if (!inStream)
{
- if (!fi.Find(_archiveFilePath))
+ if (!fi.Find(us2fs(_archiveFilePath)))
return ::GetLastError();
if (fi.IsDir())
return E_FAIL;
@@ -571,7 +519,7 @@ STDMETHODIMP CAgent::Extract(
extractCallbackSpec->Init(NULL, &GetArc(),
extractCallback2,
false, testMode ? true : false, false,
- path,
+ us2fs(path),
UStringVector(),
(UInt64)(Int64)-1);
return GetArchive()->Extract(0, (UInt32)(Int32)-1, testMode, extractCallback);
@@ -607,7 +555,7 @@ STDMETHODIMP CAgent::GetArcProp(UInt32 level, PROPID propID, PROPVARIANT *value)
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant prop;
CArc &arc = _archiveLink.Arcs[level];
- switch(propID)
+ switch (propID)
{
case kpidType: prop = GetTypeOfArc(arc); break;
case kpidPath: prop = arc.Path; break;
diff --git a/CPP/7zip/UI/Agent/Agent.h b/CPP/7zip/UI/Agent/Agent.h
index 454964bc..cc92b0dd 100755
--- a/CPP/7zip/UI/Agent/Agent.h
+++ b/CPP/7zip/UI/Agent/Agent.h
@@ -27,12 +27,21 @@ DECL_INTERFACE(IArchiveFolderInternal, 0x01, 0xC)
struct CProxyItem
{
- CProxyFolder *Folder;
+ const CProxyFolder *Folder;
UInt32 Index;
};
class CAgent;
+enum AGENT_OP
+{
+ AGENT_OP_Uni,
+ AGENT_OP_Delete,
+ AGENT_OP_CreateFolder,
+ AGENT_OP_Rename,
+ AGENT_OP_CopyFromFile
+};
+
class CAgentFolder:
public IFolderFolder,
public IFolderProperties,
@@ -46,6 +55,7 @@ class CAgentFolder:
#endif
public CMyUnknownImp
{
+ void LoadFolder(const CProxyFolder *folder);
public:
MY_QUERYINTERFACE_BEGIN2(IFolderFolder)
@@ -61,8 +71,7 @@ public:
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
- void LoadFolder(CProxyFolder *folder);
- HRESULT BindToFolder(CProxyFolder *folder, IFolderFolder **resultFolder);
+ HRESULT BindToFolder(const CProxyFolder *folder, IFolderFolder **resultFolder);
void GetRealIndices(const UINT32 *indices, UINT32 numItems, CUIntVector &realIndices) const;
INTERFACE_FolderFolder(;)
@@ -90,8 +99,8 @@ public:
CAgentFolder(): _proxyFolderItem(NULL), _flatMode(0) {}
- void Init(CProxyArchive *proxyHandler,
- CProxyFolder *proxyFolderItem,
+ void Init(const CProxyArchive *proxyHandler,
+ const CProxyFolder *proxyFolderItem,
IFolderFolder *parentFolder,
CAgent *agent)
{
@@ -104,9 +113,7 @@ public:
void GetPathParts(UStringVector &pathParts);
HRESULT CommonUpdateOperation(
- bool deleteOperation,
- bool createFolderOperation,
- bool renameOperation,
+ AGENT_OP operation,
const wchar_t *newItemName,
const NUpdateArchive::CActionSet *actionSet,
const UINT32 *indices, UINT32 numItems,
@@ -116,11 +123,10 @@ public:
UString GetPrefix(UInt32 index) const;
UString GetName(UInt32 index) const;
UString GetFullPathPrefixPlusPrefix(UInt32 index) const;
- void GetPrefixIfAny(UInt32 index, NWindows::NCOM::CPropVariant &propVariant) const;
public:
- CProxyArchive *_proxyArchive;
- CProxyFolder *_proxyFolderItem;
+ const CProxyArchive *_proxyArchive;
+ const CProxyFolder *_proxyFolderItem;
CMyComPtr<IFolderFolder> _parentFolder;
CMyComPtr<IInFolderArchive> _agent;
CAgent *_agentSpec;
@@ -156,21 +162,19 @@ public:
#ifndef EXTRACT_ONLY
INTERFACE_IOutFolderArchive(;)
- HRESULT CommonUpdate(
- const wchar_t *newArchiveName,
- int numUpdateItems,
- IArchiveUpdateCallback *updateCallback);
+ HRESULT CommonUpdate(ISequentialOutStream *outArchiveStream,
+ int numUpdateItems, IArchiveUpdateCallback *updateCallback);
- HRESULT CreateFolder(
- const wchar_t *newArchiveName,
- const wchar_t *folderName,
- IFolderArchiveUpdateCallback *updateCallback100);
+ HRESULT CreateFolder(ISequentialOutStream *outArchiveStream,
+ const wchar_t *folderName, IFolderArchiveUpdateCallback *updateCallback100);
- HRESULT RenameItem(
- const wchar_t *newArchiveName,
- const UINT32 *indices, UINT32 numItems,
- const wchar_t *newItemName,
- IFolderArchiveUpdateCallback *updateCallback100);
+ HRESULT RenameItem(ISequentialOutStream *outArchiveStream,
+ const UInt32 *indices, UInt32 numItems, const wchar_t *newItemName,
+ IFolderArchiveUpdateCallback *updateCallback100);
+
+ HRESULT UpdateOneFile(ISequentialOutStream *outArchiveStream,
+ const UInt32 *indices, UInt32 numItems, const wchar_t *diskFilePath,
+ IFolderArchiveUpdateCallback *updateCallback100);
// ISetProperties
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
@@ -190,8 +194,8 @@ public:
UString ArchiveType;
- UStringVector _names;
- UString _folderPrefix;
+ FStringVector _names;
+ FString _folderPrefix;
UString _archiveNamePrefix;
CAgentFolder *_agentFolder;
@@ -203,8 +207,8 @@ public:
CObjectVector<NWindows::NCOM::CPropVariant> m_PropValues;
#endif
- const CArc &GetArc() { return _archiveLink.Arcs.Back(); }
- IInArchive *GetArchive() { if ( _archiveLink.Arcs.IsEmpty()) return 0; return GetArc().Archive; }
+ const CArc &GetArc() const { return _archiveLink.Arcs.Back(); }
+ IInArchive *GetArchive() const { if ( _archiveLink.Arcs.IsEmpty()) return 0; return GetArc().Archive; }
bool CanUpdate() const { return _archiveLink.Arcs.Size() <= 1; }
UString GetTypeOfArc(const CArc &arc) const { return _codecs->Formats[arc.FormatIndex].Name; }
diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp
index 5d9ae62d..17f5443a 100755
--- a/CPP/7zip/UI/Agent/AgentOut.cpp
+++ b/CPP/7zip/UI/Agent/AgentOut.cpp
@@ -2,23 +2,14 @@
#include "StdAfx.h"
-#include "Common/IntToString.h"
-#include "Common/StringConvert.h"
-
#include "Windows/FileDir.h"
-#include "Windows/PropVariant.h"
-#include "Windows/PropVariantConversions.h"
+#include "Windows/FileName.h"
#include "Windows/Time.h"
#include "../../Compress/CopyCoder.h"
#include "../../Common/FileStreams.h"
-#include "../Common/EnumDirItems.h"
-#include "../Common/OpenArchive.h"
-#include "../Common/UpdateCallback.h"
-#include "../Common/UpdatePair.h"
-
#include "Agent.h"
#include "UpdateCallbackAgent.h"
@@ -33,7 +24,7 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
_agentFolder = NULL;
return S_OK;
}
- else
+
{
CMyComPtr<IFolderFolder> archiveFolder = folder;
CMyComPtr<IArchiveFolderInternal> archiveFolderInternal;
@@ -41,40 +32,18 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
RINOK(archiveFolderInternal->GetAgentFolder(&_agentFolder));
}
- UStringVector pathParts;
- pathParts.Clear();
- CMyComPtr<IFolderFolder> folderItem = folder;
- if (folderItem != NULL)
- for (;;)
- {
- CMyComPtr<IFolderFolder> newFolder;
- folderItem->BindToParentFolder(&newFolder);
- if (newFolder == NULL)
- break;
-
- NCOM::CPropVariant prop;
- if (folderItem->GetFolderProperty(kpidName, &prop) == S_OK)
- if (prop.vt == VT_BSTR)
- pathParts.Insert(0, (const wchar_t *)prop.bstrVal);
- folderItem = newFolder;
- }
-
- for (int i = 0; i < pathParts.Size(); i++)
- {
- _archiveNamePrefix += pathParts[i];
- _archiveNamePrefix += WCHAR_PATH_SEPARATOR;
- }
+ _archiveNamePrefix = _agentFolder->_proxyFolderItem->GetFullPathPrefix();
return S_OK;
}
STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix,
const wchar_t **names, UInt32 numNames)
{
- _folderPrefix = folderPrefix;
+ _folderPrefix = us2fs(folderPrefix);
_names.Clear();
_names.Reserve(numNames);
for (UInt32 i = 0; i < numNames; i++)
- _names.Add(names[i]);
+ _names.Add(us2fs(names[i]));
return S_OK;
}
@@ -89,12 +58,7 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
const CProxyFile &fileItem = item.Files[i];
CArcItem ai;
RINOK(agent->GetArc().GetItemMTime(fileItem.Index, ai.MTime, ai.MTimeDefined));
-
- CPropVariant property;
- agent->GetArchive()->GetProperty(fileItem.Index, kpidSize, &property);
- ai.SizeDefined = (property.vt != VT_EMPTY);
- if (ai.SizeDefined)
- ai.Size = ConvertPropVariantToUInt64(property);
+ RINOK(agent->GetArc().GetItemSize(fileItem.Index, ai.Size, ai.SizeDefined));
ai.IsDir = false;
ai.Name = prefix + fileItem.Name;
ai.Censored = true; // test it
@@ -139,7 +103,7 @@ HRESULT CAgUpCallbackImp::ShowDeleteFile(int arcIndex)
STDMETHODIMP CAgent::DoOperation(
CCodecs *codecs,
int formatIndex,
- const wchar_t *newArchiveName,
+ ISequentialOutStream *outArchiveStream,
const Byte *stateActions,
const wchar_t *sfxModule,
IFolderArchiveUpdateCallback *updateCallback100)
@@ -154,9 +118,9 @@ STDMETHODIMP CAgent::DoOperation(
CDirItems dirItems;
{
- UString folderPrefix = _folderPrefix;
+ FString folderPrefix = _folderPrefix;
NFile::NName::NormalizeDirPathPrefix(folderPrefix);
- UStringVector errorPaths;
+ FStringVector errorPaths;
CRecordVector<DWORD> errorCodes;
dirItems.EnumerateDirItems2(folderPrefix, _archiveNamePrefix, _names, errorPaths, errorCodes);
if (errorCodes.Size() > 0)
@@ -239,22 +203,6 @@ STDMETHODIMP CAgent::DoOperation(
updateCallbackSpec->Archive = GetArchive();
updateCallbackSpec->Callback = &updateCallbackAgent;
- COutFileStream *outStreamSpec = new COutFileStream;
- CMyComPtr<IOutStream> outStream(outStreamSpec);
- UString archiveName = newArchiveName;
- {
- UString resultPath;
- int pos;
- if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
- return E_FAIL;
- NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
- }
- if (!outStreamSpec->Create(archiveName, true))
- {
- // ShowLastErrorMessage();
- return E_FAIL;
- }
-
CMyComPtr<ISetProperties> setProperties;
if (outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties) == S_OK)
{
@@ -268,7 +216,7 @@ STDMETHODIMP CAgent::DoOperation(
for(i = 0; i < m_PropNames.Size(); i++)
names.Add((const wchar_t *)m_PropNames[i]);
- NWindows::NCOM::CPropVariant *propValues = new NWindows::NCOM::CPropVariant[m_PropValues.Size()];
+ CPropVariant *propValues = new CPropVariant[m_PropValues.Size()];
try
{
for (int i = 0; i < m_PropValues.Size(); i++)
@@ -290,88 +238,38 @@ STDMETHODIMP CAgent::DoOperation(
{
CInFileStream *sfxStreamSpec = new CInFileStream;
CMyComPtr<IInStream> sfxStream(sfxStreamSpec);
- if (!sfxStreamSpec->Open(sfxModule))
+ if (!sfxStreamSpec->Open(us2fs(sfxModule)))
return E_FAIL;
// throw "Can't open sfx module";
- RINOK(NCompress::CopyStream(sfxStream, outStream, NULL));
+ RINOK(NCompress::CopyStream(sfxStream, outArchiveStream, NULL));
}
- RINOK(outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback));
- return outStreamSpec->Close();
+ return outArchive->UpdateItems(outArchiveStream, updatePairs2.Size(),updateCallback);
}
-STDMETHODIMP CAgent::DoOperation2(
- const wchar_t *newArchiveName,
- const Byte *stateActions,
- const wchar_t *sfxModule,
- IFolderArchiveUpdateCallback *updateCallback100)
+STDMETHODIMP CAgent::DoOperation2(ISequentialOutStream *outArchiveStream,
+ const Byte *stateActions, const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback100)
{
- return DoOperation(_codecs, -1, newArchiveName,
- stateActions, sfxModule, updateCallback100);
+ return DoOperation(_codecs, -1, outArchiveStream, stateActions, sfxModule, updateCallback100);
}
-HRESULT CAgent::CommonUpdate(
- const wchar_t *newArchiveName,
- int numUpdateItems,
- IArchiveUpdateCallback *updateCallback)
+HRESULT CAgent::CommonUpdate(ISequentialOutStream *outArchiveStream,
+ int numUpdateItems, IArchiveUpdateCallback *updateCallback)
{
if (!CanUpdate())
return E_NOTIMPL;
CMyComPtr<IOutArchive> outArchive;
RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive));
-
- COutFileStream *outStreamSpec = new COutFileStream;
- CMyComPtr<IOutStream> outStream(outStreamSpec);
-
- UString archiveName = newArchiveName;
- {
- UString resultPath;
- int pos;
- if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
- throw 141716;
- NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
- }
-
- /*
- bool isOK = false;
- for (int i = 0; i < (1 << 16); i++)
- {
- resultName = newArchiveName;
- if (i > 0)
- {
- wchar_t s[16];
- ConvertUInt32ToString(i, s);
- resultName += s;
- }
- if (outStreamSpec->Open(realPath))
- {
- isOK = true;
- break;
- }
- if (::GetLastError() != ERROR_FILE_EXISTS)
- return ::GetLastError();
- }
- if (!isOK)
- return ::GetLastError();
- */
- if (!outStreamSpec->Create(archiveName, true))
- {
- // ShowLastErrorMessage();
- return E_FAIL;
- }
-
- RINOK(outArchive->UpdateItems(outStream, numUpdateItems, updateCallback));
- return outStreamSpec->Close();
+ return outArchive->UpdateItems(outArchiveStream, numUpdateItems, updateCallback);
}
-
-STDMETHODIMP CAgent::DeleteItems(
- const wchar_t *newArchiveName,
+STDMETHODIMP CAgent::DeleteItems(ISequentialOutStream *outArchiveStream,
const UInt32 *indices, UInt32 numItems,
IFolderArchiveUpdateCallback *updateCallback100)
{
if (!CanUpdate())
return E_NOTIMPL;
+ CRecordVector<CUpdatePair2> updatePairs;
CUpdateCallbackAgent updateCallbackAgent;
updateCallbackAgent.SetCallback(updateCallback100);
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
@@ -379,7 +277,6 @@ STDMETHODIMP CAgent::DeleteItems(
CUIntVector realIndices;
_agentFolder->GetRealIndices(indices, numItems, realIndices);
- CRecordVector<CUpdatePair2> updatePairs;
int curIndex = 0;
UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
@@ -400,22 +297,21 @@ STDMETHODIMP CAgent::DeleteItems(
updateCallbackSpec->UpdatePairs = &updatePairs;
updateCallbackSpec->Archive = GetArchive();
updateCallbackSpec->Callback = &updateCallbackAgent;
- return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
+ return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
}
-HRESULT CAgent::CreateFolder(
- const wchar_t *newArchiveName,
- const wchar_t *folderName,
- IFolderArchiveUpdateCallback *updateCallback100)
+HRESULT CAgent::CreateFolder(ISequentialOutStream *outArchiveStream,
+ const wchar_t *folderName, IFolderArchiveUpdateCallback *updateCallback100)
{
if (!CanUpdate())
return E_NOTIMPL;
+ CRecordVector<CUpdatePair2> updatePairs;
+ CDirItems dirItems;
CUpdateCallbackAgent updateCallbackAgent;
updateCallbackAgent.SetCallback(updateCallback100);
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
- CRecordVector<CUpdatePair2> updatePairs;
UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
for (UInt32 i = 0; i < numItemsInArchive; i++)
@@ -435,7 +331,6 @@ HRESULT CAgent::CreateFolder(
updatePairs.ReserveDown();
- CDirItems dirItems;
CDirItem di;
di.Attrib = FILE_ATTRIBUTE_DIRECTORY;
@@ -452,20 +347,19 @@ HRESULT CAgent::CreateFolder(
updateCallbackSpec->DirItems = &dirItems;
updateCallbackSpec->UpdatePairs = &updatePairs;
updateCallbackSpec->Archive = GetArchive();
- return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
+ return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
}
-HRESULT CAgent::RenameItem(
- const wchar_t *newArchiveName,
- const UInt32 *indices, UInt32 numItems,
- const wchar_t *newItemName,
+HRESULT CAgent::RenameItem(ISequentialOutStream *outArchiveStream,
+ const UInt32 *indices, UInt32 numItems, const wchar_t *newItemName,
IFolderArchiveUpdateCallback *updateCallback100)
{
if (!CanUpdate())
return E_NOTIMPL;
if (numItems != 1)
return E_INVALIDARG;
+ CRecordVector<CUpdatePair2> updatePairs;
CUpdateCallbackAgent updateCallbackAgent;
updateCallbackAgent.SetCallback(updateCallback100);
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
@@ -478,7 +372,6 @@ HRESULT CAgent::RenameItem(
UString oldItemPath = fullPrefix + _agentFolder->GetName(indices[0]);
UString newItemPath = fullPrefix + newItemName;
- CRecordVector<CUpdatePair2> updatePairs;
UStringVector newNames;
int curIndex = 0;
@@ -516,7 +409,64 @@ HRESULT CAgent::RenameItem(
updateCallbackSpec->UpdatePairs = &updatePairs;
updateCallbackSpec->NewNames = &newNames;
updateCallbackSpec->Archive = GetArchive();
- return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
+ return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
+}
+
+HRESULT CAgent::UpdateOneFile(ISequentialOutStream *outArchiveStream,
+ const UInt32 *indices, UInt32 numItems, const wchar_t *diskFilePath,
+ IFolderArchiveUpdateCallback *updateCallback100)
+{
+ if (!CanUpdate())
+ return E_NOTIMPL;
+ CRecordVector<CUpdatePair2> updatePairs;
+ CDirItems dirItems;
+ CUpdateCallbackAgent updateCallbackAgent;
+ updateCallbackAgent.SetCallback(updateCallback100);
+ CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
+ CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
+
+ UInt32 realIndex;
+ {
+ CUIntVector realIndices;
+ _agentFolder->GetRealIndices(indices, numItems, realIndices);
+ if (realIndices.Size() != 1)
+ return E_FAIL;
+ realIndex = realIndices[0];
+ }
+
+ {
+ FStringVector filePaths;
+ filePaths.Add(us2fs(diskFilePath));
+ FStringVector errorPaths;
+ CRecordVector<DWORD> errorCodes;
+ dirItems.EnumerateDirItems2(FString(), UString(), filePaths, errorPaths, errorCodes);
+ if (dirItems.Items.Size() != 1)
+ return E_FAIL;
+ }
+
+ UInt32 numItemsInArchive;
+ RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
+ for (UInt32 i = 0; i < numItemsInArchive; i++)
+ {
+ CUpdatePair2 up2;
+ up2.ArcIndex = i;
+ up2.IsAnti = false;
+ up2.NewData = false;
+ up2.NewProps = false;
+ if (realIndex == i)
+ {
+ up2.DirIndex = 0;
+ up2.NewData = true;
+ up2.NewProps = true;
+ }
+ updatePairs.Add(up2);
+ }
+ updateCallbackSpec->DirItems = &dirItems;
+ updateCallbackSpec->Callback = &updateCallbackAgent;
+ updateCallbackSpec->UpdatePairs = &updatePairs;
+ updateCallbackSpec->Archive = GetArchive();
+ updateCallbackSpec->KeepOriginalItemNames = true;
+ return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
}
STDMETHODIMP CAgent::SetProperties(const wchar_t **names,
diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp
index 9686cf34..ce9b3bfb 100755
--- a/CPP/7zip/UI/Agent/AgentProxy.cpp
+++ b/CPP/7zip/UI/Agent/AgentProxy.cpp
@@ -7,8 +7,6 @@
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
-#include "../Common/OpenArchive.h"
-
#include "AgentProxy.h"
using namespace NWindows;
@@ -79,11 +77,10 @@ void CProxyFolder::Clear()
void CProxyFolder::GetPathParts(UStringVector &pathParts) const
{
pathParts.Clear();
- UString result;
const CProxyFolder *current = this;
while (current->Parent != NULL)
{
- pathParts.Insert(0, (const wchar_t *)current->Name);
+ pathParts.Insert(0, current->Name);
current = current->Parent;
}
}
@@ -100,13 +97,6 @@ UString CProxyFolder::GetFullPathPrefix() const
return result;
}
-UString CProxyFolder::GetItemName(UInt32 index) const
-{
- if (index < (UInt32)Folders.Size())
- return Folders[index].Name;
- return Files[index - Folders.Size()].Name;
-}
-
void CProxyFolder::AddRealIndices(CUIntVector &realIndices) const
{
if (IsLeaf)
diff --git a/CPP/7zip/UI/Agent/AgentProxy.h b/CPP/7zip/UI/Agent/AgentProxy.h
index d4caca16..dcf52f04 100755
--- a/CPP/7zip/UI/Agent/AgentProxy.h
+++ b/CPP/7zip/UI/Agent/AgentProxy.h
@@ -3,8 +3,6 @@
#ifndef __AGENT_PROXY_H
#define __AGENT_PROXY_H
-#include "Common/MyString.h"
-
#include "../Common/OpenArchive.h"
struct CProxyFile
@@ -13,8 +11,11 @@ struct CProxyFile
UString Name;
};
-struct CProxyFolder: public CProxyFile
+class CProxyFolder: public CProxyFile
{
+ int FindDirSubItemIndex(const UString &name, int &insertPos) const;
+ void AddRealIndices(CUIntVector &realIndices) const;
+public:
CProxyFolder *Parent;
CObjectVector<CProxyFolder> Folders;
CObjectVector<CProxyFile> Files;
@@ -28,7 +29,6 @@ struct CProxyFolder: public CProxyFile
UInt32 NumSubFiles;
CProxyFolder(): Parent(NULL) {};
- int FindDirSubItemIndex(const UString &name, int &insertPos) const;
int FindDirSubItemIndex(const UString &name) const;
CProxyFolder* AddDirSubItem(UInt32 index, bool leaf, const UString &name);
void AddFileSubItem(UInt32 index, const UString &name);
@@ -36,8 +36,6 @@ struct CProxyFolder: public CProxyFile
void GetPathParts(UStringVector &pathParts) const;
UString GetFullPathPrefix() const;
- UString GetItemName(UInt32 index) const;
- void AddRealIndices(CUIntVector &realIndices) const;
void GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const;
void CalculateSizes(IInArchive *archive);
};
diff --git a/CPP/7zip/UI/Agent/ArchiveFolder.cpp b/CPP/7zip/UI/Agent/ArchiveFolder.cpp
index 57975e7d..237afa05 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolder.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolder.cpp
@@ -8,46 +8,20 @@
#include "Agent.h"
-using namespace NWindows;
-using namespace NCOM;
-
STDMETHODIMP CAgentFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback)
{
COM_TRY_BEGIN
- CArchiveExtractCallback *extractCallbackSpec = new
- CArchiveExtractCallback;
- CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
- UStringVector pathParts;
- CProxyFolder *currentProxyFolder = _proxyFolderItem;
- while (currentProxyFolder->Parent)
- {
- pathParts.Insert(0, currentProxyFolder->Name);
- currentProxyFolder = currentProxyFolder->Parent;
- }
-
CMyComPtr<IFolderArchiveExtractCallback> extractCallback2;
{
CMyComPtr<IFolderOperationsExtractCallback> callbackWrap = callback;
- RINOK(callbackWrap.QueryInterface(
- IID_IFolderArchiveExtractCallback, &extractCallback2));
+ RINOK(callbackWrap.QueryInterface(IID_IFolderArchiveExtractCallback, &extractCallback2));
}
-
NExtract::NPathMode::EEnum pathMode = _flatMode ?
NExtract::NPathMode::kNoPathnames :
NExtract::NPathMode::kCurrentPathnames;
-
- extractCallbackSpec->InitForMulti(false, pathMode, NExtract::NOverwriteMode::kAskBefore);
- extractCallbackSpec->Init(NULL, &_agentSpec->GetArc(),
- extractCallback2,
- false, false, false,
- path,
- pathParts,
- (UInt64)(Int64)-1);
- CUIntVector realIndices;
- GetRealIndices(indices, numItems, realIndices);
- return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
- realIndices.Size(), BoolToInt(false), extractCallback);
+ return Extract(indices,numItems, pathMode, NExtract::NOverwriteMode::kAskBefore,
+ path, BoolToInt(false), extractCallback2);
COM_TRY_END
}
@@ -56,4 +30,3 @@ STDMETHODIMP CAgentFolder::MoveTo(const UInt32 * /* indices */, UInt32 /* numIte
{
return E_NOTIMPL;
}
-
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
index 477e052c..3a16a667 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
@@ -1,22 +1,9 @@
-// Zip/ArchiveFolder.cpp
+// Agent/ArchiveFolderOpen.cpp
#include "StdAfx.h"
#include "Agent.h"
-#include "Common/StringConvert.h"
-
-extern HINSTANCE g_hInstance;
-
-static inline UINT GetCurrentFileCodePage()
-{
- #ifdef UNDER_CE
- return CP_ACP;
- #else
- return AreFileApisANSI() ? CP_ACP : CP_OEMCP;
- #endif
-}
-
void CArchiveFolderManager::LoadFormats()
{
if (!_codecs)
@@ -39,7 +26,7 @@ STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream,
IFolderFolder **resultFolder, IProgress *progress)
{
CMyComPtr<IArchiveOpenCallback> openArchiveCallback;
- if (progress != 0)
+ if (progress)
{
CMyComPtr<IProgress> progressWrapper = progress;
progressWrapper.QueryInterface(IID_IArchiveOpenCallback, &openArchiveCallback);
@@ -104,16 +91,18 @@ STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPa
if (lib.FindIconIndex(ext, ii))
{
*iconIndex = ii;
- return StringToBstr(GetUnicodeString(lib.Path, GetCurrentFileCodePage()), iconPath);
+ return StringToBstr(fs2us(lib.Path), iconPath);
}
}
int ii;
if (_codecs->InternalIcons.FindIconIndex(ext, ii))
{
- *iconIndex = ii;
- UString path;
- NWindows::NDLL::MyGetModuleFileName(g_hInstance, path);
- return StringToBstr(path, iconPath);
+ FString path;
+ if (NWindows::NDLL::MyGetModuleFileName(path))
+ {
+ *iconIndex = ii;
+ return StringToBstr(fs2us(path), iconPath);
+ }
}
return S_OK;
}
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
index cf3e2d5a..656602cb 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
@@ -6,6 +6,7 @@
#include "Windows/FileDir.h"
+#include "../../Common/FileStreams.h"
#include "../Common/WorkDir.h"
#include "Agent.h"
@@ -14,32 +15,20 @@ using namespace NWindows;
using namespace NFile;
using namespace NDirectory;
-static LPCWSTR kTempArcivePrefix = L"7zA";
-
void CAgentFolder::GetPathParts(UStringVector &pathParts)
{
_proxyFolderItem->GetPathParts(pathParts);
}
HRESULT CAgentFolder::CommonUpdateOperation(
- bool deleteOperation,
- bool createFolderOperation,
- bool renameOperation,
+ AGENT_OP operation,
const wchar_t *newItemName,
const NUpdateArchive::CActionSet *actionSet,
const UINT32 *indices, UINT32 numItems,
IFolderArchiveUpdateCallback *updateCallback100)
{
- NWorkDir::CInfo workDirInfo;
- workDirInfo.Load();
- UString archiveFilePath = _agentSpec->_archiveFilePath;
- UString workDir = GetWorkDir(workDirInfo, archiveFilePath);
- CreateComplexDirectory(workDir);
-
- CTempFileW tempFile;
- UString tempFileName;
- if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
- return E_FAIL;
+ CWorkDirTempFile tempFile;
+ RINOK(tempFile.CreateTempFile(us2fs(_agentSpec->_archiveFilePath)));
/*
if (SetOutProperties(anOutArchive, aCompressionInfo.Method) != S_OK)
@@ -53,44 +42,39 @@ HRESULT CAgentFolder::CommonUpdateOperation(
GetPathParts(pathParts);
HRESULT result;
- if (deleteOperation)
- result = _agentSpec->DeleteItems(tempFileName,
- indices, numItems, updateCallback100);
- else if (createFolderOperation)
+ switch (operation)
{
- result = _agentSpec->CreateFolder(tempFileName,
- newItemName, updateCallback100);
- }
- else if (renameOperation)
- {
- result = _agentSpec->RenameItem(
- tempFileName,
- indices, numItems,
- newItemName,
- updateCallback100);
- }
- else
- {
- Byte actionSetByte[NUpdateArchive::NPairState::kNumValues];
- for (int i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
- actionSetByte[i] = (Byte)actionSet->StateActions[i];
- result = _agentSpec->DoOperation2(tempFileName, actionSetByte, NULL, updateCallback100);
+ case AGENT_OP_Delete:
+ result = _agentSpec->DeleteItems(tempFile.OutStream, indices, numItems, updateCallback100);
+ break;
+ case AGENT_OP_CreateFolder:
+ result = _agentSpec->CreateFolder(tempFile.OutStream, newItemName, updateCallback100);
+ break;
+ case AGENT_OP_Rename:
+ result = _agentSpec->RenameItem(tempFile.OutStream, indices, numItems, newItemName, updateCallback100);
+ break;
+ case AGENT_OP_CopyFromFile:
+ result = _agentSpec->UpdateOneFile(tempFile.OutStream, indices, numItems, newItemName, updateCallback100);
+ break;
+ case AGENT_OP_Uni:
+ {
+ Byte actionSetByte[NUpdateArchive::NPairState::kNumValues];
+ for (int i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
+ actionSetByte[i] = (Byte)actionSet->StateActions[i];
+ result = _agentSpec->DoOperation2(tempFile.OutStream, actionSetByte, NULL, updateCallback100);
+ break;
+ }
+ default:
+ return E_FAIL;
}
- if (result != S_OK)
- return result;
+ RINOK(result);
_agentSpec->Close();
// m_FolderItem = NULL;
- if (NFind::DoesFileExist(archiveFilePath))
- if (!DeleteFileAlways(archiveFilePath))
- return GetLastError();
-
- tempFile.DisableDeleting();
- if (!MyMoveFile(tempFileName, archiveFilePath))
- return GetLastError();
+ RINOK(tempFile.MoveToOriginal(true));
{
CMyComPtr<IArchiveOpenCallback> openCallback;
@@ -134,7 +118,7 @@ STDMETHODIMP CAgentFolder::CopyFrom(
{
COM_TRY_BEGIN
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
- if (progress != 0)
+ if (progress)
{
RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&updateCallback100));
}
@@ -142,7 +126,7 @@ STDMETHODIMP CAgentFolder::CopyFrom(
{
RINOK(_agentSpec->SetFiles(fromFolderPath, itemsPaths, numItems));
RINOK(_agentSpec->SetFolder(this));
- return CommonUpdateOperation(false, false, false, NULL,
+ return CommonUpdateOperation(AGENT_OP_Uni, NULL,
&NUpdateArchive::kAddActionSet, 0, 0, updateCallback100);
}
catch(const UString &s)
@@ -153,18 +137,43 @@ STDMETHODIMP CAgentFolder::CopyFrom(
COM_TRY_END
}
+STDMETHODIMP CAgentFolder::CopyFromFile(UInt32 destIndex, const wchar_t *itemPath, IProgress * progress)
+{
+ COM_TRY_BEGIN
+ CUIntVector indices;
+ indices.Add(destIndex);
+ CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
+ if (progress)
+ {
+ RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&updateCallback100));
+ }
+ try
+ {
+ RINOK(_agentSpec->SetFolder(this));
+ return CommonUpdateOperation(AGENT_OP_CopyFromFile, itemPath,
+ &NUpdateArchive::kAddActionSet,
+ &indices.Front(), indices.Size(), updateCallback100);
+ }
+ catch(const UString &s)
+ {
+ RINOK(updateCallback100->UpdateErrorMessage(UString(L"Error: ") + s));
+ return E_FAIL;
+ }
+ COM_TRY_END
+}
+
STDMETHODIMP CAgentFolder::Delete(const UINT32 *indices, UINT32 numItems, IProgress *progress)
{
COM_TRY_BEGIN
RINOK(_agentSpec->SetFolder(this));
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
- if (progress != 0)
+ if (progress)
{
CMyComPtr<IProgress> progressWrapper = progress;
RINOK(progressWrapper.QueryInterface(
IID_IFolderArchiveUpdateCallback, &updateCallback100));
}
- return CommonUpdateOperation(true, false, false, NULL,
+ return CommonUpdateOperation(AGENT_OP_Delete, NULL,
&NUpdateArchive::kDeleteActionSet, indices, numItems, updateCallback100);
COM_TRY_END
}
@@ -176,12 +185,12 @@ STDMETHODIMP CAgentFolder::CreateFolder(const wchar_t *name, IProgress *progress
return ERROR_ALREADY_EXISTS;
RINOK(_agentSpec->SetFolder(this));
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
- if (progress != 0)
+ if (progress)
{
CMyComPtr<IProgress> progressWrapper = progress;
RINOK(progressWrapper.QueryInterface(IID_IFolderArchiveUpdateCallback, &updateCallback100));
}
- return CommonUpdateOperation(false, true, false, name, NULL, NULL, 0, updateCallback100);
+ return CommonUpdateOperation(AGENT_OP_CreateFolder, name, NULL, NULL, 0, updateCallback100);
COM_TRY_END
}
@@ -192,12 +201,12 @@ STDMETHODIMP CAgentFolder::Rename(UINT32 index, const wchar_t *newName, IProgres
indices.Add(index);
RINOK(_agentSpec->SetFolder(this));
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
- if (progress != 0)
+ if (progress)
{
CMyComPtr<IProgress> progressWrapper = progress;
RINOK(progressWrapper.QueryInterface(IID_IFolderArchiveUpdateCallback, &updateCallback100));
}
- return CommonUpdateOperation(false, false, true, newName, NULL, &indices.Front(),
+ return CommonUpdateOperation(AGENT_OP_Rename, newName, NULL, &indices.Front(),
indices.Size(), updateCallback100);
COM_TRY_END
}
diff --git a/CPP/7zip/UI/Agent/IFolderArchive.h b/CPP/7zip/UI/Agent/IFolderArchive.h
index 867ae279..2357af31 100755
--- a/CPP/7zip/UI/Agent/IFolderArchive.h
+++ b/CPP/7zip/UI/Agent/IFolderArchive.h
@@ -3,7 +3,6 @@
#ifndef __IFOLDER_ARCHIVE_H
#define __IFOLDER_ARCHIVE_H
-#include "../../IDecl.h"
#include "../../Archive/IArchive.h"
#include "../../UI/Common/LoadCodecs.h"
#include "../../UI/FileManager/IFolder.h"
@@ -57,13 +56,14 @@ FOLDER_ARCHIVE_INTERFACE_SUB(IFolderArchiveUpdateCallback, IProgress, 0x0B)
#define INTERFACE_IOutFolderArchive(x) \
STDMETHOD(SetFolder)(IFolderFolder *folder) x; \
STDMETHOD(SetFiles)(const wchar_t *folderPrefix, const wchar_t **names, UInt32 numNames) x; \
- STDMETHOD(DeleteItems)(const wchar_t *newArchiveName, \
+ STDMETHOD(DeleteItems)(ISequentialOutStream *outArchiveStream, \
const UInt32 *indices, UInt32 numItems, IFolderArchiveUpdateCallback *updateCallback) x; \
STDMETHOD(DoOperation)(CCodecs *codecs, int index, \
- const wchar_t *newArchiveName, const Byte *stateActions, const wchar_t *sfxModule, \
+ ISequentialOutStream *outArchiveStream, const Byte *stateActions, const wchar_t *sfxModule, \
+ IFolderArchiveUpdateCallback *updateCallback) x; \
+ STDMETHOD(DoOperation2)( \
+ ISequentialOutStream *outArchiveStream, const Byte *stateActions, const wchar_t *sfxModule, \
IFolderArchiveUpdateCallback *updateCallback) x; \
- STDMETHOD(DoOperation2)(const wchar_t *newArchiveName, const Byte *stateActions, \
- const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback) x; \
FOLDER_ARCHIVE_INTERFACE(IOutFolderArchive, 0x0A)
{
diff --git a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
index e4aa4438..3687c3d0 100755
--- a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
+++ b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
@@ -66,7 +66,7 @@ HRESULT CUpdateCallbackAgent::OpenFileError(const wchar_t *name, DWORD systemErr
UString(L"WARNING: ") +
NError::MyFormatMessageW(systemError) +
UString(L": ") +
- UString(name)));
+ name));
return S_FALSE;
}
}
diff --git a/CPP/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp
index 410b800d..d181843d 100755
--- a/CPP/7zip/UI/Client7z/Client7z.cpp
+++ b/CPP/7zip/UI/Client7z/Client7z.cpp
@@ -21,6 +21,10 @@
#include "../../IPassword.h"
#include "../../MyVersion.h"
+#ifdef _WIN32
+HINSTANCE g_hInstance = 0;
+#endif
+
// use another CLSIDs, if you want to support other formats (zip, rar, ...).
// {23170F69-40C1-278A-1000-000110070000}
DEFINE_GUID(CLSID_CFormat7z,
@@ -30,9 +34,9 @@ using namespace NWindows;
#define kDllName "7z.dll"
-static const char *kCopyrightString = MY_7ZIP_VERSION
+static const char *kCopyrightString = "\n" MY_7ZIP_VERSION
" (" kDllName " client) "
-MY_COPYRIGHT " " MY_DATE;
+MY_COPYRIGHT " " MY_DATE "\n";
static const char *kHelpString =
"Usage: Client7z.exe [a | l | x ] archive.7z [fileName ...]\n"
@@ -48,28 +52,46 @@ typedef UINT32 (WINAPI * CreateObjectFunc)(
void **outObject);
-void PrintString(const UString &s)
+static AString FStringToConsoleString(const FString &s)
+{
+ return GetOemString(fs2us(s));
+}
+
+static FString CmdStringToFString(const char *s)
+{
+ return us2fs(GetUnicodeString(s));
+}
+
+static void PrintString(const UString &s)
{
printf("%s", (LPCSTR)GetOemString(s));
}
-void PrintString(const AString &s)
+static void PrintString(const AString &s)
{
printf("%s", (LPCSTR)s);
}
-void PrintNewLine()
+static void PrintNewLine()
{
PrintString("\n");
}
-void PrintStringLn(const AString &s)
+static void PrintStringLn(const AString &s)
{
PrintString(s);
PrintNewLine();
}
-void PrintError(const AString &s)
+static void PrintError(const char *message, const FString &name)
+{
+ printf("Error: %s", (LPCSTR)message);
+ PrintNewLine();
+ PrintString(FStringToConsoleString(name));
+ PrintNewLine();
+}
+
+static void PrintError(const AString &s)
{
PrintNewLine();
PrintString(s);
@@ -148,8 +170,6 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
//////////////////////////////////////////////////////////////
// Archive Extracting callback class
-static const wchar_t *kCantDeleteOutputFile = L"ERROR: Can not delete output file ";
-
static const char *kTestingString = "Testing ";
static const char *kExtractingString = "Extracting ";
static const char *kSkippingString = "Skipping ";
@@ -181,9 +201,9 @@ public:
private:
CMyComPtr<IInArchive> _archiveHandler;
- UString _directoryPath; // Output directory
+ FString _directoryPath; // Output directory
UString _filePath; // name inside arcvhive
- UString _diskFilePath; // full path to file on disk
+ FString _diskFilePath; // full path to file on disk
bool _extractMode;
struct CProcessedFileInfo
{
@@ -198,7 +218,7 @@ private:
CMyComPtr<ISequentialOutStream> _outFileStream;
public:
- void Init(IInArchive *archiveHandler, const UString &directoryPath);
+ void Init(IInArchive *archiveHandler, const FString &directoryPath);
UInt64 NumErrors;
bool PasswordIsDefined;
@@ -207,7 +227,7 @@ public:
CArchiveExtractCallback() : PasswordIsDefined(false) {}
};
-void CArchiveExtractCallback::Init(IInArchive *archiveHandler, const UString &directoryPath)
+void CArchiveExtractCallback::Init(IInArchive *archiveHandler, const FString &directoryPath)
{
NumErrors = 0;
_archiveHandler = archiveHandler;
@@ -305,10 +325,10 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
// Create folders for file
int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (slashPos >= 0)
- NFile::NDirectory::CreateComplexDirectory(_directoryPath + _filePath.Left(slashPos));
+ NFile::NDirectory::CreateComplexDirectory(_directoryPath + us2fs(_filePath.Left(slashPos)));
}
- UString fullProcessedPath = _directoryPath + _filePath;
+ FString fullProcessedPath = _directoryPath + us2fs(_filePath);
_diskFilePath = fullProcessedPath;
if (_processedFileInfo.isDir)
@@ -317,12 +337,12 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
}
else
{
- NFile::NFind::CFileInfoW fi;
+ NFile::NFind::CFileInfo fi;
if (fi.Find(fullProcessedPath))
{
if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
{
- PrintString(UString(kCantDeleteOutputFile) + fullProcessedPath);
+ PrintError("Can not delete output file", fullProcessedPath);
return E_ABORT;
}
}
@@ -331,7 +351,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
if (!_outFileStreamSpec->Open(fullProcessedPath, CREATE_ALWAYS))
{
- PrintString((UString)L"can not open output file " + fullProcessedPath);
+ PrintError("Can not open output file", fullProcessedPath);
return E_ABORT;
}
_outFileStream = outStreamLoc;
@@ -423,7 +443,7 @@ struct CDirItem
FILETIME ATime;
FILETIME MTime;
UString Name;
- UString FullPath;
+ FString FullPath;
UInt32 Attrib;
bool isDir() const { return (Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 ; }
@@ -458,7 +478,7 @@ public:
UString VolName;
UString VolExt;
- UString DirPrefix;
+ FString DirPrefix;
const CObjectVector<CDirItem> *DirItems;
bool PasswordIsDefined;
@@ -467,7 +487,7 @@ public:
bool m_NeedBeClosed;
- UStringVector FailedFiles;
+ FStringVector FailedFiles;
CRecordVector<HRESULT> FailedCodes;
CArchiveUpdateCallback(): PasswordIsDefined(false), AskPassword(false), DirItems(0) {};
@@ -514,7 +534,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
- NWindows::NCOM::CPropVariant prop;
+ NCOM::CPropVariant prop;
if (propID == kpidIsAnti)
{
@@ -571,7 +591,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
{
CInFileStream *inStreamSpec = new CInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
- UString path = DirPrefix + dirItem.FullPath;
+ FString path = DirPrefix + dirItem.FullPath;
if (!inStreamSpec->Open(path))
{
DWORD sysError = ::GetLastError();
@@ -620,7 +640,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOu
fileName += VolExt;
COutFileStream *streamSpec = new COutFileStream;
CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);
- if (!streamSpec->Create(fileName, false))
+ if (!streamSpec->Create(us2fs(fileName), false))
return ::GetLastError();
*volumeStream = streamLoc.Detach();
return S_OK;
@@ -643,8 +663,6 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef
return StringToBstr(Password, password);
}
-
-
//////////////////////////////////////////////////////////////////////////
// Main function
@@ -661,8 +679,8 @@ int MY_CDECL main(int numArgs, const char *args[])
PrintStringLn(kHelpString);
return 1;
}
- NWindows::NDLL::CLibrary lib;
- if (!lib.Load(TEXT(kDllName)))
+ NDLL::CLibrary lib;
+ if (!lib.Load(NDLL::GetModuleDirPrefix() + FTEXT(kDllName)))
{
PrintError("Can not load 7-zip library");
return 1;
@@ -682,10 +700,10 @@ int MY_CDECL main(int numArgs, const char *args[])
PrintError("incorrect command");
return 1;
}
- c = MyCharLower(command[0]);
+ c = (char)MyCharUpper(command[0]);
}
- UString archiveName = GetUnicodeString(args[2]);
- if (c == 'a')
+ FString archiveName = CmdStringToFString(args[2]);
+ if (c == 'A')
{
// create archive command
if (numArgs < 4)
@@ -698,12 +716,12 @@ int MY_CDECL main(int numArgs, const char *args[])
for (i = 3; i < numArgs; i++)
{
CDirItem di;
- UString name = GetUnicodeString(args[i]);
+ FString name = CmdStringToFString(args[i]);
- NFile::NFind::CFileInfoW fi;
+ NFile::NFind::CFileInfo fi;
if (!fi.Find(name))
{
- PrintString(UString(L"Can't find file") + name);
+ PrintError("Can't find file", name);
return 1;
}
@@ -712,7 +730,7 @@ int MY_CDECL main(int numArgs, const char *args[])
di.CTime = fi.CTime;
di.ATime = fi.ATime;
di.MTime = fi.MTime;
- di.Name = name;
+ di.Name = fs2us(name);
di.FullPath = name;
dirItems.Add(di);
}
@@ -745,7 +763,7 @@ int MY_CDECL main(int numArgs, const char *args[])
L"x"
};
const int kNumProps = sizeof(names) / sizeof(names[0]);
- NWindows::NCOM::CPropVariant values[kNumProps] =
+ NCOM::CPropVariant values[kNumProps] =
{
false, // solid mode OFF
(UInt32)9 // compression level = 9 - ultra
@@ -771,7 +789,7 @@ int MY_CDECL main(int numArgs, const char *args[])
for (i = 0; i < updateCallbackSpec->FailedFiles.Size(); i++)
{
PrintNewLine();
- PrintString((UString)L"Error for file: " + updateCallbackSpec->FailedFiles[i]);
+ PrintError("Error for file", updateCallbackSpec->FailedFiles[i]);
}
if (updateCallbackSpec->FailedFiles.Size() != 0)
return 1;
@@ -785,9 +803,9 @@ int MY_CDECL main(int numArgs, const char *args[])
}
bool listCommand;
- if (c == 'l')
+ if (c == 'L')
listCommand = true;
- else if (c == 'x')
+ else if (c == 'X')
listCommand = false;
else
{
@@ -807,7 +825,7 @@ int MY_CDECL main(int numArgs, const char *args[])
if (!fileSpec->Open(archiveName))
{
- PrintError("Can not open archive file");
+ PrintError("Can not open archive file", archiveName);
return 1;
}
@@ -820,7 +838,7 @@ int MY_CDECL main(int numArgs, const char *args[])
if (archive->Open(file, 0, openCallback) != S_OK)
{
- PrintError("Can not open archive");
+ PrintError("Can not open file as archive", archiveName);
return 1;
}
}
@@ -834,7 +852,7 @@ int MY_CDECL main(int numArgs, const char *args[])
{
{
// Get uncompressed size of file
- NWindows::NCOM::CPropVariant prop;
+ NCOM::CPropVariant prop;
archive->GetProperty(i, kpidSize, &prop);
UString s = ConvertPropVariantToString(prop);
PrintString(s);
@@ -842,12 +860,12 @@ int MY_CDECL main(int numArgs, const char *args[])
}
{
// Get name of file
- NWindows::NCOM::CPropVariant prop;
+ NCOM::CPropVariant prop;
archive->GetProperty(i, kpidPath, &prop);
UString s = ConvertPropVariantToString(prop);
PrintString(s);
}
- PrintString("\n");
+ PrintNewLine();
}
}
else
@@ -855,7 +873,7 @@ int MY_CDECL main(int numArgs, const char *args[])
// Extract command
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
- extractCallbackSpec->Init(archive, L""); // second parameter is output folder path
+ extractCallbackSpec->Init(archive, FTEXT("")); // second parameter is output folder path
extractCallbackSpec->PasswordIsDefined = false;
// extractCallbackSpec->PasswordIsDefined = true;
// extractCallbackSpec->Password = L"1";
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
index 8ae2e15e..85ec17b4 100755
--- a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
@@ -283,9 +283,9 @@ static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
{
UStringVector names;
- if (!NFind::DoesFileExist(fileName))
+ if (!NFind::DoesFileExist(us2fs(fileName)))
throw kCannotFindListFile;
- if (!ReadNamesFromListFile(fileName, names, codePage))
+ if (!ReadNamesFromListFile(us2fs(fileName), names, codePage))
throw kIncorrectListFile;
for (int i = 0; i < names.Size(); i++)
AddNameToCensor(wildcardCensor, names[i], include, type);
@@ -420,9 +420,9 @@ static void ConvertToLongName(const UString &prefix, UString &name)
{
if (name.IsEmpty() || DoesNameContainWildCard(name))
return;
- NFind::CFileInfoW fi;
- if (fi.Find(prefix + name))
- name = fi.Name;
+ NFind::CFileInfo fi;
+ if (fi.Find(us2fs(prefix + name)))
+ name = fs2us(fi.Name);
}
static void ConvertToLongNames(const UString &prefix, CObjectVector<NWildcard::CItem> &items)
@@ -463,7 +463,7 @@ static void ConvertToLongNames(const UString &prefix, NWildcard::CCensorNode &no
for (i = 0; i < node.SubNodes.Size(); i++)
{
NWildcard::CCensorNode &nextNode = node.SubNodes[i];
- ConvertToLongNames(prefix + nextNode.Name + wchar_t(NFile::NName::kDirDelimiter), nextNode);
+ ConvertToLongNames(prefix + nextNode.Name + WCHAR_PATH_SEPARATOR, nextNode);
}
}
@@ -647,11 +647,11 @@ static void SetAddCommandOptions(
if (postString.IsEmpty())
NDirectory::MyGetTempPath(options.WorkingDir);
else
- options.WorkingDir = postString;
+ options.WorkingDir = us2fs(postString);
}
options.SfxMode = parser[NKey::kSfx].ThereIs;
if (options.SfxMode)
- options.SfxModule = parser[NKey::kSfx].PostStrings[0];
+ options.SfxModule = us2fs(parser[NKey::kSfx].PostStrings[0]);
if (parser[NKey::kVolume].ThereIs)
{
@@ -670,7 +670,6 @@ static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &pr
{
if (parser[NKey::kProperty].ThereIs)
{
- // options.MethodMode.Properties.Clear();
for (int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
{
CProperty property;
@@ -774,7 +773,7 @@ void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor,
{
CDirItems dirItems;
{
- UStringVector errorPaths;
+ FStringVector errorPaths;
CRecordVector<DWORD> errorCodes;
HRESULT res = EnumerateItems(wildcardCensor, dirItems, NULL, errorPaths, errorCodes);
if (res != S_OK || errorPaths.Size() > 0)
@@ -796,9 +795,9 @@ void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor,
int i;
for (i = 0; i < paths.Size(); i++)
{
- UString fullPath;
- NFile::NDirectory::MyGetFullPathName(paths[i], fullPath);
- fullPaths.Add(fullPath);
+ FString fullPath;
+ NFile::NDirectory::MyGetFullPathName(us2fs(paths[i]), fullPath);
+ fullPaths.Add(fs2us(fullPath));
}
CIntVector indices;
SortFileNames(fullPaths, indices);
@@ -886,6 +885,8 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
if (parser[NKey::kArchiveType].ThereIs)
options.ArcType = parser[NKey::kArchiveType].PostStrings[0];
+ SetMethodOptions(parser, options.Properties);
+
if (isExtractOrList)
{
if (!options.WildcardCensor.AllAreRelative())
@@ -924,12 +925,11 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
if (isExtractGroupCommand)
{
- SetMethodOptions(parser, options.ExtractProperties);
if (options.StdOutMode && options.IsStdOutTerminal && options.IsStdErrTerminal)
throw kSameTerminalError;
if (parser[NKey::kOutputDir].ThereIs)
{
- options.OutputDir = parser[NKey::kOutputDir].PostStrings[0];
+ options.OutputDir = us2fs(parser[NKey::kOutputDir].PostStrings[0]);
NFile::NName::NormalizeDirPathPrefix(options.OutputDir);
}
@@ -946,7 +946,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
- SetMethodOptions(parser, updateOptions.MethodMode.Properties);
+ updateOptions.MethodMode.Properties = options.Properties;
if (parser[NKey::kShareForWrite].ThereIs)
updateOptions.OpenShareForWrite = true;
@@ -988,50 +988,12 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
}
else if (options.Command.CommandType == NCommandType::kBenchmark)
{
- options.NumThreads = (UInt32)-1;
- options.DictionarySize = (UInt32)-1;
options.NumIterations = 1;
if (curCommandIndex < numNonSwitchStrings)
{
if (!ConvertStringToUInt32(nonSwitchStrings[curCommandIndex++], options.NumIterations))
ThrowUserErrorException();
}
- for (int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
- {
- UString postString = parser[NKey::kProperty].PostStrings[i];
- postString.MakeUpper();
- if (postString.Length() < 2)
- ThrowUserErrorException();
- if (postString[0] == 'D')
- {
- int pos = 1;
- if (postString[pos] == '=')
- pos++;
- UInt32 logSize;
- if (!ConvertStringToUInt32((const wchar_t *)postString + pos, logSize))
- ThrowUserErrorException();
- if (logSize > 31)
- ThrowUserErrorException();
- options.DictionarySize = 1 << logSize;
- }
- else if (postString[0] == 'M' && postString[1] == 'T' )
- {
- int pos = 2;
- if (postString[pos] == '=')
- pos++;
- if (postString[pos] != 0)
- if (!ConvertStringToUInt32((const wchar_t *)postString + pos, options.NumThreads))
- ThrowUserErrorException();
- }
- else if (postString[0] == 'M' && postString[1] == '=' )
- {
- int pos = 2;
- if (postString[pos] != 0)
- options.Method = postString.Mid(2);
- }
- else
- ThrowUserErrorException();
- }
}
else if (options.Command.CommandType == NCommandType::kInfo)
{
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.h b/CPP/7zip/UI/Common/ArchiveCommandLine.h
index e8f601df..96646d60 100755
--- a/CPP/7zip/UI/Common/ArchiveCommandLine.h
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.h
@@ -75,11 +75,11 @@ struct CArchiveCommandLineOptions
// Extract
bool CalcCrc;
bool AppendName;
- UString OutputDir;
+ FString OutputDir;
NExtract::NOverwriteMode::EEnum OverwriteMode;
UStringVector ArchivePathsSorted;
UStringVector ArchivePathsFullSorted;
- CObjectVector<CProperty> ExtractProperties;
+ CObjectVector<CProperty> Properties;
CUpdateOptions UpdateOptions;
UString ArcType;
@@ -87,10 +87,6 @@ struct CArchiveCommandLineOptions
// Benchmark
UInt32 NumIterations;
- UInt32 NumThreads;
- UInt32 DictionarySize;
- UString Method;
-
CArchiveCommandLineOptions(): StdInMode(false), StdOutMode(false) {};
};
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
index 4c0cc90b..9c9c0422 100755
--- a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
@@ -3,10 +3,12 @@
#include "StdAfx.h"
#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
#include "Common/Wildcard.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
@@ -18,16 +20,16 @@
using namespace NWindows;
-static const wchar_t *kCantAutoRename = L"ERROR: Can not create file with auto name";
-static const wchar_t *kCantRenameFile = L"ERROR: Can not rename existing file ";
-static const wchar_t *kCantDeleteOutputFile = L"ERROR: Can not delete output file ";
+static const char *kCantAutoRename = "ERROR: Can not create file with auto name";
+static const char *kCantRenameFile = "ERROR: Can not rename existing file ";
+static const char *kCantDeleteOutputFile = "ERROR: Can not delete output file ";
void CArchiveExtractCallback::Init(
const NWildcard::CCensorNode *wildcardCensor,
const CArc *arc,
IFolderArchiveExtractCallback *extractCallback2,
bool stdOutMode, bool testMode, bool crcMode,
- const UString &directoryPath,
+ const FString &directoryPath,
const UStringVector &removePathParts,
UInt64 packSize)
{
@@ -107,14 +109,14 @@ STDMETHODIMP CArchiveExtractCallback::SetRatioInfo(const UInt64 *inSize, const U
COM_TRY_END
}
-void CArchiveExtractCallback::CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath)
+void CArchiveExtractCallback::CreateComplexDirectory(const UStringVector &dirPathParts, FString &fullPath)
{
fullPath = _directoryPath;
for (int i = 0; i < dirPathParts.Size(); i++)
{
if (i > 0)
- fullPath += wchar_t(NFile::NName::kDirDelimiter);
- fullPath += dirPathParts[i];
+ fullPath += FCHAR_PATH_SEPARATOR;
+ fullPath += us2fs(dirPathParts[i]);
NFile::NDirectory::MyCreateDirectory(fullPath);
}
}
@@ -136,12 +138,12 @@ HRESULT CArchiveExtractCallback::GetTime(int index, PROPID propID, FILETIME &fil
HRESULT CArchiveExtractCallback::GetUnpackSize()
{
- NCOM::CPropVariant prop;
- RINOK(_arc->Archive->GetProperty(_index, kpidSize, &prop));
- _curSizeDefined = (prop.vt != VT_EMPTY);
- if (_curSizeDefined)
- _curSize = ConvertPropVariantToUInt64(prop);
- return S_OK;
+ return _arc->GetItemSize(_index, _curSize, _curSizeDefined);
+}
+
+HRESULT CArchiveExtractCallback::SendMessageError(const char *message, const FString &path)
+{
+ return _extractCallback2->MessageError(GetUnicodeString(message) + fs2us(path));
}
STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)
@@ -256,7 +258,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
if (!pathParts.IsEmpty())
{
- UString fullPathNew;
+ FString fullPathNew;
CreateComplexDirectory(pathParts, fullPathNew);
if (_fi.IsDir)
NFile::NDirectory::SetDirTime(fullPathNew,
@@ -267,7 +269,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
}
- UString fullProcessedPath = _directoryPath + processedPath;
+ FString fullProcessedPath = _directoryPath + us2fs(processedPath);
if (_fi.IsDir)
{
@@ -279,7 +281,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
if (!_isSplit)
{
- NFile::NFind::CFileInfoW fileInfo;
+ NFile::NFind::CFileInfo fileInfo;
if (fileInfo.Find(fullProcessedPath))
{
switch(_overwriteMode)
@@ -290,7 +292,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
{
Int32 overwiteResult;
RINOK(_extractCallback2->AskOverwrite(
- fullProcessedPath, &fileInfo.MTime, &fileInfo.Size, fullPath,
+ fs2us(fullProcessedPath), &fileInfo.MTime, &fileInfo.Size, fullPath,
_fi.MTimeDefined ? &_fi.MTime : NULL,
_curSizeDefined ? &_curSize : NULL,
&overwiteResult))
@@ -321,32 +323,28 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
{
if (!AutoRenamePath(fullProcessedPath))
{
- UString message = UString(kCantAutoRename) + fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
+ RINOK(SendMessageError(kCantAutoRename, fullProcessedPath));
return E_FAIL;
}
}
else if (_overwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting)
{
- UString existPath = fullProcessedPath;
+ FString existPath = fullProcessedPath;
if (!AutoRenamePath(existPath))
{
- UString message = kCantAutoRename + fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
+ RINOK(SendMessageError(kCantAutoRename, fullProcessedPath));
return E_FAIL;
}
if (!NFile::NDirectory::MyMoveFile(fullProcessedPath, existPath))
{
- UString message = UString(kCantRenameFile) + fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
+ RINOK(SendMessageError(kCantRenameFile, fullProcessedPath));
return E_FAIL;
}
}
else
if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
{
- UString message = UString(kCantDeleteOutputFile) + fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
+ RINOK(SendMessageError(kCantDeleteOutputFile, fullProcessedPath));
return S_OK;
// return E_FAIL;
}
@@ -360,8 +358,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
{
// if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit)
{
- UString message = L"can not open output file " + fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
+ RINOK(SendMessageError("can not open output file ", fullProcessedPath));
return S_OK;
}
}
@@ -485,4 +482,3 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
return _cryptoGetTextPassword->CryptoGetTextPassword(password);
COM_TRY_END
}
-
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.h b/CPP/7zip/UI/Common/ArchiveExtractCallback.h
index 367e4b07..cee7c5b6 100755
--- a/CPP/7zip/UI/Common/ArchiveExtractCallback.h
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.h
@@ -31,11 +31,11 @@ class CArchiveExtractCallback:
CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2;
CMyComPtr<ICompressProgressInfo> _compressProgress;
CMyComPtr<ICryptoGetTextPassword> _cryptoGetTextPassword;
- UString _directoryPath;
+ FString _directoryPath;
NExtract::NPathMode::EEnum _pathMode;
NExtract::NOverwriteMode::EEnum _overwriteMode;
- UString _diskFilePath;
+ FString _diskFilePath;
UString _filePath;
UInt64 _position;
bool _isSplit;
@@ -83,10 +83,12 @@ class CArchiveExtractCallback:
UInt64 _packTotal;
UInt64 _unpTotal;
- void CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath);
+ void CreateComplexDirectory(const UStringVector &dirPathParts, FString &fullPath);
HRESULT GetTime(int index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined);
HRESULT GetUnpackSize();
+ HRESULT SendMessageError(const char *message, const FString &path);
+
public:
CLocalProgress *LocalProgressSpec;
@@ -134,7 +136,7 @@ public:
const CArc *arc,
IFolderArchiveExtractCallback *extractCallback2,
bool stdOutMode, bool testMode, bool crcMode,
- const UString &directoryPath,
+ const FString &directoryPath,
const UStringVector &removePathParts,
UInt64 packSize);
diff --git a/CPP/7zip/UI/Common/ArchiveName.cpp b/CPP/7zip/UI/Common/ArchiveName.cpp
index c3684def..17947dce 100755
--- a/CPP/7zip/UI/Common/ArchiveName.cpp
+++ b/CPP/7zip/UI/Common/ArchiveName.cpp
@@ -9,19 +9,19 @@
using namespace NWindows;
-static UString CreateArchiveName2(const UString &srcName, bool fromPrev, bool keepName)
+static FString CreateArchiveName2(const FString &srcName, bool fromPrev, bool keepName)
{
- UString resultName = L"Archive";
+ FString resultName = FTEXT("Archive");
if (fromPrev)
{
- UString dirPrefix;
+ FString dirPrefix;
if (NFile::NDirectory::GetOnlyDirPrefix(srcName, dirPrefix))
{
if (dirPrefix.Length() > 0)
- if (dirPrefix[dirPrefix.Length() - 1] == WCHAR_PATH_SEPARATOR)
+ if (dirPrefix.Back() == FCHAR_PATH_SEPARATOR)
{
- dirPrefix.Delete(dirPrefix.Length() - 1);
- NFile::NFind::CFileInfoW fileInfo;
+ dirPrefix.DeleteBack();
+ NFile::NFind::CFileInfo fileInfo;
if (fileInfo.Find(dirPrefix))
resultName = fileInfo.Name;
}
@@ -29,7 +29,7 @@ static UString CreateArchiveName2(const UString &srcName, bool fromPrev, bool ke
}
else
{
- NFile::NFind::CFileInfoW fileInfo;
+ NFile::NFind::CFileInfo fileInfo;
if (!fileInfo.Find(srcName))
// return resultName;
return srcName;
@@ -39,8 +39,8 @@ static UString CreateArchiveName2(const UString &srcName, bool fromPrev, bool ke
int dotPos = resultName.ReverseFind('.');
if (dotPos > 0)
{
- UString archiveName2 = resultName.Left(dotPos);
- if (archiveName2.ReverseFind('.') < 0)
+ FString archiveName2 = resultName.Left(dotPos);
+ if (archiveName2.ReverseFind(FTEXT('.')) < 0)
resultName = archiveName2;
}
}
@@ -50,5 +50,5 @@ static UString CreateArchiveName2(const UString &srcName, bool fromPrev, bool ke
UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName)
{
- return GetCorrectFsPath(CreateArchiveName2(srcName, fromPrev, keepName));
+ return GetCorrectFsPath(fs2us(CreateArchiveName2(us2fs(srcName), fromPrev, keepName)));
}
diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
index e7e61713..be20940c 100755
--- a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
+++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
@@ -2,7 +2,6 @@
#include "StdAfx.h"
-#include "Common/StringConvert.h"
#include "Common/ComTry.h"
#include "Windows/PropVariant.h"
@@ -94,7 +93,7 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre
RINOK(Callback->Open_CheckBreak());
}
*inStream = NULL;
- UString fullPath = _folderPrefix + name;
+ FString fullPath = _folderPrefix + us2fs(name);
if (!_fileInfo.Find(fullPath))
return S_FALSE;
if (_fileInfo.IsDir())
@@ -130,4 +129,3 @@ STDMETHODIMP COpenCallbackImp::CryptoGetTextPassword(BSTR *password)
COM_TRY_END
}
#endif
-
diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.h b/CPP/7zip/UI/Common/ArchiveOpenCallback.h
index c6651e8f..afada4a6 100755
--- a/CPP/7zip/UI/Common/ArchiveOpenCallback.h
+++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.h
@@ -77,8 +77,8 @@ public:
}
private:
- UString _folderPrefix;
- NWindows::NFile::NFind::CFileInfoW _fileInfo;
+ FString _folderPrefix;
+ NWindows::NFile::NFind::CFileInfo _fileInfo;
bool _subArchiveMode;
UString _subArchiveName;
public:
@@ -88,7 +88,7 @@ public:
UInt64 TotalSize;
COpenCallbackImp(): Callback(NULL) {}
- void Init(const UString &folderPrefix, const UString &fileName)
+ void Init(const FString &folderPrefix, const FString &fileName)
{
_folderPrefix = folderPrefix;
if (!_fileInfo.Find(_folderPrefix + fileName))
diff --git a/CPP/7zip/UI/Common/Bench.cpp b/CPP/7zip/UI/Common/Bench.cpp
index 282f405f..5adfcc20 100755
--- a/CPP/7zip/UI/Common/Bench.cpp
+++ b/CPP/7zip/UI/Common/Bench.cpp
@@ -2,8 +2,6 @@
#include "StdAfx.h"
-#include "Bench.h"
-
#ifndef _WIN32
#define USE_POSIX_TIME
#define USE_POSIX_TIME2
@@ -31,18 +29,30 @@
#include "../../../../C/7zCrc.h"
#include "../../../../C/Alloc.h"
+#if !defined(_7ZIP_ST) || defined(_WIN32)
+#include "../../../Windows/System.h"
+#endif
+
#ifndef _7ZIP_ST
#include "../../../Windows/Synchronization.h"
#include "../../../Windows/Thread.h"
#endif
-#include "../../../Windows/PropVariant.h"
+#include "../../../Common/IntToString.h"
+#include "../../../Common/StringConvert.h"
+#include "../../../Common/StringToInt.h"
+
+#include "../../Common/MethodProps.h"
+
+#include "Bench.h"
+
+using namespace NWindows;
-static const UInt32 kUncompressMinBlockSize =
+static const UInt64 kUncompressMinBlockSize =
#ifdef UNDER_CE
-1 << 24;
+(UInt64)1 << 30;
#else
-1 << 26;
+(UInt64)1 << 33;
#endif
static const UInt32 kCrcBlockSize =
@@ -52,6 +62,8 @@ static const UInt32 kCrcBlockSize =
1 << 30;
#endif
+static const unsigned kOldLzmaDictBits = 30;
+
static const UInt32 kAdditionalSize = (1 << 16);
static const UInt32 kCompressedAdditionalSize = (1 << 10);
static const UInt32 kMaxLzmaPropSize = 5;
@@ -99,7 +111,7 @@ class CBenchRandomGenerator: public CBenchBuffer
CBaseRandomGenerator *RG;
public:
void Set(CBaseRandomGenerator *rg) { RG = rg; }
- UInt32 GetVal(UInt32 &res, int numBits)
+ UInt32 GetVal(UInt32 &res, unsigned numBits)
{
UInt32 val = res & (((UInt32)1 << numBits) - 1);
res >>= numBits;
@@ -110,7 +122,7 @@ public:
UInt32 len = GetVal(res, 2);
return GetVal(res, 1 + len);
}
- void Generate()
+ void Generate(unsigned dictBits)
{
UInt32 pos = 0;
UInt32 rep0 = 1;
@@ -131,7 +143,7 @@ public:
{
UInt32 ppp = GetVal(res, 5) + 6;
res = RG->GetRnd();
- if (ppp > 30)
+ if (ppp > dictBits)
continue;
rep0 = /* (1 << ppp) +*/ GetVal(res, ppp);
res = RG->GetRnd();
@@ -275,15 +287,33 @@ static UInt64 GetFreq()
#endif
}
-#ifndef USE_POSIX_TIME
-static inline UInt64 GetTime64(const FILETIME &t) { return ((UInt64)t.dwHighDateTime << 32) | t.dwLowDateTime; }
-#endif
+#ifdef USE_POSIX_TIME
-static UInt64 GetUserTime()
+struct CUserTime
+{
+ UInt64 Sum;
+ clock_t Prev;
+
+ void Init()
+ {
+ Prev = clock();
+ Sum = 0;
+ }
+
+ UInt64 GetUserTime()
+ {
+ clock_t v = clock();
+ Sum += v - Prev;
+ Prev = v;
+ return Sum;
+ }
+};
+
+#else
+
+static inline UInt64 GetTime64(const FILETIME &t) { return ((UInt64)t.dwHighDateTime << 32) | t.dwLowDateTime; }
+UInt64 GetWinUserTime()
{
- #ifdef USE_POSIX_TIME
- return clock();
- #else
FILETIME creationTime, exitTime, kernelTime, userTime;
if (
#ifdef UNDER_CE
@@ -294,9 +324,18 @@ static UInt64 GetUserTime()
, &creationTime, &exitTime, &kernelTime, &userTime) != 0)
return GetTime64(userTime) + GetTime64(kernelTime);
return (UInt64)GetTickCount() * 10000;
- #endif
}
+struct CUserTime
+{
+ UInt64 StartTime;
+
+ void Init() { StartTime = GetWinUserTime(); }
+ UInt64 GetUserTime() { return GetWinUserTime() - StartTime; }
+};
+
+#endif
+
static UInt64 GetUserFreq()
{
#ifdef USE_POSIX_TIME
@@ -309,7 +348,7 @@ static UInt64 GetUserFreq()
class CBenchProgressStatus
{
#ifndef _7ZIP_ST
- NWindows::NSynchronization::CCriticalSection CS;
+ NSynchronization::CCriticalSection CS;
#endif
public:
HRESULT Res;
@@ -317,14 +356,14 @@ public:
void SetResult(HRESULT res)
{
#ifndef _7ZIP_ST
- NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ NSynchronization::CCriticalSectionLock lock(CS);
#endif
Res = res;
}
HRESULT GetResult()
{
#ifndef _7ZIP_ST
- NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ NSynchronization::CCriticalSectionLock lock(CS);
#endif
return Res;
}
@@ -337,27 +376,31 @@ class CBenchProgressInfo:
public:
CBenchProgressStatus *Status;
CBenchInfo BenchInfo;
+ CUserTime UserTime;
HRESULT Res;
- IBenchCallback *callback;
- CBenchProgressInfo(): callback(0) {}
+ IBenchCallback *Callback;
+
+ CBenchProgressInfo(): Callback(0) {}
+ void SetStartTime();
+ void SetFinishTime(CBenchInfo &dest);
MY_UNKNOWN_IMP
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
};
-static void SetStartTime(CBenchInfo &bi)
+void CBenchProgressInfo::SetStartTime()
{
- bi.GlobalFreq = GetFreq();
- bi.UserFreq = GetUserFreq();
- bi.GlobalTime = ::GetTimeCount();
- bi.UserTime = ::GetUserTime();
+ BenchInfo.GlobalFreq = GetFreq();
+ BenchInfo.UserFreq = GetUserFreq();
+ BenchInfo.GlobalTime = ::GetTimeCount();
+ BenchInfo.UserTime = 0;
+ UserTime.Init();
}
-static void SetFinishTime(const CBenchInfo &biStart, CBenchInfo &dest)
+void CBenchProgressInfo::SetFinishTime(CBenchInfo &dest)
{
- dest.GlobalFreq = GetFreq();
- dest.UserFreq = GetUserFreq();
- dest.GlobalTime = ::GetTimeCount() - biStart.GlobalTime;
- dest.UserTime = ::GetUserTime() - biStart.UserTime;
+ dest = BenchInfo;
+ dest.GlobalTime = ::GetTimeCount() - BenchInfo.GlobalTime;
+ dest.UserTime = UserTime.GetUserTime();
}
STDMETHODIMP CBenchProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
@@ -365,21 +408,21 @@ STDMETHODIMP CBenchProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64
HRESULT res = Status->GetResult();
if (res != S_OK)
return res;
- if (!callback)
+ if (!Callback)
return res;
- CBenchInfo info = BenchInfo;
- SetFinishTime(BenchInfo, info);
+ CBenchInfo info;
+ SetFinishTime(info);
if (Status->EncodeMode)
{
info.UnpackSize = *inSize;
info.PackSize = *outSize;
- res = callback->SetEncodeResult(info, false);
+ res = Callback->SetEncodeResult(info, false);
}
else
{
info.PackSize = BenchInfo.PackSize + *inSize;
info.UnpackSize = BenchInfo.UnpackSize + *outSize;
- res = callback->SetDecodeResult(info, false);
+ res = Callback->SetDecodeResult(info, false);
}
if (res != S_OK)
Status->SetResult(res);
@@ -406,12 +449,12 @@ static void NormalizeVals(UInt64 &v1, UInt64 &v2)
}
}
-UInt64 GetUsage(const CBenchInfo &info)
+UInt64 CBenchInfo::GetUsage() const
{
- UInt64 userTime = info.UserTime;
- UInt64 userFreq = info.UserFreq;
- UInt64 globalTime = info.GlobalTime;
- UInt64 globalFreq = info.GlobalFreq;
+ UInt64 userTime = UserTime;
+ UInt64 userFreq = UserFreq;
+ UInt64 globalTime = GlobalTime;
+ UInt64 globalFreq = GlobalFreq;
NormalizeVals(userTime, userFreq);
NormalizeVals(globalFreq, globalTime);
if (userFreq == 0)
@@ -421,19 +464,19 @@ UInt64 GetUsage(const CBenchInfo &info)
return userTime * globalFreq * 1000000 / userFreq / globalTime;
}
-UInt64 GetRatingPerUsage(const CBenchInfo &info, UInt64 rating)
+UInt64 CBenchInfo::GetRatingPerUsage(UInt64 rating) const
{
- UInt64 userTime = info.UserTime;
- UInt64 userFreq = info.UserFreq;
- UInt64 globalTime = info.GlobalTime;
- UInt64 globalFreq = info.GlobalFreq;
+ UInt64 userTime = UserTime;
+ UInt64 userFreq = UserFreq;
+ UInt64 globalTime = GlobalTime;
+ UInt64 globalFreq = GlobalFreq;
NormalizeVals(userFreq, userTime);
NormalizeVals(globalTime, globalFreq);
if (globalFreq == 0)
globalFreq = 1;
if (userTime == 0)
userTime = 1;
- return userFreq * globalTime / globalFreq * rating / userTime;
+ return userFreq * globalTime / globalFreq * rating / userTime;
}
static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
@@ -445,26 +488,74 @@ static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
return value * freq / elTime;
}
-UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 size)
+struct CBenchProps
+{
+ bool LzmaRatingMode;
+
+ UInt32 EncComplex;
+ UInt32 DecComplexCompr;
+ UInt32 DecComplexUnc;
+
+ CBenchProps(): LzmaRatingMode(false) {}
+ void SetLzmaCompexity();
+
+ UInt64 GeDecomprCommands(UInt64 packSize, UInt64 unpackSize)
+ {
+ return (packSize * DecComplexCompr + unpackSize * DecComplexUnc);
+ }
+
+ UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
+ UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations);
+};
+
+void CBenchProps::SetLzmaCompexity()
+{
+ DecComplexUnc = 4;
+ DecComplexCompr = 200;
+ LzmaRatingMode = true;
+}
+
+UInt64 CBenchProps::GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size)
{
- UInt64 t = GetLogSize(dictionarySize) - (kBenchMinDicLogSize << kSubBits);
- UInt64 numCommandsForOne = 870 + ((t * t * 5) >> (2 * kSubBits));
- UInt64 numCommands = (UInt64)(size) * numCommandsForOne;
+ if (dictSize < (1 << kBenchMinDicLogSize))
+ dictSize = (1 << kBenchMinDicLogSize);
+ UInt64 encComplex = EncComplex;
+ if (LzmaRatingMode)
+ {
+ UInt64 t = GetLogSize(dictSize) - (kBenchMinDicLogSize << kSubBits);
+ encComplex = 870 + ((t * t * 5) >> (2 * kSubBits));
+ }
+ UInt64 numCommands = (UInt64)size * encComplex;
return MyMultDiv64(numCommands, elapsedTime, freq);
}
-UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations)
+UInt64 CBenchProps::GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations)
{
- UInt64 numCommands = (inSize * 200 + outSize * 4) * numIterations;
+ UInt64 numCommands = (inSize * DecComplexCompr + outSize * DecComplexUnc) * numIterations;
return MyMultDiv64(numCommands, elapsedTime, freq);
}
+UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size)
+{
+ CBenchProps props;
+ props.SetLzmaCompexity();
+ return props.GetCompressRating(dictSize, elapsedTime, freq, size);
+}
+
+UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations)
+{
+ CBenchProps props;
+ props.SetLzmaCompexity();
+ return props.GetDecompressRating(elapsedTime, freq, outSize, inSize, numIterations);
+}
+
struct CEncoderInfo;
struct CEncoderInfo
{
#ifndef _7ZIP_ST
NWindows::CThread thread[2];
+ UInt32 NumDecoderSubThreads;
#endif
CMyComPtr<ICompressCoder> encoder;
CBenchProgressInfo *progressInfoSpec[2];
@@ -490,17 +581,22 @@ struct CEncoderInfo
CBenchmarkOutStream *outStreamSpec;
CMyComPtr<ISequentialOutStream> outStream;
IBenchCallback *callback;
+ IBenchPrintCallback *printCallback;
UInt32 crc;
UInt32 kBufferSize;
UInt32 compressedSize;
CBenchRandomGenerator rg;
CBenchmarkOutStream *propStreamSpec;
CMyComPtr<ISequentialOutStream> propStream;
- HRESULT Init(UInt32 dictionarySize, UInt32 numThreads, CBaseRandomGenerator *rg);
+ HRESULT Init(
+ const COneMethodInfo &method,
+ UInt32 uncompressedDataSize,
+ unsigned generateDictBits,
+ CBaseRandomGenerator *rg);
HRESULT Encode();
HRESULT Decode(UInt32 decoderIndex);
- CEncoderInfo(): outStreamSpec(0), callback(0), propStreamSpec(0) {}
+ CEncoderInfo(): outStreamSpec(0), callback(0), printCallback(0), propStreamSpec(0) {}
#ifndef _7ZIP_ST
static THREAD_FUNC_DECL EncodeThreadFunction(void *param)
@@ -550,14 +646,20 @@ struct CEncoderInfo
#endif
};
-HRESULT CEncoderInfo::Init(UInt32 dictionarySize, UInt32 numThreads, CBaseRandomGenerator *rgLoc)
+static const UInt32 k_LZMA = 0x030101;
+
+HRESULT CEncoderInfo::Init(
+ const COneMethodInfo &method,
+ UInt32 uncompressedDataSize,
+ unsigned generateDictBits,
+ CBaseRandomGenerator *rgLoc)
{
rg.Set(rgLoc);
- kBufferSize = dictionarySize + kAdditionalSize;
- UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
+ kBufferSize = uncompressedDataSize;
+ UInt32 kCompressedBufferSize = (kBufferSize - kBufferSize / 4) + kCompressedAdditionalSize;
if (!rg.Alloc(kBufferSize))
return E_OUTOFMEMORY;
- rg.Generate();
+ rg.Generate(generateDictBits);
crc = CrcCalc(rg.Buffer, rg.BufferSize);
outStreamSpec = new CBenchmarkOutStream;
@@ -576,31 +678,26 @@ HRESULT CEncoderInfo::Init(UInt32 dictionarySize, UInt32 numThreads, CBaseRandom
return E_OUTOFMEMORY;
propStreamSpec->Init();
- PROPID propIDs[] =
+
{
- NCoderPropID::kDictionarySize,
- NCoderPropID::kNumThreads
- };
- const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
- PROPVARIANT props[kNumProps];
- props[0].vt = VT_UI4;
- props[0].ulVal = dictionarySize;
-
- props[1].vt = VT_UI4;
- props[1].ulVal = numThreads;
+ CMyComPtr<ICompressSetCoderProperties> scp;
+ encoder.QueryInterface(IID_ICompressSetCoderProperties, &scp);
+ if (scp)
+ {
+ UInt64 reduceSize = uncompressedDataSize;
+ RINOK(method.SetCoderProps(scp, &reduceSize));
+ }
+ else
+ {
+ if (method.AreThereNonOptionalProps())
+ return E_FAIL;
+ }
- {
- CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
- RINOK(encoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties));
- if (!setCoderProperties)
- return E_FAIL;
- RINOK(setCoderProperties->SetCoderProperties(propIDs, props, kNumProps));
-
- CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
- encoder.QueryInterface(IID_ICompressWriteCoderProperties, &writeCoderProperties);
- if (writeCoderProperties)
+ CMyComPtr<ICompressWriteCoderProperties> writeCoderProps;
+ encoder.QueryInterface(IID_ICompressWriteCoderProperties, &writeCoderProps);
+ if (writeCoderProps)
{
- RINOK(writeCoderProperties->WriteCoderProperties(propStream));
+ RINOK(writeCoderProps->WriteCoderProperties(propStream));
}
}
return S_OK;
@@ -625,9 +722,9 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex)
CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
CMyComPtr<ICompressCoder> &decoder = decoders[decoderIndex];
- CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
- decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &compressSetDecoderProperties);
- if (!compressSetDecoderProperties)
+ CMyComPtr<ICompressSetDecoderProperties2> setDecProps;
+ decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecProps);
+ if (!setDecProps && propStreamSpec->Pos != 0)
return E_FAIL;
CCrcOutStream *crcOutStreamSpec = new CCrcOutStream;
@@ -637,12 +734,30 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex)
pi->BenchInfo.UnpackSize = 0;
pi->BenchInfo.PackSize = 0;
+ #ifndef _7ZIP_ST
+ {
+ CMyComPtr<ICompressSetCoderMt> setCoderMt;
+ decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
+ if (setCoderMt)
+ {
+ RINOK(setCoderMt->SetNumberOfThreads(NumDecoderSubThreads));
+ }
+ }
+ #endif
+
for (UInt32 j = 0; j < NumIterations; j++)
{
+ if (printCallback)
+ {
+ RINOK(printCallback->CheckBreak());
+ }
inStreamSpec->Init(outStreamSpec->Buffer, compressedSize);
crcOutStreamSpec->Init();
- RINOK(compressSetDecoderProperties->SetDecoderProperties2(propStreamSpec->Buffer, propStreamSpec->Pos));
+ if (setDecProps)
+ {
+ RINOK(setDecProps->SetDecoderProperties2(propStreamSpec->Buffer, propStreamSpec->Pos));
+ }
UInt64 outSize = kBufferSize;
RINOK(decoder->Code(inStream, crcOutStream, 0, &outSize, progressInfo[decoderIndex]));
if (CRC_GET_DIGEST(crcOutStreamSpec->Crc) != crc)
@@ -654,7 +769,7 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex)
return S_OK;
}
-static const UInt32 kNumThreadsMax = (1 << 16);
+static const UInt32 kNumThreadsMax = (1 << 12);
struct CBenchEncoders
{
@@ -663,44 +778,66 @@ struct CBenchEncoders
~CBenchEncoders() { delete []encoders; }
};
-HRESULT LzmaBench(
- DECL_EXTERNAL_CODECS_LOC_VARS
- UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback)
+static HRESULT MethodBench(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ bool oldLzmaBenchMode,
+ UInt32 numThreads,
+ const COneMethodInfo &method2,
+ UInt32 uncompressedDataSize,
+ unsigned generateDictBits,
+ IBenchPrintCallback *printCallback,
+ IBenchCallback *callback,
+ CBenchProps *benchProps)
{
- UInt32 numEncoderThreads =
- #ifndef _7ZIP_ST
- (numThreads > 1 ? numThreads / 2 : 1);
- #else
- 1;
- #endif
- UInt32 numSubDecoderThreads =
- #ifndef _7ZIP_ST
- (numThreads > 1 ? 2 : 1);
- #else
- 1;
- #endif
- if (dictionarySize < (1 << kBenchMinDicLogSize) || numThreads < 1 || numEncoderThreads > kNumThreadsMax)
- {
+ COneMethodInfo method = method2;
+ UInt64 methodId;
+ UInt32 numInStreams, numOutStreams;
+ if (!FindMethod(
+ EXTERNAL_CODECS_LOC_VARS
+ method.MethodName, methodId, numInStreams, numOutStreams))
+ return E_NOTIMPL;
+ if (numInStreams != 1 || numOutStreams != 1)
+ return E_INVALIDARG;
+
+ UInt32 numEncoderThreads = 1;
+ UInt32 numSubDecoderThreads = 1;
+
+ #ifndef _7ZIP_ST
+ numEncoderThreads = numThreads;
+
+ if (oldLzmaBenchMode && methodId == k_LZMA)
+ {
+ bool fixedNumber;
+ UInt32 numLzmaThreads = method.Get_Lzma_NumThreads(fixedNumber);
+ if (!fixedNumber && numThreads == 1)
+ method.AddNumThreadsProp(1);
+ if (numThreads > 1 && numLzmaThreads > 1)
+ {
+ numEncoderThreads = numThreads / 2;
+ numSubDecoderThreads = 2;
+ }
+ }
+ #endif
+
+ if (numThreads < 1 || numEncoderThreads > kNumThreadsMax)
return E_INVALIDARG;
- }
CBenchEncoders encodersSpec(numEncoderThreads);
CEncoderInfo *encoders = encodersSpec.encoders;
-
UInt32 i;
for (i = 0; i < numEncoderThreads; i++)
{
CEncoderInfo &encoder = encoders[i];
encoder.callback = (i == 0) ? callback : 0;
+ encoder.printCallback = printCallback;
- const UInt32 kLzmaId = 0x030101;
- RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS kLzmaId, encoder.encoder, true));
+ RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS methodId, encoder.encoder, true));
if (!encoder.encoder)
return E_NOTIMPL;
for (UInt32 j = 0; j < numSubDecoderThreads; j++)
{
- RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS kLzmaId, encoder.decoders[j], false));
+ RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS methodId, encoder.decoders[j], false));
if (!encoder.decoders[j])
return E_NOTIMPL;
}
@@ -710,7 +847,7 @@ HRESULT LzmaBench(
rg.Init();
for (i = 0; i < numEncoderThreads; i++)
{
- RINOK(encoders[i].Init(dictionarySize, numThreads, &rg));
+ RINOK(encoders[i].Init(method, uncompressedDataSize, generateDictBits, &rg));
}
CBenchProgressStatus status;
@@ -727,9 +864,10 @@ HRESULT LzmaBench(
}
if (i == 0)
{
- encoder.progressInfoSpec[0]->callback = callback;
- encoder.progressInfoSpec[0]->BenchInfo.NumIterations = numEncoderThreads;
- SetStartTime(encoder.progressInfoSpec[0]->BenchInfo);
+ CBenchProgressInfo *bpi = encoder.progressInfoSpec[0];
+ bpi->Callback = callback;
+ bpi->BenchInfo.NumIterations = numEncoderThreads;
+ bpi->SetStartTime();
}
#ifndef _7ZIP_ST
@@ -756,7 +894,7 @@ HRESULT LzmaBench(
CBenchInfo info;
- SetFinishTime(encoders[0].progressInfoSpec[0]->BenchInfo, info);
+ encoders[0].progressInfoSpec[0]->SetFinishTime(info);
info.UnpackSize = 0;
info.PackSize = 0;
info.NumIterations = 1; // progressInfoSpec->NumIterations;
@@ -776,16 +914,24 @@ HRESULT LzmaBench(
for (i = 0; i < numEncoderThreads; i++)
{
CEncoderInfo &encoder = encoders[i];
- encoder.NumIterations = 2 + kUncompressMinBlockSize / encoder.kBufferSize;
if (i == 0)
{
- encoder.progressInfoSpec[0]->callback = callback;
- encoder.progressInfoSpec[0]->BenchInfo.NumIterations = numDecoderThreads;
- SetStartTime(encoder.progressInfoSpec[0]->BenchInfo);
+ encoder.NumIterations = (UInt32)(1 + kUncompressMinBlockSize /
+ benchProps->GeDecomprCommands(encoder.compressedSize, encoder.kBufferSize));
+ CBenchProgressInfo *bpi = encoder.progressInfoSpec[0];
+ bpi->Callback = callback;
+ bpi->BenchInfo.NumIterations = numDecoderThreads;
+ bpi->SetStartTime();
}
+ else
+ encoder.NumIterations = encoders[0].NumIterations;
#ifndef _7ZIP_ST
+ {
+ int numSubThreads = method.Get_NumThreads();
+ encoder.NumDecoderSubThreads = (numSubThreads <= 0) ? 1 : numSubThreads;
+ }
if (numDecoderThreads > 1)
{
for (UInt32 j = 0; j < numSubDecoderThreads; j++)
@@ -818,7 +964,7 @@ HRESULT LzmaBench(
RINOK(res);
#endif
RINOK(status.Res);
- SetFinishTime(encoders[0].progressInfoSpec[0]->BenchInfo, info);
+ encoders[0].progressInfoSpec[0]->SetFinishTime(info);
#ifndef _7ZIP_ST
#ifdef UNDER_CE
if (numDecoderThreads > 1)
@@ -966,7 +1112,7 @@ bool CrcInternalTest()
return true;
}
-HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed)
+static HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed)
{
if (numThreads == 0)
numThreads = 1;
@@ -1026,3 +1172,462 @@ HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed)
speed = MyMultDiv64(size, timeVal, GetFreq());
return S_OK;
}
+
+struct CBenchMethod
+{
+ unsigned dictBits;
+ UInt32 EncComplex;
+ UInt32 DecComplexCompr;
+ UInt32 DecComplexUnc;
+ const char *Name;
+};
+
+static const CBenchMethod g_Bench[] =
+{
+ { 17, 340, 155, 20, "LZMA:x1" },
+ { 24, 1182, 155, 20, "LZMA:x5:mt1" },
+ { 24, 1182, 155, 20, "LZMA:x5:mt2" },
+ { 16, 124, 47, 14, "Deflate:x1" },
+ { 16, 376, 47, 14, "Deflate:x5" },
+ { 16, 1084, 47, 14, "Deflate:x7" },
+ { 17, 420, 47, 14, "Deflate64:x5" },
+ { 15, 590, 69, 70, "BZip2:x1" },
+ { 19, 792, 119, 119, "BZip2:x5" },
+ #ifndef UNDER_CE
+ { 19, 792, 119, 119, "BZip2:x5:mt2" },
+ #endif
+ { 19, 2500, 118, 118, "BZip2:x7" },
+ { 18, 1010, 0, 1155, "PPMD:x1" },
+ { 22, 1650, 0, 1830, "PPMD:x5" }
+};
+
+struct CTotalBenchRes
+{
+ UInt64 NumIterations;
+ UInt64 Rating;
+ UInt64 Usage;
+ UInt64 RPU;
+ void Init() { NumIterations = 0; Rating = 0; Usage = 0; RPU = 0; }
+ void Normalize()
+ {
+ if (NumIterations == 0)
+ return;
+ Rating /= NumIterations;
+ Usage /= NumIterations;
+ RPU /= NumIterations;
+ NumIterations = 1;
+ }
+ void SetMid(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
+ {
+ Rating = (r1.Rating + r2.Rating) / 2;
+ Usage = (r1.Usage + r2.Usage) / 2;
+ RPU = (r1.RPU + r2.RPU) / 2;
+ NumIterations = (r1.NumIterations + r2.NumIterations) / 2;
+ }
+};
+
+static void PrintNumber(IBenchPrintCallback &f, UInt64 value, int size, bool withSpace = true)
+{
+ char s[128];
+ int startPos = (int)sizeof(s) - 32;
+ memset(s, ' ', startPos);
+ ConvertUInt64ToString(value, s + startPos);
+ if (withSpace)
+ {
+ startPos--;
+ size++;
+ }
+ int len = (int)strlen(s + startPos);
+ if (size > len)
+ {
+ startPos -= (size - len);
+ if (startPos < 0)
+ startPos = 0;
+ }
+ f.Print(s + startPos);
+}
+
+static void PrintRating(IBenchPrintCallback &f, UInt64 rating)
+{
+ PrintNumber(f, rating / 1000000, 6);
+}
+
+static void PrintResults(IBenchPrintCallback &f, UInt64 usage, UInt64 rpu, UInt64 rating)
+{
+ PrintNumber(f, (usage + 5000) / 10000, 5);
+ PrintRating(f, rpu);
+ PrintRating(f, rating);
+}
+
+static void PrintResults(IBenchPrintCallback &f, const CBenchInfo &info, UInt64 rating, CTotalBenchRes &res)
+{
+ UInt64 speed = MyMultDiv64(info.UnpackSize, info.GlobalTime, info.GlobalFreq);
+ PrintNumber(f, speed / 1024, 7);
+ UInt64 usage = info.GetUsage();
+ UInt64 rpu = info.GetRatingPerUsage(rating);
+ PrintResults(f, usage, rpu, rating);
+ res.NumIterations++;
+ res.RPU += rpu;
+ res.Rating += rating;
+ res.Usage += usage;
+}
+
+static void PrintTotals(IBenchPrintCallback &f, const CTotalBenchRes &res)
+{
+ f.Print(" ");
+ PrintResults(f, res.Usage, res.RPU, res.Rating);
+}
+
+static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
+{
+ f.Print("RAM ");
+ f.Print(sizeString);
+ PrintNumber(f, (size >> 20), 5, true);
+ f.Print(" MB, # ");
+ f.Print(threadsString);
+ PrintNumber(f, numThreads, 3, true);
+ f.NewLine();
+}
+
+struct CBenchCallbackToPrint: public IBenchCallback
+{
+ CBenchProps BenchProps;
+ CTotalBenchRes EncodeRes;
+ CTotalBenchRes DecodeRes;
+ IBenchPrintCallback *_file;
+ UInt32 DictSize;
+
+ void Init() { EncodeRes.Init(); DecodeRes.Init(); }
+ void Normalize() { EncodeRes.Normalize(); DecodeRes.Normalize(); }
+ HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
+ HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
+ void Print(const char *string);
+ void NewLine();
+ void PrintLeftAligned(const char *string, unsigned size);
+};
+
+HRESULT CBenchCallbackToPrint::SetEncodeResult(const CBenchInfo &info, bool final)
+{
+ RINOK(_file->CheckBreak());
+ if (final)
+ {
+ UInt64 rating = BenchProps.GetCompressRating(DictSize, info.GlobalTime, info.GlobalFreq, info.UnpackSize);
+ PrintResults(*_file, info, rating, EncodeRes);
+ }
+ return S_OK;
+}
+
+static const char *kSep = " | ";
+
+
+HRESULT CBenchCallbackToPrint::SetDecodeResult(const CBenchInfo &info, bool final)
+{
+ RINOK(_file->CheckBreak());
+ if (final)
+ {
+ UInt64 rating = BenchProps.GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
+ _file->Print(kSep);
+ CBenchInfo info2 = info;
+ info2.UnpackSize *= info2.NumIterations;
+ info2.PackSize *= info2.NumIterations;
+ info2.NumIterations = 1;
+ PrintResults(*_file, info2, rating, DecodeRes);
+ }
+ return S_OK;
+}
+
+void CBenchCallbackToPrint::Print(const char *s)
+{
+ _file->Print(s);
+}
+
+void CBenchCallbackToPrint::NewLine()
+{
+ _file->NewLine();
+}
+
+void CBenchCallbackToPrint::PrintLeftAligned(const char *s, unsigned size)
+{
+ AString s2 = s;
+ for (unsigned len = (unsigned)strlen(s); len < size; len++)
+ s2 += ' ';
+ Print(s2);
+}
+
+static HRESULT TotalBench(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ UInt32 numThreads, UInt32 unpackSize, IBenchPrintCallback *printCallback, CBenchCallbackToPrint *callback)
+{
+ for (unsigned i = 0; i < sizeof(g_Bench) / sizeof(g_Bench[0]); i++)
+ {
+ CBenchMethod bench = g_Bench[i];
+ callback->PrintLeftAligned(bench.Name, 12);
+ callback->BenchProps.DecComplexUnc = bench.DecComplexUnc;
+ callback->BenchProps.DecComplexCompr = bench.DecComplexCompr;
+ callback->BenchProps.EncComplex = bench.EncComplex;
+ COneMethodInfo method;
+ NCOM::CPropVariant propVariant;
+ propVariant = bench.Name;
+ RINOK(method.ParseMethodFromPROPVARIANT(L"", propVariant));
+
+ HRESULT res = MethodBench(
+ EXTERNAL_CODECS_LOC_VARS
+ false, numThreads, method, unpackSize, bench.dictBits,
+ printCallback, callback, &callback->BenchProps);
+ if (res == E_NOTIMPL)
+ callback->Print(" ---");
+ else
+ {
+ RINOK(res);
+ }
+ callback->NewLine();
+ }
+ return S_OK;
+}
+
+struct CTempValues
+{
+ UInt64 *Values;
+ CTempValues(UInt32 num) { Values = new UInt64[num]; }
+ ~CTempValues() { delete []Values; }
+};
+
+static void String_to_PropVariant(const UString &s, NCOM::CPropVariant &prop)
+{
+ const wchar_t *endPtr;
+ UInt64 result = ConvertStringToUInt64(s, &endPtr);
+ if (endPtr - (const wchar_t *)s != s.Length())
+ prop = s;
+ else if (result <= 0xFFFFFFFF)
+ prop = (UInt32)result;
+ else
+ prop = result;
+}
+
+HRESULT Bench(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IBenchPrintCallback *printCallback,
+ IBenchCallback *benchCallback,
+ const CObjectVector<CProperty> props,
+ UInt32 numIterations,
+ bool multiDict)
+{
+ if (!CrcInternalTest())
+ return S_FALSE;
+
+ UInt32 numCPUs = 1;
+ UInt64 ramSize = (UInt64)512 << 20;
+ #ifndef _7ZIP_ST
+ numCPUs = NSystem::GetNumberOfProcessors();
+ #endif
+ #if !defined(_7ZIP_ST) || defined(_WIN32)
+ ramSize = NSystem::GetRamSize();
+ #endif
+ UInt32 numThreads = numCPUs;
+
+ if (printCallback)
+ PrintRequirements(*printCallback, "size: ", ramSize, "CPU hardware threads:", numCPUs);
+
+ COneMethodInfo method;
+ int i;
+ for (i = 0; i < props.Size(); i++)
+ {
+ const CProperty &property = props[i];
+ NCOM::CPropVariant propVariant;
+ UString name = property.Name;
+ name.MakeUpper();
+ if (!property.Value.IsEmpty())
+ String_to_PropVariant(property.Value, propVariant);
+ if (name.Left(2).CompareNoCase(L"MT") == 0)
+ {
+ #ifndef _7ZIP_ST
+ RINOK(ParseMtProp(name.Mid(2), propVariant, numCPUs, numThreads));
+ #endif
+ continue;
+ }
+ RINOK(method.ParseMethodFromPROPVARIANT(name, propVariant));
+ }
+
+ UInt32 dict;
+ bool dictIsDefined = method.Get_DicSize(dict);
+
+ if (method.MethodName.IsEmpty())
+ method.MethodName = L"LZMA";
+
+ if (benchCallback)
+ {
+ CBenchProps benchProps;
+ benchProps.SetLzmaCompexity();
+ UInt32 dictSize = method.Get_Lzma_DicSize();
+ UInt32 uncompressedDataSize = kAdditionalSize + dictSize;
+ return MethodBench(
+ EXTERNAL_CODECS_LOC_VARS
+ true, numThreads,
+ method, uncompressedDataSize,
+ kOldLzmaDictBits, printCallback, benchCallback, &benchProps);
+ }
+
+ if (method.MethodName.CompareNoCase(L"CRC") == 0)
+ {
+ if (!printCallback)
+ return S_FALSE;
+ IBenchPrintCallback &f = *printCallback;
+ if (!dictIsDefined)
+ dict = (1 << 24);
+
+ CTempValues speedTotals(numThreads);
+ f.NewLine();
+ f.Print("Size");
+ for (UInt32 ti = 0; ti < numThreads; ti++)
+ {
+ PrintNumber(f, ti + 1, 5);
+ speedTotals.Values[ti] = 0;
+ }
+ f.NewLine();
+ f.NewLine();
+
+ UInt64 numSteps = 0;
+ for (UInt32 i = 0; i < numIterations; i++)
+ {
+ for (int pow = 10; pow < 32; pow++)
+ {
+ UInt32 bufSize = (UInt32)1 << pow;
+ if (bufSize > dict)
+ break;
+ PrintNumber(f, pow, 2, false);
+ f.Print(": ");
+ for (UInt32 ti = 0; ti < numThreads; ti++)
+ {
+ RINOK(f.CheckBreak());
+ UInt64 speed;
+ RINOK(CrcBench(ti + 1, bufSize, speed));
+ PrintNumber(f, (speed >> 20), 5);
+ speedTotals.Values[ti] += speed;
+ }
+ f.NewLine();
+ numSteps++;
+ }
+ }
+ if (numSteps != 0)
+ {
+ f.NewLine();
+ f.Print("Avg:");
+ for (UInt32 ti = 0; ti < numThreads; ti++)
+ PrintNumber(f, ((speedTotals.Values[ti] / numSteps) >> 20), 5);
+ f.NewLine();
+ }
+ return S_OK;
+ }
+
+ CBenchCallbackToPrint callback;
+ callback.Init();
+ callback._file = printCallback;
+
+ if (!dictIsDefined)
+ {
+ int dicSizeLog;
+ for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
+ if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
+ break;
+ dict = (1 << dicSizeLog);
+ }
+
+ IBenchPrintCallback &f = *printCallback;
+ PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dict), "Benchmark threads: ", numThreads);
+
+ bool totalBenchMode = (method.MethodName == L"*");
+ f.NewLine();
+ f.Print(totalBenchMode ? "Method " : "Dict");
+ f.Print(" Compressing | Decompressing");
+ f.NewLine();
+ const char *kSpaces = totalBenchMode ? " " : " ";
+ f.Print(kSpaces);
+ int j;
+
+ for (j = 0; j < 2; j++)
+ {
+ f.Print(" Speed Usage R/U Rating");
+ if (j == 0)
+ f.Print(kSep);
+ }
+ f.NewLine();
+ f.Print(kSpaces);
+ for (j = 0; j < 2; j++)
+ {
+ f.Print(" KB/s % MIPS MIPS");
+ if (j == 0)
+ f.Print(kSep);
+ }
+ f.NewLine();
+ f.NewLine();
+
+ if (totalBenchMode)
+ {
+ if (!dictIsDefined)
+ dict =
+ #ifdef UNDER_CE
+ (UInt64)1 << 20;
+ #else
+ (UInt64)1 << 24;
+ #endif
+ for (UInt32 i = 0; i < numIterations; i++)
+ {
+ if (i != 0)
+ printCallback->NewLine();
+ HRESULT res = TotalBench(
+ EXTERNAL_CODECS_LOC_VARS
+ numThreads, dict, printCallback, &callback);
+ RINOK(res);
+ }
+ }
+ else
+ {
+
+ callback.BenchProps.SetLzmaCompexity();
+
+ for (i = 0; i < (int)numIterations; i++)
+ {
+ const int kStartDicLog = 22;
+ int pow = (dict < ((UInt32)1 << kStartDicLog)) ? kBenchMinDicLogSize : kStartDicLog;
+ if (!multiDict)
+ pow = 31;
+ while (((UInt32)1 << pow) > dict)
+ pow--;
+ for (; ((UInt32)1 << pow) <= dict; pow++)
+ {
+ PrintNumber(f, pow, 2, false);
+ f.Print(":");
+ callback.DictSize = (UInt32)1 << pow;
+
+ UInt32 uncompressedDataSize = kAdditionalSize + callback.DictSize;
+
+ HRESULT res = MethodBench(
+ EXTERNAL_CODECS_LOC_VARS
+ true, numThreads,
+ method, uncompressedDataSize,
+ kOldLzmaDictBits, printCallback, &callback, &callback.BenchProps);
+ f.NewLine();
+ RINOK(res);
+ if (!multiDict)
+ break;
+ }
+ }
+ }
+ callback.Normalize();
+ f.Print("----------------------------------------------------------------");
+ f.NewLine();
+ f.Print("Avr:");
+ const char *kSpaces2 = totalBenchMode ? " " : "";
+ f.Print(kSpaces2);
+ PrintTotals(f, callback.EncodeRes);
+ f.Print(" ");
+ PrintTotals(f, callback.DecodeRes);
+ f.NewLine();
+ f.Print("Tot:");
+ f.Print(kSpaces2);
+ CTotalBenchRes midRes;
+ midRes.SetMid(callback.EncodeRes, callback.DecodeRes);
+ PrintTotals(f, midRes);
+ f.NewLine();
+ return S_OK;
+}
diff --git a/CPP/7zip/UI/Common/Bench.h b/CPP/7zip/UI/Common/Bench.h
index a8d02a19..46146e24 100755
--- a/CPP/7zip/UI/Common/Bench.h
+++ b/CPP/7zip/UI/Common/Bench.h
@@ -4,6 +4,7 @@
#define __7ZIP_BENCH_H
#include "../../Common/CreateCoder.h"
+#include "../../UI/Common/Property.h"
struct CBenchInfo
{
@@ -14,7 +15,10 @@ struct CBenchInfo
UInt64 UnpackSize;
UInt64 PackSize;
UInt32 NumIterations;
+
CBenchInfo(): NumIterations(0) {}
+ UInt64 GetUsage() const;
+ UInt64 GetRatingPerUsage(UInt64 rating) const;
};
struct IBenchCallback
@@ -23,20 +27,27 @@ struct IBenchCallback
virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0;
};
-UInt64 GetUsage(const CBenchInfo &benchOnfo);
-UInt64 GetRatingPerUsage(const CBenchInfo &info, UInt64 rating);
-UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
+UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations);
-HRESULT LzmaBench(
- DECL_EXTERNAL_CODECS_LOC_VARS
- UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback);
-
const int kBenchMinDicLogSize = 18;
UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary);
-bool CrcInternalTest();
-HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed);
+struct IBenchPrintCallback
+{
+ virtual void Print(const char *s) = 0;
+ virtual void NewLine() = 0;
+ virtual HRESULT CheckBreak() = 0;
+};
+
+HRESULT Bench(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ IBenchPrintCallback *printCallback,
+ IBenchCallback *benchCallback,
+ const CObjectVector<CProperty> props,
+ UInt32 numIterations,
+ bool multiDict
+ );
#endif
diff --git a/CPP/7zip/UI/Common/CompressCall.cpp b/CPP/7zip/UI/Common/CompressCall.cpp
index c2685f79..eb20d5cc 100755
--- a/CPP/7zip/UI/Common/CompressCall.cpp
+++ b/CPP/7zip/UI/Common/CompressCall.cpp
@@ -7,12 +7,13 @@
#include "Common/Random.h"
#include "Common/StringConvert.h"
+#include "Windows/DLL.h"
+#include "Windows/Error.h"
#include "Windows/FileDir.h"
#include "Windows/FileMapping.h"
#include "Windows/Process.h"
#include "Windows/Synchronization.h"
-#include "../FileManager/ProgramLocation.h"
#include "../FileManager/RegistryUtils.h"
#include "CompressCall.h"
@@ -31,10 +32,13 @@ static LPCWSTR kArcIncludeSwitches = L" -an -ai";
static LPCWSTR kStopSwitchParsing = L" --";
static LPCWSTR kLargePagesDisable = L" -slp-";
+extern HWND g_HWND;
+
UString GetQuotedString(const UString &s)
{
return UString(L'\"') + s + UString(L'\"');
}
+
static void ErrorMessage(LPCWSTR message)
{
MessageBoxW(g_HWND, message, L"7-Zip", MB_ICONERROR | MB_OK);
@@ -42,7 +46,7 @@ static void ErrorMessage(LPCWSTR message)
static void ErrorMessageHRESULT(HRESULT res, LPCWSTR s = NULL)
{
- UString s2 = HResultToMessage(res);
+ UString s2 = NError::MyFormatMessageW(res);
if (s)
{
s2 += L'\n';
@@ -80,9 +84,7 @@ static void AddLagePagesSwitch(UString &params)
static UString Get7zGuiPath()
{
- UString path;
- GetProgramFolderPath(path);
- return path + L"7zG.exe";
+ return fs2us(NWindows::NDLL::GetModuleDirPrefix()) + L"7zG.exe";
}
class CRandNameGenerator
@@ -238,9 +240,9 @@ HRESULT TestArchives(const UStringVector &arcPaths)
MY_TRY_FINISH
}
-HRESULT Benchmark()
+HRESULT Benchmark(bool totalMode)
{
MY_TRY_BEGIN
- return MyCreateProcess(Get7zGuiPath(), L'b', 0, false, NULL);
+ return MyCreateProcess(Get7zGuiPath(), totalMode ? L"b -mm=*" : L"b", 0, false, NULL);
MY_TRY_FINISH
}
diff --git a/CPP/7zip/UI/Common/CompressCall.h b/CPP/7zip/UI/Common/CompressCall.h
index fc18df57..f777b9f2 100755
--- a/CPP/7zip/UI/Common/CompressCall.h
+++ b/CPP/7zip/UI/Common/CompressCall.h
@@ -7,9 +7,6 @@
UString GetQuotedString(const UString &s);
-extern HWND g_HWND;
-UString HResultToMessage(HRESULT errorCode);
-
HRESULT CompressFiles(
const UString &arcPathPrefix,
const UString &arcName,
@@ -19,6 +16,6 @@ HRESULT CompressFiles(
HRESULT ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog);
HRESULT TestArchives(const UStringVector &arcPaths);
-HRESULT Benchmark();
+HRESULT Benchmark(bool totalMode);
#endif
diff --git a/CPP/7zip/UI/Common/CompressCall2.cpp b/CPP/7zip/UI/Common/CompressCall2.cpp
index 473f7d93..ab483d2f 100755
--- a/CPP/7zip/UI/Common/CompressCall2.cpp
+++ b/CPP/7zip/UI/Common/CompressCall2.cpp
@@ -14,6 +14,8 @@
#include "CompressCall.h"
+extern HWND g_HWND;
+
#define MY_TRY_BEGIN try {
#define MY_TRY_FINISH } \
catch(CSystemException &e) { result = e.ErrorCode; } \
@@ -110,7 +112,7 @@ static HRESULT ExtractGroupCommand(const UStringVector &arcPaths,
CREATE_CODECS
CExtractOptions eo;
- eo.OutputDir = outFolder;
+ eo.OutputDir = us2fs(outFolder);
eo.TestMode = testMode;
CExtractCallbackImp *ecs = new CExtractCallbackImp;
@@ -158,7 +160,7 @@ HRESULT TestArchives(const UStringVector &arcPaths)
return ExtractGroupCommand(arcPaths, true, UString(), true);
}
-HRESULT Benchmark()
+HRESULT Benchmark(bool totalMode)
{
HRESULT result;
MY_TRY_BEGIN
@@ -168,11 +170,19 @@ HRESULT Benchmark()
CObjectVector<CCodecInfoEx> externalCodecs;
RINOK(LoadExternalCodecs(codecs, externalCodecs));
#endif
+ CObjectVector<CProperty> props;
+ if (totalMode)
+ {
+ CProperty prop;
+ prop.Name = L"m";
+ prop.Value = L"*";
+ props.Add(prop);
+ }
result = Benchmark(
#ifdef EXTERNAL_CODECS
codecs, &externalCodecs,
#endif
- (UInt32)-1, (UInt32)-1, g_HWND);
+ props, g_HWND);
MY_TRY_FINISH
return result;
}
diff --git a/CPP/7zip/UI/Common/DirItem.h b/CPP/7zip/UI/Common/DirItem.h
index 29cc60d9..6d6dc673 100755
--- a/CPP/7zip/UI/Common/DirItem.h
+++ b/CPP/7zip/UI/Common/DirItem.h
@@ -39,14 +39,14 @@ public:
int AddPrefix(int phyParent, int logParent, const UString &prefix);
void DeleteLastPrefix();
- void EnumerateDirectory(int phyParent, int logParent, const UString &phyPrefix,
- UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
+ void EnumerateDirectory(int phyParent, int logParent, const FString &phyPrefix,
+ FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
void EnumerateDirItems2(
- const UString &phyPrefix,
+ const FString &phyPrefix,
const UString &logPrefix,
- const UStringVector &filePaths,
- UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
+ const FStringVector &filePaths,
+ FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
void ReserveDown();
};
diff --git a/CPP/7zip/UI/Common/EnumDirItems.cpp b/CPP/7zip/UI/Common/EnumDirItems.cpp
index ba03ea35..8c83a9fb 100755
--- a/CPP/7zip/UI/Common/EnumDirItems.cpp
+++ b/CPP/7zip/UI/Common/EnumDirItems.cpp
@@ -2,6 +2,8 @@
#include "StdAfx.h"
+#include "Windows/FileName.h"
+
#include "EnumDirItems.h"
using namespace NWindows;
@@ -9,7 +11,7 @@ using namespace NFile;
using namespace NName;
void AddDirFileInfo(int phyParent, int logParent,
- const NFind::CFileInfoW &fi, CObjectVector<CDirItem> &dirItems)
+ const NFind::CFileInfo &fi, CObjectVector<CDirItem> &dirItems)
{
CDirItem di;
di.Size = fi.Size;
@@ -19,7 +21,7 @@ void AddDirFileInfo(int phyParent, int logParent,
di.Attrib = fi.Attrib;
di.PhyParent = phyParent;
di.LogParent = logParent;
- di.Name = fi.Name;
+ di.Name = fs2us(fi.Name);
dirItems.Add(di);
}
@@ -79,13 +81,13 @@ void CDirItems::DeleteLastPrefix()
Prefixes.DeleteBack();
}
-void CDirItems::EnumerateDirectory(int phyParent, int logParent, const UString &phyPrefix,
- UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
+void CDirItems::EnumerateDirectory(int phyParent, int logParent, const FString &phyPrefix,
+ FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
{
- NFind::CEnumeratorW enumerator(phyPrefix + (wchar_t)kAnyStringWildcard);
+ NFind::CEnumerator enumerator(phyPrefix + FCHAR_ANY_MASK);
for (;;)
{
- NFind::CFileInfoW fi;
+ NFind::CFileInfo fi;
bool found;
if (!enumerator.Next(fi, found))
{
@@ -98,43 +100,43 @@ void CDirItems::EnumerateDirectory(int phyParent, int logParent, const UString &
AddDirFileInfo(phyParent, logParent, fi, Items);
if (fi.IsDir())
{
- const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
- int parent = AddPrefix(phyParent, logParent, name2);
+ const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR;
+ int parent = AddPrefix(phyParent, logParent, fs2us(name2));
EnumerateDirectory(parent, parent, phyPrefix + name2, errorPaths, errorCodes);
}
}
}
-void CDirItems::EnumerateDirItems2(const UString &phyPrefix, const UString &logPrefix,
- const UStringVector &filePaths, UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
+void CDirItems::EnumerateDirItems2(const FString &phyPrefix, const UString &logPrefix,
+ const FStringVector &filePaths, FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
{
- int phyParent = phyPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, phyPrefix);
+ int phyParent = phyPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, fs2us(phyPrefix));
int logParent = logPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, logPrefix);
for (int i = 0; i < filePaths.Size(); i++)
{
- const UString &filePath = filePaths[i];
- NFind::CFileInfoW fi;
- const UString phyPath = phyPrefix + filePath;
+ const FString &filePath = filePaths[i];
+ NFind::CFileInfo fi;
+ const FString phyPath = phyPrefix + filePath;
if (!fi.Find(phyPath))
{
errorCodes.Add(::GetLastError());
errorPaths.Add(phyPath);
continue;
}
- int delimiter = filePath.ReverseFind((wchar_t)kDirDelimiter);
- UString phyPrefixCur;
+ int delimiter = filePath.ReverseFind(FCHAR_PATH_SEPARATOR);
+ FString phyPrefixCur;
int phyParentCur = phyParent;
if (delimiter >= 0)
{
phyPrefixCur = filePath.Left(delimiter + 1);
- phyParentCur = AddPrefix(phyParent, logParent, phyPrefixCur);
+ phyParentCur = AddPrefix(phyParent, logParent, fs2us(phyPrefixCur));
}
AddDirFileInfo(phyParentCur, logParent, fi, Items);
if (fi.IsDir())
{
- const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
- int parent = AddPrefix(phyParentCur, logParent, name2);
+ const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR;
+ int parent = AddPrefix(phyParentCur, logParent, fs2us(name2));
EnumerateDirectory(parent, parent, phyPrefix + phyPrefixCur + name2, errorPaths, errorCodes);
}
}
@@ -142,27 +144,27 @@ void CDirItems::EnumerateDirItems2(const UString &phyPrefix, const UString &logP
}
static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
- int phyParent, int logParent, const UString &phyPrefix,
+ int phyParent, int logParent, const FString &phyPrefix,
const UStringVector &addArchivePrefix,
CDirItems &dirItems,
bool enterToSubFolders,
IEnumDirItemCallback *callback,
- UStringVector &errorPaths,
+ FStringVector &errorPaths,
CRecordVector<DWORD> &errorCodes);
static HRESULT EnumerateDirItems_Spec(const NWildcard::CCensorNode &curNode,
- int phyParent, int logParent, const UString &curFolderName,
- const UString &phyPrefix,
+ int phyParent, int logParent, const FString &curFolderName,
+ const FString &phyPrefix,
const UStringVector &addArchivePrefix,
CDirItems &dirItems,
bool enterToSubFolders,
IEnumDirItemCallback *callback,
- UStringVector &errorPaths,
+ FStringVector &errorPaths,
CRecordVector<DWORD> &errorCodes)
{
- const UString name2 = curFolderName + (wchar_t)kDirDelimiter;
- int parent = dirItems.AddPrefix(phyParent, logParent, name2);
+ const FString name2 = curFolderName + FCHAR_PATH_SEPARATOR;
+ int parent = dirItems.AddPrefix(phyParent, logParent, fs2us(name2));
int numItems = dirItems.Items.Size();
HRESULT res = EnumerateDirItems(curNode, parent, parent, phyPrefix + name2,
addArchivePrefix, dirItems, enterToSubFolders, callback, errorPaths, errorCodes);
@@ -173,19 +175,19 @@ static HRESULT EnumerateDirItems_Spec(const NWildcard::CCensorNode &curNode,
static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
- int phyParent, int logParent, const UString &phyPrefix,
+ int phyParent, int logParent, const FString &phyPrefix,
const UStringVector &addArchivePrefix, // prefix from curNode
CDirItems &dirItems,
bool enterToSubFolders,
IEnumDirItemCallback *callback,
- UStringVector &errorPaths,
+ FStringVector &errorPaths,
CRecordVector<DWORD> &errorCodes)
{
if (!enterToSubFolders)
if (curNode.NeedCheckSubDirs())
enterToSubFolders = true;
if (callback)
- RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), phyPrefix));
+ RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), fs2us(phyPrefix)));
// try direct_names case at first
if (addArchivePrefix.IsEmpty() && !enterToSubFolders)
@@ -210,8 +212,8 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
{
const NWildcard::CItem &item = curNode.IncludeItems[i];
const UString &name = item.PathParts.Front();
- const UString fullPath = phyPrefix + name;
- NFind::CFileInfoW fi;
+ const FString fullPath = phyPrefix + us2fs(name);
+ NFind::CFileInfo fi;
if (!fi.Find(fullPath))
{
errorCodes.Add(::GetLastError());
@@ -227,7 +229,7 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
}
{
UStringVector pathParts;
- pathParts.Add(fi.Name);
+ pathParts.Add(fs2us(fi.Name));
if (curNode.CheckPathToRoot(false, pathParts, !isDir))
continue;
}
@@ -260,8 +262,8 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
if (!needEnterVector[i])
continue;
const NWildcard::CCensorNode &nextNode = curNode.SubNodes[i];
- const UString fullPath = phyPrefix + nextNode.Name;
- NFind::CFileInfoW fi;
+ const FString fullPath = phyPrefix + us2fs(nextNode.Name);
+ NFind::CFileInfo fi;
if (!fi.Find(fullPath))
{
if (!nextNode.AreThereIncludeItems())
@@ -285,10 +287,10 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
}
- NFind::CEnumeratorW enumerator(phyPrefix + wchar_t(kAnyStringWildcard));
+ NFind::CEnumerator enumerator(phyPrefix + FCHAR_ANY_MASK);
for (int ttt = 0; ; ttt++)
{
- NFind::CFileInfoW fi;
+ NFind::CFileInfo fi;
bool found;
if (!enumerator.Next(fi, found))
{
@@ -300,8 +302,8 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
break;
if (callback && (ttt & 0xFF) == 0xFF)
- RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), phyPrefix));
- const UString &name = fi.Name;
+ RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), fs2us(phyPrefix)));
+ const UString &name = fs2us(fi.Name);
bool enterToSubFolders2 = enterToSubFolders;
UStringVector addArchivePrefixNew = addArchivePrefix;
addArchivePrefixNew.Add(name);
@@ -336,7 +338,7 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
addArchivePrefixNew.Add(name);
}
- RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, name, phyPrefix,
+ RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, fi.Name, phyPrefix,
addArchivePrefixNew, dirItems, enterToSubFolders2, callback, errorPaths, errorCodes));
}
return S_OK;
@@ -346,14 +348,14 @@ HRESULT EnumerateItems(
const NWildcard::CCensor &censor,
CDirItems &dirItems,
IEnumDirItemCallback *callback,
- UStringVector &errorPaths,
+ FStringVector &errorPaths,
CRecordVector<DWORD> &errorCodes)
{
for (int i = 0; i < censor.Pairs.Size(); i++)
{
const NWildcard::CPair &pair = censor.Pairs[i];
int phyParent = pair.Prefix.IsEmpty() ? -1 : dirItems.AddPrefix(-1, -1, pair.Prefix);
- RINOK(EnumerateDirItems(pair.Head, phyParent, -1, pair.Prefix, UStringVector(), dirItems, false,
+ RINOK(EnumerateDirItems(pair.Head, phyParent, -1, us2fs(pair.Prefix), UStringVector(), dirItems, false,
callback, errorPaths, errorCodes));
}
dirItems.ReserveDown();
diff --git a/CPP/7zip/UI/Common/EnumDirItems.h b/CPP/7zip/UI/Common/EnumDirItems.h
index d0ce950e..c96c7b9e 100755
--- a/CPP/7zip/UI/Common/EnumDirItems.h
+++ b/CPP/7zip/UI/Common/EnumDirItems.h
@@ -8,7 +8,7 @@
#include "DirItem.h"
void AddDirFileInfo(int phyParent, int logParent,
- const NWindows::NFile::NFind::CFileInfoW &fi, CObjectVector<CDirItem> &dirItems);
+ const NWindows::NFile::NFind::CFileInfo &fi, CObjectVector<CDirItem> &dirItems);
struct IEnumDirItemCallback
{
@@ -19,7 +19,7 @@ HRESULT EnumerateItems(
const NWildcard::CCensor &censor,
CDirItems &dirItems,
IEnumDirItemCallback *callback,
- UStringVector &errorPaths,
+ FStringVector &errorPaths,
CRecordVector<DWORD> &errorCodes);
#endif
diff --git a/CPP/7zip/UI/Common/Extract.cpp b/CPP/7zip/UI/Common/Extract.cpp
index ca2c8c73..81186772 100755
--- a/CPP/7zip/UI/Common/Extract.cpp
+++ b/CPP/7zip/UI/Common/Extract.cpp
@@ -52,8 +52,8 @@ static HRESULT DecompressArchive(
UStringVector removePathParts;
- UString outDir = options.OutputDir;
- outDir.Replace(L"*", GetCorrectFsPath(arc.DefaultName));
+ FString outDir = options.OutputDir;
+ outDir.Replace(FSTRING_ANY_MASK, us2fs(GetCorrectFsPath(arc.DefaultName)));
#ifdef _WIN32
// GetCorrectFullFsPath doesn't like "..".
// outDir.TrimRight();
@@ -66,7 +66,7 @@ static HRESULT DecompressArchive(
HRESULT res = ::GetLastError();
if (res == S_OK)
res = E_FAIL;
- errorMessage = ((UString)L"Can not create output directory ") + outDir;
+ errorMessage = ((UString)L"Can not create output directory ") + fs2us(outDir);
return res;
}
@@ -118,11 +118,11 @@ HRESULT DecompressArchives(
for (i = 0; i < numArcs; i++)
{
- NFile::NFind::CFileInfoW fi;
+ NFile::NFind::CFileInfo fi;
fi.Size = 0;
if (!options.StdInMode)
{
- const UString &arcPath = arcPaths[i];
+ const FString &arcPath = us2fs(arcPaths[i]);
if (!fi.Find(arcPath))
throw "there is no such archive";
if (fi.IsDir())
@@ -142,7 +142,7 @@ HRESULT DecompressArchives(
for (i = 0; i < numArcs; i++)
{
const UString &arcPath = arcPaths[i];
- NFile::NFind::CFileInfoW fi;
+ NFile::NFind::CFileInfo fi;
if (options.StdInMode)
{
fi.Size = 0;
@@ -150,7 +150,7 @@ HRESULT DecompressArchives(
}
else
{
- if (!fi.Find(arcPath) || fi.IsDir())
+ if (!fi.Find(us2fs(arcPath)) || fi.IsDir())
throw "there is no such archive";
}
diff --git a/CPP/7zip/UI/Common/Extract.h b/CPP/7zip/UI/Common/Extract.h
index 5a939ed2..2904a0ab 100755
--- a/CPP/7zip/UI/Common/Extract.h
+++ b/CPP/7zip/UI/Common/Extract.h
@@ -23,7 +23,7 @@ struct CExtractOptions
bool CalcCrc;
NExtract::NPathMode::EEnum PathMode;
NExtract::NOverwriteMode::EEnum OverwriteMode;
- UString OutputDir;
+ FString OutputDir;
// bool ShowDialog;
// bool PasswordEnabled;
diff --git a/CPP/7zip/UI/Common/ExtractingFilePath.cpp b/CPP/7zip/UI/Common/ExtractingFilePath.cpp
index 8f31708b..25494d0e 100755
--- a/CPP/7zip/UI/Common/ExtractingFilePath.cpp
+++ b/CPP/7zip/UI/Common/ExtractingFilePath.cpp
@@ -20,8 +20,8 @@ static UString ReplaceIncorrectChars(const UString &s)
res += c;
}
res.TrimRight();
- while (!res.IsEmpty() && res[res.Length() - 1] == '.')
- res.Delete(res.Length() - 1);
+ while (!res.IsEmpty() && res.Back() == '.')
+ res.DeleteBack();
return res;
#else
return s;
@@ -132,8 +132,8 @@ UString GetCorrectFullFsPath(const UString &path)
{
UString &s = parts[i];
#ifdef _WIN32
- while (!s.IsEmpty() && s[s.Length() - 1] == '.')
- s.Delete(s.Length() - 1);
+ while (!s.IsEmpty() && s.Back() == '.')
+ s.DeleteBack();
if (!IsSupportedName(s))
s = (UString)L"_" + s;
#endif
diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp
index 856e47fb..cb4f83ee 100755
--- a/CPP/7zip/UI/Common/LoadCodecs.cpp
+++ b/CPP/7zip/UI/Common/LoadCodecs.cpp
@@ -22,6 +22,7 @@ static const UINT kIconTypesResId = 100;
#endif
#ifdef _WIN32
+#include "Windows/FileName.h"
#include "Windows/Registry.h"
#endif
@@ -32,53 +33,52 @@ using namespace NFile;
extern HINSTANCE g_hInstance;
#endif
-static CSysString GetLibraryFolderPrefix()
-{
- #ifdef _WIN32
- TCHAR fullPath[MAX_PATH + 1];
- ::GetModuleFileName(g_hInstance, fullPath, MAX_PATH);
- CSysString path = fullPath;
- int pos = path.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
- return path.Left(pos + 1);
- #else
- return CSysString(); // FIX IT
- #endif
-}
-
-#define kCodecsFolderName TEXT("Codecs")
-#define kFormatsFolderName TEXT("Formats")
-static const TCHAR *kMainDll = TEXT("7z.dll");
+#define kCodecsFolderName FTEXT("Codecs")
+#define kFormatsFolderName FTEXT("Formats")
+static CFSTR kMainDll = FTEXT("7z.dll");
#ifdef _WIN32
+
static LPCTSTR kRegistryPath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-zip");
-static LPCTSTR kProgramPathValue = TEXT("Path");
-static bool ReadPathFromRegistry(HKEY baseKey, CSysString &path)
+static LPCWSTR kProgramPathValue = L"Path";
+static LPCWSTR kProgramPath2Value = L"Path"
+ #ifdef _WIN64
+ L"64";
+ #else
+ L"32";
+ #endif
+
+static bool ReadPathFromRegistry(HKEY baseKey, LPCWSTR value, FString &path)
{
NRegistry::CKey key;
- if(key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
- if (key.QueryValue(kProgramPathValue, path) == ERROR_SUCCESS)
+ if (key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
+ {
+ UString pathU;
+ if (key.QueryValue(value, pathU) == ERROR_SUCCESS)
{
+ path = us2fs(pathU);
NName::NormalizeDirPathPrefix(path);
- return true;
+ return NFind::DoesFileExist(path + kMainDll);
}
+ }
return false;
}
#endif
-CSysString GetBaseFolderPrefixFromRegistry()
+static FString GetBaseFolderPrefixFromRegistry()
{
- CSysString moduleFolderPrefix = GetLibraryFolderPrefix();
+ FString moduleFolderPrefix = NDLL::GetModuleDirPrefix();
#ifdef _WIN32
if (!NFind::DoesFileExist(moduleFolderPrefix + kMainDll) &&
!NFind::DoesDirExist(moduleFolderPrefix + kCodecsFolderName) &&
!NFind::DoesDirExist(moduleFolderPrefix + kFormatsFolderName))
{
- CSysString path;
- if (ReadPathFromRegistry(HKEY_CURRENT_USER, path))
- return path;
- if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
- return path;
+ FString path;
+ if (ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPath2Value, path)) return path;
+ if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPath2Value, path)) return path;
+ if (ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPathValue, path)) return path;
+ if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPathValue, path)) return path;
}
#endif
return moduleFolderPrefix;
@@ -210,6 +210,14 @@ static void SplitString(const UString &srcString, UStringVector &destStrings)
destStrings.Add(s);
}
+int CArcInfoEx::FindExtension(const UString &ext) const
+{
+ for (int i = 0; i < Exts.Size(); i++)
+ if (ext.CompareNoCase(Exts[i].Ext) == 0)
+ return i;
+ return -1;
+}
+
void CArcInfoEx::AddExts(const wchar_t *ext, const wchar_t *addExt)
{
UStringVector exts, addExts;
@@ -344,7 +352,7 @@ extern "C"
}
#endif
-HRESULT CCodecs::LoadDll(const CSysString &dllPath, bool needCheckDll)
+HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll)
{
if (needCheckDll)
{
@@ -393,9 +401,9 @@ HRESULT CCodecs::LoadDll(const CSysString &dllPath, bool needCheckDll)
return res;
}
-HRESULT CCodecs::LoadDllsFromFolder(const CSysString &folderPrefix)
+HRESULT CCodecs::LoadDllsFromFolder(const FString &folderPrefix)
{
- NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*")));
+ NFile::NFind::CEnumerator enumerator(folderPrefix + FCHAR_ANY_MASK);
NFile::NFind::CFileInfo fi;
while (enumerator.Next(fi))
{
@@ -443,10 +451,10 @@ HRESULT CCodecs::Load()
Formats.Add(item);
}
#ifdef EXTERNAL_CODECS
- const CSysString baseFolder = GetBaseFolderPrefixFromRegistry();
+ const FString baseFolder = GetBaseFolderPrefixFromRegistry();
RINOK(LoadDll(baseFolder + kMainDll, false));
- RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName TEXT(STRING_PATH_SEPARATOR)));
- RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName TEXT(STRING_PATH_SEPARATOR)));
+ RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName FSTRING_PATH_SEPARATOR));
+ RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName FSTRING_PATH_SEPARATOR));
#endif
return S_OK;
}
@@ -455,12 +463,11 @@ HRESULT CCodecs::Load()
int CCodecs::FindFormatForArchiveName(const UString &arcPath) const
{
- int slashPos1 = arcPath.ReverseFind(WCHAR_PATH_SEPARATOR);
- int slashPos2 = arcPath.ReverseFind(L'.');
+ int slashPos = arcPath.ReverseFind(WCHAR_PATH_SEPARATOR);
int dotPos = arcPath.ReverseFind(L'.');
- if (dotPos < 0 || dotPos < slashPos1 || dotPos < slashPos2)
+ if (dotPos < 0 || dotPos < slashPos)
return -1;
- UString ext = arcPath.Mid(dotPos + 1);
+ const UString ext = arcPath.Mid(dotPos + 1);
for (int i = 0; i < Formats.Size(); i++)
{
const CArcInfoEx &arc = Formats[i];
diff --git a/CPP/7zip/UI/Common/LoadCodecs.h b/CPP/7zip/UI/Common/LoadCodecs.h
index a633dd2e..f5963ed6 100755
--- a/CPP/7zip/UI/Common/LoadCodecs.h
+++ b/CPP/7zip/UI/Common/LoadCodecs.h
@@ -1,9 +1,8 @@
// LoadCodecs.h
-#ifndef __LOADCODECS_H
-#define __LOADCODECS_H
+#ifndef __LOAD_CODECS_H
+#define __LOAD_CODECS_H
-#include "../../../Common/Types.h"
#include "../../../Common/MyCom.h"
#include "../../../Common/MyString.h"
#include "../../../Common/Buffer.h"
@@ -58,19 +57,16 @@ struct CArcInfoEx
#endif
#endif
bool KeepName;
+
UString GetMainExt() const
{
if (Exts.IsEmpty())
return UString();
return Exts[0].Ext;
}
- int FindExtension(const UString &ext) const
- {
- for (int i = 0; i < Exts.Size(); i++)
- if (ext.CompareNoCase(Exts[i].Ext) == 0)
- return i;
- return -1;
- }
+ int FindExtension(const UString &ext) const;
+
+ /*
UString GetAllExtensions() const
{
UString s;
@@ -82,6 +78,7 @@ struct CArcInfoEx
}
return s;
}
+ */
void AddExts(const wchar_t* ext, const wchar_t* addExt);
@@ -125,7 +122,7 @@ struct CCodecLib
GetMethodPropertyFunc GetMethodProperty;
CreateObjectFunc CreateObject;
#ifdef NEW_FOLDER_INTERFACE
- CSysString Path;
+ FString Path;
void LoadIcons() { CCodecIcons::LoadIcons((HMODULE)Lib); }
#endif
CCodecLib(): GetMethodProperty(0) {}
@@ -151,8 +148,8 @@ public:
HRESULT LoadCodecs();
HRESULT LoadFormats();
- HRESULT LoadDll(const CSysString &path, bool needCheckDll);
- HRESULT LoadDllsFromFolder(const CSysString &folderPrefix);
+ HRESULT LoadDll(const FString &path, bool needCheckDll);
+ HRESULT LoadDllsFromFolder(const FString &folderPrefix);
HRESULT CreateArchiveHandler(const CArcInfoEx &ai, void **archive, bool outHandler) const
{
diff --git a/CPP/7zip/UI/Common/OpenArchive.cpp b/CPP/7zip/UI/Common/OpenArchive.cpp
index 56a63046..60d2f6f5 100755
--- a/CPP/7zip/UI/Common/OpenArchive.cpp
+++ b/CPP/7zip/UI/Common/OpenArchive.cpp
@@ -63,6 +63,25 @@ HRESULT CArc::GetItemPath(UInt32 index, UString &result) const
return S_OK;
}
+HRESULT CArc::GetItemSize(UInt32 index, UInt64 &size, bool &defined) const
+{
+ NCOM::CPropVariant prop;
+ defined = false;
+ size = 0;
+ RINOK(Archive->GetProperty(index, kpidSize, &prop));
+ switch (prop.vt)
+ {
+ case VT_UI1: size = prop.bVal; break;
+ case VT_UI2: size = prop.uiVal; break;
+ case VT_UI4: size = prop.ulVal; break;
+ case VT_UI8: size = (UInt64)prop.uhVal.QuadPart; break;
+ case VT_EMPTY: return S_OK;
+ default: return E_FAIL;
+ }
+ defined = true;
+ return S_OK;
+}
+
HRESULT CArc::GetItemMTime(UInt32 index, FILETIME &ft, bool &defined) const
{
NCOM::CPropVariant prop;
@@ -339,7 +358,7 @@ HRESULT CArc::OpenStreamOrFile(
{
CInFileStream *fileStreamSpec = new CInFileStream;
fileStream = fileStreamSpec;
- if (!fileStreamSpec->Open(Path))
+ if (!fileStreamSpec->Open(us2fs(Path)))
return GetLastError();
stream = fileStream;
}
@@ -461,7 +480,7 @@ HRESULT CArchiveLink::Open(
return S_OK;
}
-static void SetCallback(const UString &filePath,
+static void SetCallback(const FString &filePath,
IOpenCallbackUI *callbackUI,
IArchiveOpenCallback *reOpenCallback,
CMyComPtr<IArchiveOpenCallback> &callback)
@@ -471,12 +490,9 @@ static void SetCallback(const UString &filePath,
openCallbackSpec->Callback = callbackUI;
openCallbackSpec->ReOpenCallback = reOpenCallback;
- UString fullName;
- int fileNamePartStartIndex;
- NFile::NDirectory::MyGetFullPathName(filePath, fullName, fileNamePartStartIndex);
- openCallbackSpec->Init(
- fullName.Left(fileNamePartStartIndex),
- fullName.Mid(fileNamePartStartIndex));
+ FString dirPrefix, fileName;
+ NFile::NDirectory::GetFullPathAndSplit(filePath, dirPrefix, fileName);
+ openCallbackSpec->Init(dirPrefix, fileName);
}
HRESULT CArchiveLink::Open2(CCodecs *codecs,
@@ -491,14 +507,10 @@ HRESULT CArchiveLink::Open2(CCodecs *codecs,
CMyComPtr<IArchiveOpenCallback> callback = openCallbackSpec;
openCallbackSpec->Callback = callbackUI;
- UString fullName, prefix, name;
+ FString prefix, name;
if (!stream && !stdInMode)
{
- int fileNamePartStartIndex;
- if (!NFile::NDirectory::MyGetFullPathName(filePath, fullName, fileNamePartStartIndex))
- return GetLastError();
- prefix = fullName.Left(fileNamePartStartIndex);
- name = fullName.Mid(fileNamePartStartIndex);
+ NFile::NDirectory::GetFullPathAndSplit(us2fs(filePath), prefix, name);
openCallbackSpec->Init(prefix, name);
}
else
@@ -507,9 +519,9 @@ HRESULT CArchiveLink::Open2(CCodecs *codecs,
}
RINOK(Open(codecs, formatIndices, stdInMode, stream, filePath, callback));
- VolumePaths.Add(prefix + name);
+ VolumePaths.Add(fs2us(prefix + name));
for (int i = 0; i < openCallbackSpec->FileNames.Size(); i++)
- VolumePaths.Add(prefix + openCallbackSpec->FileNames[i]);
+ VolumePaths.Add(fs2us(prefix) + openCallbackSpec->FileNames[i]);
VolumesSize = openCallbackSpec->TotalSize;
return S_OK;
}
@@ -524,11 +536,11 @@ HRESULT CArchiveLink::ReOpen(CCodecs *codecs, const UString &filePath,
return Open2(codecs, CIntVector(), false, NULL, filePath, 0);
CMyComPtr<IArchiveOpenCallback> openCallbackNew;
- SetCallback(filePath, NULL, callback, openCallbackNew);
+ SetCallback(us2fs(filePath), NULL, callback, openCallbackNew);
CInFileStream *fileStreamSpec = new CInFileStream;
CMyComPtr<IInStream> stream(fileStreamSpec);
- if (!fileStreamSpec->Open(filePath))
+ if (!fileStreamSpec->Open(us2fs(filePath)))
return GetLastError();
HRESULT res = GetArchive()->Open(stream, &kMaxCheckStartPosition, callback);
IsOpen = (res == S_OK);
diff --git a/CPP/7zip/UI/Common/OpenArchive.h b/CPP/7zip/UI/Common/OpenArchive.h
index 4a003ee6..25f739e3 100755
--- a/CPP/7zip/UI/Common/OpenArchive.h
+++ b/CPP/7zip/UI/Common/OpenArchive.h
@@ -29,6 +29,7 @@ struct CArc
CArc(): MTimeDefined(false) {}
HRESULT GetItemPath(UInt32 index, UString &result) const;
+ HRESULT GetItemSize(UInt32 index, UInt64 &size, bool &defined) const;
HRESULT GetItemMTime(UInt32 index, FILETIME &ft, bool &defined) const;
HRESULT IsItemAnti(UInt32 index, bool &result) const
{ return GetArchiveItemBoolProp(Archive, index, kpidIsAnti, result); }
diff --git a/CPP/7zip/UI/Common/Property.h b/CPP/7zip/UI/Common/Property.h
index 9fd340cb..8b57a2a6 100755
--- a/CPP/7zip/UI/Common/Property.h
+++ b/CPP/7zip/UI/Common/Property.h
@@ -1,9 +1,9 @@
// Property.h
-#ifndef __PROPERTY_H
-#define __PROPERTY_H
+#ifndef __7Z_PROPERTY_H
+#define __7Z_PROPERTY_H
-#include "Common/MyString.h"
+#include "../../../Common/MyString.h"
struct CProperty
{
diff --git a/CPP/7zip/UI/Common/SetProperties.cpp b/CPP/7zip/UI/Common/SetProperties.cpp
index 4827f2a7..ac9b59a3 100755
--- a/CPP/7zip/UI/Common/SetProperties.cpp
+++ b/CPP/7zip/UI/Common/SetProperties.cpp
@@ -49,13 +49,13 @@ HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &propert
{
if (!name.IsEmpty())
{
- wchar_t c = name[name.Length() - 1];
+ wchar_t c = name.Back();
if (c == L'-')
propVariant = false;
else if (c == L'+')
propVariant = true;
if (propVariant.vt != VT_EMPTY)
- name = name.Left(name.Length() - 1);
+ name.DeleteBack();
}
}
else
diff --git a/CPP/7zip/UI/Common/TempFiles.cpp b/CPP/7zip/UI/Common/TempFiles.cpp
index eeaec180..c799c7bf 100755
--- a/CPP/7zip/UI/Common/TempFiles.cpp
+++ b/CPP/7zip/UI/Common/TempFiles.cpp
@@ -5,16 +5,15 @@
#include "TempFiles.h"
#include "Windows/FileDir.h"
-#include "Windows/FileIO.h"
using namespace NWindows;
using namespace NFile;
void CTempFiles::Clear()
{
- while(!Paths.IsEmpty())
+ while (!Paths.IsEmpty())
{
- NDirectory::DeleteFileAlways((LPCWSTR)Paths.Back());
+ NDirectory::DeleteFileAlways(Paths.Back());
Paths.DeleteBack();
}
}
diff --git a/CPP/7zip/UI/Common/TempFiles.h b/CPP/7zip/UI/Common/TempFiles.h
index eb474a76..5dcda5b6 100755
--- a/CPP/7zip/UI/Common/TempFiles.h
+++ b/CPP/7zip/UI/Common/TempFiles.h
@@ -1,7 +1,7 @@
// TempFiles.h
-#ifndef __TEMPFILES_H
-#define __TEMPFILES_H
+#ifndef __TEMP_FILES_H
+#define __TEMP_FILES_H
#include "Common/MyString.h"
@@ -9,7 +9,7 @@ class CTempFiles
{
void Clear();
public:
- UStringVector Paths;
+ FStringVector Paths;
~CTempFiles() { Clear(); }
};
diff --git a/CPP/7zip/UI/Common/Update.cpp b/CPP/7zip/UI/Common/Update.cpp
index a57ec2a6..e740e8a7 100755
--- a/CPP/7zip/UI/Common/Update.cpp
+++ b/CPP/7zip/UI/Common/Update.cpp
@@ -7,10 +7,7 @@
#include "Common/IntToString.h"
#include "Common/StringConvert.h"
-#ifdef _WIN32
#include "Windows/DLL.h"
-#endif
-
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
#include "Windows/FileName.h"
@@ -40,7 +37,7 @@ using namespace NCOM;
using namespace NFile;
using namespace NName;
-static const wchar_t *kTempFolderPrefix = L"7zE";
+static CFSTR kTempFolderPrefix = FTEXT("7zE");
using namespace NUpdateArchive;
@@ -57,7 +54,7 @@ class COutMultiVolStream:
{
COutFileStream *StreamSpec;
CMyComPtr<IOutStream> Stream;
- UString Name;
+ FString Name;
UInt64 Pos;
UInt64 RealSize;
};
@@ -65,7 +62,7 @@ class COutMultiVolStream:
public:
// CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
CRecordVector<UInt64> Sizes;
- UString Prefix;
+ FString Prefix;
CTempFiles *TempFiles;
void Init()
@@ -107,18 +104,18 @@ STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *pr
{
if (processedSize != NULL)
*processedSize = 0;
- while(size > 0)
+ while (size > 0)
{
if (_streamIndex >= Streams.Size())
{
CSubStreamInfo subStream;
- wchar_t temp[16];
+ FChar temp[16];
ConvertUInt32ToString(_streamIndex + 1, temp);
- UString res = temp;
+ FString res = temp;
while (res.Length() < 3)
- res = UString(L'0') + res;
- UString name = Prefix + res;
+ res = FString(FTEXT('0')) + res;
+ FString name = Prefix + res;
subStream.StreamSpec = new COutFileStream;
subStream.Stream = subStream.StreamSpec;
if (!subStream.StreamSpec->Create(name, false))
@@ -311,7 +308,7 @@ static HRESULT Compress(
bool stdOutMode,
const CDirItems &dirItems,
bool sfxMode,
- const UString &sfxModule,
+ const FString &sfxModule,
const CRecordVector<UInt64> &volumesSizes,
CTempFiles &tempFiles,
CUpdateErrorInfo &errorInfo,
@@ -389,11 +386,10 @@ static HRESULT Compress(
if (!stdOutMode)
{
- UString resultPath;
- int pos;
- if (!NFile::NDirectory::MyGetFullPathName(archivePath.GetFinalPath(), resultPath, pos))
+ FString dirPrefix;
+ if (!NFile::NDirectory::GetOnlyDirPrefix(us2fs(archivePath.GetFinalPath()), dirPrefix))
throw 1417161;
- NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
+ NFile::NDirectory::CreateComplexDirectory(dirPrefix);
}
COutFileStream *outStreamSpec = NULL;
@@ -408,21 +404,21 @@ static HRESULT Compress(
outStreamSpec = new COutFileStream;
outStream = outStreamSpec;
bool isOK = false;
- UString realPath;
+ FString realPath;
for (int i = 0; i < (1 << 16); i++)
{
if (archivePath.Temp)
{
if (i > 0)
{
- wchar_t s[16];
+ FChar s[16];
ConvertUInt32ToString(i, s);
archivePath.TempPostfix = s;
}
realPath = archivePath.GetTempPath();
}
else
- realPath = archivePath.GetFinalPath();
+ realPath = us2fs(archivePath.GetFinalPath());
if (outStreamSpec->Create(realPath, false))
{
tempFiles.Paths.Add(realPath);
@@ -450,7 +446,7 @@ static HRESULT Compress(
volStreamSpec = new COutMultiVolStream;
outStream = volStreamSpec;
volStreamSpec->Sizes = volumesSizes;
- volStreamSpec->Prefix = archivePath.GetFinalPath() + UString(L".");
+ volStreamSpec->Prefix = us2fs(archivePath.GetFinalPath() + L".");
volStreamSpec->TempFiles = &tempFiles;
volStreamSpec->Init();
@@ -484,7 +480,7 @@ static HRESULT Compress(
{
outStreamSpec = new COutFileStream;
sfxOutStream = outStreamSpec;
- UString realPath = archivePath.GetFinalPath();
+ FString realPath = us2fs(archivePath.GetFinalPath());
if (!outStreamSpec->Create(realPath, false))
{
errorInfo.SystemError = ::GetLastError();
@@ -527,14 +523,7 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
RINOK(IsArchiveItemFolder(archive, i, ai.IsDir));
ai.Censored = censor.CheckPath(ai.Name, !ai.IsDir);
RINOK(arc.GetItemMTime(i, ai.MTime, ai.MTimeDefined));
-
- {
- CPropVariant prop;
- RINOK(archive->GetProperty(i, kpidSize, &prop));
- ai.SizeDefined = (prop.vt != VT_EMPTY);
- if (ai.SizeDefined)
- ai.Size = ConvertPropVariantToUInt64(prop);
- }
+ RINOK(arc.GetItemSize(i, ai.Size, ai.SizeDefined));
{
CPropVariant prop;
@@ -608,11 +597,11 @@ static HRESULT UpdateWithItemLists(
#if defined(_WIN32) && !defined(UNDER_CE)
class CCurrentDirRestorer
{
- UString _path;
+ FString _path;
public:
CCurrentDirRestorer() { NFile::NDirectory::MyGetCurrentDirectory(_path); }
~CCurrentDirRestorer() { RestoreDirectory();}
- bool RestoreDirectory() { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(_path)); }
+ bool RestoreDirectory() const { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(_path)); }
};
#endif
@@ -661,17 +650,25 @@ HRESULT UpdateArchive(
errorInfo.Message = L"SFX file is not specified";
return E_FAIL;
}
- UString name = options.SfxModule;
- #ifdef UNDER_CE
- if (!NFind::DoesFileExist(name))
- #else
- if (!NDirectory::MySearchPath(NULL, name, NULL, options.SfxModule))
- #endif
+ bool found = false;
+ if (options.SfxModule.Find(FCHAR_PATH_SEPARATOR) < 0)
{
- errorInfo.SystemError = ::GetLastError();
- errorInfo.Message = L"7-Zip cannot find specified SFX module";
- errorInfo.FileName = name;
- return E_FAIL;
+ const FString fullName = NDLL::GetModuleDirPrefix() + options.SfxModule;
+ if (NFind::DoesFileExist(fullName))
+ {
+ options.SfxModule = fullName;
+ found = true;
+ }
+ }
+ if (!found)
+ {
+ if (!NFind::DoesFileExist(options.SfxModule))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"7-Zip cannot find specified SFX module";
+ errorInfo.FileName = options.SfxModule;
+ return E_FAIL;
+ }
}
}
@@ -681,8 +678,8 @@ HRESULT UpdateArchive(
if (!options.ArchivePath.OriginalPath.IsEmpty())
{
- NFind::CFileInfoW fi;
- if (fi.Find(arcPath))
+ NFind::CFileInfo fi;
+ if (fi.Find(us2fs(arcPath)))
{
if (fi.IsDir())
throw "there is no such archive";
@@ -738,12 +735,12 @@ HRESULT UpdateArchive(
CEnumDirItemUpdateCallback enumCallback;
enumCallback.Callback = callback;
RINOK(callback->StartScanning());
- UStringVector errorPaths;
+ FStringVector errorPaths;
CRecordVector<DWORD> errorCodes;
HRESULT res = EnumerateItems(censor, dirItems, &enumCallback, errorPaths, errorCodes);
for (int i = 0; i < errorPaths.Size(); i++)
{
- RINOK(callback->CanNotFindError(errorPaths[i], errorCodes[i]));
+ RINOK(callback->CanNotFindError(fs2us(errorPaths[i]), errorCodes[i]));
}
if (res != S_OK)
{
@@ -755,11 +752,11 @@ HRESULT UpdateArchive(
}
}
- UString tempDirPrefix;
+ FString tempDirPrefix;
bool usesTempDir = false;
#ifdef _WIN32
- NDirectory::CTempDirectoryW tempDirectory;
+ NDirectory::CTempDir tempDirectory;
if (options.EMailMode && options.EMailRemoveAfter)
{
tempDirectory.Create(kTempFolderPrefix);
@@ -792,20 +789,20 @@ HRESULT UpdateArchive(
}
}
- for(int i = 0; i < options.Commands.Size(); i++)
+ for (int i = 0; i < options.Commands.Size(); i++)
{
CArchivePath &ap = options.Commands[i].ArchivePath;
if (usesTempDir)
{
// Check it
- ap.Prefix = tempDirPrefix;
+ ap.Prefix = fs2us(tempDirPrefix);
// ap.Temp = true;
// ap.TempPrefix = tempDirPrefix;
}
if (!options.StdOutMode &&
(i > 0 || !createTempFile))
{
- const UString &path = ap.GetFinalPath();
+ const FString path = us2fs(ap.GetFinalPath());
if (NFind::DoesFileOrDirExist(path))
{
errorInfo.SystemError = 0;
@@ -839,21 +836,21 @@ HRESULT UpdateArchive(
try
{
CArchivePath &ap = options.Commands[0].ArchivePath;
- const UString &tempPath = ap.GetTempPath();
+ const FString &tempPath = ap.GetTempPath();
if (thereIsInArchive)
- if (!NDirectory::DeleteFileAlways(arcPath))
+ if (!NDirectory::DeleteFileAlways(us2fs(arcPath)))
{
errorInfo.SystemError = ::GetLastError();
errorInfo.Message = L"7-Zip cannot delete the file";
- errorInfo.FileName = arcPath;
+ errorInfo.FileName = us2fs(arcPath);
return E_FAIL;
}
- if (!NDirectory::MyMoveFile(tempPath, arcPath))
+ if (!NDirectory::MyMoveFile(tempPath, us2fs(arcPath)))
{
errorInfo.SystemError = ::GetLastError();
errorInfo.Message = L"7-Zip cannot move the file";
errorInfo.FileName = tempPath;
- errorInfo.FileName2 = arcPath;
+ errorInfo.FileName2 = us2fs(arcPath);
return E_FAIL;
}
}
@@ -867,7 +864,7 @@ HRESULT UpdateArchive(
if (options.EMailMode)
{
NDLL::CLibrary mapiLib;
- if (!mapiLib.Load(TEXT("Mapi32.dll")))
+ if (!mapiLib.Load(FTEXT("Mapi32.dll")))
{
errorInfo.SystemError = ::GetLastError();
errorInfo.Message = L"7-Zip cannot load Mapi32.dll";
@@ -880,13 +877,13 @@ HRESULT UpdateArchive(
errorInfo.Message = L"7-Zip cannot find MAPISendDocuments function";
return E_FAIL;
}
- UStringVector fullPaths;
+ FStringVector fullPaths;
int i;
- for(i = 0; i < options.Commands.Size(); i++)
+ for (i = 0; i < options.Commands.Size(); i++)
{
CArchivePath &ap = options.Commands[i].ArchivePath;
- UString arcPath;
- if (!NFile::NDirectory::MyGetFullPathName(ap.GetFinalPath(), arcPath))
+ FString arcPath;
+ if (!NFile::NDirectory::MyGetFullPathName(us2fs(ap.GetFinalPath()), arcPath))
{
errorInfo.SystemError = ::GetLastError();
errorInfo.Message = L"GetFullPathName error";
@@ -895,9 +892,9 @@ HRESULT UpdateArchive(
fullPaths.Add(arcPath);
}
CCurrentDirRestorer curDirRestorer;
- for(i = 0; i < fullPaths.Size(); i++)
+ for (i = 0; i < fullPaths.Size(); i++)
{
- UString arcPath = fullPaths[i];
+ UString arcPath = fs2us(fullPaths[i]);
UString fileName = ExtractFileNameFromPath(arcPath);
AString path = GetAnsiString(arcPath);
AString name = GetAnsiString(fileName);
diff --git a/CPP/7zip/UI/Common/Update.h b/CPP/7zip/UI/Common/Update.h
index 49af0092..43a3c0fd 100755
--- a/CPP/7zip/UI/Common/Update.h
+++ b/CPP/7zip/UI/Common/Update.h
@@ -21,8 +21,8 @@ struct CArchivePath
UString VolExtension; // archive type extension for volumes
bool Temp;
- UString TempPrefix; // path(folder) for temp location
- UString TempPostfix;
+ FString TempPrefix; // path(folder) for temp location
+ FString TempPostfix;
CArchivePath(): Temp(false) {};
@@ -63,12 +63,12 @@ struct CArchivePath
}
- UString GetTempPath() const
+ FString GetTempPath() const
{
- UString path = TempPrefix + Name;
+ FString path = TempPrefix + us2fs(Name);
if (!BaseExtension.IsEmpty())
- path += UString(L'.') + BaseExtension;
- path += L".tmp";
+ path += FString(FTEXT('.')) + us2fs(BaseExtension);
+ path += FTEXT(".tmp");
path += TempPostfix;
return path;
}
@@ -97,7 +97,7 @@ struct CUpdateOptions
CArchivePath ArchivePath;
bool SfxMode;
- UString SfxModule;
+ FString SfxModule;
bool OpenShareForWrite;
@@ -109,7 +109,7 @@ struct CUpdateOptions
bool EMailRemoveAfter;
UString EMailAddress;
- UString WorkingDir;
+ FString WorkingDir;
bool Init(const CCodecs *codecs, const CIntVector &formatIndices, const UString &arcPath);
@@ -137,8 +137,8 @@ struct CUpdateOptions
struct CErrorInfo
{
DWORD SystemError;
- UString FileName;
- UString FileName2;
+ FString FileName;
+ FString FileName2;
UString Message;
// UStringVector ErrorPaths;
// CRecordVector<DWORD> ErrorCodes;
diff --git a/CPP/7zip/UI/Common/UpdateCallback.cpp b/CPP/7zip/UI/Common/UpdateCallback.cpp
index 0f229058..21146bb0 100755
--- a/CPP/7zip/UI/Common/UpdateCallback.cpp
+++ b/CPP/7zip/UI/Common/UpdateCallback.cpp
@@ -22,7 +22,8 @@ CArchiveUpdateCallback::CArchiveUpdateCallback():
DirItems(0),
ArcItems(0),
UpdatePairs(0),
- NewNames(0)
+ NewNames(0),
+ KeepOriginalItemNames(0)
{}
@@ -120,7 +121,22 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR
const CDirItem &di = DirItems->Items[up.DirIndex];
switch(propID)
{
- case kpidPath: prop = DirItems->GetLogPath(up.DirIndex); break;
+ case kpidPath:
+ {
+ if (KeepOriginalItemNames)
+ {
+ if (up.ExistInArchive() && Archive)
+ {
+ UInt32 indexInArchive;
+ if (ArcItems == 0)
+ indexInArchive = up.ArcIndex;
+ else
+ indexInArchive = (*ArcItems)[up.ArcIndex].IndexInServer;
+ return Archive->GetProperty(indexInArchive, propID, value);
+ }
+ }
+ prop = DirItems->GetLogPath(up.DirIndex); break;
+ }
case kpidIsDir: prop = di.IsDir(); break;
case kpidSize: prop = di.Size; break;
case kpidAttrib: prop = di.Attrib; break;
@@ -186,7 +202,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
CInFileStream *inStreamSpec = new CInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
const UString path = DirItems->GetPhyPath(up.DirIndex);
- if (!inStreamSpec->OpenShared(path, ShareForWrite))
+ if (!inStreamSpec->OpenShared(us2fs(path), ShareForWrite))
{
return Callback->OpenFileError(path, ::GetLastError());
}
@@ -216,12 +232,12 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size)
STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream)
{
COM_TRY_BEGIN
- wchar_t temp[16];
+ FChar temp[16];
ConvertUInt32ToString(index + 1, temp);
- UString res = temp;
+ FString res = temp;
while (res.Length() < 2)
- res = UString(L'0') + res;
- UString fileName = VolName;
+ res = FString(FTEXT('0')) + res;
+ FString fileName = VolName;
fileName += L'.';
fileName += res;
fileName += VolExt;
diff --git a/CPP/7zip/UI/Common/UpdateCallback.h b/CPP/7zip/UI/Common/UpdateCallback.h
index 9a20c315..09f1c0d3 100755
--- a/CPP/7zip/UI/Common/UpdateCallback.h
+++ b/CPP/7zip/UI/Common/UpdateCallback.h
@@ -55,8 +55,8 @@ public:
public:
CRecordVector<UInt64> VolumesSizes;
- UString VolName;
- UString VolExt;
+ FString VolName;
+ FString VolExt;
IUpdateCallbackUI *Callback;
@@ -67,6 +67,7 @@ public:
const CRecordVector<CUpdatePair2> *UpdatePairs;
const UStringVector *NewNames;
CMyComPtr<IInArchive> Archive;
+ bool KeepOriginalItemNames;
CArchiveUpdateCallback();
};
diff --git a/CPP/7zip/UI/Common/WorkDir.cpp b/CPP/7zip/UI/Common/WorkDir.cpp
index 164118e2..1ecb5b54 100755
--- a/CPP/7zip/UI/Common/WorkDir.cpp
+++ b/CPP/7zip/UI/Common/WorkDir.cpp
@@ -5,23 +5,23 @@
#include "Common/StringConvert.h"
#include "Common/Wildcard.h"
-#include "Windows/FileDir.h"
#include "Windows/FileName.h"
#include "WorkDir.h"
using namespace NWindows;
using namespace NFile;
+using namespace NDirectory;
-UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
+FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FString &fileName)
{
NWorkDir::NMode::EEnum mode = workDirInfo.Mode;
#ifndef UNDER_CE
if (workDirInfo.ForRemovableOnly)
{
mode = NWorkDir::NMode::kCurrent;
- UString prefix = path.Left(3);
- if (prefix[1] == L':' && prefix[2] == L'\\')
+ FString prefix = path.Left(3);
+ if (prefix[1] == FTEXT(':') && prefix[2] == FTEXT('\\'))
{
UINT driveType = GetDriveType(GetSystemString(prefix, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP));
if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE)
@@ -36,24 +36,56 @@ UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
*/
}
#endif
- switch(mode)
+ int pos = path.ReverseFind(FCHAR_PATH_SEPARATOR) + 1;
+ fileName = path.Mid(pos);
+ switch (mode)
{
case NWorkDir::NMode::kCurrent:
{
- return ExtractDirPrefixFromPath(path);
+ return path.Left(pos);;
}
case NWorkDir::NMode::kSpecified:
{
- UString tempDir = workDirInfo.Path;
+ FString tempDir = workDirInfo.Path;
NName::NormalizeDirPathPrefix(tempDir);
return tempDir;
}
default:
{
- UString tempDir;
- if (!NDirectory::MyGetTempPath(tempDir))
+ FString tempDir;
+ if (!MyGetTempPath(tempDir))
throw 141717;
return tempDir;
}
}
}
+
+HRESULT CWorkDirTempFile::CreateTempFile(const FString &originalPath)
+{
+ NWorkDir::CInfo workDirInfo;
+ workDirInfo.Load();
+ FString namePart;
+ FString workDir = GetWorkDir(workDirInfo, originalPath, namePart);
+ CreateComplexDirectory(workDir);
+ CTempFile tempFile;
+ _outStreamSpec = new COutFileStream;
+ OutStream = _outStreamSpec;
+ if (!_tempFile.Create(workDir + namePart, &_outStreamSpec->File))
+ {
+ DWORD error = GetLastError();
+ return error ? error : E_FAIL;
+ }
+ _originalPath = originalPath;
+ return S_OK;
+}
+
+HRESULT CWorkDirTempFile::MoveToOriginal(bool deleteOriginal)
+{
+ OutStream.Release();
+ if (!_tempFile.MoveTo(_originalPath, deleteOriginal))
+ {
+ DWORD error = GetLastError();
+ return error ? error : E_FAIL;
+ }
+ return S_OK;
+}
diff --git a/CPP/7zip/UI/Common/WorkDir.h b/CPP/7zip/UI/Common/WorkDir.h
index 0643d67a..79ea2b9d 100755
--- a/CPP/7zip/UI/Common/WorkDir.h
+++ b/CPP/7zip/UI/Common/WorkDir.h
@@ -1,10 +1,26 @@
// WorkDir.h
-#ifndef __WORKDIR_H
-#define __WORKDIR_H
+#ifndef __WORK_DIR_H
+#define __WORK_DIR_H
+
+#include "Windows/FileDir.h"
#include "ZipRegistry.h"
-UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path);
+#include "../../Common/FileStreams.h"
+
+FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FString &fileName);
+
+class CWorkDirTempFile
+{
+ FString _originalPath;
+ NWindows::NFile::NDirectory::CTempFile _tempFile;
+ COutFileStream *_outStreamSpec;
+public:
+ CMyComPtr<IOutStream> OutStream;
+
+ HRESULT CreateTempFile(const FString &originalPath);
+ HRESULT MoveToOriginal(bool deleteOriginal);
+};
#endif
diff --git a/CPP/7zip/UI/Common/ZipRegistry.cpp b/CPP/7zip/UI/Common/ZipRegistry.cpp
index ac178078..d2aec4c6 100755
--- a/CPP/7zip/UI/Common/ZipRegistry.cpp
+++ b/CPP/7zip/UI/Common/ZipRegistry.cpp
@@ -3,7 +3,6 @@
#include "StdAfx.h"
#include "Common/IntToString.h"
-#include "Common/StringConvert.h"
#include "Windows/FileDir.h"
#include "Windows/Registry.h"
@@ -53,6 +52,13 @@ void CInfo::Save() const
key.SetValue_Strings(kPathHistory, Paths);
}
+void Save_ShowPassword(bool showPassword)
+{
+ CS_LOCK
+ CKey key;
+ CreateMainKey(key, kKeyName);
+ key.SetValue(kShowPassword, showPassword);
+}
void CInfo::Load()
{
@@ -75,6 +81,17 @@ void CInfo::Load()
key.GetValue_IfOk(kShowPassword, ShowPassword);
}
+bool Read_ShowPassword()
+{
+ CS_LOCK
+ CKey key;
+ bool showPassword = false;
+ if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS)
+ return showPassword;
+ key.GetValue_IfOk(kShowPassword, showPassword);
+ return showPassword;
+}
+
}
namespace NCompression
@@ -234,7 +251,7 @@ void CInfo::Save()const
CKey key;
CreateMainKey(key, kOptionsInfoKeyName);
key.SetValue(kWorkDirType, (UInt32)Mode);
- key.SetValue(kWorkDirPath, Path);
+ key.SetValue(kWorkDirPath, fs2us(Path));
key.SetValue(kTempRemovableOnly, ForRemovableOnly);
}
@@ -257,7 +274,10 @@ void CInfo::Load()
case NMode::kSpecified:
Mode = (NMode::EEnum)dirType;
}
- if (key.QueryValue(kWorkDirPath, Path) != ERROR_SUCCESS)
+ UString pathU;
+ if (key.QueryValue(kWorkDirPath, pathU) == ERROR_SUCCESS)
+ Path = us2fs(pathU);
+ else
{
Path.Empty();
if (Mode == NMode::kSpecified)
diff --git a/CPP/7zip/UI/Common/ZipRegistry.h b/CPP/7zip/UI/Common/ZipRegistry.h
index 37835386..6d8b7c13 100755
--- a/CPP/7zip/UI/Common/ZipRegistry.h
+++ b/CPP/7zip/UI/Common/ZipRegistry.h
@@ -20,6 +20,8 @@ namespace NExtract
void Save() const;
void Load();
};
+ void Save_ShowPassword(bool showPassword);
+ bool Read_ShowPassword();
}
namespace NCompression
@@ -76,7 +78,7 @@ namespace NWorkDir
struct CInfo
{
NMode::EEnum Mode;
- UString Path;
+ FString Path;
bool ForRemovableOnly;
void SetForRemovableOnlyDefault() { ForRemovableOnly = true; }
diff --git a/CPP/7zip/UI/Console/BenchCon.cpp b/CPP/7zip/UI/Console/BenchCon.cpp
index 35e868c9..d0e43222 100755
--- a/CPP/7zip/UI/Console/BenchCon.cpp
+++ b/CPP/7zip/UI/Console/BenchCon.cpp
@@ -2,296 +2,41 @@
#include "StdAfx.h"
-#include "../../../Common/IntToString.h"
-#include "../../../Common/MyCom.h"
-
-#if !defined(_7ZIP_ST) || defined(_WIN32)
-#include "../../../Windows/System.h"
-#endif
-
#include "../Common/Bench.h"
#include "BenchCon.h"
#include "ConsoleClose.h"
-struct CTotalBenchRes
+struct CPrintBenchCallback: public IBenchPrintCallback
{
- UInt64 NumIterations;
- UInt64 Rating;
- UInt64 Usage;
- UInt64 RPU;
- void Init() { NumIterations = 0; Rating = 0; Usage = 0; RPU = 0; }
- void Normalize()
- {
- if (NumIterations == 0)
- return;
- Rating /= NumIterations;
- Usage /= NumIterations;
- RPU /= NumIterations;
- NumIterations = 1;
- }
- void SetMid(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
- {
- Rating = (r1.Rating + r2.Rating) / 2;
- Usage = (r1.Usage + r2.Usage) / 2;
- RPU = (r1.RPU + r2.RPU) / 2;
- NumIterations = (r1.NumIterations + r2.NumIterations) / 2;
- }
-};
+ FILE *_file;
-struct CBenchCallback: public IBenchCallback
-{
- CTotalBenchRes EncodeRes;
- CTotalBenchRes DecodeRes;
- FILE *f;
- void Init() { EncodeRes.Init(); DecodeRes.Init(); }
- void Normalize() { EncodeRes.Normalize(); DecodeRes.Normalize(); }
- UInt32 dictionarySize;
- HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
- HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
+ void Print(const char *s);
+ void NewLine();
+ HRESULT CheckBreak();
};
-static void NormalizeVals(UInt64 &v1, UInt64 &v2)
-{
- while (v1 > 1000000)
- {
- v1 >>= 1;
- v2 >>= 1;
- }
-}
-
-static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
-{
- UInt64 elTime = elapsedTime;
- NormalizeVals(freq, elTime);
- if (elTime == 0)
- elTime = 1;
- return value * freq / elTime;
-}
-
-static void PrintNumber(FILE *f, UInt64 value, int size)
-{
- char s[32];
- ConvertUInt64ToString(value, s);
- fprintf(f, " ");
- for (int len = (int)strlen(s); len < size; len++)
- fprintf(f, " ");
- fputs(s, f);
-}
-
-static void PrintRating(FILE *f, UInt64 rating)
-{
- PrintNumber(f, rating / 1000000, 6);
-}
-
-static void PrintResults(FILE *f, UInt64 usage, UInt64 rpu, UInt64 rating)
-{
- PrintNumber(f, (usage + 5000) / 10000, 5);
- PrintRating(f, rpu);
- PrintRating(f, rating);
-}
-
-
-static void PrintResults(FILE *f, const CBenchInfo &info, UInt64 rating, CTotalBenchRes &res)
+void CPrintBenchCallback::Print(const char *s)
{
- UInt64 speed = MyMultDiv64(info.UnpackSize, info.GlobalTime, info.GlobalFreq);
- PrintNumber(f, speed / 1024, 7);
- UInt64 usage = GetUsage(info);
- UInt64 rpu = GetRatingPerUsage(info, rating);
- PrintResults(f, usage, rpu, rating);
- res.NumIterations++;
- res.RPU += rpu;
- res.Rating += rating;
- res.Usage += usage;
+ fputs(s, _file);
}
-static void PrintTotals(FILE *f, const CTotalBenchRes &res)
+void CPrintBenchCallback::NewLine()
{
- fprintf(f, " ");
- PrintResults(f, res.Usage, res.RPU, res.Rating);
+ Print("\n");
}
-
-HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
-{
- if (NConsoleClose::TestBreakSignal())
- return E_ABORT;
- if (final)
- {
- UInt64 rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, info.UnpackSize);
- PrintResults(f, info, rating, EncodeRes);
- }
- return S_OK;
-}
-
-static const char *kSep = " | ";
-
-
-HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
-{
- if (NConsoleClose::TestBreakSignal())
- return E_ABORT;
- if (final)
- {
- UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
- fputs(kSep, f);
- CBenchInfo info2 = info;
- info2.UnpackSize *= info2.NumIterations;
- info2.PackSize *= info2.NumIterations;
- info2.NumIterations = 1;
- PrintResults(f, info2, rating, DecodeRes);
- }
- return S_OK;
-}
-
-static void PrintRequirements(FILE *f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
-{
- fprintf(f, "\nRAM %s ", sizeString);
- PrintNumber(f, (size >> 20), 5);
- fprintf(f, " MB, # %s %3d", threadsString, (unsigned int)numThreads);
-}
-
-HRESULT LzmaBenchCon(
- DECL_EXTERNAL_CODECS_LOC_VARS
- FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
+HRESULT CPrintBenchCallback::CheckBreak()
{
- if (!CrcInternalTest())
- return S_FALSE;
- #ifndef _7ZIP_ST
- UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
- UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
- PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
- if (numThreads == (UInt32)-1)
- numThreads = numCPUs;
- if (numThreads > 1)
- numThreads &= ~1;
- if (dictionary == (UInt32)-1)
- {
- int dicSizeLog;
- for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
- if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
- break;
- dictionary = (1 << dicSizeLog);
- }
- #else
- if (dictionary == (UInt32)-1)
- dictionary = (1 << 22);
- numThreads = 1;
- #endif
-
- PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dictionary), "Benchmark threads: ", numThreads);
-
- CBenchCallback callback;
- callback.Init();
- callback.f = f;
-
- fprintf(f, "\n\nDict Compressing | Decompressing\n ");
- int j;
- for (j = 0; j < 2; j++)
- {
- fprintf(f, " Speed Usage R/U Rating");
- if (j == 0)
- fputs(kSep, f);
- }
- fprintf(f, "\n ");
- for (j = 0; j < 2; j++)
- {
- fprintf(f, " KB/s %% MIPS MIPS");
- if (j == 0)
- fputs(kSep, f);
- }
- fprintf(f, "\n\n");
- for (UInt32 i = 0; i < numIterations; i++)
- {
- const int kStartDicLog = 22;
- int pow = (dictionary < ((UInt32)1 << kStartDicLog)) ? kBenchMinDicLogSize : kStartDicLog;
- while (((UInt32)1 << pow) > dictionary)
- pow--;
- for (; ((UInt32)1 << pow) <= dictionary; pow++)
- {
- fprintf(f, "%2d:", pow);
- callback.dictionarySize = (UInt32)1 << pow;
- HRESULT res = LzmaBench(
- EXTERNAL_CODECS_LOC_VARS
- numThreads, callback.dictionarySize, &callback);
- fprintf(f, "\n");
- RINOK(res);
- }
- }
- callback.Normalize();
- fprintf(f, "----------------------------------------------------------------\nAvr:");
- PrintTotals(f, callback.EncodeRes);
- fprintf(f, " ");
- PrintTotals(f, callback.DecodeRes);
- fprintf(f, "\nTot:");
- CTotalBenchRes midRes;
- midRes.SetMid(callback.EncodeRes, callback.DecodeRes);
- PrintTotals(f, midRes);
- fprintf(f, "\n");
- return S_OK;
+ return NConsoleClose::TestBreakSignal() ? E_ABORT: S_OK;
}
-struct CTempValues
-{
- UInt64 *Values;
- CTempValues(UInt32 num) { Values = new UInt64[num]; }
- ~CTempValues() { delete []Values; }
-};
-
-HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
+HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
+ const CObjectVector<CProperty> props, UInt32 numIterations, FILE *f)
{
- if (!CrcInternalTest())
- return S_FALSE;
-
- #ifndef _7ZIP_ST
- UInt64 ramSize = NWindows::NSystem::GetRamSize();
- UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
- PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
- if (numThreads == (UInt32)-1)
- numThreads = numCPUs;
- #else
- numThreads = 1;
- #endif
- if (dictionary == (UInt32)-1)
- dictionary = (1 << 24);
-
- CTempValues speedTotals(numThreads);
- fprintf(f, "\n\nSize");
- for (UInt32 ti = 0; ti < numThreads; ti++)
- {
- fprintf(f, " %5d", ti + 1);
- speedTotals.Values[ti] = 0;
- }
- fprintf(f, "\n\n");
-
- UInt64 numSteps = 0;
- for (UInt32 i = 0; i < numIterations; i++)
- {
- for (int pow = 10; pow < 32; pow++)
- {
- UInt32 bufSize = (UInt32)1 << pow;
- if (bufSize > dictionary)
- break;
- fprintf(f, "%2d: ", pow);
- UInt64 speed;
- for (UInt32 ti = 0; ti < numThreads; ti++)
- {
- if (NConsoleClose::TestBreakSignal())
- return E_ABORT;
- RINOK(CrcBench(ti + 1, bufSize, speed));
- PrintNumber(f, (speed >> 20), 5);
- speedTotals.Values[ti] += speed;
- }
- fprintf(f, "\n");
- numSteps++;
- }
- }
- if (numSteps != 0)
- {
- fprintf(f, "\nAvg:");
- for (UInt32 ti = 0; ti < numThreads; ti++)
- PrintNumber(f, ((speedTotals.Values[ti] / numSteps) >> 20), 5);
- fprintf(f, "\n");
- }
- return S_OK;
+ CPrintBenchCallback callback;
+ callback._file = f;
+ callback.NewLine();
+ return Bench(EXTERNAL_CODECS_LOC_VARS
+ &callback, NULL, props, numIterations, true);
}
diff --git a/CPP/7zip/UI/Console/BenchCon.h b/CPP/7zip/UI/Console/BenchCon.h
index 966a83a6..73972186 100755
--- a/CPP/7zip/UI/Console/BenchCon.h
+++ b/CPP/7zip/UI/Console/BenchCon.h
@@ -6,11 +6,9 @@
#include <stdio.h>
#include "../../Common/CreateCoder.h"
+#include "../../UI/Common/Property.h"
-HRESULT LzmaBenchCon(
- DECL_EXTERNAL_CODECS_LOC_VARS
- FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
-
-HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
+HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
+ const CObjectVector<CProperty> props, UInt32 numIterations, FILE *f);
#endif
diff --git a/CPP/7zip/UI/Console/Console.dsp b/CPP/7zip/UI/Console/Console.dsp
index 09633ee5..7c1719da 100755
--- a/CPP/7zip/UI/Console/Console.dsp
+++ b/CPP/7zip/UI/Console/Console.dsp
@@ -628,14 +628,6 @@ SOURCE=..\Common\UpdateProduce.h
# End Source File
# Begin Source File
-SOURCE=..\Common\WorkDir.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\WorkDir.h
-# End Source File
-# Begin Source File
-
SOURCE=..\Common\ZipRegistry.h
# End Source File
# End Group
@@ -676,6 +668,14 @@ SOURCE=..\..\Common\FilterCoder.h
# End Source File
# Begin Source File
+SOURCE=..\..\Common\MethodProps.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MethodProps.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Common\ProgressUtils.cpp
# End Source File
# Begin Source File
diff --git a/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
index af65739c..af379861 100755
--- a/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
+++ b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
@@ -182,7 +182,7 @@ HRESULT CExtractCallbackConsole::OpenResult(const wchar_t * /* name */, HRESULT
if (result == E_OUTOFMEMORY)
(*OutStream) << "Can't allocate required memory";
else
- (*OutStream) << NError::MyFormatMessage(result);
+ (*OutStream) << NError::MyFormatMessageW(result);
}
(*OutStream) << endl;
NumArchiveErrors++;
@@ -218,11 +218,7 @@ HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
if (result == E_OUTOFMEMORY)
(*OutStream) << kMemoryExceptionMessage;
else
- {
- UString message;
- NError::MyFormatMessage(result, message);
- (*OutStream) << message;
- }
+ (*OutStream) << NError::MyFormatMessageW(result);
(*OutStream) << endl;
return S_OK;
}
diff --git a/CPP/7zip/UI/Console/List.cpp b/CPP/7zip/UI/Console/List.cpp
index f747cfda..7de2379a 100755
--- a/CPP/7zip/UI/Console/List.cpp
+++ b/CPP/7zip/UI/Console/List.cpp
@@ -437,8 +437,8 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
UInt64 arcPackSize = 0;
if (!stdInMode)
{
- NFile::NFind::CFileInfoW fi;
- if (!fi.Find(archiveName) || fi.IsDir())
+ NFile::NFind::CFileInfo fi;
+ if (!fi.Find(us2fs(archiveName)) || fi.IsDir())
{
g_StdOut << endl << "Error: " << archiveName << " is not file" << endl;
numErrors++;
@@ -477,7 +477,7 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
else if (result == E_OUTOFMEMORY)
g_StdOut << "Can't allocate required memory";
else
- g_StdOut << NError::MyFormatMessage(result);
+ g_StdOut << NError::MyFormatMessageW(result);
g_StdOut << endl;
numErrors++;
continue;
diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp
index 9bd451f8..722b09e2 100755
--- a/CPP/7zip/UI/Console/Main.cpp
+++ b/CPP/7zip/UI/Console/Main.cpp
@@ -39,7 +39,9 @@ using namespace NWindows;
using namespace NFile;
using namespace NCommandLineParser;
+#ifdef _WIN32
HINSTANCE g_hInstance = 0;
+#endif
extern CStdOutStream *g_StdStream;
static const char *kCopyrightString = "\n7-Zip"
@@ -111,7 +113,7 @@ static const char *kUserErrorMessage = "Incorrect command line";
static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
static const char *kUnsupportedArcTypeMessage = "Unsupported archive type";
-static const wchar_t *kDefaultSfxModule = L"7zCon.sfx";
+static CFSTR kDefaultSfxModule = FTEXT("7zCon.sfx");
static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExitCode::EEnum code)
{
@@ -338,20 +340,6 @@ int Main2(
}
else if (options.Command.CommandType == NCommandType::kBenchmark)
{
- if (options.Method.CompareNoCase(L"CRC") == 0)
- {
- HRESULT res = CrcBenchCon((FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
- if (res != S_OK)
- {
- if (res == S_FALSE)
- {
- stdStream << "\nCRC Error\n";
- return NExitCode::kFatalError;
- }
- throw CSystemException(res);
- }
- }
- else
{
HRESULT res;
#ifdef EXTERNAL_CODECS
@@ -360,11 +348,11 @@ int Main2(
if (res != S_OK)
throw CSystemException(res);
#endif
- res = LzmaBenchCon(
+ res = BenchCon(
#ifdef EXTERNAL_CODECS
compressCodecsInfo, &externalCodecs,
#endif
- (FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
+ options.Properties, options.NumIterations, (FILE *)stdStream);
if (res != S_OK)
{
if (res == S_FALSE)
@@ -410,7 +398,7 @@ int Main2(
eo.YesToAll = options.YesToAll;
eo.CalcCrc = options.CalcCrc;
#if !defined(_7ZIP_ST) && !defined(_SFX)
- eo.Properties = options.ExtractProperties;
+ eo.Properties = options.Properties;
#endif
UString errorMessage;
CDecompressStat stat;
@@ -480,7 +468,7 @@ int Main2(
numErrors);
if (numErrors > 0)
{
- g_StdOut << endl << "Errors: " << numErrors;
+ g_StdOut << endl << "Errors: " << numErrors << endl;
return NExitCode::kFatalError;
}
if (result != S_OK)
@@ -551,12 +539,12 @@ int Main2(
}
if (!errorInfo.FileName.IsEmpty())
{
- message += errorInfo.FileName;
+ message += fs2us(errorInfo.FileName);
message += L"\n";
}
if (!errorInfo.FileName2.IsEmpty())
{
- message += errorInfo.FileName2;
+ message += fs2us(errorInfo.FileName2);
message += L"\n";
}
if (errorInfo.SystemError != 0)
diff --git a/CPP/7zip/UI/Console/MainAr.cpp b/CPP/7zip/UI/Console/MainAr.cpp
index c54a3d09..25f4bd0d 100755
--- a/CPP/7zip/UI/Console/MainAr.cpp
+++ b/CPP/7zip/UI/Console/MainAr.cpp
@@ -79,9 +79,8 @@ int MY_CDECL main
(*g_StdStream) << endl << kUserBreak;
return (NExitCode::kUserBreak);
}
- UString message;
- NError::MyFormatMessage(systemError.ErrorCode, message);
- (*g_StdStream) << endl << endl << "System error:" << endl << message << endl;
+ (*g_StdStream) << endl << endl << "System error:" << endl <<
+ NError::MyFormatMessageW(systemError.ErrorCode) << endl;
return (NExitCode::kFatalError);
}
catch(NExitCode::EEnum &exitCode)
diff --git a/CPP/7zip/UI/Console/PercentPrinter.cpp b/CPP/7zip/UI/Console/PercentPrinter.cpp
index 28452b17..786db1bc 100755
--- a/CPP/7zip/UI/Console/PercentPrinter.cpp
+++ b/CPP/7zip/UI/Console/PercentPrinter.cpp
@@ -7,13 +7,13 @@
#include "PercentPrinter.h"
-const int kPaddingSize = 2;
-const int kPercentsSize = 4;
-const int kMaxExtraSize = kPaddingSize + 32 + kPercentsSize;
+static const unsigned kPaddingSize = 2;
+static const unsigned kPercentsSize = 4;
+static const unsigned kMaxExtraSize = kPaddingSize + 32 + kPercentsSize;
-static void ClearPrev(char *p, int num)
+static void ClearPrev(char *p, unsigned num)
{
- int i;
+ unsigned i;
for (i = 0; i < num; i++) *p++ = '\b';
for (i = 0; i < num; i++) *p++ = ' ';
for (i = 0; i < num; i++) *p++ = '\b';
@@ -51,18 +51,30 @@ void CPercentPrinter::PrintNewLine()
void CPercentPrinter::RePrintRatio()
{
char s[32];
- ConvertUInt64ToString(((m_Total == 0) ? 0 : (m_CurValue * 100 / m_Total)), s);
- int size = (int)strlen(s);
- s[size++] = '%';
- s[size] = '\0';
+ unsigned size;
+ {
+ char c = '%';
+ UInt64 value = 0;
+ if (m_Total == (UInt64)(Int64)-1)
+ {
+ value = m_CurValue >> 20;
+ c = 'M';
+ }
+ else if (m_Total != 0)
+ value = m_CurValue * 100 / m_Total;
+ ConvertUInt64ToString(value, s);
+ size = (unsigned)strlen(s);
+ s[size++] = c;
+ s[size] = '\0';
+ }
- int extraSize = kPaddingSize + MyMax(size, kPercentsSize);
+ unsigned extraSize = kPaddingSize + MyMax(size, kPercentsSize);
if (extraSize < m_NumExtraChars)
extraSize = m_NumExtraChars;
char fullString[kMaxExtraSize * 3];
char *p = fullString;
- int i;
+ unsigned i;
if (m_NumExtraChars == 0)
{
for (i = 0; i < extraSize; i++)
@@ -73,7 +85,7 @@ void CPercentPrinter::RePrintRatio()
for (i = 0; i < m_NumExtraChars; i++)
*p++ = '\b';
m_NumExtraChars = extraSize;
- for (; size < m_NumExtraChars; size++)
+ for (; size < extraSize; size++)
*p++ = ' ';
MyStringCopy(p, s);
(*OutStream) << fullString;
diff --git a/CPP/7zip/UI/Console/PercentPrinter.h b/CPP/7zip/UI/Console/PercentPrinter.h
index 97f2e6ad..d970cc4b 100755
--- a/CPP/7zip/UI/Console/PercentPrinter.h
+++ b/CPP/7zip/UI/Console/PercentPrinter.h
@@ -1,9 +1,8 @@
// PercentPrinter.h
-#ifndef __PERCENTPRINTER_H
-#define __PERCENTPRINTER_H
+#ifndef __PERCENT_PRINTER_H
+#define __PERCENT_PRINTER_H
-#include "Common/Types.h"
#include "Common/StdOutStream.h"
class CPercentPrinter
@@ -12,12 +11,12 @@ class CPercentPrinter
UInt64 m_PrevValue;
UInt64 m_CurValue;
UInt64 m_Total;
- int m_NumExtraChars;
+ unsigned m_NumExtraChars;
public:
CStdOutStream *OutStream;
CPercentPrinter(UInt64 minStepSize = 1): m_MinStepSize(minStepSize),
- m_PrevValue(0), m_CurValue(0), m_Total(1), m_NumExtraChars(0) {}
+ m_PrevValue(0), m_CurValue(0), m_Total((UInt64)(Int64)-1), m_NumExtraChars(0) {}
void SetTotal(UInt64 total) { m_Total = total; m_PrevValue = 0; }
void SetRatio(UInt64 doneValue) { m_CurValue = doneValue; }
void PrintString(const char *s);
diff --git a/CPP/7zip/UI/Console/makefile b/CPP/7zip/UI/Console/makefile
index 9b8fc37a..f100f635 100755
--- a/CPP/7zip/UI/Console/makefile
+++ b/CPP/7zip/UI/Console/makefile
@@ -54,6 +54,7 @@ WIN_OBJS = \
$O\FilePathAutoRename.obj \
$O\FileStreams.obj \
$O\FilterCoder.obj \
+ $O\MethodProps.obj \
$O\ProgressUtils.obj \
$O\StreamUtils.obj \
@@ -77,7 +78,6 @@ UI_COMMON_OBJS = \
$O\UpdateCallback.obj \
$O\UpdatePair.obj \
$O\UpdateProduce.obj \
- $O\WorkDir.obj \
AR_COMMON_OBJS = \
$O\OutStreamWithCRC.obj \
diff --git a/CPP/7zip/UI/Explorer/ContextMenu.cpp b/CPP/7zip/UI/Explorer/ContextMenu.cpp
index ca5bf816..4bdc397a 100755
--- a/CPP/7zip/UI/Explorer/ContextMenu.cpp
+++ b/CPP/7zip/UI/Explorer/ContextMenu.cpp
@@ -7,8 +7,10 @@
#include "Common/StringConvert.h"
#include "Windows/COM.h"
+#include "Windows/DLL.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
#include "Windows/Memory.h"
#include "Windows/Menu.h"
#include "Windows/Process.h"
@@ -20,7 +22,6 @@
#include "../Common/ZipRegistry.h"
#include "../FileManager/FormatUtils.h"
-#include "../FileManager/ProgramLocation.h"
#ifdef LANG
#include "../FileManager/LangUtils.h"
@@ -338,8 +339,9 @@ static const char *kExtractExludeExtensions =
static const char *kNoOpenAsExtensions =
" 7z arj bz2 cab chm cpio dmg flv gz lha lzh lzma rar swm tar tbz2 tgz wim xar xz z zip ";
-static bool FindExt(const char *p, const UString &name)
+static bool FindExt(const char *p, const FString &nameF)
{
+ const UString name = fs2us(nameF);
int extPos = name.ReverseFind('.');
if (extPos < 0)
return false;
@@ -357,7 +359,7 @@ static bool FindExt(const char *p, const UString &name)
return false;
}
-static bool DoNeedExtract(const UString &name)
+static bool DoNeedExtract(const FString &name)
{
return !FindExt(kExtractExludeExtensions, name);
}
@@ -408,11 +410,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if (_fileNames.Size() == 1 && currentCommandID + 6 <= commandIDLast)
{
const UString &fileName = _fileNames.Front();
- UString folderPrefix;
- NFile::NDirectory::GetOnlyDirPrefix(fileName, folderPrefix);
-
- NFile::NFind::CFileInfoW fileInfo;
- if (!fileInfo.Find(fileName))
+ NFile::NFind::CFileInfo fileInfo;
+ if (!fileInfo.Find(us2fs(fileName)))
return E_FAIL;
if (!fileInfo.IsDir() && DoNeedExtract(fileInfo.Name))
{
@@ -473,10 +472,10 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if (_fileNames.Size() > 0 && currentCommandID + 10 <= commandIDLast)
{
bool needExtract = false;
- for(int i = 0; i < _fileNames.Size(); i++)
+ for (int i = 0; i < _fileNames.Size(); i++)
{
- NFile::NFind::CFileInfoW fileInfo;
- if (!fileInfo.Find(_fileNames[i]))
+ NFile::NFind::CFileInfo fileInfo;
+ if (!fileInfo.Find(us2fs(_fileNames[i])))
return E_FAIL;
if (!fileInfo.IsDir() && DoNeedExtract(fileInfo.Name))
needExtract = true;
@@ -484,10 +483,10 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
const UString &fileName = _fileNames.Front();
if (needExtract)
{
- UString folderPrefix;
- NFile::NDirectory::GetOnlyDirPrefix(fileName, folderPrefix);
- NFile::NFind::CFileInfoW fileInfo;
- if (!fileInfo.Find(fileName))
+ FString folderPrefix;
+ NFile::NDirectory::GetOnlyDirPrefix(us2fs(fileName), folderPrefix);
+ NFile::NFind::CFileInfo fileInfo;
+ if (!fileInfo.Find(us2fs(fileName)))
return E_FAIL;
// Extract
if ((contextMenuFlags & NContextMenuFlags::kExtract) != 0)
@@ -497,8 +496,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if (_dropMode)
commandMapItem.Folder = _dropPath;
else
- commandMapItem.Folder = folderPrefix;
- commandMapItem.Folder += GetSubFolderNameForExtract(fileInfo.Name) + UString(WCHAR_PATH_SEPARATOR);
+ commandMapItem.Folder = fs2us(folderPrefix);
+ commandMapItem.Folder += GetSubFolderNameForExtract(fs2us(fileInfo.Name)) + UString(WCHAR_PATH_SEPARATOR);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
@@ -512,7 +511,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if (_dropMode)
commandMapItem.Folder = _dropPath;
else
- commandMapItem.Folder = folderPrefix;
+ commandMapItem.Folder = fs2us(folderPrefix);
_commandMap.Add(commandMapItem);
}
@@ -524,13 +523,13 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
FillCommand(kExtractTo, s, commandMapItem);
UString folder;
if (_fileNames.Size() == 1)
- folder = GetSubFolderNameForExtract(fileInfo.Name);
+ folder = GetSubFolderNameForExtract(fs2us(fileInfo.Name));
else
folder = L'*';
if (_dropMode)
commandMapItem.Folder = _dropPath;
else
- commandMapItem.Folder = folderPrefix;
+ commandMapItem.Folder = fs2us(folderPrefix);
commandMapItem.Folder += folder;
s = MyFormatNew(s, GetQuotedReducedString(folder + UString(WCHAR_PATH_SEPARATOR)));
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
@@ -548,8 +547,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
UString archiveName = CreateArchiveName(fileName, _fileNames.Size() > 1, false);
UString archiveName7z = archiveName + L".7z";
UString archiveNameZip = archiveName + L".zip";
- UString archivePathPrefix;
- NFile::NDirectory::GetOnlyDirPrefix(fileName, archivePathPrefix);
+ FString archivePathPrefix;
+ NFile::NDirectory::GetOnlyDirPrefix(us2fs(fileName), archivePathPrefix);
// Compress
if ((contextMenuFlags & NContextMenuFlags::kCompress) != 0)
@@ -558,7 +557,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if (_dropMode)
commandMapItem.Folder = _dropPath;
else
- commandMapItem.Folder = archivePathPrefix;
+ commandMapItem.Folder = fs2us(archivePathPrefix);
commandMapItem.ArcName = archiveName;
FillCommand(kCompress, mainString, commandMapItem);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
@@ -586,7 +585,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if (_dropMode)
commandMapItem.Folder = _dropPath;
else
- commandMapItem.Folder = archivePathPrefix;
+ commandMapItem.Folder = fs2us(archivePathPrefix);
commandMapItem.ArcName = archiveName7z;
commandMapItem.ArcType = L"7z";
s = MyFormatNew(s, GetQuotedReducedString(archiveName7z));
@@ -618,7 +617,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if (_dropMode)
commandMapItem.Folder = _dropPath;
else
- commandMapItem.Folder = archivePathPrefix;
+ commandMapItem.Folder = fs2us(archivePathPrefix);
commandMapItem.ArcName = archiveNameZip;
commandMapItem.ArcType = L"zip";
s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip));
@@ -675,9 +674,7 @@ int CZipContextMenu::FindVerb(const UString &verb)
static UString Get7zFmPath()
{
- UString path;
- GetProgramFolderPath(path);
- return path + L"7zFM.exe";
+ return fs2us(NWindows::NDLL::GetModuleDirPrefix()) + L"7zFM.exe";
}
STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
diff --git a/CPP/7zip/UI/Explorer/DllExports.cpp b/CPP/7zip/UI/Explorer/DllExports.cpp
index bc8ae177..4f649f59 100755
--- a/CPP/7zip/UI/Explorer/DllExports.cpp
+++ b/CPP/7zip/UI/Explorer/DllExports.cpp
@@ -35,16 +35,6 @@ using namespace NWindows;
HINSTANCE g_hInstance = 0;
HWND g_HWND = 0;
-UString HResultToMessage(HRESULT errorCode)
-{
- UString message;
- if (!NError::MyFormatMessage(errorCode, message))
- message.Empty();
- if (message.IsEmpty())
- message = L"Error";
- return message;
-}
-
LONG g_DllRefCount = 0; // Reference count of this DLL.
static LPCWSTR kShellExtName = L"7-Zip Shell Extension";
@@ -191,14 +181,15 @@ static BOOL RegisterServer(CLSID clsid, LPCWSTR title)
if (!GetStringFromIID(clsid, clsidString, MAX_PATH))
return FALSE;
- UString modulePath;
- if (!NDLL::MyGetModuleFileName(g_hInstance, modulePath))
+ FString modulePath;
+ if (!NDLL::MyGetModuleFileName(modulePath))
return FALSE;
+ UString modulePathU = fs2us(modulePath);
CRegItem clsidEntries[] =
{
HKEY_CLASSES_ROOT, kClsidMask, NULL, title,
- HKEY_CLASSES_ROOT, kClsidInprocMask, NULL, modulePath,
+ HKEY_CLASSES_ROOT, kClsidInprocMask, NULL, modulePathU,
HKEY_CLASSES_ROOT, kClsidInprocMask, L"ThreadingModel", L"Apartment",
NULL, NULL, NULL, NULL
};
diff --git a/CPP/7zip/UI/Far/FarUtils.cpp b/CPP/7zip/UI/Far/FarUtils.cpp
index b980d846..9f55e8e5 100755
--- a/CPP/7zip/UI/Far/FarUtils.cpp
+++ b/CPP/7zip/UI/Far/FarUtils.cpp
@@ -449,8 +449,7 @@ bool WasEscPressed()
void ShowErrorMessage(DWORD errorCode)
{
- UString message;
- NError::MyFormatMessage(errorCode, message);
+ UString message = NError::MyFormatMessageW(errorCode);
message.Replace(L"\x0D", L"");
message.Replace(L"\x0A", L" ");
g_StartupInfo.ShowMessage(UnicodeStringToMultiByte(message, CP_OEMCP));
diff --git a/CPP/7zip/UI/Far/Main.cpp b/CPP/7zip/UI/Far/Main.cpp
index 5e017b80..7b58d0ca 100755
--- a/CPP/7zip/UI/Far/Main.cpp
+++ b/CPP/7zip/UI/Far/Main.cpp
@@ -87,12 +87,12 @@ class COpenArchiveCallback:
DWORD m_PrevTickCount;
- NWindows::NFile::NFind::CFileInfoW _fileInfo;
+ NWindows::NFile::NFind::CFileInfo _fileInfo;
public:
bool PasswordIsDefined;
UString Password;
- UString _folderPrefix;
+ FString _folderPrefix;
public:
MY_UNKNOWN_IMP3(
@@ -130,7 +130,7 @@ public:
}
void ShowMessage();
- void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
+ void LoadFileInfo(const FString &folderPrefix, const FString &fileName)
{
_folderPrefix = folderPrefix;
if (!_fileInfo.Find(_folderPrefix + fileName))
@@ -251,7 +251,7 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **in
if (WasEscPressed())
return E_ABORT;
*inStream = NULL;
- UString fullPath = _folderPrefix + name;
+ FString fullPath = _folderPrefix + us2fs(name);
if (!_fileInfo.Find(fullPath))
return S_FALSE;
if (_fileInfo.IsDir())
@@ -333,16 +333,15 @@ HRESULT OpenArchive(const CSysString &fileName,
static HANDLE MyOpenFilePluginW(const wchar_t *name)
{
- UString normalizedName = name;
+ FString normalizedName = us2fs(name);
normalizedName.Trim();
- UString fullName;
- int fileNamePartStartIndex;
- NFile::NDirectory::MyGetFullPathName(normalizedName, fullName, fileNamePartStartIndex);
- NFile::NFind::CFileInfoW fileInfo;
+ FString fullName;
+ NFile::NDirectory::MyGetFullPathName(normalizedName, fullName);
+ NFile::NFind::CFileInfo fileInfo;
if (!fileInfo.Find(fullName))
return INVALID_HANDLE_VALUE;
if (fileInfo.IsDir())
- return INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
CMyComPtr<IInFolderArchive> archiveHandler;
@@ -360,9 +359,11 @@ static HANDLE MyOpenFilePluginW(const wchar_t *name)
// if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
openArchiveCallbackSpec->Init();
- openArchiveCallbackSpec->LoadFileInfo(
- fullName.Left(fileNamePartStartIndex),
- fullName.Mid(fileNamePartStartIndex));
+ {
+ FString dirPrefix, fileName;
+ NFile::NDirectory::GetFullPathAndSplit(fullName, dirPrefix, fileName);
+ openArchiveCallbackSpec->LoadFileInfo(dirPrefix, fileName);
+ }
// ::OutputDebugStringA("before OpenArchive\n");
@@ -449,7 +450,7 @@ EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, INT_PTR item)
if(fileName.IsEmpty())
return INVALID_HANDLE_VALUE;
if (fileName.Length() >= 2 &&
- fileName[0] == '\"' && fileName[fileName.Length() - 1] == '\"')
+ fileName[0] == '\"' && fileName.Back() == '\"')
fileName = fileName.Mid(1, fileName.Length() - 2);
return MyOpenFilePlugin(fileName);
diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp
index a19b037c..8bdfb10d 100755
--- a/CPP/7zip/UI/Far/Plugin.cpp
+++ b/CPP/7zip/UI/Far/Plugin.cpp
@@ -18,7 +18,7 @@
using namespace NWindows;
using namespace NFar;
-CPlugin::CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName):
+CPlugin::CPlugin(const FString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName):
m_ArchiveHandler(archiveHandler),
m_FileName(fileName),
_archiveTypeName(archiveTypeName)
@@ -532,10 +532,10 @@ static void InsertSeparator(InfoPanelLine *lines, int &numItems)
void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
{
info->StructSize = sizeof(*info);
- info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS| OPIF_USEHIGHLIGHTING|
+ info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS | OPIF_USEHIGHLIGHTING |
OPIF_ADDDOTS | OPIF_COMPAREFATTIME;
- COPY_STR_LIMITED(m_FileNameBuffer, UnicodeStringToMultiByte(m_FileName, CP_OEMCP));
+ COPY_STR_LIMITED(m_FileNameBuffer, UnicodeStringToMultiByte(fs2us(m_FileName), CP_OEMCP));
info->HostFile = m_FileNameBuffer; // test it it is not static
COPY_STR_LIMITED(m_CurrentDirBuffer, UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP));
@@ -545,10 +545,9 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
UString name;
{
- UString fullName;
- int index;
- NFile::NDirectory::MyGetFullPathName(m_FileName, fullName, index);
- name = fullName.Mid(index);
+ FString dirPrefix, fileName;
+ NFile::NDirectory::GetFullPathAndSplit(m_FileName, dirPrefix, fileName);
+ name = fs2us(fileName);
}
m_PannelTitle =
@@ -852,14 +851,14 @@ int CPlugin::ProcessKey(int key, unsigned int controlState)
}
if ((controlState & PKF_ALT) != 0 && key == VK_F6)
{
- UString folderPath;
+ FString folderPath;
if (!NFile::NDirectory::GetOnlyDirPrefix(m_FileName, folderPath))
return FALSE;
PanelInfo panelInfo;
g_StartupInfo.ControlGetActivePanelInfo(panelInfo);
GetFilesReal(panelInfo.SelectedItems,
panelInfo.SelectedItemsNumber, FALSE,
- UnicodeStringToMultiByte(folderPath, CP_OEMCP), OPM_SILENT, true);
+ UnicodeStringToMultiByte(fs2us(folderPath), CP_OEMCP), OPM_SILENT, true);
g_StartupInfo.Control(this, FCTL_UPDATEPANEL, NULL);
g_StartupInfo.Control(this, FCTL_REDRAWPANEL, NULL);
g_StartupInfo.Control(this, FCTL_UPDATEANOTHERPANEL, NULL);
diff --git a/CPP/7zip/UI/Far/Plugin.h b/CPP/7zip/UI/Far/Plugin.h
index ab534e21..c4122c45 100755
--- a/CPP/7zip/UI/Far/Plugin.h
+++ b/CPP/7zip/UI/Far/Plugin.h
@@ -9,6 +9,8 @@
#include "Windows/FileFind.h"
#include "Windows/PropVariant.h"
+#include "../Common/WorkDir.h"
+
#include "../Agent/IFolderArchive.h"
#include "FarUtils.h"
@@ -36,9 +38,10 @@ class CPlugin
void EnterToDirectory(const UString &dirName);
void GetPathParts(UStringVector &pathParts);
void GetCurrentDir();
+ HRESULT AfterUpdate(CWorkDirTempFile &tempFile, const UStringVector &pathVector);
public:
- UString m_FileName;
- NWindows::NFile::NFind::CFileInfoW m_FileInfo;
+ FString m_FileName;
+ NWindows::NFile::NFind::CFileInfo m_FileInfo;
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
CMyComPtr<IFolderFolder> _folder;
@@ -48,7 +51,7 @@ public:
bool PasswordIsDefined;
UString Password;
- CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName);
+ CPlugin(const FString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName);
~CPlugin();
void ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex);
diff --git a/CPP/7zip/UI/Far/PluginDelete.cpp b/CPP/7zip/UI/Far/PluginDelete.cpp
index c8d784c3..3a3df300 100755
--- a/CPP/7zip/UI/Far/PluginDelete.cpp
+++ b/CPP/7zip/UI/Far/PluginDelete.cpp
@@ -2,20 +2,11 @@
#include "StdAfx.h"
-#include "Windows/FileDir.h"
-
-#include "../Common/WorkDir.h"
-
#include "Messages.h"
#include "Plugin.h"
#include "UpdateCallback100.h"
using namespace NFar;
-using namespace NWindows;
-using namespace NFile;
-using namespace NDirectory;
-
-static LPCWSTR kTempArchivePrefix = L"7zA";
int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
{
@@ -67,18 +58,10 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
g_StartupInfo.GetMsgString(NMessageID::kDeleting), 48);
}
- NWorkDir::CInfo workDirInfo;
- workDirInfo.Load();
-
- UString workDir = GetWorkDir(workDirInfo, m_FileName);
- CreateComplexDirectory(workDir);
-
- CTempFileW tempFile;
- UString tempFileName;
- if (tempFile.Create(workDir, kTempArchivePrefix, tempFileName) == 0)
+ CWorkDirTempFile tempFile;
+ if (tempFile.CreateTempFile(m_FileName) != S_OK)
return FALSE;
-
CRecordVector<UINT32> indices;
indices.Reserve(numItems);
int i;
@@ -101,61 +84,23 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
outArchive->SetFolder(_folder);
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
- CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
+ CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec);
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
-
- result = outArchive->DeleteItems(
- tempFileName,
- &indices.Front(), indices.Size(),
- updateCallback);
+ result = outArchive->DeleteItems(tempFile.OutStream, &indices.Front(), indices.Size(), updateCallback);
updateCallback.Release();
outArchive.Release();
- if (result != S_OK)
- {
- ShowErrorMessage(result);
- return FALSE;
- }
-
- _folder.Release();
- m_ArchiveHandler->Close();
-
- if (!DeleteFileAlways(m_FileName))
+ if (result == S_OK)
{
- ShowLastErrorMessage();
- return FALSE;
+ result = AfterUpdate(tempFile, pathVector);
}
-
- tempFile.DisableDeleting();
- if (!MyMoveFile(tempFileName, m_FileName))
- {
- ShowLastErrorMessage();
- return FALSE;
- }
-
- result = m_ArchiveHandler->ReOpen(NULL);
if (result != S_OK)
{
ShowErrorMessage(result);
return FALSE;
}
-
-
- ////////////////////////////
- // Restore _folder;
-
- m_ArchiveHandler->BindToRootFolder(&_folder);
- for (i = 0; i < pathVector.Size(); i++)
- {
- CMyComPtr<IFolderFolder> newFolder;
- _folder->BindToFolder(pathVector[i], &newFolder);
- if (!newFolder)
- break;
- _folder = newFolder;
- }
GetCurrentDir();
-
return TRUE;
}
diff --git a/CPP/7zip/UI/Far/PluginRead.cpp b/CPP/7zip/UI/Far/PluginRead.cpp
index 965030ea..a4450064 100755
--- a/CPP/7zip/UI/Far/PluginRead.cpp
+++ b/CPP/7zip/UI/Far/PluginRead.cpp
@@ -194,9 +194,11 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
#ifdef UNDER_CE
destPathU = L"\\";
#else
- if (!NFile::NDirectory::MyGetCurrentDirectory(destPathU))
+ FString destPathF = us2fs(destPathU);
+ if (!NFile::NDirectory::MyGetCurrentDirectory(destPathF))
throw 318016;
- NFile::NName::NormalizeDirPathPrefix(destPathU);
+ NFile::NName::NormalizeDirPathPrefix(destPathF);
+ destPathU = fs2us(destPathF);
#endif
break;
}
@@ -251,7 +253,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
passwordIsDefined = !password.IsEmpty();
}
- NFile::NDirectory::CreateComplexDirectory(destPathU);
+ NFile::NDirectory::CreateComplexDirectory(us2fs(destPathU));
/*
vector<int> realIndices;
diff --git a/CPP/7zip/UI/Far/PluginWrite.cpp b/CPP/7zip/UI/Far/PluginWrite.cpp
index be9616a4..e02f4d80 100755
--- a/CPP/7zip/UI/Far/PluginWrite.cpp
+++ b/CPP/7zip/UI/Far/PluginWrite.cpp
@@ -7,15 +7,10 @@
#include "Common/Wildcard.h"
#include "Common/StringConvert.h"
-#include "Windows/FileDir.h"
#include "Windows/FileName.h"
#include "Windows/FileFind.h"
-#include "Windows/Defs.h"
-#include "Windows/PropVariant.h"
#include "../Common/ZipRegistry.h"
-#include "../Common/WorkDir.h"
-#include "../Common/OpenArchive.h"
#include "../Agent/Agent.h"
@@ -30,13 +25,11 @@ using namespace NFar;
using namespace NUpdateArchive;
-static const char *kHelpTopic = "Update";
-
-static LPCWSTR kTempArcivePrefix = L"7zA";
+static const char *kHelpTopic = "Update";
static const char *kArchiveHistoryKeyName = "7-ZipArcName";
-static UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
+static const UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
{
@@ -47,18 +40,39 @@ static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
realNames.Add(UString(L"x"));
NCOM::CPropVariant value = (UInt32)method;
CRecordVector<const wchar_t *> names;
- for(int i = 0; i < realNames.Size(); i++)
+ for (int i = 0; i < realNames.Size(); i++)
names.Add(realNames[i]);
RINOK(setProperties->SetProperties(&names.Front(), &value, names.Size()));
}
return S_OK;
}
+HRESULT CPlugin::AfterUpdate(CWorkDirTempFile &tempFile, const UStringVector &pathVector)
+{
+ _folder.Release();
+ m_ArchiveHandler->Close();
+
+ RINOK(tempFile.MoveToOriginal(true));
+
+ RINOK(m_ArchiveHandler->ReOpen(NULL)); // check it
+
+ m_ArchiveHandler->BindToRootFolder(&_folder);
+ for (int i = 0; i < pathVector.Size(); i++)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToFolder(pathVector[i], &newFolder);
+ if (!newFolder)
+ break;
+ _folder = newFolder;
+ }
+ return S_OK;
+}
+
NFileOperationReturnCode::EEnum CPlugin::PutFiles(
struct PluginPanelItem *panelItems, int numItems,
int moveMode, int opMode)
{
- if(moveMode != 0)
+ if (moveMode != 0)
{
g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported);
return NFileOperationReturnCode::kError;
@@ -153,20 +167,14 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
compressionInfo.Save();
- NWorkDir::CInfo workDirInfo;
- workDirInfo.Load();
- UString workDir = GetWorkDir(workDirInfo, m_FileName);
- CreateComplexDirectory(workDir);
-
- CTempFileW tempFile;
- UString tempFileName;
- if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
+ CWorkDirTempFile tempFile;;
+ if (tempFile.CreateTempFile(m_FileName) != S_OK)
return NFileOperationReturnCode::kError;
/*
CSysStringVector fileNames;
- for(int i = 0; i < numItems; i++)
+ for (int i = 0; i < numItems; i++)
{
const PluginPanelItem &panelItem = panelItems[i];
CSysString fullName;
@@ -189,44 +197,28 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
}
- ////////////////////////////
- // Save FolderItem;
- UStringVector aPathVector;
- GetPathParts(aPathVector);
+ UStringVector pathVector;
+ GetPathParts(pathVector);
- /*
- UString anArchivePrefix;
- for(i = aPathVector.Size() - 1; i >= 0; i--)
- {
- anArchivePrefix += aPathVector[i];
- anArchivePrefix += wchar_t(NName::kDirDelimiter);
- }
- /////////////////////////////////
- */
-
UStringVector fileNames;
fileNames.Reserve(numItems);
- for(i = 0; i < numItems; i++)
+ for (i = 0; i < numItems; i++)
fileNames.Add(MultiByteToUnicodeString(panelItems[i].FindData.cFileName, CP_OEMCP));
CRecordVector<const wchar_t *> fileNamePointers;
fileNamePointers.Reserve(numItems);
- for(i = 0; i < numItems; i++)
+ for (i = 0; i < numItems; i++)
fileNamePointers.Add(fileNames[i]);
CMyComPtr<IOutFolderArchive> outArchive;
HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive);
- if(result != S_OK)
+ if (result != S_OK)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return NFileOperationReturnCode::kError;
}
outArchive->SetFolder(_folder);
- // CSysString aCurrentFolder;
- // MyGetCurrentDirectory(aCurrentFolder);
- // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
- outArchive->SetFiles(L"",
- &fileNamePointers.Front(), fileNamePointers.Size());
+ outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size());
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
@@ -239,42 +231,14 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
return NFileOperationReturnCode::kError;
- result = outArchive->DoOperation2(tempFileName, actionSetByte, NULL, updateCallback);
+ result = outArchive->DoOperation2(tempFile.OutStream, actionSetByte, NULL, updateCallback);
updateCallback.Release();
outArchive.Release();
- /*
- HRESULT result = Compress(fileNames, anArchivePrefix, *actionSet,
- m_ProxyHandler.get(),
- m_ArchiverInfo.ClassID, compressionInfo.Method == 0,
- compressionInfo.Method == 2, tempFileName, progressBoxPointer);
- */
-
- if (result != S_OK)
+ if (result == S_OK)
{
- ShowErrorMessage(result);
- return NFileOperationReturnCode::kError;
+ result = AfterUpdate(tempFile, pathVector);
}
-
- _folder.Release();
- m_ArchiveHandler->Close();
-
- // m_FolderItem = NULL;
-
- if (!DeleteFileAlways(m_FileName))
- {
- ShowLastErrorMessage();
- return NFileOperationReturnCode::kError;
- }
-
- tempFile.DisableDeleting();
- if (!MyMoveFile(tempFileName, m_FileName))
- {
- ShowLastErrorMessage();
- return NFileOperationReturnCode::kError;
- }
-
- m_ArchiveHandler->ReOpen(NULL);
if (result != S_OK)
{
ShowErrorMessage(result);
@@ -282,37 +246,17 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
}
/*
- if(m_ProxyHandler->ReInit(NULL) != S_OK)
- return NFileOperationReturnCode::kError;
- */
-
- ////////////////////////////
- // Restore FolderItem;
-
- m_ArchiveHandler->BindToRootFolder(&_folder);
- for (i = 0; i < aPathVector.Size(); i++)
+ if (moveMode != 0)
{
- CMyComPtr<IFolderFolder> newFolder;
- _folder->BindToFolder(aPathVector[i], &newFolder);
- if(!newFolder )
- break;
- _folder = newFolder;
- }
-
- /*
- if(moveMode != 0)
- {
- for(int i = 0; i < numItems; i++)
+ for (int i = 0; i < numItems; i++)
{
- const PluginPanelItem &aPluginPanelItem = panelItems[i];
+ const PluginPanelItem &pluginPanelItem = panelItems[i];
bool result;
- if(NFile::NFind::NAttributes::IsDir(aPluginPanelItem.FindData.dwFileAttributes))
- result = NFile::NDirectory::RemoveDirectoryWithSubItems(
- aPluginPanelItem.FindData.cFileName);
+ if (NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
+ result = NFile::NDirectory::RemoveDirectoryWithSubItems(pluginPanelItem.FindData.cFileName);
else
- result = NFile::NDirectory::DeleteFileAlways(
- aPluginPanelItem.FindData.cFileName);
- if(!result)
+ result = NFile::NDirectory::DeleteFileAlways(pluginPanelItem.FindData.cFileName);
+ if (!result)
return NFileOperationReturnCode::kError;
}
}
@@ -361,11 +305,11 @@ void CParsedPath::ParsePath(const UString &path)
case NPathType::kLocal:
{
int posDiskDelimiter = path.Find(kDiskDelimiter);
- if(posDiskDelimiter >= 0)
+ if (posDiskDelimiter >= 0)
{
curPos = posDiskDelimiter + 1;
if (path.Length() > curPos)
- if(path[curPos] == kDirDelimiter)
+ if (path[curPos] == kDirDelimiter)
curPos++;
}
break;
@@ -373,7 +317,7 @@ void CParsedPath::ParsePath(const UString &path)
case NPathType::kUNC:
{
int curPos = path.Find(kDirDelimiter, 2);
- if(curPos < 0)
+ if (curPos < 0)
curPos = path.Length();
else
curPos++;
@@ -386,7 +330,7 @@ void CParsedPath::ParsePath(const UString &path)
UString CParsedPath::MergePath() const
{
UString result = Prefix;
- for(int i = 0; i < PathParts.Size(); i++)
+ for (int i = 0; i < PathParts.Size(); i++)
{
if (i != 0)
result += kDirDelimiter;
@@ -409,20 +353,20 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
UStringVector fileNames;
int i;
- for(i = 0; i < pluginPanelItems.Size(); i++)
+ for (i = 0; i < pluginPanelItems.Size(); i++)
{
const PluginPanelItem &panelItem = pluginPanelItems[i];
- UString fullName;
if (strcmp(panelItem.FindData.cFileName, "..") == 0 &&
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
return E_FAIL;
if (strcmp(panelItem.FindData.cFileName, ".") == 0 &&
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
return E_FAIL;
- UString fileNameUnicode = MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP);
- if (!MyGetFullPathName(fileNameUnicode, fullName))
+ FString fullPath;
+ FString fileNameUnicode = us2fs(MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP));
+ if (!MyGetFullPathName(fileNameUnicode, fullPath))
return E_FAIL;
- fileNames.Add(fullName);
+ fileNames.Add(fs2us(fullPath));
}
NCompression::CInfo compressionInfo;
@@ -453,7 +397,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
{
CParsedPath parsedPath;
parsedPath.ParsePath(fileNames.Front());
- if(parsedPath.PathParts.Size() == 0)
+ if (parsedPath.PathParts.Size() == 0)
return E_FAIL;
if (fileNames.Size() == 1 || parsedPath.PathParts.Size() == 1)
{
@@ -589,7 +533,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
{
CIntVector indices;
CSysStringVector archiverNames;
- for(int i = 0; i < codecs->Formats.Size(); i++)
+ for (int i = 0; i < codecs->Formats.Size(); i++)
{
const CArcInfoEx &arc = codecs->Formats[i];
if (arc.UpdateEnabled)
@@ -602,7 +546,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT,
g_StartupInfo.GetMsgString(NMessageID::kUpdateSelectArchiverMenuTitle),
NULL, archiverNames, archiverIndex);
- if(index >= 0)
+ if (index >= 0)
{
const CArcInfoEx &prevArchiverInfo = codecs->Formats[prevFormat];
if (prevArchiverInfo.KeepName)
@@ -653,18 +597,12 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
NWorkDir::CInfo workDirInfo;
workDirInfo.Load();
- UString fullArchiveName;
- if (!MyGetFullPathName(archiveName, fullArchiveName))
+ FString fullArchiveName;
+ if (!MyGetFullPathName(us2fs(archiveName), fullArchiveName))
return E_FAIL;
- UString workDir = GetWorkDir(workDirInfo, fullArchiveName);
- CreateComplexDirectory(workDir);
-
- CTempFileW tempFile;
- UString tempFileName;
- if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
- return E_FAIL;
-
+ CWorkDirTempFile tempFile;
+ RINOK(tempFile.CreateTempFile(fullArchiveName));
CScreenRestorer screenRestorer;
CProgressBox progressBox;
@@ -678,12 +616,12 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
- NFind::CFileInfoW fileInfo;
+ NFind::CFileInfo fileInfo;
CMyComPtr<IOutFolderArchive> outArchive;
CMyComPtr<IInFolderArchive> archiveHandler;
- if(fileInfo.Find(fullArchiveName))
+ if (fileInfo.Find(fullArchiveName))
{
if (fileInfo.IsDir())
throw "There is Directory with such name";
@@ -702,7 +640,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
throw "Type of existing archive differs from specified type";
HRESULT result = archiveHandler.QueryInterface(
IID_IOutFolderArchive, &outArchive);
- if(result != S_OK)
+ if (result != S_OK)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return E_FAIL;
@@ -726,15 +664,11 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
CRecordVector<const wchar_t *> fileNamePointers;
fileNamePointers.Reserve(fileNames.Size());
- for(i = 0; i < fileNames.Size(); i++)
+ for (i = 0; i < fileNames.Size(); i++)
fileNamePointers.Add(fileNames[i]);
outArchive->SetFolder(NULL);
- // CSysString aCurrentFolder;
- // MyGetCurrentDirectory(aCurrentFolder);
- // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
- outArchive->SetFiles(L"",
- &fileNamePointers.Front(), fileNamePointers.Size());
+ outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size());
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
@@ -749,7 +683,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
HRESULT result = outArchive->DoOperation(
codecs, archiverIndex,
- tempFileName, actionSetByte,
+ tempFile.OutStream, actionSetByte,
NULL, updateCallback);
updateCallback.Release();
outArchive.Release();
@@ -760,21 +694,14 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
return result;
}
- if(archiveHandler)
+ if (archiveHandler)
{
archiveHandler->Close();
- if (!DeleteFileAlways(fullArchiveName))
- {
- ShowLastErrorMessage();
- return NFileOperationReturnCode::kError;
- }
}
- tempFile.DisableDeleting();
- if (!MyMoveFile(tempFileName, fullArchiveName))
+ if (!tempFile.MoveToOriginal(archiveHandler != NULL))
{
ShowLastErrorMessage();
return E_FAIL;
}
-
return S_OK;
}
diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp
index c195a79d..5f31f607 100755
--- a/CPP/7zip/UI/FileManager/App.cpp
+++ b/CPP/7zip/UI/FileManager/App.cpp
@@ -11,6 +11,8 @@
#include "Windows/COM.h"
#include "Windows/Error.h"
#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
#include "Windows/Thread.h"
@@ -31,7 +33,7 @@ using namespace NFind;
extern DWORD g_ComCtl32Version;
extern HINSTANCE g_hInstance;
-static LPCWSTR kTempDirPrefix = L"7zE";
+static CFSTR kTempDirPrefix = FTEXT("7zE");
void CPanelCallbackImp::OnTab()
{
@@ -374,7 +376,7 @@ static void ReducePathToRealFileSystemPath(UString &path)
{
while (!path.IsEmpty())
{
- if (NFind::DoesDirExist(path))
+ if (NFind::DoesDirExist(us2fs(path)))
{
NName::NormalizeDirPathPrefix(path);
break;
@@ -510,6 +512,8 @@ UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
return info;
}
+bool IsCorrectFsName(const UString name);
+
void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
@@ -599,10 +603,10 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
if (indices.Size() > 1 ||
(!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) ||
- NFind::DoesDirExist(destPath) ||
+ NFind::DoesDirExist(us2fs(destPath)) ||
srcPanel.IsArcFolder())
{
- NDirectory::CreateComplexDirectory(destPath);
+ NDirectory::CreateComplexDirectory(us2fs(destPath));
NName::NormalizeDirPathPrefix(destPath);
if (!CheckFolderPath(destPath))
{
@@ -616,11 +620,16 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
}
else
{
+ if (!IsCorrectFsName(destPath))
+ {
+ srcPanel.MessageBoxError(E_INVALIDARG);
+ return;
+ }
int pos = destPath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos >= 0)
{
UString prefix = destPath.Left(pos + 1);
- NDirectory::CreateComplexDirectory(prefix);
+ NDirectory::CreateComplexDirectory(us2fs(prefix));
if (!CheckFolderPath(prefix))
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
@@ -645,8 +654,8 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
bool useSrcPanel = (!useDestPanel || !srcPanel.IsFsOrDrivesFolder() || destPanel.IsFSFolder());
bool useTemp = useSrcPanel && useDestPanel;
- NFile::NDirectory::CTempDirectoryW tempDirectory;
- UString tempDirPrefix;
+ NFile::NDirectory::CTempDir tempDirectory;
+ FString tempDirPrefix;
if (useTemp)
{
tempDirectory.Create(kTempDirPrefix);
@@ -662,7 +671,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
HRESULT result;
if (useSrcPanel)
{
- UString folder = useTemp ? tempDirPrefix : destPath;
+ UString folder = useTemp ? fs2us(tempDirPrefix) : destPath;
result = srcPanel.CopyTo(indices, folder, move, true, 0);
if (result != S_OK)
{
@@ -681,7 +690,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
UStringVector filePaths;
UString folderPrefix;
if (useTemp)
- folderPrefix = tempDirPrefix;
+ folderPrefix = fs2us(tempDirPrefix);
else
folderPrefix = srcPanel._currentFolderPrefix;
filePaths.Reserve(indices.Size());
diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h
index a057c34e..2af63b47 100755
--- a/CPP/7zip/UI/FileManager/App.h
+++ b/CPP/7zip/UI/FileManager/App.h
@@ -202,7 +202,7 @@ public:
void SelectSpec(bool selectMode) { GetFocusedPanel().SelectSpec(selectMode); }
void SelectByType(bool selectMode) { GetFocusedPanel().SelectByType(selectMode); }
- void RefreshStatusBar() { GetFocusedPanel().RefreshStatusBar(); }
+ void Refresh_StatusBar() { GetFocusedPanel().Refresh_StatusBar(); }
void SetListViewMode(UInt32 index) { GetFocusedPanel().SetListViewMode(index); }
UInt32 GetListViewMode() { return GetFocusedPanel().GetListViewMode(); }
diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.cpp b/CPP/7zip/UI/FileManager/BrowseDialog.cpp
index 602b12f3..1c350064 100755
--- a/CPP/7zip/UI/FileManager/BrowseDialog.cpp
+++ b/CPP/7zip/UI/FileManager/BrowseDialog.cpp
@@ -2,13 +2,14 @@
#include "StdAfx.h"
-#ifdef UNDER_CE
+#include "BrowseDialog.h"
+
+#ifdef USE_MY_BROWSE_DIALOG
#include "Common/IntToString.h"
#include "Windows/PropVariantConversions.h"
-#include "BrowseDialog.h"
#include "LangUtils.h"
#include "PropertyNameRes.h"
@@ -60,7 +61,7 @@ bool CBrowseDialog::OnInit()
_list.Attach(GetItem(IDC_BROWSE_LIST));
#ifndef UNDER_CE
- _list.SetUnicodeFormat(true);
+ _list.SetUnicodeFormat();
#endif
#ifndef _SFX
@@ -191,8 +192,8 @@ int CBrowseDialog::CompareItems(LPARAM lParam1, LPARAM lParam2)
{
if (lParam1 == kParentIndex) return -1;
if (lParam2 == kParentIndex) return 1;
- const CFileInfoW &f1 = _files[(int)lParam1];
- const CFileInfoW &f2 = _files[(int)lParam2];
+ const CFileInfo &f1 = _files[(int)lParam1];
+ const CFileInfo &f2 = _files[(int)lParam2];
bool isDir1 = f1.IsDir();
bool isDir2 = f2.IsDir();
@@ -225,12 +226,12 @@ static HRESULT GetNormalizedError()
HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selectedName)
{
- CEnumeratorW enumerator(pathPrefix + L'*');
- CObjectVector<CFileInfoW> files;
+ CEnumerator enumerator(us2fs(pathPrefix + L'*'));
+ CObjectVector<CFileInfo> files;
for (;;)
{
bool found;
- CFileInfoW fi;
+ CFileInfo fi;
if (!enumerator.Next(fi, found))
return GetNormalizedError();
if (!found)
@@ -278,16 +279,17 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
for (int i = 0; i < _files.Size(); i++)
{
- const CFileInfoW &fi = _files[i];
+ const CFileInfo &fi = _files[i];
item.iItem = index;
- if (fi.Name.CompareNoCase(selectedName) == 0)
+ const UString name = fs2us(fi.Name);
+ if (name.CompareNoCase(selectedName) == 0)
cursorIndex = item.iItem;
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
int subItem = 0;
item.iSubItem = subItem++;
item.lParam = i;
- item.pszText = (wchar_t *)(const wchar_t *)fi.Name;
- item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, Path + fi.Name);
+ item.pszText = (wchar_t *)(const wchar_t *)name;
+ item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, Path + name);
if (item.iImage < 0)
item.iImage = 0;
_list.InsertItem(&item);
@@ -325,7 +327,7 @@ HRESULT CBrowseDialog::Reload()
{
int fileIndex = GetRealItemIndex(index);
if (fileIndex != kParentIndex)
- selectedCur = _files[fileIndex].Name;
+ selectedCur = fs2us(_files[fileIndex].Name);
}
return Reload(Path, selectedCur);
}
@@ -443,13 +445,13 @@ void CBrowseDialog::FinishOnOK()
OpenParentFolder();
return;
}
- const CFileInfoW &file = _files[fileIndex];
+ const CFileInfo &file = _files[fileIndex];
if (file.IsDir() != FolderMode)
{
ShowSelectError();
return;
}
- Path += file.Name;
+ Path += fs2us(file.Name);
}
End(IDOK);
}
@@ -464,7 +466,7 @@ void CBrowseDialog::OnItemEnter()
OpenParentFolder();
else
{
- const CFileInfoW &file = _files[fileIndex];
+ const CFileInfo &file = _files[fileIndex];
if (!file.IsDir())
{
if (!FolderMode)
@@ -473,7 +475,7 @@ void CBrowseDialog::OnItemEnter()
ShowSelectError();
return;
}
- HRESULT res = Reload(Path + file.Name + WCHAR_PATH_SEPARATOR, L"");
+ HRESULT res = Reload(Path + fs2us(file.Name) + WCHAR_PATH_SEPARATOR, L"");
if (res != S_OK)
ShowError(HResultToMessage(res));
}
@@ -481,6 +483,8 @@ void CBrowseDialog::OnItemEnter()
void CBrowseDialog::OnOK()
{
+ // When we press "Enter" in listview, windows sends message to first Button.
+ // We check that message was from listview;
if (GetFocus() == _list)
{
OnItemEnter();
diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.h b/CPP/7zip/UI/FileManager/BrowseDialog.h
index 41eb6b50..f597d1c3 100755
--- a/CPP/7zip/UI/FileManager/BrowseDialog.h
+++ b/CPP/7zip/UI/FileManager/BrowseDialog.h
@@ -4,6 +4,10 @@
#define __BROWSE_DIALOG_H
#ifdef UNDER_CE
+#define USE_MY_BROWSE_DIALOG
+#endif
+
+#ifdef USE_MY_BROWSE_DIALOG
#include "Windows/FileFind.h"
@@ -16,7 +20,7 @@
class CBrowseDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CListView _list;
- CObjectVector<NWindows::NFile::NFind::CFileInfoW> _files;
+ CObjectVector<NWindows::NFile::NFind::CFileInfo> _files;
CExtToIconMap _extToIconMap;
int _sortIndex;
bool _ascending;
diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp
index d27db23f..90076ebb 100755
--- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp
+++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp
@@ -2,12 +2,18 @@
#include "StdAfx.h"
+#include "Common/StringConvert.h"
+
#include "Windows/Error.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
#include "../../Common/FilePathAutoRename.h"
+#ifndef _SFX
+#include "../Common/ZipRegistry.h"
+#endif
+
#include "../GUI/ExtractRes.h"
#include "ExtractCallback.h"
@@ -177,6 +183,11 @@ STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
return S_OK;
}
+HRESULT CExtractCallbackImp::MessageError(const char *message, const FString &path)
+{
+ return MessageError(GetUnicodeString(message) + fs2us(path));
+}
+
STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *message)
{
AddErrorMessage(message);
@@ -296,7 +307,7 @@ HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, boo
MyLoadStringW(IDS_MEM_ERROR);
#endif
else
- NError::MyFormatMessage(result, message2);
+ message2 = NError::MyFormatMessageW(result);
message += message2;
}
MessageError(message);
@@ -339,11 +350,19 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
if (!PasswordIsDefined)
{
CPasswordDialog dialog;
+ #ifndef _SFX
+ bool showPassword = NExtract::Read_ShowPassword();
+ dialog.ShowPassword = showPassword;
+ #endif
ProgressDialog->WaitCreating();
if (dialog.Create(*ProgressDialog) == IDCANCEL)
return E_ABORT;
Password = dialog.Password;
PasswordIsDefined = true;
+ #ifndef _SFX
+ if (dialog.ShowPassword != showPassword)
+ NExtract::Save_ShowPassword(dialog.ShowPassword);
+ #endif
}
return StringToBstr(Password, password);
}
@@ -366,19 +385,16 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
*writeAnswer = BoolToInt(false);
UString destPathSpec = destPath;
- UString destPathSys = destPathSpec;
+ FString destPathSys = us2fs(destPath);
bool srcIsFolderSpec = IntToBool(srcIsFolder);
- CFileInfoW destFileInfo;
+ CFileInfo destFileInfo;
if (destFileInfo.Find(destPathSys))
{
if (srcIsFolderSpec)
{
if (!destFileInfo.IsDir())
{
- UString message = UString(L"can not replace file \'")
- + destPathSpec +
- UString(L"\' with folder with same name");
- RINOK(MessageError(message));
+ RINOK(MessageError("can not replace file with folder with same name: ", destPathSys));
return E_ABORT;
}
*writeAnswer = BoolToInt(false);
@@ -386,10 +402,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
}
if (destFileInfo.IsDir())
{
- UString message = UString(L"can not replace folder \'")
- + destPathSpec +
- UString(L"\' with file with same name");
- RINOK(MessageError(message));
+ RINOK(MessageError("can not replace folder with file with same name: ", destPathSys));
return E_FAIL;
}
@@ -432,19 +445,15 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
{
if (!AutoRenamePath(destPathSys))
{
- UString message = UString(L"can not create name of file ")
- + destPathSys;
- RINOK(MessageError(message));
+ RINOK(MessageError("can not create name for file: ", destPathSys));
return E_ABORT;
}
- destPathResultTemp = destPathSys;
+ destPathResultTemp = fs2us(destPathSys);
}
else
if (!NFile::NDirectory::DeleteFileAlways(destPathSys))
{
- UString message = UString(L"can not delete output file ")
- + destPathSys;
- RINOK(MessageError(message));
+ RINOK(MessageError("can not delete output file: ", destPathSys));
return E_ABORT;
}
}
diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.h b/CPP/7zip/UI/FileManager/ExtractCallback.h
index b4e88fd5..19c29e77 100755
--- a/CPP/7zip/UI/FileManager/ExtractCallback.h
+++ b/CPP/7zip/UI/FileManager/ExtractCallback.h
@@ -35,6 +35,7 @@ class CExtractCallbackImp:
#endif
public CMyUnknownImp
{
+ HRESULT MessageError(const char *message, const FString &path);
public:
MY_QUERYINTERFACE_BEGIN2(IFolderOperationsExtractCallback)
MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback)
diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp
index f3b48704..147a1fb7 100755
--- a/CPP/7zip/UI/FileManager/FM.cpp
+++ b/CPP/7zip/UI/FileManager/FM.cpp
@@ -33,7 +33,9 @@ using namespace NFind;
#define MENU_HEIGHT 26
+#ifdef _WIN32
HINSTANCE g_hInstance;
+#endif
HWND g_HWND;
bool g_OpenArchive = false;
static UString g_MainPath;
@@ -114,7 +116,7 @@ public:
};
static bool g_CanChangeSplitter = false;
-static UINT32 g_SplitterPos = 0;
+static UInt32 g_SplitterPos = 0;
static CSplitterPos g_Splitter;
static bool g_PanelsInfoDefined = false;
@@ -208,7 +210,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
ySize = rect.bottom - rect.top;
}
- UINT32 numPanels, currentPanel;
+ UInt32 numPanels, currentPanel;
g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos);
if (g_PanelsInfoDefined)
{
@@ -409,6 +411,30 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
{
#ifdef _WIN32
+ /*
+ #ifndef _WIN64
+ #ifndef UNDER_CE
+ {
+ HMODULE hMod = GetModuleHandle("Kernel32.dll");
+ if (hMod)
+ {
+ typedef BOOL (WINAPI *PSETDEP)(DWORD);
+ #define MY_PROCESS_DEP_ENABLE 1
+ PSETDEP procSet = (PSETDEP)GetProcAddress(hMod,"SetProcessDEPPolicy");
+ if (procSet)
+ procSet(MY_PROCESS_DEP_ENABLE);
+
+ typedef BOOL (WINAPI *HSI)(HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
+ HSI hsi = (HSI)GetProcAddress(hMod, "HeapSetInformation");
+ #define MY_HeapEnableTerminationOnCorruption ((HEAP_INFORMATION_CLASS)1)
+ if (hsi)
+ hsi(NULL, MY_HeapEnableTerminationOnCorruption, NULL, 0);
+ }
+ }
+ #endif
+ #endif
+ */
+
NT_CHECK
SetLargePageSize();
@@ -639,7 +665,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
bool needOpenFile = false;
if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
{
- if (NFile::NFind::DoesFileExist(g_MainPath))
+ if (NFile::NFind::DoesFileExist(us2fs(g_MainPath)))
needOpenFile = true;
}
HRESULT res = g_App.Create(hWnd, g_MainPath, g_ArcFormat, xSizes, archiveIsOpened, encrypted);
@@ -665,8 +691,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (res == E_OUTOFMEMORY)
message = LangString(IDS_MEM_ERROR, 0x0200060B);
else
- if (!NError::MyFormatMessage(res, message))
- message = L"Error";
+ message = NError::MyFormatMessageW(res);
}
}
MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
diff --git a/CPP/7zip/UI/FileManager/FSDrives.cpp b/CPP/7zip/UI/FileManager/FSDrives.cpp
index 87ee3fc9..823b0826 100755
--- a/CPP/7zip/UI/FileManager/FSDrives.cpp
+++ b/CPP/7zip/UI/FileManager/FSDrives.cpp
@@ -26,9 +26,9 @@ using namespace NWindows;
using namespace NFile;
using namespace NFind;
-static const wchar_t *kVolPrefix = L"\\\\.\\";
+static CFSTR kVolPrefix = FTEXT("\\\\.\\");
-UString CDriveInfo::GetDeviceFileIoName() const
+FString CDriveInfo::GetDeviceFileIoName() const
{
return kVolPrefix + Name;
}
@@ -40,7 +40,7 @@ struct CPhysTempBuffer
~CPhysTempBuffer() { MidFree(buffer); }
};
-static HRESULT CopyFileSpec(LPCWSTR fromPath, LPCWSTR toPath, bool writeToDisk, UInt64 fileSize,
+static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt64 fileSize,
UInt32 bufferSize, UInt64 progressStart, IProgress *progress)
{
NFile::NIO::CInFile inFile;
@@ -120,17 +120,17 @@ STDMETHODIMP CFSDrives::LoadItems()
{
_drives.Clear();
- UStringVector driveStrings;
+ FStringVector driveStrings;
MyGetLogicalDriveStrings(driveStrings);
for (int i = 0; i < driveStrings.Size(); i++)
{
CDriveInfo di;
- const UString &driveName = driveStrings[i];
+ const FString &driveName = driveStrings[i];
di.FullSystemName = driveName;
-
- di.Name = di.FullSystemName.Left(di.FullSystemName.Length() - 1);
+ if (!driveName.IsEmpty())
+ di.Name = driveName.Left(driveName.Length() - 1);
di.ClusterSize = 0;
di.DriveSize = 0;
di.FreeSpace = 0;
@@ -150,14 +150,11 @@ STDMETHODIMP CFSDrives::LoadItems()
}
if (needRead)
{
- UString volumeName, fileSystemName;
DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
NFile::NSystem::MyGetVolumeInformation(driveName,
- volumeName,
+ di.VolumeName,
&volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
- fileSystemName);
- di.VolumeName = volumeName;
- di.FileSystemName = fileSystemName;
+ di.FileSystemName);
NFile::NSystem::MyGetDiskFreeSpace(driveName,
di.ClusterSize, di.DriveSize, di.FreeSpace);
@@ -198,7 +195,7 @@ STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
return S_OK;
}
-HRESULT CFSDrives::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
+HRESULT CFSDrives::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
{
*resultFolder = 0;
if (_volumeMode)
@@ -232,7 +229,7 @@ STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
{
- return BindToFolderSpec(name, resultFolder);
+ return BindToFolderSpec(us2fs(name), resultFolder);
}
STDMETHODIMP CFSDrives::BindToParentFolder(IFolderFolder **resultFolder)
@@ -252,7 +249,7 @@ STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value)
case kpidType: prop = L"FSDrives"; break;
case kpidPath:
if (_volumeMode)
- prop = kVolPrefix;
+ prop = fs2us(kVolPrefix);
else
prop = LangString(IDS_COMPUTER, 0x03020300) + UString(WCHAR_PATH_SEPARATOR);
break;
@@ -325,7 +322,7 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
UString destPath = path;
if (destPath.IsEmpty())
return E_INVALIDARG;
- bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ bool directName = (destPath.Back() != WCHAR_PATH_SEPARATOR);
if (directName)
{
if (numItems > 1)
@@ -339,18 +336,18 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
int index = indices[i];
const CDriveInfo &di = _drives[index];
UString destPath2 = destPath;
- UString name = di.Name;
+ UString name = fs2us(di.Name);
if (!directName)
{
UString destName = name;
- if (!destName.IsEmpty() && destName[destName.Length() - 1] == L':')
+ if (!destName.IsEmpty() && destName.Back() == L':')
{
- destName.Delete(destName.Length() - 1);
+ destName.DeleteBack();
destName += GetExt(index);
}
destPath2 += destName;
}
- UString srcPath = di.GetDeviceFileIoName();
+ FString srcPath = di.GetDeviceFileIoName();
UInt64 fileSize = 0;
if (GetLength(index, fileSize) != S_OK)
@@ -363,16 +360,16 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
Int32 writeAskResult;
CMyComBSTR destPathResult;
- RINOK(callback->AskWrite(srcPath, BoolToInt(false), NULL, &fileSize,
+ RINOK(callback->AskWrite(fs2us(srcPath), BoolToInt(false), NULL, &fileSize,
destPath2, &destPathResult, &writeAskResult));
if (!IntToBool(writeAskResult))
continue;
- RINOK(callback->SetCurrentFilePath(srcPath));
+ RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
static const UInt32 kBufferSize = (4 << 20);
UInt32 bufferSize = (di.DriveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
- RINOK(CopyFileSpec(srcPath, destPathResult, false, fileSize, bufferSize, completedSize, callback));
+ RINOK(CopyFileSpec(srcPath, us2fs(destPathResult), false, fileSize, bufferSize, completedSize, callback));
completedSize += fileSize;
}
return S_OK;
@@ -393,6 +390,11 @@ STDMETHODIMP CFSDrives::CopyFrom(const wchar_t * /* fromFolderPath */,
return E_NOTIMPL;
}
+STDMETHODIMP CFSDrives::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
STDMETHODIMP CFSDrives::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */)
{
return E_NOTIMPL;
diff --git a/CPP/7zip/UI/FileManager/FSDrives.h b/CPP/7zip/UI/FileManager/FSDrives.h
index fc99bce7..a0cfd9be 100755
--- a/CPP/7zip/UI/FileManager/FSDrives.h
+++ b/CPP/7zip/UI/FileManager/FSDrives.h
@@ -10,8 +10,8 @@
struct CDriveInfo
{
- UString Name;
- UString FullSystemName;
+ FString Name;
+ FString FullSystemName;
bool KnownSizes;
UInt64 DriveSize;
UInt64 FreeSpace;
@@ -21,7 +21,7 @@ struct CDriveInfo
UString FileSystemName;
UINT DriveType;
- UString GetDeviceFileIoName() const;
+ FString GetDeviceFileIoName() const;
};
class CFSDrives:
@@ -33,7 +33,7 @@ class CFSDrives:
CObjectVector<CDriveInfo> _drives;
bool _volumeMode;
- HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
+ HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
UString GetExt(int index) const;
HRESULT GetLength(int index, UInt64 &length) const;
public:
diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp
index 1b3837cf..e4cb9f27 100755
--- a/CPP/7zip/UI/FileManager/FSFolder.cpp
+++ b/CPP/7zip/UI/FileManager/FSFolder.cpp
@@ -24,7 +24,7 @@
namespace NWindows {
namespace NFile {
-bool GetLongPath(LPCWSTR path, UString &longPath);
+bool GetLongPath(CFSTR path, UString &longPath);
}}
@@ -47,7 +47,7 @@ static STATPROPSTG kProps[] =
{ NULL, kpidPrefix, VT_BSTR}
};
-HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
+HRESULT CFSFolder::Init(const FString &path, IFolderFolder *parentFolder)
{
_parentFolder = parentFolder;
_path = path;
@@ -65,25 +65,25 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
{
DWORD lastError = GetLastError();
CFindFile findFile;
- CFileInfoW fi;
- if (!findFile.FindFirst(_path + UString(L"*"), fi))
+ CFileInfo fi;
+ if (!findFile.FindFirst(_path + FCHAR_ANY_MASK, fi))
return lastError;
}
return S_OK;
}
-HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
+static HRESULT GetFolderSize(const FString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
{
RINOK(progress->SetCompleted(NULL));
numFiles = numFolders = size = 0;
- CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*"));
- CFileInfoW fi;
+ CEnumerator enumerator(path + FSTRING_PATH_SEPARATOR FSTRING_ANY_MASK);
+ CFileInfo fi;
while (enumerator.Next(fi))
{
if (fi.IsDir())
{
UInt64 subFolders, subFiles, subSize;
- RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fi.Name, subFolders, subFiles, subSize, progress));
+ RINOK(GetFolderSize(path + FCHAR_PATH_SEPARATOR + fi.Name, subFolders, subFiles, subSize, progress));
numFolders += subFolders;
numFolders++;
numFiles += subFiles;
@@ -98,10 +98,10 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles,
return S_OK;
}
-HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
+HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const FString &path)
{
{
- CEnumeratorW enumerator(path + L"*");
+ CEnumerator enumerator(path + FCHAR_ANY_MASK);
CDirItem fi;
while (enumerator.Next(fi))
{
@@ -128,7 +128,7 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
{
CDirItem &item = dirItem.Files[i];
if (item.IsDir())
- LoadSubItems(item, path + item.Name + WCHAR_PATH_SEPARATOR);
+ LoadSubItems(item, path + item.Name + FCHAR_PATH_SEPARATOR);
}
return S_OK;
}
@@ -166,7 +166,7 @@ STDMETHODIMP CFSFolder::LoadItems()
return S_OK;
}
-static const wchar_t *kDescriptionFileName = L"descript.ion";
+static CFSTR kDescriptionFileName = FTEXT("descript.ion");
bool CFSFolder::LoadComments()
{
@@ -244,10 +244,10 @@ STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
*/
#ifndef UNDER_CE
-static bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
+static bool MyGetCompressedFileSizeW(CFSTR fileName, UInt64 &size)
{
DWORD highPart;
- DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
+ DWORD lowPart = ::GetCompressedFileSizeW(fs2us(fileName), &highPart);
if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
{
#ifdef WIN_LONG_PATH
@@ -274,7 +274,7 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
switch(propID)
{
case kpidIsDir: prop = fi.IsDir(); break;
- case kpidName: prop = fi.Name; break;
+ case kpidName: prop = fs2us(fi.Name); break;
case kpidSize: if (!fi.IsDir()) prop = fi.Size; break;
case kpidPackSize:
#ifdef UNDER_CE
@@ -298,7 +298,7 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
{
LoadComments();
UString comment;
- if (_comments.GetValue(GetRelPath(fi), comment))
+ if (_comments.GetValue(fs2us(GetRelPath(fi)), comment))
prop = comment;
break;
}
@@ -313,29 +313,29 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
return S_OK;
}
-HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
+HRESULT CFSFolder::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
{
*resultFolder = 0;
CFSFolder *folderSpec = new CFSFolder;
CMyComPtr<IFolderFolder> subFolder = folderSpec;
- RINOK(folderSpec->Init(_path + name + UString(WCHAR_PATH_SEPARATOR), 0));
+ RINOK(folderSpec->Init(_path + name + FCHAR_PATH_SEPARATOR, 0));
*resultFolder = subFolder.Detach();
return S_OK;
}
-UString CFSFolder::GetPrefix(const CDirItem &item) const
+FString CFSFolder::GetPrefix(const CDirItem &item) const
{
- UString path;
+ FString path;
CDirItem *cur = item.Parent;
while (cur->Parent != 0)
{
- path = cur->Name + UString(WCHAR_PATH_SEPARATOR) + path;
+ path = cur->Name + FCHAR_PATH_SEPARATOR + path;
cur = cur->Parent;
}
return path;
}
-UString CFSFolder::GetRelPath(const CDirItem &item) const
+FString CFSFolder::GetRelPath(const CDirItem &item) const
{
return GetPrefix(item) + item.Name;
}
@@ -351,7 +351,7 @@ STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
{
- return BindToFolderSpec(name, resultFolder);
+ return BindToFolderSpec(us2fs(name), resultFolder);
}
STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
@@ -365,11 +365,11 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
}
if (_path.IsEmpty())
return E_INVALIDARG;
- int pos = _path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ int pos = _path.ReverseFind(FCHAR_PATH_SEPARATOR);
if (pos < 0 || pos != _path.Length() - 1)
return E_FAIL;
- UString parentPath = _path.Left(pos);
- pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR);
+ FString parentPath = _path.Left(pos);
+ pos = parentPath.ReverseFind(FCHAR_PATH_SEPARATOR);
if (pos < 0)
{
#ifdef UNDER_CE
@@ -382,17 +382,17 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
#endif
return S_OK;
}
- UString parentPathReduced = parentPath.Left(pos);
+ FString parentPathReduced = parentPath.Left(pos);
parentPath = parentPath.Left(pos + 1);
#ifndef UNDER_CE
- pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR);
+ pos = parentPathReduced.ReverseFind(FCHAR_PATH_SEPARATOR);
if (pos == 1)
{
- if (parentPath[0] != WCHAR_PATH_SEPARATOR)
+ if (parentPath[0] != FCHAR_PATH_SEPARATOR)
return E_FAIL;
CNetFolder *netFolderSpec = new CNetFolder;
CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
- netFolderSpec->Init(parentPath);
+ netFolderSpec->Init(fs2us(parentPath));
*resultFolder = netFolder.Detach();
return S_OK;
}
@@ -421,7 +421,7 @@ STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
switch(propID)
{
case kpidType: prop = L"FSFolder"; break;
- case kpidPath: prop = _path; break;
+ case kpidPath: prop = fs2us(_path); break;
}
prop.Detach(value);
return S_OK;
@@ -532,13 +532,13 @@ STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgr
return result;
}
-HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
+HRESULT CFSFolder::GetComplexName(CFSTR name, FString &resultPath)
{
- UString newName = name;
+ FString newName = name;
resultPath = _path + newName;
if (newName.Length() < 1)
return S_OK;
- if (newName[0] == WCHAR_PATH_SEPARATOR)
+ if (newName[0] == FCHAR_PATH_SEPARATOR)
{
resultPath = newName;
return S_OK;
@@ -552,11 +552,11 @@ HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */)
{
- UString processedName;
- RINOK(GetComplexName(name, processedName));
- if(NDirectory::MyCreateDirectory(processedName))
+ FString processedName;
+ RINOK(GetComplexName(us2fs(name), processedName));
+ if (NDirectory::MyCreateDirectory(processedName))
return S_OK;
- if(::GetLastError() == ERROR_ALREADY_EXISTS)
+ if (::GetLastError() == ERROR_ALREADY_EXISTS)
return ::GetLastError();
if (!NDirectory::CreateComplexDirectory(processedName))
return ::GetLastError();
@@ -565,8 +565,8 @@ STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progres
STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */)
{
- UString processedName;
- RINOK(GetComplexName(name, processedName));
+ FString processedName;
+ RINOK(GetComplexName(us2fs(name), processedName));
NIO::COutFile outFile;
if (!outFile.Create(processedName, false))
return ::GetLastError();
@@ -576,8 +576,8 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress
STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */)
{
const CDirItem &fi = *_refs[index];
- const UString fullPrefix = _path + GetPrefix(fi);
- if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + newName))
+ const FString fullPrefix = _path + GetPrefix(fi);
+ if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + us2fs(newName)))
return GetLastError();
return S_OK;
}
@@ -588,7 +588,7 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress
for (UInt32 i = 0; i < numItems; i++)
{
const CDirItem &fi = *_refs[indices[i]];
- const UString fullPath = _path + GetRelPath(fi);
+ const FString fullPath = _path + GetRelPath(fi);
bool result;
if (fi.IsDir())
result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
@@ -614,7 +614,7 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
{
case kpidComment:
{
- UString filename = fi.Name;
+ UString filename = fs2us(fi.Name);
filename.Trim();
if (value->vt == VT_EMPTY)
_comments.DeletePair(filename);
diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h
index e39004ad..13e9e018 100755
--- a/CPP/7zip/UI/FileManager/FSFolder.h
+++ b/CPP/7zip/UI/FileManager/FSFolder.h
@@ -1,7 +1,7 @@
// FSFolder.h
-#ifndef __FSFOLDER_H
-#define __FSFOLDER_H
+#ifndef __FS_FOLDER_H
+#define __FS_FOLDER_H
#include "Common/MyCom.h"
@@ -14,7 +14,7 @@ namespace NFsFolder {
class CFSFolder;
-struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
+struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfo
{
#ifndef UNDER_CE
bool CompressedSizeIsDefined;
@@ -74,7 +74,7 @@ public:
STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
private:
- UString _path;
+ FString _path;
CDirItem _root;
CRecordVector<CDirItem *> _refs;
@@ -90,24 +90,24 @@ private:
HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
- HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
- HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
+ HRESULT GetComplexName(CFSTR name, FString &resultPath);
+ HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
bool LoadComments();
bool SaveComments();
- HRESULT LoadSubItems(CDirItem &dirItem, const UString &path);
+ HRESULT LoadSubItems(CDirItem &dirItem, const FString &path);
void AddRefs(CDirItem &dirItem);
public:
- HRESULT Init(const UString &path, IFolderFolder *parentFolder);
+ HRESULT Init(const FString &path, IFolderFolder *parentFolder);
#ifdef UNDER_CE
- HRESULT InitToRoot() { return Init(L"\\", NULL); }
+ HRESULT InitToRoot() { return Init(FTEXT("\\"), NULL); }
#endif
CFSFolder() : _flatMode(false) {}
- UString GetPrefix(const CDirItem &item) const;
- UString GetRelPath(const CDirItem &item) const;
- UString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
+ FString GetPrefix(const CDirItem &item) const;
+ FString GetRelPath(const CDirItem &item) const;
+ FString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
void Clear()
{
@@ -116,8 +116,6 @@ public:
}
};
-HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
-
}
#endif
diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
index b6ffd574..c31498c7 100755
--- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
+++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
@@ -102,13 +102,7 @@ typedef BOOL (WINAPI * CopyFileExPointerW)(
IN DWORD dwCopyFlags
);
-#ifndef _UNICODE
-static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-static CSysString GetSysPath(LPCWSTR sysPath)
- { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
-#endif
-
-static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
+static bool MyCopyFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, UInt64 &completedSize)
{
CProgressInfo progressInfo;
progressInfo.Progress = progress;
@@ -128,8 +122,8 @@ static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
My_GetProcAddress(::GetModuleHandleW(k_DllName), "CopyFileExW");
if (copyFunctionW == 0)
- return BOOLToBool(::CopyFileW(existingFile, newFile, TRUE));
- if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
+ return BOOLToBool(::CopyFileW(fs2us(existingFile), fs2us(newFile), TRUE));
+ if (copyFunctionW(fs2us(existingFile), fs2us(newFile), CopyProgressRoutine,
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
return true;
#ifdef WIN_LONG_PATH
@@ -150,13 +144,13 @@ static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
"CopyFileExA");
if (copyFunction != 0)
{
- if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
+ if (copyFunction(fs2fas(existingFile), fs2fas(newFile),
CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
return true;
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return false;
}
- return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
+ return BOOLToBool(::CopyFile(fs2fas(existingFile), fs2fas(newFile), TRUE));
}
#endif
}
@@ -169,7 +163,7 @@ typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
IN DWORD dwFlags
);
-static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
+static bool MyMoveFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, UInt64 &completedSize)
{
#ifndef UNDER_CE
// if (IsItWindows2000orHigher())
@@ -184,7 +178,7 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
if (moveFunction != 0)
{
if (moveFunction(
- existingFile, newFile, CopyProgressRoutine,
+ fs2us(existingFile), fs2us(newFile), CopyProgressRoutine,
&progressInfo, MOVEFILE_COPY_ALLOWED))
return true;
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
@@ -207,41 +201,48 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
return NDirectory::MyMoveFile(existingFile, newFile);
}
+static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
+ const wchar_t *message, const FString &fileName)
+{
+ return callback->ShowMessage(message + fs2us(fileName));
+}
+
+static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
+ const char *message, const FString &fileName)
+{
+ return SendMessageError(callback, MultiByteToUnicodeString(message), fileName);
+}
+
static HRESULT MyCopyFile(
- const UString &srcPath,
- const CFileInfoW &srcFileInfo,
- const UString &destPathSpec,
+ const FString &srcPath,
+ const CFileInfo &srcFileInfo,
+ const FString &destPathSpec,
IFolderOperationsExtractCallback *callback,
UInt64 &completedSize)
{
- UString destPath = destPathSpec;
+ FString destPath = destPathSpec;
if (destPath.CompareNoCase(srcPath) == 0)
{
- UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not copy file onto itself: ", destPath));
return E_ABORT;
}
Int32 writeAskResult;
CMyComBSTR destPathResult;
RINOK(callback->AskWrite(
- srcPath,
+ fs2us(srcPath),
BoolToInt(false),
&srcFileInfo.MTime, &srcFileInfo.Size,
- destPath,
+ fs2us(destPath),
&destPathResult,
&writeAskResult));
if (IntToBool(writeAskResult))
{
- UString destPathNew = UString(destPathResult);
- RINOK(callback->SetCurrentFilePath(srcPath));
+ FString destPathNew = us2fs(destPathResult);
+ RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
if (!MyCopyFile(srcPath, destPathNew, callback, completedSize))
{
- UString message = NError::MyFormatMessageW(GetLastError()) +
- UString(L" \'") +
- UString(destPathNew) +
- UString(L"\'");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, NError::MyFormatMessageW(GetLastError()) + L" : ", destPathNew));
return E_ABORT;
}
}
@@ -249,44 +250,41 @@ static HRESULT MyCopyFile(
return callback->SetCompleted(&completedSize);
}
-static UString CombinePath(const UString &folderPath, const UString &fileName)
+static FString CombinePath(const FString &folderPath, const FString &fileName)
{
- return folderPath + UString(WCHAR_PATH_SEPARATOR) + fileName;
+ return folderPath + FCHAR_PATH_SEPARATOR + fileName;
}
static HRESULT CopyFolder(
- const UString &srcPath,
- const UString &destPathSpec,
+ const FString &srcPath,
+ const FString &destPathSpec,
IFolderOperationsExtractCallback *callback,
UInt64 &completedSize)
{
RINOK(callback->SetCompleted(&completedSize));
- const UString destPath = destPathSpec;
+ const FString destPath = destPathSpec;
int len = srcPath.Length();
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
{
- if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
+ if (destPath.Length() == len || destPath[len] == FCHAR_PATH_SEPARATOR)
{
- UString message = UString(L"can not copy folder \'") +
- destPath + UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not copy folder onto itself: ", destPath));
return E_ABORT;
}
}
if (!NDirectory::CreateComplexDirectory(destPath))
{
- UString message = UString(L"can not create folder ") + destPath;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not create folder: ", destPath));
return E_ABORT;
}
- CEnumeratorW enumerator(CombinePath(srcPath, L"*"));
+ CEnumerator enumerator(CombinePath(srcPath, FSTRING_ANY_MASK));
CFileInfoEx fi;
while (enumerator.Next(fi))
{
- const UString srcPath2 = CombinePath(srcPath, fi.Name);
- const UString destPath2 = CombinePath(destPath, fi.Name);
+ const FString srcPath2 = CombinePath(srcPath, fi.Name);
+ const FString destPath2 = CombinePath(destPath, fi.Name);
if (fi.IsDir())
{
RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize))
@@ -313,7 +311,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
UString destPath = path;
if (destPath.IsEmpty())
return E_INVALIDARG;
- bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ bool directName = (destPath.Back() != WCHAR_PATH_SEPARATOR);
if (directName)
{
if (numItems > 1)
@@ -337,10 +335,10 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
for (UInt32 i = 0; i < numItems; i++)
{
const CDirItem &fi = *_refs[indices[i]];
- UString destPath2 = destPath;
+ FString destPath2 = us2fs(destPath);
if (!directName)
destPath2 += fi.Name;
- UString srcPath = _path + GetPrefix(fi) + fi.Name;
+ FString srcPath = _path + GetPrefix(fi) + fi.Name;
if (fi.IsDir())
{
RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
@@ -356,40 +354,35 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
/////////////////////////////////////////////////
// Move Operations
-HRESULT MyMoveFile(
- const UString &srcPath,
- const CFileInfoW &srcFileInfo,
- const UString &destPathSpec,
+static HRESULT MyMoveFile(
+ const FString &srcPath,
+ const CFileInfo &srcFileInfo,
+ const FString &destPath,
IFolderOperationsExtractCallback *callback,
UInt64 &completedSize)
{
- UString destPath = destPathSpec;
if (destPath.CompareNoCase(srcPath) == 0)
{
- UString message = UString(L"can not move file \'")
- + destPath +
- UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not move file onto itself: ", srcPath));
return E_ABORT;
}
Int32 writeAskResult;
CMyComBSTR destPathResult;
RINOK(callback->AskWrite(
- srcPath,
+ fs2us(srcPath),
BoolToInt(false),
&srcFileInfo.MTime, &srcFileInfo.Size,
- destPath,
+ fs2us(destPath),
&destPathResult,
&writeAskResult));
if (IntToBool(writeAskResult))
{
- UString destPathNew = UString(destPathResult);
- RINOK(callback->SetCurrentFilePath(srcPath));
+ FString destPathNew = us2fs(destPathResult);
+ RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
{
- UString message = UString(L"can not move to file ") + destPathNew;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not move to file: ", destPathNew));
}
}
completedSize += srcFileInfo.Size;
@@ -397,21 +390,18 @@ HRESULT MyMoveFile(
return S_OK;
}
-HRESULT MyMoveFolder(
- const UString &srcPath,
- const UString &destPathSpec,
+static HRESULT MyMoveFolder(
+ const FString &srcPath,
+ const FString &destPath,
IFolderOperationsExtractCallback *callback,
UInt64 &completedSize)
{
- UString destPath = destPathSpec;
int len = srcPath.Length();
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
{
- if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
+ if (destPath.Length() == len || destPath[len] == FCHAR_PATH_SEPARATOR)
{
- UString message = UString(L"can not move folder \'") +
- destPath + UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not move folder onto itself: ", destPath));
return E_ABORT;
}
}
@@ -421,17 +411,16 @@ HRESULT MyMoveFolder(
if (!NDirectory::CreateComplexDirectory(destPath))
{
- UString message = UString(L"can not create folder ") + destPath;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not create folder: ", destPath));
return E_ABORT;
}
{
- CEnumeratorW enumerator(CombinePath(srcPath, L"*"));
+ CEnumerator enumerator(CombinePath(srcPath, FSTRING_ANY_MASK));
CFileInfoEx fi;
while (enumerator.Next(fi))
{
- const UString srcPath2 = CombinePath(srcPath, fi.Name);
- const UString destPath2 = CombinePath(destPath, fi.Name);
+ const FString srcPath2 = CombinePath(srcPath, fi.Name);
+ const FString destPath2 = CombinePath(destPath, fi.Name);
if (fi.IsDir())
{
RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
@@ -444,8 +433,7 @@ HRESULT MyMoveFolder(
}
if (!NDirectory::MyRemoveDirectory(srcPath))
{
- UString message = UString(L"can not remove folder") + srcPath;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not remove folder: ", srcPath));
return E_ABORT;
}
return S_OK;
@@ -465,10 +453,10 @@ STDMETHODIMP CFSFolder::MoveTo(
RINOK(callback->SetTotal(totalSize));
RINOK(callback->SetNumFiles(numFiles));
- UString destPath = path;
+ FString destPath = us2fs(path);
if (destPath.IsEmpty())
return E_INVALIDARG;
- bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ bool directName = (destPath.Back() != FCHAR_PATH_SEPARATOR);
if (directName)
{
if (numItems > 1)
@@ -477,9 +465,7 @@ STDMETHODIMP CFSFolder::MoveTo(
else
if (!NDirectory::CreateComplexDirectory(destPath))
{
- UString message = UString(L"can not create folder ") +
- destPath;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not create folder: ", destPath));
return E_ABORT;
}
@@ -488,10 +474,10 @@ STDMETHODIMP CFSFolder::MoveTo(
for (UInt32 i = 0; i < numItems; i++)
{
const CDirItem &fi = *_refs[indices[i]];
- UString destPath2 = destPath;
+ FString destPath2 = destPath;
if (!directName)
destPath2 += fi.Name;
- UString srcPath = _path + GetPrefix(fi) + fi.Name;
+ FString srcPath = _path + GetPrefix(fi) + fi.Name;
if (fi.IsDir())
{
RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
@@ -515,7 +501,7 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
{
UString path = (UString)fromFolderPath + itemsPaths[i];
- CFileInfoW fi;
+ CFileInfo fi;
if (!FindFile(path, fi))
return ::GetLastError();
if (fi.IsDir())
@@ -544,4 +530,9 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
return E_NOTIMPL;
}
+STDMETHODIMP CFSFolder::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
}
diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
index 08f15c18..d29ac44c 100755
--- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
+++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
@@ -4,6 +4,7 @@
#include "resource.h"
+#include "Windows/FileName.h"
#include "Windows/Thread.h"
#include "../Agent/Agent.h"
@@ -11,11 +12,9 @@
#include "LangUtils.h"
#include "OpenCallback.h"
#include "PluginLoader.h"
-#include "RegistryAssociations.h"
#include "RegistryPlugins.h"
using namespace NWindows;
-using namespace NRegistryAssociations;
struct CThreadArchiveOpen
{
@@ -56,9 +55,29 @@ static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &
}
*/
+static const FChar kExtensionDelimiter = FTEXT('.');
+
+static void SplitNameToPureNameAndExtension(const FString &fullName,
+ FString &pureName, FString &extensionDelimiter, FString &extension)
+{
+ int index = fullName.ReverseFind(kExtensionDelimiter);
+ if (index < 0)
+ {
+ pureName = fullName;
+ extensionDelimiter.Empty();
+ extension.Empty();
+ }
+ else
+ {
+ pureName = fullName.Left(index);
+ extensionDelimiter = kExtensionDelimiter;
+ extension = fullName.Mid(index + 1);
+ }
+}
+
HRESULT OpenFileFolderPlugin(
IInStream *inStream,
- const UString &path,
+ const FString &path,
const UString &arcFormat,
HMODULE *module,
IFolderFolder **resultFolder,
@@ -68,11 +87,11 @@ HRESULT OpenFileFolderPlugin(
CObjectVector<CPluginInfo> plugins;
ReadFileFolderPluginInfoList(plugins);
- UString extension, name, pureName, dot;
+ FString extension, name, pureName, dot;
- int slashPos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
- UString dirPrefix;
- UString fileName;
+ int slashPos = path.ReverseFind(FCHAR_PATH_SEPARATOR);
+ FString dirPrefix;
+ FString fileName;
if (slashPos >= 0)
{
dirPrefix = path.Left(slashPos + 1);
@@ -81,7 +100,7 @@ HRESULT OpenFileFolderPlugin(
else
fileName = path;
- NFile::NName::SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
+ SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
/*
if (!extension.IsEmpty())
@@ -124,12 +143,12 @@ HRESULT OpenFileFolderPlugin(
t.OpenCallbackSpec->ParentWindow = parentWindow;
if (inStream)
- t.OpenCallbackSpec->SetSubArchiveName(fileName);
+ t.OpenCallbackSpec->SetSubArchiveName(fs2us(fileName));
else
t.OpenCallbackSpec->LoadFileInfo(dirPrefix, fileName);
t.InStream = inStream;
- t.Path = path;
+ t.Path = fs2us(path);
t.ArcFormat = arcFormat;
UString progressTitle = LangString(IDS_OPENNING, 0x03020283);
diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
index 85717efd..593880e9 100755
--- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
+++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
@@ -3,7 +3,7 @@
#ifndef __FILE_FOLDER_PLUGIN_OPEN_H
#define __FILE_FOLDER_PLUGIN_OPEN_H
-HRESULT OpenFileFolderPlugin(IInStream *inStream, const UString &path, const UString &arcFormat,
+HRESULT OpenFileFolderPlugin(IInStream *inStream, const FString &path, const UString &arcFormat,
HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password);
#endif
diff --git a/CPP/7zip/UI/FileManager/FilePlugins.cpp b/CPP/7zip/UI/FileManager/FilePlugins.cpp
index 22993383..b81850fd 100755
--- a/CPP/7zip/UI/FileManager/FilePlugins.cpp
+++ b/CPP/7zip/UI/FileManager/FilePlugins.cpp
@@ -2,73 +2,39 @@
#include "StdAfx.h"
-#include "Common/MyCom.h"
-
#include "../Agent/Agent.h"
#include "FilePlugins.h"
#include "PluginLoader.h"
#include "StringUtils.h"
-using namespace NRegistryAssociations;
-
-int CExtDatabase::FindExtInfoBig(const UString &ext)
-{
- for (int i = 0; i < ExtBigItems.Size(); i++)
- if (ExtBigItems[i].Ext.CompareNoCase(ext) == 0)
- return i;
- return -1;
-}
-
-int CExtDatabase::FindPlugin(const UString &plugin)
+int CExtDatabase::FindExt(const UString &ext)
{
- for (int i = 0; i < Plugins.Size(); i++)
- if (Plugins[i].Name.CompareNoCase(plugin) == 0)
+ for (int i = 0; i < Exts.Size(); i++)
+ if (Exts[i].Ext.CompareNoCase(ext) == 0)
return i;
return -1;
}
void CExtDatabase::Read()
{
- /*
- CObjectVector<CExtInfo> extItems;
- ReadInternalAssociations(extItems);
- */
ReadFileFolderPluginInfoList(Plugins);
- /*
- for (int i = 0; i < extItems.Size(); i++)
- {
- const CExtInfo &extInfo = extItems[i];
- CExtInfoBig extInfoBig;
- extInfoBig.Ext = extInfo.Ext;
- extInfoBig.Associated = false;
- for (int p = 0; p < extInfo.Plugins.Size(); p++)
- {
- int pluginIndex = FindPlugin(extInfo.Plugins[p]);
- if (pluginIndex >= 0)
- extInfoBig.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, true));
- }
- ExtBigItems.Add(extInfoBig);
- }
- */
for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++)
{
- const CPluginInfo &pluginInfo = Plugins[pluginIndex];
+ const CPluginInfo &plugin = Plugins[pluginIndex];
- CPluginLibrary pluginLibrary;
+ CPluginLibrary pluginLib;
CMyComPtr<IFolderManager> folderManager;
- if (pluginInfo.FilePath.IsEmpty())
+ if (plugin.FilePath.IsEmpty())
folderManager = new CArchiveFolderManager;
- else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath,
- pluginInfo.ClassID, &folderManager) != S_OK)
+ else if (pluginLib.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK)
continue;
CMyComBSTR extBSTR;
if (folderManager->GetExtensions(&extBSTR) != S_OK)
return;
- const UString ext2 = (const wchar_t *)extBSTR;
UStringVector exts;
- SplitString(ext2, exts);
+ SplitString((const wchar_t *)extBSTR, exts);
for (int i = 0; i < exts.Size(); i++)
{
const UString &ext = exts[i];
@@ -76,44 +42,28 @@ void CExtDatabase::Read()
if (ext == L"cab")
continue;
#endif
- int index = FindExtInfoBig(ext);
- if (index < 0)
- {
- CExtInfoBig extInfo;
- extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
- extInfo.Associated = false;
- extInfo.Ext = ext;
- ExtBigItems.Add(extInfo);
- }
+
+ Int32 iconIndex;
+ CMyComBSTR iconPath;
+ CPluginToIcon plugPair;
+ plugPair.PluginIndex = pluginIndex;
+ if (folderManager->GetIconPath(ext, &iconPath, &iconIndex) == S_OK)
+ if (iconPath != 0)
+ {
+ plugPair.IconPath = (const wchar_t *)iconPath;
+ plugPair.IconIndex = iconIndex;
+ }
+
+ int index = FindExt(ext);
+ if (index >= 0)
+ Exts[index].Plugins.Add(plugPair);
else
{
- CExtInfoBig &extInfo = ExtBigItems[index];
- int pluginIndexIndex = extInfo.FindPlugin(pluginIndex);
- if (pluginIndexIndex < 0)
- extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
+ CExtPlugins extInfo;
+ extInfo.Plugins.Add(plugPair);
+ extInfo.Ext = ext;
+ Exts.Add(extInfo);
}
}
}
}
-
-void CExtDatabase::Save()
-{
- /*
- CObjectVector<CExtInfo> extItems;
- for (int i = 0; i < ExtBigItems.Size(); i++)
- {
- const CExtInfoBig &extInfoBig = ExtBigItems[i];
- CExtInfo extInfo;
- // extInfo.Enabled = extInfoBig.Associated;
- extInfo.Ext = extInfoBig.Ext;
- for (int p = 0; p < extInfoBig.PluginsPairs.Size(); p++)
- {
- CPluginEnabledPair pluginPair = extInfoBig.PluginsPairs[p];
- if (pluginPair.Enabled)
- extInfo.Plugins.Add(Plugins[pluginPair.Index].Name);
- }
- extItems.Add(extInfo);
- }
- WriteInternalAssociations(extItems);
- */
-}
diff --git a/CPP/7zip/UI/FileManager/FilePlugins.h b/CPP/7zip/UI/FileManager/FilePlugins.h
index 1becb9d1..43b05f92 100755
--- a/CPP/7zip/UI/FileManager/FilePlugins.h
+++ b/CPP/7zip/UI/FileManager/FilePlugins.h
@@ -1,54 +1,33 @@
// FilePlugins.h
-#ifndef __FILEPLUGINS_H
-#define __FILEPLUGINS_H
+#ifndef __FILE_PLUGINS_H
+#define __FILE_PLUGINS_H
#include "RegistryPlugins.h"
-#include "RegistryAssociations.h"
-struct CPluginEnabledPair
+struct CPluginToIcon
{
- int Index;
- bool Enabled;
- CPluginEnabledPair(int index, bool enabled): Index(index),Enabled(enabled) {}
+ int PluginIndex;
+ UString IconPath;
+ int IconIndex;
+
+ CPluginToIcon(): IconIndex(-1) {}
};
-struct CExtInfoBig
+struct CExtPlugins
{
UString Ext;
- bool Associated;
- CRecordVector<CPluginEnabledPair> PluginsPairs;
- int FindPlugin(int pluginIndex)
- {
- for (int i = 0; i < PluginsPairs.Size(); i++)
- if (PluginsPairs[i].Index == pluginIndex)
- return i;
- return -1;
- }
+ CObjectVector<CPluginToIcon> Plugins;
};
class CExtDatabase
{
+ int FindExt(const UString &ext);
public:
- CObjectVector<CExtInfoBig> ExtBigItems;
+ CObjectVector<CExtPlugins> Exts;
CObjectVector<CPluginInfo> Plugins;
- int FindExtInfoBig(const UString &ext);
- int FindPlugin(const UString &plugin);
-
- UString GetMainPluginNameForExtItem(int extIndex) const
- {
- const CExtInfoBig &extInfo = ExtBigItems[extIndex];
- if (extInfo.PluginsPairs.IsEmpty())
- return UString();
- else
- return Plugins[extInfo.PluginsPairs.Front().Index].Name;
- }
-
+
void Read();
- void Save();
};
-
#endif
-
-
diff --git a/CPP/7zip/UI/FileManager/FoldersPage.cpp b/CPP/7zip/UI/FileManager/FoldersPage.cpp
index 068b9d47..b7366fed 100755
--- a/CPP/7zip/UI/FileManager/FoldersPage.cpp
+++ b/CPP/7zip/UI/FileManager/FoldersPage.cpp
@@ -42,7 +42,7 @@ bool CFoldersPage::OnInit()
m_WorkPath.Init(*this, IDC_FOLDERS_WORK_EDIT_PATH);
m_ButtonSetWorkPath.Init(*this, IDC_FOLDERS_WORK_BUTTON_PATH);
- m_WorkPath.SetText(m_WorkDirInfo.Path);
+ m_WorkPath.SetText(fs2us(m_WorkDirInfo.Path));
MyEnableControls();
@@ -66,7 +66,9 @@ void CFoldersPage::MyEnableControls()
void CFoldersPage::GetWorkDir(NWorkDir::CInfo &workDirInfo)
{
- m_WorkPath.GetText(workDirInfo.Path);
+ UString s;
+ m_WorkPath.GetText(s);
+ workDirInfo.Path = us2fs(s);
workDirInfo.ForRemovableOnly = IsButtonCheckedBool(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE);
workDirInfo.Mode = NWorkDir::NMode::EEnum(GetWorkMode());
}
@@ -143,7 +145,7 @@ LONG CFoldersPage::OnApply()
return PSNRET_NOERROR;
}
-static LPCWSTR kFoldersTopic = L"fm/plugins/7-zip/options.htm#folders";
+static LPCWSTR kFoldersTopic = L"fm/options.htm#folders";
void CFoldersPage::OnNotifyHelp()
{
diff --git a/CPP/7zip/UI/FileManager/HelpUtils.cpp b/CPP/7zip/UI/FileManager/HelpUtils.cpp
index a1c17399..3128cb28 100755
--- a/CPP/7zip/UI/FileManager/HelpUtils.cpp
+++ b/CPP/7zip/UI/FileManager/HelpUtils.cpp
@@ -5,8 +5,8 @@
#include <HtmlHelp.h>
#include "Common/StringConvert.h"
+#include "Windows/DLL.h"
#include "HelpUtils.h"
-#include "ProgramLocation.h"
static LPCWSTR kHelpFileName = L"7-zip.chm::/";
@@ -17,11 +17,7 @@ void ShowHelpWindow(HWND, LPCWSTR)
#else
void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
{
- UString path;
- if (!::GetProgramFolderPath(path))
- return;
- path += kHelpFileName;
- path += topicFile;
- HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);
+ FString path = NWindows::NDLL::GetModuleDirPrefix();
+ HtmlHelp(hwnd, GetSystemString(fs2us(path) + kHelpFileName + topicFile), HH_DISPLAY_TOPIC, NULL);
}
#endif
diff --git a/CPP/7zip/UI/FileManager/IFolder.h b/CPP/7zip/UI/FileManager/IFolder.h
index 743017b8..d6cce88f 100755
--- a/CPP/7zip/UI/FileManager/IFolder.h
+++ b/CPP/7zip/UI/FileManager/IFolder.h
@@ -70,8 +70,9 @@ FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B)
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath, \
const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress) x; \
STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) x; \
+ STDMETHOD(CopyFromFile)(UInt32 index, const wchar_t *fullFilePath, IProgress *progress) x; \
-FOLDER_INTERFACE(IFolderOperations, 0x06)
+FOLDER_INTERFACE(IFolderOperations, 0x12)
{
INTERFACE_FolderOperations(PURE)
};
diff --git a/CPP/7zip/UI/FileManager/LangUtils.cpp b/CPP/7zip/UI/FileManager/LangUtils.cpp
index 52f85348..20f4655b 100755
--- a/CPP/7zip/UI/FileManager/LangUtils.cpp
+++ b/CPP/7zip/UI/FileManager/LangUtils.cpp
@@ -2,14 +2,16 @@
#include "StdAfx.h"
-#include "LangUtils.h"
#include "Common/StringConvert.h"
#include "Common/StringToInt.h"
+
+#include "Windows/DLL.h"
+#include "Windows/FileFind.h"
#include "Windows/Synchronization.h"
#include "Windows/Window.h"
-#include "Windows/FileFind.h"
+
+#include "LangUtils.h"
#include "RegistryUtils.h"
-#include "ProgramLocation.h"
using namespace NWindows;
@@ -20,20 +22,23 @@ UString g_LangID;
extern bool g_IsNT;
#endif
+static FString GetLangDirPrefix()
+{
+ return NDLL::GetModuleDirPrefix() + FString(FTEXT("Lang") FSTRING_PATH_SEPARATOR);
+}
+
void ReloadLang()
{
ReadRegLang(g_LangID);
g_Lang.Clear();
if (!g_LangID.IsEmpty() && g_LangID != L"-")
{
- UString langPath = g_LangID;
+ FString langPath = us2fs(g_LangID);
if (langPath.Find(WCHAR_PATH_SEPARATOR) < 0)
{
- if (langPath.Find(L'.') < 0)
- langPath += L".txt";
- UString folderPath;
- if (GetProgramFolderPath(folderPath))
- langPath = folderPath + UString(L"Lang" WSTRING_PATH_SEPARATOR) + langPath;
+ if (langPath.Find(FTEXT('.')) < 0)
+ langPath += FTEXT(".txt");
+ langPath = GetLangDirPrefix() + langPath;
}
g_Lang.Open(langPath);
}
@@ -51,7 +56,7 @@ void LoadLangOneTime()
ReloadLang();
}
-void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems)
+void LangSetDlgItemsText(HWND dialogWindow, const CIDLangPair *idLangPairs, int numItems)
{
for (int i = 0; i < numItems; i++)
{
@@ -85,30 +90,26 @@ UString LangString(UINT resourceID, UInt32 langID)
UString message;
if (g_Lang.GetMessage(langID, message))
return message;
- return NWindows::MyLoadStringW(resourceID);
+ return MyLoadStringW(resourceID);
}
void LoadLangs(CObjectVector<CLangEx> &langs)
{
langs.Clear();
- UString folderPath;
- if (!::GetProgramFolderPath(folderPath))
- return;
- folderPath += L"Lang" WSTRING_PATH_SEPARATOR;
- NWindows::NFile::NFind::CEnumeratorW enumerator(folderPath + L"*.txt");
- NWindows::NFile::NFind::CFileInfoW fileInfo;
- while (enumerator.Next(fileInfo))
+ const FString dirPrefix = GetLangDirPrefix();
+ NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt"));
+ NFile::NFind::CFileInfo fi;
+ while (enumerator.Next(fi))
{
- if (fileInfo.IsDir())
+ if (fi.IsDir())
continue;
- CLangEx lang;
- UString filePath = folderPath + fileInfo.Name;
const int kExtSize = 4;
- const UString ext = fileInfo.Name.Right(kExtSize);
- if (ext.CompareNoCase(L".txt") != 0)
+ const FString ext = fi.Name.Right(kExtSize);
+ if (ext.CompareNoCase(FTEXT(".txt")) != 0)
continue;
- lang.ShortName = fileInfo.Name.Left(fileInfo.Name.Length() - kExtSize);
- if (lang.Lang.Open(filePath))
+ CLangEx lang;
+ lang.ShortName = fs2us(fi.Name.Left(fi.Name.Length() - kExtSize));
+ if (lang.Lang.Open(dirPrefix + fi.Name))
langs.Add(lang);
}
}
diff --git a/CPP/7zip/UI/FileManager/LangUtils.h b/CPP/7zip/UI/FileManager/LangUtils.h
index 40debdfe..d11082f6 100755
--- a/CPP/7zip/UI/FileManager/LangUtils.h
+++ b/CPP/7zip/UI/FileManager/LangUtils.h
@@ -1,7 +1,7 @@
// LangUtils.h
-#ifndef __LANGUTILS_H
-#define __LANGUTILS_H
+#ifndef __LANG_UTILS_H
+#define __LANG_UTILS_H
#include "Common/Lang.h"
#include "Windows/ResourceString.h"
@@ -26,7 +26,7 @@ struct CLangEx
void LoadLangs(CObjectVector<CLangEx> &langs);
-void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems);
+void LangSetDlgItemsText(HWND dialogWindow, const CIDLangPair *idLangPairs, int numItems);
void LangSetWindowText(HWND window, UInt32 langID);
UString LangString(UInt32 langID);
diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.cpp b/CPP/7zip/UI/FileManager/ListViewDialog.cpp
index f70572b9..b3e989c4 100755
--- a/CPP/7zip/UI/FileManager/ListViewDialog.cpp
+++ b/CPP/7zip/UI/FileManager/ListViewDialog.cpp
@@ -125,17 +125,12 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
}
case 'A':
{
- // probably that code is unused ?
- /*
bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
if (ctrl)
{
- int numItems = _listView.GetItemCount();
- for (int i = 0; i < numItems; i++)
- _listView.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+ _listView.SelectAll();
return true;
}
- */
}
}
}
diff --git a/CPP/7zip/UI/FileManager/MenuPage.cpp b/CPP/7zip/UI/FileManager/MenuPage.cpp
index e1041204..c3e013b5 100755
--- a/CPP/7zip/UI/FileManager/MenuPage.cpp
+++ b/CPP/7zip/UI/FileManager/MenuPage.cpp
@@ -23,7 +23,7 @@ static CIDLangPair kIDLangPairs[] =
{ IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS, 0x01000310}
};
-static LPCWSTR kSystemTopic = L"fm/plugins/7-zip/options.htm#system";
+static LPCWSTR kSystemTopic = L"fm/options.htm#sevenZip";
struct CContextMenuItem
{
diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.cpp b/CPP/7zip/UI/FileManager/MessagesDialog.cpp
index 3d73ade1..05aa823f 100755
--- a/CPP/7zip/UI/FileManager/MessagesDialog.cpp
+++ b/CPP/7zip/UI/FileManager/MessagesDialog.cpp
@@ -51,10 +51,7 @@ bool CMessagesDialog::OnInit()
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_messageList.Attach(GetItem(IDC_MESSAGE_LIST));
-
- #ifndef UNDER_CE
- _messageList.SetUnicodeFormat(true);
- #endif
+ _messageList.SetUnicodeFormat();
_messageList.InsertColumn(0, L"", 30);
diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
index ccfd33cc..b16e8948 100755
--- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
+++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
@@ -513,6 +513,13 @@ bool ExecuteFileCommand(int id)
return true;
}
+static void MyBenchmark(bool totalMode)
+{
+ CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]);
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]);
+ Benchmark(totalMode);
+}
+
bool OnMenuCommand(HWND hWnd, int id)
{
if (ExecuteFileCommand(id))
@@ -538,31 +545,31 @@ bool OnMenuCommand(HWND hWnd, int id)
break;
case IDM_SELECT_ALL:
g_App.SelectAll(true);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_DESELECT_ALL:
g_App.SelectAll(false);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_INVERT_SELECTION:
g_App.InvertSelection();
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_SELECT:
g_App.SelectSpec(true);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_DESELECT:
g_App.SelectSpec(false);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_SELECT_BY_TYPE:
g_App.SelectByType(true);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_DESELECT_BY_TYPE:
g_App.SelectByType(false);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
//View
@@ -646,13 +653,9 @@ bool OnMenuCommand(HWND hWnd, int id)
OptionsDialog(hWnd, g_hInstance);
break;
- case IDM_BENCHMARK:
- {
- CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]);
- CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]);
- Benchmark();
- break;
- }
+ case IDM_BENCHMARK: MyBenchmark(false); break;
+ case IDM_BENCHMARK2: MyBenchmark(true); break;
+
// Help
case IDM_HELP_CONTENTS:
ShowHelpWindow(NULL, kFMHelpTopic);
diff --git a/CPP/7zip/UI/FileManager/NetFolder.cpp b/CPP/7zip/UI/FileManager/NetFolder.cpp
index e1fa1965..07387328 100755
--- a/CPP/7zip/UI/FileManager/NetFolder.cpp
+++ b/CPP/7zip/UI/FileManager/NetFolder.cpp
@@ -136,8 +136,8 @@ STDMETHODIMP CNetFolder::LoadItems()
resource.RemoteName = _path + resource.Name;
NFile::NFind::CFindFile findFile;
- NFile::NFind::CFileInfoW fileInfo;
- if (!findFile.FindFirst(resource.RemoteName + UString(WCHAR_PATH_SEPARATOR) + UString(L"*"), fileInfo))
+ NFile::NFind::CFileInfo fileInfo;
+ if (!findFile.FindFirst(us2fs(resource.RemoteName) + FString(FCHAR_PATH_SEPARATOR) + FCHAR_ANY_MASK, fileInfo))
continue;
resource.Usage = RESOURCEUSAGE_CONNECTABLE;
resource.LocalNameIsDefined = false;
@@ -185,7 +185,7 @@ STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder
{
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
- RINOK(fsFolderSpec->Init(resource.RemoteName + WCHAR_PATH_SEPARATOR, this));
+ RINOK(fsFolderSpec->Init(us2fs(resource.RemoteName + WCHAR_PATH_SEPARATOR), this));
*resultFolder = subFolder.Detach();
}
else
@@ -253,7 +253,7 @@ STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER ||
resource.Usage == RESOURCEUSAGE_CONNECTABLE)
{
- if (GetRealIconIndex(resource.RemoteName, 0, iconIndexTemp))
+ if (GetRealIconIndex(us2fs(resource.RemoteName), 0, iconIndexTemp))
{
*iconIndex = iconIndexTemp;
return S_OK;
@@ -261,7 +261,7 @@ STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
}
else
{
- if (GetRealIconIndex(TEXT(""), FILE_ATTRIBUTE_DIRECTORY, iconIndexTemp))
+ if (GetRealIconIndex(FTEXT(""), FILE_ATTRIBUTE_DIRECTORY, iconIndexTemp))
{
*iconIndex = iconIndexTemp;
return S_OK;
diff --git a/CPP/7zip/UI/FileManager/OpenCallback.cpp b/CPP/7zip/UI/FileManager/OpenCallback.cpp
index 72245ac4..95daf37a 100755
--- a/CPP/7zip/UI/FileManager/OpenCallback.cpp
+++ b/CPP/7zip/UI/FileManager/OpenCallback.cpp
@@ -8,6 +8,8 @@
#include "../../Common/FileStreams.h"
+#include "../Common/ZipRegistry.h"
+
#include "OpenCallback.h"
#include "PasswordDialog.h"
@@ -82,16 +84,15 @@ STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
- IInStream **inStream)
+STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream)
{
*inStream = NULL;
if (_subArchiveMode)
return S_FALSE;
- NFile::NFind::CFileInfoW fileInfo;
+ NFile::NFind::CFileInfo fileInfo;
- UString fullPath = _folderPrefix + name;
+ FString fullPath = _folderPrefix + us2fs(name);
if (!fileInfo.Find(fullPath))
return S_FALSE;
_fileInfo = fileInfo;
@@ -111,6 +112,8 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
if (!PasswordIsDefined)
{
CPasswordDialog dialog;
+ bool showPassword = NExtract::Read_ShowPassword();
+ dialog.ShowPassword = showPassword;
ProgressDialog.WaitCreating();
if (dialog.Create(ProgressDialog) == IDCANCEL)
@@ -118,6 +121,8 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
Password = dialog.Password;
PasswordIsDefined = true;
+ if (dialog.ShowPassword != showPassword)
+ NExtract::Save_ShowPassword(dialog.ShowPassword);
}
return StringToBstr(Password, password);
}
diff --git a/CPP/7zip/UI/FileManager/OpenCallback.h b/CPP/7zip/UI/FileManager/OpenCallback.h
index 559eb8fc..a0c0167e 100755
--- a/CPP/7zip/UI/FileManager/OpenCallback.h
+++ b/CPP/7zip/UI/FileManager/OpenCallback.h
@@ -27,8 +27,8 @@ class COpenArchiveCallback:
public ICryptoGetTextPassword,
public CMyUnknownImp
{
- UString _folderPrefix;
- NWindows::NFile::NFind::CFileInfoW _fileInfo;
+ FString _folderPrefix;
+ NWindows::NFile::NFind::CFileInfo _fileInfo;
NWindows::NSynchronization::CCriticalSection _criticalSection;
bool _subArchiveMode;
UString _subArchiveName;
@@ -75,7 +75,7 @@ public:
_subArchiveMode = false;
}
*/
- void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
+ void LoadFileInfo(const FString &folderPrefix, const FString &fileName)
{
_folderPrefix = folderPrefix;
if (!_fileInfo.Find(_folderPrefix + fileName))
diff --git a/CPP/7zip/UI/FileManager/OptionsDialog.cpp b/CPP/7zip/UI/FileManager/OptionsDialog.cpp
index 7a7e90fb..a1ef1b1d 100755
--- a/CPP/7zip/UI/FileManager/OptionsDialog.cpp
+++ b/CPP/7zip/UI/FileManager/OptionsDialog.cpp
@@ -24,7 +24,6 @@
#include "App.h"
#include "LangUtils.h"
#include "MyLoadMenu.h"
-#include "ProgramLocation.h"
#include "resource.h"
@@ -42,11 +41,10 @@ static void ShowMenuErrorMessage(const wchar_t *m)
static int DllRegisterServer2(const char *name)
{
- NWindows::NDLL::CLibrary lib;
+ NDLL::CLibrary lib;
- UString prefix;
- GetProgramFolderPath(prefix);
- if (!lib.Load(prefix + L"7-zip.dll"))
+ FString prefix = NDLL::GetModuleDirPrefix();
+ if (!lib.Load(prefix + FTEXT("7-zip.dll")))
{
ShowMenuErrorMessage(L"7-Zip cannot load 7-zip.dll");
return E_FAIL;
@@ -94,7 +92,7 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */)
CFoldersPage foldersPage;
CObjectVector<NControl::CPageInfo> pages;
- UINT32 langIDs[] = { 0x03010300,
+ const UInt32 langIDs[] = { 0x03010300,
// 0x03010100,
0xFFFFFFFF,
0x01000200, 0x03010200, 0x03010400, 0x01000400};
diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp
index 27aa7a54..ebbe12b9 100755
--- a/CPP/7zip/UI/FileManager/Panel.cpp
+++ b/CPP/7zip/UI/FileManager/Panel.cpp
@@ -79,6 +79,7 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
_mainWindow = mainWindow;
_processTimer = true;
_processNotify = true;
+ _processStatusBar = true;
_panelCallback = panelCallback;
_appState = appState;
@@ -91,8 +92,11 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
if (!currentFolderPrefix.IsEmpty())
if (currentFolderPrefix[0] == L'.')
- if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp))
- cfp = currentFolderPrefix;
+ {
+ FString cfpF;
+ if (NFile::NDirectory::MyGetFullPathName(us2fs(currentFolderPrefix), cfpF))
+ cfp = fs2us(cfpF);
+ }
RINOK(BindToPath(cfp, arcFormat, archiveIsOpened, encrypted));
if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
@@ -104,7 +108,7 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message)
+ switch (message)
{
case kShiftSelectMessage:
OnShiftSelectMessage();
@@ -117,12 +121,15 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return 0;
case kOpenItemChanged:
return OnOpenItemChanged(lParam);
- case kRefreshStatusBar:
- OnRefreshStatusBar();
+ case kRefresh_StatusBar:
+ if (_processStatusBar)
+ Refresh_StatusBar();
return 0;
- case kRefreshHeaderComboBox:
+ #ifdef UNDER_CE
+ case kRefresh_HeaderComboBox:
LoadFullPathAndShow();
return 0;
+ #endif
case WM_TIMER:
OnTimer();
return 0;
@@ -139,15 +146,6 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return CWindow2::OnMessage(message, wParam, lParam);
}
-static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- CWindow tempDialog(hwnd);
- CMyListView *w = (CMyListView *)(tempDialog.GetUserDataLongPtr());
- if (w == NULL)
- return 0;
- return w->OnMessage(message, wParam, lParam);
-}
-
LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_CHAR)
@@ -187,7 +185,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
// bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
// bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
- switch(wParam)
+ switch (wParam)
{
/*
case VK_RETURN:
@@ -233,12 +231,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
_panel->_lastFocusedIsList = true;
_panel->_panelCallback->PanelWasFocused();
}
- #ifndef _UNICODE
- if (g_IsNT)
- return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
- else
- #endif
- return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+ return CListView2::OnMessage(message, wParam, lParam);
}
/*
@@ -365,21 +358,9 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL))
return false;
- #ifndef UNDER_CE
- _listView.SetUnicodeFormat(true);
- #endif
-
- _listView.SetUserDataLongPtr(LONG_PTR(&_listView));
+ _listView.SetUnicodeFormat();
_listView._panel = this;
-
- #ifndef _UNICODE
- if(g_IsNT)
- _listView._origWindowProc =
- (WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
- else
- #endif
- _listView._origWindowProc =
- (WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
+ _listView.SetWindowProc();
_listView.SetImageList(GetSysImageList(true), LVSIL_SMALL);
_listView.SetImageList(GetSysImageList(false), LVSIL_NORMAL);
@@ -552,7 +533,6 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
// InitListCtrl();
RefreshListCtrl();
- RefreshStatusBar();
return true;
}
@@ -614,7 +594,7 @@ bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */)
{
- switch(header->code)
+ switch (header->code)
{
case RBN_HEIGHTCHANGE:
{
@@ -790,9 +770,10 @@ void CPanel::ChangeFlatMode()
}
-void CPanel::RefreshStatusBar()
+void CPanel::Post_Refresh_StatusBar()
{
- PostMessage(kRefreshStatusBar);
+ if (_processStatusBar)
+ PostMessage(kRefresh_StatusBar);
}
void CPanel::AddToArchive()
@@ -953,6 +934,12 @@ void CPanel::TestArchives()
extracter.ExtractCallbackSpec = new CExtractCallbackImp;
extracter.ExtractCallback = extracter.ExtractCallbackSpec;
extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog;
+ if (!_parentFolders.IsEmpty())
+ {
+ const CFolderLink &fl = _parentFolders.Back();
+ extracter.ExtractCallbackSpec->PasswordIsDefined = fl.UsePassword;
+ extracter.ExtractCallbackSpec->Password = fl.Password;
+ }
if (indices.IsEmpty())
return;
diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h
index 9cda94a4..e33a37a2 100755
--- a/CPP/7zip/UI/FileManager/Panel.h
+++ b/CPP/7zip/UI/FileManager/Panel.h
@@ -85,13 +85,14 @@ public:
struct CTempFileInfo
{
- UString ItemName;
- UString FolderPath;
- UString FilePath;
- NWindows::NFile::NFind::CFileInfoW FileInfo;
+ UInt32 FileIndex; // index of file in folder
+ UString RelPath; // Relative path of file from Folder
+ FString FolderPath;
+ FString FilePath;
+ NWindows::NFile::NFind::CFileInfo FileInfo;
bool NeedDelete;
- CTempFileInfo(): NeedDelete(false) {}
+ CTempFileInfo(): FileIndex((UInt32)(Int32)-1), NeedDelete(false) {}
void DeleteDirAndFile() const
{
if (NeedDelete)
@@ -100,7 +101,7 @@ struct CTempFileInfo
NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath);
}
}
- bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
+ bool WasChanged(const NWindows::NFile::NFind::CFileInfo &newFileInfo) const
{
return newFileInfo.Size != FileInfo.Size ||
CompareFileTime(&newFileInfo.MTime, &FileInfo.MTime) != 0;
@@ -118,7 +119,7 @@ struct CFolderLink: public CTempFileInfo
UString VirtualPath;
CFolderLink(): UsePassword(false), IsVirtual(false) {}
- bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
+ bool WasChanged(const NWindows::NFile::NFind::CFileInfo &newFileInfo) const
{
return IsVirtual || CTempFileInfo::WasChanged(newFileInfo);
}
@@ -131,18 +132,19 @@ enum MyMessages
kReLoadMessage,
kSetFocusToListView,
kOpenItemChanged,
- kRefreshStatusBar,
- kRefreshHeaderComboBox
+ kRefresh_StatusBar
+ #ifdef UNDER_CE
+ , kRefresh_HeaderComboBox
+ #endif
};
UString GetFolderPath(IFolderFolder * folder);
class CPanel;
-class CMyListView: public NWindows::NControl::CListView
+class CMyListView: public NWindows::NControl::CListView2
{
public:
- WNDPROC _origWindowProc;
CPanel *_panel;
LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
};
@@ -482,34 +484,33 @@ public:
bool _processTimer;
bool _processNotify;
+ bool _processStatusBar;
class CDisableTimerProcessing
{
bool _processTimerMem;
bool _processNotifyMem;
+ bool _processStatusBarMem;
CPanel &_panel;
public:
- CDisableTimerProcessing(CPanel &panel): _panel(panel)
- {
- Disable();
- }
+ CDisableTimerProcessing(CPanel &panel): _panel(panel) { Disable(); }
+ ~CDisableTimerProcessing() { Restore(); }
void Disable()
{
_processTimerMem = _panel._processTimer;
_processNotifyMem = _panel._processNotify;
+ _processStatusBarMem = _panel._processStatusBar;
_panel._processTimer = false;
_panel._processNotify = false;
+ _panel._processStatusBar = false;
}
void Restore()
{
_panel._processTimer = _processTimerMem;
_panel._processNotify = _processNotifyMem;
- }
- ~CDisableTimerProcessing()
- {
- Restore();
+ _panel._processStatusBar = _processStatusBarMem;
}
CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
};
@@ -544,11 +545,11 @@ public:
const UString &virtualFilePath,
const UString &arcFormat,
bool &encrypted);
- HRESULT OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted);
+ HRESULT OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted);
HRESULT OpenItemAsArchive(int index);
void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
bool editMode);
- HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password);
+ HRESULT OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, bool usePassword, const UString &password);
LRESULT OnOpenItemChanged(LPARAM lParam);
void OpenItem(int index, bool tryInternal, bool tryExternal);
@@ -565,8 +566,8 @@ public:
void ChangeFlatMode();
bool GetFlatMode() const { return _flatMode; }
- void RefreshStatusBar();
- void OnRefreshStatusBar();
+ void Post_Refresh_StatusBar();
+ void Refresh_StatusBar();
void AddToArchive();
diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp
index 6b00a9b5..2dd5e7ce 100755
--- a/CPP/7zip/UI/FileManager/PanelCrc.cpp
+++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp
@@ -29,13 +29,13 @@ static const UInt32 kBufSize = (1 << 15);
struct CDirEnumerator
{
bool FlatMode;
- UString BasePrefix;
- UStringVector FileNames;
+ FString BasePrefix;
+ FStringVector FileNames;
- CObjectVector<NFind::CEnumeratorW> Enumerators;
- UStringVector Prefixes;
+ CObjectVector<NFind::CEnumerator> Enumerators;
+ FStringVector Prefixes;
int Index;
- HRESULT GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath);
+ HRESULT GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &fullPath);
void Init();
CDirEnumerator(): FlatMode(false) {};
@@ -54,7 +54,7 @@ static HRESULT GetNormalizedError()
return (errorCode == 0) ? E_FAIL : errorCode;
}
-HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath)
+HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &resPath)
{
filled = false;
for (;;)
@@ -63,8 +63,8 @@ HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, U
{
if (Index >= FileNames.Size())
return S_OK;
- const UString &path = FileNames[Index];
- int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ const FString &path = FileNames[Index];
+ int pos = path.ReverseFind(FCHAR_PATH_SEPARATOR);
resPath.Empty();
if (pos >= 0)
resPath = path.Left(pos + 1);
@@ -106,8 +106,8 @@ HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, U
resPath += fileInfo.Name;
if (!FlatMode && fileInfo.IsDir())
{
- UString prefix = resPath + WCHAR_PATH_SEPARATOR;
- Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)NName::kAnyStringWildcard));
+ FString prefix = resPath + FCHAR_PATH_SEPARATOR;
+ Enumerators.Add(NFind::CEnumerator(BasePrefix + prefix + FCHAR_ANY_MASK));
Prefixes.Add(prefix);
}
filled = true;
@@ -212,13 +212,13 @@ HRESULT CThreadCrc::ProcessVirt()
for (;;)
{
- NFind::CFileInfoW fileInfo;
+ NFind::CFileInfo fileInfo;
bool filled;
- UString resPath;
+ FString resPath;
HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
if (errorCode != 0)
{
- ErrorPath1 = resPath;
+ SetErrorPath1(resPath);
return errorCode;
}
if (!filled)
@@ -228,7 +228,7 @@ HRESULT CThreadCrc::ProcessVirt()
totalSize += fileInfo.Size;
NumFilesScan++;
}
- sync.SetCurrentFileName(scanningStr + resPath);
+ sync.SetCurrentFileName(scanningStr + fs2us(resPath));
sync.SetProgress(totalSize, 0);
RINOK(sync.SetPosAndCheckPaused(0));
}
@@ -239,13 +239,13 @@ HRESULT CThreadCrc::ProcessVirt()
for (;;)
{
- NFind::CFileInfoW fileInfo;
+ NFind::CFileInfo fileInfo;
bool filled;
- UString resPath;
+ FString resPath;
HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
if (errorCode != 0)
{
- ErrorPath1 = resPath;
+ SetErrorPath1(resPath);
return errorCode;
}
if (!filled)
@@ -263,10 +263,10 @@ HRESULT CThreadCrc::ProcessVirt()
if (!inFile.Open(Enumerator.BasePrefix + resPath))
{
errorCode = GetNormalizedError();
- ErrorPath1 = resPath;
+ SetErrorPath1(resPath);
return errorCode;
}
- sync.SetCurrentFileName(resPath);
+ sync.SetCurrentFileName(fs2us(resPath));
sync.SetNumFilesCur(NumFiles);
NumFiles++;
for (;;)
@@ -275,7 +275,7 @@ HRESULT CThreadCrc::ProcessVirt()
if (!inFile.Read(buffer, kBufSize, processedSize))
{
errorCode = GetNormalizedError();
- ErrorPath1 = resPath;
+ SetErrorPath1(resPath);
return errorCode;
}
if (processedSize == 0)
@@ -323,8 +323,8 @@ void CApp::CalculateCrc()
{
CThreadCrc t;
for (int i = 0; i < indices.Size(); i++)
- t.Enumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i]));
- t.Enumerator.BasePrefix = srcPanel.GetFsPath();
+ t.Enumerator.FileNames.Add(us2fs(srcPanel.GetItemRelPath(indices[i])));
+ t.Enumerator.BasePrefix = us2fs(srcPanel.GetFsPath());
t.Enumerator.FlatMode = GetFlatMode();
t.ProgressDialog.ShowCompressionInfo = false;
diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp
index eb5ad871..02bccc03 100755
--- a/CPP/7zip/UI/FileManager/PanelDrag.cpp
+++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp
@@ -10,6 +10,7 @@
#include "Windows/Memory.h"
#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
#include "Windows/Shell.h"
#include "../Common/ArchiveName.h"
@@ -26,7 +27,7 @@ using namespace NWindows;
extern bool g_IsNT;
#endif
-static wchar_t *kTempDirPrefix = L"7zE";
+static CFSTR kTempDirPrefix = FTEXT("7zE");
static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
////////////////////////////////////////////////////////
@@ -304,12 +305,12 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
// CSelectedState selState;
// SaveSelectedState(selState);
- UString dirPrefix;
- NFile::NDirectory::CTempDirectoryW tempDirectory;
+ FString dirPrefix;
+ NFile::NDirectory::CTempDir tempDirectory;
bool isFSFolder = IsFSFolder();
if (isFSFolder)
- dirPrefix = _currentFolderPrefix;
+ dirPrefix = us2fs(_currentFolderPrefix);
else
{
tempDirectory.Create(kTempDirPrefix);
@@ -330,7 +331,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
s = GetItemRelPath(index);
else
s = GetItemName(index);
- names.Add(dirPrefix + s);
+ names.Add(fs2us(dirPrefix) + s);
}
if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names))
return;
@@ -341,7 +342,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
dropSourceSpec->NeedExtract = !isFSFolder;
dropSourceSpec->Panel = this;
dropSourceSpec->Indices = indices;
- dropSourceSpec->Folder = dirPrefix;
+ dropSourceSpec->Folder = fs2us(dirPrefix);
dropSourceSpec->DataObjectSpec = dataObjectSpec;
dropSourceSpec->DataObject = dataObjectSpec;
@@ -748,9 +749,9 @@ void CPanel::CompressDropFiles(HDROP dr)
}
*/
-static bool IsFolderInTemp(const UString &path)
+static bool IsFolderInTemp(const FString &path)
{
- UString tempPath;
+ FString tempPath;
if (!NFile::NDirectory::MyGetTempPath(tempPath))
return false;
if (tempPath.IsEmpty())
@@ -760,9 +761,10 @@ static bool IsFolderInTemp(const UString &path)
static bool AreThereNamesFromTemp(const UStringVector &fileNames)
{
- UString tempPath;
- if (!NFile::NDirectory::MyGetTempPath(tempPath))
+ FString tempPathF;
+ if (!NFile::NDirectory::MyGetTempPath(tempPathF))
return false;
+ UString tempPath = fs2us(tempPathF);
if (tempPath.IsEmpty())
return false;
for (int i = 0; i < fileNames.Size(); i++)
@@ -784,8 +786,10 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo
UString folderPath2 = folderPath;
if (folderPath2.IsEmpty())
{
- NFile::NDirectory::GetOnlyDirPrefix(fileNames.Front(), folderPath2);
- if (IsFolderInTemp(folderPath2))
+ FString folderPath2F;
+ NFile::NDirectory::GetOnlyDirPrefix(us2fs(fileNames.Front()), folderPath2F);
+ folderPath2 = fs2us(folderPath2F);
+ if (IsFolderInTemp(folderPath2F))
folderPath2 = ROOT_FS_FOLDER;
}
const UString archiveName = CreateArchiveName(fileNames.Front(), (fileNames.Size() > 1), false);
diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
index afa4c041..995124be 100755
--- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
+++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
@@ -5,6 +5,7 @@
#include "Common/StringConvert.h"
#include "Common/Wildcard.h"
+#include "Windows/FileName.h"
#include "Windows/PropVariant.h"
#include "../../PropID.h"
@@ -73,11 +74,11 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
CloseOpenFolders();
UString sysPath = fullPath;
- CFileInfoW fileInfo;
+ CFileInfo fileInfo;
UStringVector reducedParts;
while (!sysPath.IsEmpty())
{
- if (fileInfo.Find(sysPath))
+ if (fileInfo.Find(us2fs(sysPath)))
break;
int pos = sysPath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos < 0)
@@ -104,17 +105,14 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
}
else
{
- UString dirPrefix;
- if (!NDirectory::GetOnlyDirPrefix(sysPath, dirPrefix))
- dirPrefix.Empty();
- if (_folder->BindToFolder(dirPrefix, &newFolder) == S_OK)
+ FString dirPrefix, fileName;
+ NDirectory::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
+ if (_folder->BindToFolder(fs2us(dirPrefix), &newFolder) == S_OK)
{
_folder = newFolder;
LoadFullPath();
- UString fileName;
- if (NDirectory::GetOnlyName(sysPath, fileName))
{
- HRESULT res = OpenItemAsArchive(fileName, arcFormat, encrypted);
+ HRESULT res = OpenItemAsArchive(fs2us(fileName), arcFormat, encrypted);
if (res != S_FALSE)
{
RINOK(res);
@@ -176,14 +174,14 @@ void CPanel::LoadFullPath()
{
const CFolderLink &folderLink = _parentFolders[i];
_currentFolderPrefix += GetFolderPath(folderLink.ParentFolder);
- _currentFolderPrefix += folderLink.ItemName;
+ _currentFolderPrefix += folderLink.RelPath;
_currentFolderPrefix += WCHAR_PATH_SEPARATOR;
}
if (_folder)
_currentFolderPrefix += GetFolderPath(_folder);
}
-static int GetRealIconIndex(LPCWSTR path, DWORD attributes)
+static int GetRealIconIndex(CFSTR path, DWORD attributes)
{
int index = -1;
if (GetRealIconIndex(path, attributes, index) != 0)
@@ -209,15 +207,22 @@ void CPanel::LoadFullPathAndShow()
#else
1
#endif
- && path[path.Length() - 1] == WCHAR_PATH_SEPARATOR)
- path.Delete(path.Length() - 1);
+ && path.Back() == WCHAR_PATH_SEPARATOR)
+ path.DeleteBack();
- CFileInfoW info;
DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
- if (info.Find(path))
- attrib = info.Attrib;
-
- item.iImage = GetRealIconIndex(path, attrib);
+
+ // GetRealIconIndex is slow for direct DVD/UDF path. So we use dummy path
+ UString excludePrefix = L"\\\\.\\";
+ UString path2 = L"_TestFolder_";
+ if (excludePrefix != path.Left(excludePrefix.Length()))
+ {
+ path2 = path;
+ CFileInfo info;
+ if (info.Find(us2fs(path)))
+ attrib = info.Attrib;
+ }
+ item.iImage = GetRealIconIndex(us2fs(path2), attrib);
if (item.iImage >= 0)
{
@@ -356,11 +361,11 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
UString name = pathParts[i];
sumPass += name;
sumPass += WCHAR_PATH_SEPARATOR;
- CFileInfoW info;
+ CFileInfo info;
DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
- if (info.Find(sumPass))
+ if (info.Find(us2fs(sumPass)))
attrib = info.Attrib;
- AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(sumPass, attrib), i, false);
+ AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(us2fs(sumPass), attrib), i, false);
ComboBoxPaths.Add(sumPass);
}
@@ -374,16 +379,16 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
name = RootFolder_GetName_Computer(iconIndex);
AddComboBoxItem(name, iconIndex, 0, true);
- UStringVector driveStrings;
+ FStringVector driveStrings;
MyGetLogicalDriveStrings(driveStrings);
for (i = 0; i < driveStrings.Size(); i++)
{
- UString s = driveStrings[i];
- ComboBoxPaths.Add(s);
+ FString s = driveStrings[i];
+ ComboBoxPaths.Add(fs2us(s));
int iconIndex = GetRealIconIndex(s, 0);
- if (s.Length() > 0 && s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
- s.Delete(s.Length() - 1);
- AddComboBoxItem(s, iconIndex, 1, false);
+ if (s.Length() > 0 && s.Back() == FCHAR_PATH_SEPARATOR)
+ s.DeleteBack();
+ AddComboBoxItem(fs2us(s), iconIndex, 1, false);
}
name = RootFolder_GetName_Network(iconIndex);
@@ -407,9 +412,8 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
{
PostMessage(kSetFocusToListView);
#ifdef UNDER_CE
- PostMessage(kRefreshHeaderComboBox);
+ PostMessage(kRefresh_HeaderComboBox);
#endif
-
return true;
}
}
@@ -522,7 +526,7 @@ void CPanel::OpenParentFolder()
CFolderLink &link = _parentFolders.Back();
_folder = link.ParentFolder;
_library.Attach(link.Library.Detach());
- focucedName = link.ItemName;
+ focucedName = link.RelPath;
if (_parentFolders.Size() > 1)
OpenParentArchiveFolder();
_parentFolders.DeleteBack();
@@ -540,7 +544,6 @@ void CPanel::OpenParentFolder()
// ::SetCurrentDirectory(::_currentFolderPrefix);
RefreshListCtrl(focucedName, -1, true, selectedItems);
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
- RefreshStatusBar();
}
void CPanel::CloseOpenFolders()
@@ -607,7 +610,6 @@ void CPanel::OpenFolder(int index)
LoadFullPath();
// ::SetCurrentDirectory(::_currentFolderPrefix);
RefreshListCtrl();
- UINT state = LVIS_SELECTED;
- _listView.SetItemState(_listView.GetFocusedItem(), state, state);
+ _listView.SetItemState_Selected(_listView.GetFocusedItem());
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
}
diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
index 934e98d3..6c4309c6 100755
--- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
@@ -2,12 +2,15 @@
#include "StdAfx.h"
+#include <tlhelp32.h>
+
#include "Common/AutoPtr.h"
#include "Common/StringConvert.h"
#include "Windows/Error.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
#include "Windows/Process.h"
#include "Windows/PropVariant.h"
#include "Windows/Thread.h"
@@ -33,8 +36,122 @@ using namespace NDirectory;
extern bool g_IsNT;
#endif
-static wchar_t *kTempDirPrefix = L"7zO";
+static CFSTR kTempDirPrefix = FTEXT("7zO");
+
+#ifndef UNDER_CE
+
+class CProcessSnapshot
+{
+ HANDLE _handle;
+public:
+ CProcessSnapshot(): _handle(INVALID_HANDLE_VALUE) {};
+ ~CProcessSnapshot() { Close(); }
+
+ bool Close()
+ {
+ if (_handle == INVALID_HANDLE_VALUE)
+ return true;
+ if (!::CloseHandle(_handle))
+ return false;
+ _handle = INVALID_HANDLE_VALUE;
+ return true;
+ }
+
+ bool Create()
+ {
+ _handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+ return (_handle != INVALID_HANDLE_VALUE);
+ }
+
+ bool GetFirstProcess(PROCESSENTRY32 *pe) { return BOOLToBool(Process32First(_handle, pe)); }
+ bool GetNextProcess(PROCESSENTRY32 *pe) { return BOOLToBool(Process32Next(_handle, pe)); }
+};
+
+#endif
+
+typedef DWORD (WINAPI *GetProcessIdFunc)(HANDLE process);
+
+class CChildProcesses
+{
+ #ifndef UNDER_CE
+ CRecordVector<DWORD> _ids;
+ #endif
+public:
+ CRecordVector<HANDLE> Handles;
+ CRecordVector<bool> NeedWait;
+
+ ~CChildProcesses() { CloseAll(); }
+ void DisableWait(int index) { NeedWait[index] = false; }
+
+ void CloseAll()
+ {
+ for (int i = 0; i < Handles.Size(); i++)
+ {
+ HANDLE h = Handles[i];
+ if (h != NULL)
+ CloseHandle(h);
+ }
+ Handles.Clear();
+ NeedWait.Clear();
+ }
+
+ void AddProcess(HANDLE h)
+ {
+ #ifndef UNDER_CE
+ GetProcessIdFunc func = (GetProcessIdFunc)::GetProcAddress(::GetModuleHandleA("kernel32.dll"), "GetProcessId");
+ if (func)
+ _ids.AddToUniqueSorted(func(h));
+ #endif
+ Handles.Add(h);
+ NeedWait.Add(true);
+ }
+
+ void Update()
+ {
+ #ifndef UNDER_CE
+ CRecordVector<DWORD> ids, parents;
+ {
+ CProcessSnapshot snapshot;
+ if (snapshot.Create())
+ {
+ PROCESSENTRY32 pe;
+ memset(&pe, 0, sizeof(pe));
+ pe.dwSize = sizeof(pe);
+ BOOL res = snapshot.GetFirstProcess(&pe);
+ while (res)
+ {
+ ids.Add(pe.th32ProcessID);
+ parents.Add(pe.th32ParentProcessID);
+ res = snapshot.GetNextProcess(&pe);
+ }
+ }
+ }
+ for (;;)
+ {
+ int i;
+ for (i = 0; i < ids.Size(); i++)
+ {
+ DWORD id = ids[i];
+ if (_ids.FindInSorted(parents[i]) >= 0 &&
+ _ids.FindInSorted(id) < 0)
+ {
+ HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, id);
+ if (hProcess)
+ {
+ _ids.AddToUniqueSorted(id);
+ Handles.Add(hProcess);
+ NeedWait.Add(true);
+ break;
+ }
+ }
+ }
+ if (i == ids.Size())
+ break;
+ }
+ #endif
+ }
+};
static bool IsNameVirus(const UString &name)
{
@@ -43,11 +160,12 @@ static bool IsNameVirus(const UString &name)
struct CTmpProcessInfo: public CTempFileInfo
{
- HANDLE ProcessHandle;
+ CChildProcesses Processes;
HWND Window;
UString FullPathFolderPrefix;
bool UsePassword;
UString Password;
+
CTmpProcessInfo(): UsePassword(false) {}
};
@@ -56,8 +174,8 @@ class CTmpProcessInfoRelease
CTmpProcessInfo *_tmpProcessInfo;
public:
bool _needDelete;
- CTmpProcessInfoRelease(CTmpProcessInfo &tmpProcessInfo):
- _tmpProcessInfo(&tmpProcessInfo), _needDelete(true) {}
+ CTmpProcessInfoRelease(CTmpProcessInfo &tpi):
+ _tmpProcessInfo(&tpi), _needDelete(true) {}
~CTmpProcessInfoRelease()
{
if (_needDelete)
@@ -96,7 +214,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
UString password;
RINOK(OpenFileFolderPlugin(inStream,
- folderLink.FilePath.IsEmpty() ? virtualFilePath : folderLink.FilePath,
+ folderLink.FilePath.IsEmpty() ? us2fs(virtualFilePath) : folderLink.FilePath,
arcFormat,
&library, &newFolder, GetParent(), encrypted, password));
@@ -157,13 +275,14 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
return S_OK;
}
-HRESULT CPanel::OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted)
+HRESULT CPanel::OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted)
{
CTempFileInfo tfi;
- tfi.ItemName = name;
- tfi.FolderPath = _currentFolderPrefix;
- tfi.FilePath = _currentFolderPrefix + name;
- return OpenItemAsArchive(NULL, tfi, _currentFolderPrefix + name, arcFormat, encrypted);
+ tfi.RelPath = relPath;
+ tfi.FolderPath = us2fs(_currentFolderPrefix);
+ const UString fullPath = _currentFolderPrefix + relPath;
+ tfi.FilePath = us2fs(fullPath);
+ return OpenItemAsArchive(NULL, tfi, fullPath, arcFormat, encrypted);
}
HRESULT CPanel::OpenItemAsArchive(int index)
@@ -180,21 +299,21 @@ HRESULT CPanel::OpenParentArchiveFolder()
CDisableTimerProcessing disableTimerProcessing1(*this);
if (_parentFolders.Size() < 2)
return S_OK;
+ const CFolderLink &folderLinkPrev = _parentFolders[_parentFolders.Size() - 2];
const CFolderLink &folderLink = _parentFolders.Back();
- NFind::CFileInfoW newFileInfo;
+ NFind::CFileInfo newFileInfo;
if (newFileInfo.Find(folderLink.FilePath))
{
if (folderLink.WasChanged(newFileInfo))
{
- UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
- 0x03020280, folderLink.ItemName);
+ UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, 0x03020280, folderLink.RelPath);
if (::MessageBoxW(HWND(*this), message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
{
- if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName,
- folderLink.UsePassword, folderLink.Password) != S_OK)
+ if (OnOpenItemChanged(folderLink.FileIndex, folderLink.FilePath,
+ folderLinkPrev.UsePassword, folderLinkPrev.Password) != S_OK)
{
::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
- 0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ 0x03020281, fs2us(folderLink.FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
return S_OK;
}
}
@@ -263,9 +382,11 @@ static HRESULT StartEditApplication(const UString &path, HWND window, CProcess &
#ifdef UNDER_CE
command = L"\\Windows\\";
#else
- if (!MyGetWindowsDirectory(command))
+ FString winDir;
+ if (!MyGetWindowsDirectory(winDir))
return 0;
- NFile::NName::NormalizeDirPathPrefix(command);
+ NFile::NName::NormalizeDirPathPrefix(winDir);
+ command = fs2us(winDir);
#endif
command += L"notepad.exe";
}
@@ -466,8 +587,8 @@ class CThreadCopyFrom: public CProgressThreadVirt
{
HRESULT ProcessVirt();
public:
- UString PathPrefix;
- UString Name;
+ UString FullPath;
+ UInt32 ItemIndex;
CMyComPtr<IFolderOperations> FolderOperations;
CMyComPtr<IProgress> UpdateCallback;
@@ -476,14 +597,10 @@ public:
HRESULT CThreadCopyFrom::ProcessVirt()
{
- UStringVector fileNames;
- CRecordVector<const wchar_t *> fileNamePointers;
- fileNames.Add(Name);
- fileNamePointers.Add(fileNames[0]);
- return FolderOperations->CopyFrom(PathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), UpdateCallback);
+ return FolderOperations->CopyFromFile(ItemIndex, FullPath, UpdateCallback);
}
-HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName,
+HRESULT CPanel::OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath,
bool usePassword, const UString &password)
{
CMyComPtr<IFolderOperations> folderOperations;
@@ -497,41 +614,48 @@ HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item
t.UpdateCallbackSpec = new CUpdateCallback100Imp;
t.UpdateCallback = t.UpdateCallbackSpec;
t.UpdateCallbackSpec->ProgressDialog = &t.ProgressDialog;
- t.Name = itemName;
- t.PathPrefix = folderPath;
- NName::NormalizeDirPathPrefix(t.PathPrefix);
+ t.ItemIndex = index;
+ t.FullPath = fullFilePath;
t.FolderOperations = folderOperations;
t.UpdateCallbackSpec->Init(usePassword, password);
- RINOK(t.Create(itemName, (HWND)*this));
+ RINOK(t.Create(GetItemName(index), (HWND)*this));
return t.Result;
}
LRESULT CPanel::OnOpenItemChanged(LPARAM lParam)
{
- CTmpProcessInfo &tmpProcessInfo = *(CTmpProcessInfo *)lParam;
- // LoadCurrentPath()
- if (tmpProcessInfo.FullPathFolderPrefix != _currentFolderPrefix)
+ CTmpProcessInfo &tpi = *(CTmpProcessInfo *)lParam;
+ if (tpi.FullPathFolderPrefix != _currentFolderPrefix)
return 0;
+ UInt32 fileIndex = tpi.FileIndex;
+ UInt32 numItems;
+ _folder->GetNumberOfItems(&numItems);
+
+ // This code is not 100% OK for cases when there are several files with
+ // tpi.RelPath name and there are changes in archive before update.
+ // So tpi.FileIndex can point to another file.
+
+ if (fileIndex >= numItems || GetItemRelPath(fileIndex) != tpi.RelPath)
+ {
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ if (GetItemRelPath(i) == tpi.RelPath)
+ break;
+ if (i == numItems)
+ return 0;
+ fileIndex = i;
+ }
CSelectedState state;
SaveSelectedState(state);
- HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName,
- tmpProcessInfo.UsePassword, tmpProcessInfo.Password);
+ HRESULT result = OnOpenItemChanged(fileIndex, tpi.FilePath, tpi.UsePassword, tpi.Password);
if (result != S_OK)
return 0;
RefreshListCtrl(state);
return 1;
}
-/*
-class CTmpProcessInfoList
-{
-public:
- CObjectVector<CTmpProcessInfo> _items;
-} g_TmpProcessInfoList;
-*/
-
class CExitEventLauncher
{
public:
@@ -547,42 +671,64 @@ public:
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr((CTmpProcessInfo *)param);
- const CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
+ CTmpProcessInfo *tpi = tmpProcessInfoPtr.get();
+ CChildProcesses &processes = tpi->Processes;
- HANDLE hProcess = tmpProcessInfo->ProcessHandle;
- HANDLE events[2] = { g_ExitEventLauncher._exitEvent, hProcess};
- DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
- ::CloseHandle(hProcess);
- if (waitResult == WAIT_OBJECT_0 + 0)
- return 0;
- if (waitResult != WAIT_OBJECT_0 + 1)
- return 1;
- Sleep(200);
- NFind::CFileInfoW newFileInfo;
- if (newFileInfo.Find(tmpProcessInfo->FilePath))
+ for (;;)
+ {
+ CRecordVector<HANDLE> handles;
+ CRecordVector<int> indices;
+ for (int i = 0; i < processes.Handles.Size(); i++)
+ {
+ if (processes.NeedWait[i])
+ {
+ handles.Add(processes.Handles[i]);
+ indices.Add(i);
+ }
+ }
+ if (handles.IsEmpty())
+ break;
+
+ handles.Add(g_ExitEventLauncher._exitEvent);
+
+ DWORD waitResult = ::WaitForMultipleObjects(handles.Size(), &handles.Front(), FALSE, INFINITE);
+
+ if (waitResult >= (DWORD)handles.Size() - 1)
+ {
+ processes.CloseAll();
+ return waitResult >= (DWORD)handles.Size() ? 1 : 0;
+ }
+ processes.Update();
+ processes.DisableWait(indices[waitResult]);
+ }
+
+ NFind::CFileInfo newFileInfo;
+ if (newFileInfo.Find(tpi->FilePath))
{
- if (tmpProcessInfo->WasChanged(newFileInfo))
+ if (tpi->WasChanged(newFileInfo))
{
UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
- 0x03020280, tmpProcessInfo->ItemName);
+ 0x03020280, tpi->RelPath);
if (::MessageBoxW(g_HWND, message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
{
- if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
+ if (SendMessage(tpi->Window, kOpenItemChanged, 0, (LONG_PTR)tpi) != 1)
{
::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
- 0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ 0x03020281, fs2us(tpi->FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
return 0;
}
}
}
}
- tmpProcessInfo->DeleteDirAndFile();
+ tpi->DeleteDirAndFile();
return 0;
}
void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode)
{
const UString name = GetItemName(index);
+ const UString relPath = GetItemRelPath(index);
+
if (IsNameVirus(name))
{
MessageBoxErrorLang(IDS_VIRUS, 0x03020284);
@@ -598,18 +744,22 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
bool tryAsArchive = tryInternal && (!tryExternal || !DoItemAlwaysStart(name));
- UString fullVirtPath = _currentFolderPrefix + name;
+ UString fullVirtPath = _currentFolderPrefix + relPath;
- NFile::NDirectory::CTempDirectoryW tempDirectory;
- tempDirectory.Create(kTempDirPrefix);
- UString tempDir = tempDirectory.GetPath();
- UString tempDirNorm = tempDir;
+ NFile::NDirectory::CTempDir tempDirectory;
+ if (!tempDirectory.Create(kTempDirPrefix))
+ {
+ MessageBoxLastError();
+ return;
+ }
+ FString tempDir = tempDirectory.GetPath();
+ FString tempDirNorm = tempDir;
NFile::NName::NormalizeDirPathPrefix(tempDirNorm);
-
- UString tempFilePath = tempDirNorm + GetCorrectFsPath(name);
+ FString tempFilePath = tempDirNorm + us2fs(GetCorrectFsPath(name));
CTempFileInfo tempFileInfo;
- tempFileInfo.ItemName = name;
+ tempFileInfo.FileIndex = index;
+ tempFileInfo.RelPath = relPath;
tempFileInfo.FolderPath = tempDir;
tempFileInfo.FilePath = tempFilePath;
tempFileInfo.NeedDelete = true;
@@ -655,7 +805,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
password = fl.Password;
}
- HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages, usePassword, password);
+ HRESULT result = CopyTo(indices, fs2us(tempDirNorm), false, true, &messages, usePassword, password);
if (_parentFolders.Size() > 0)
{
@@ -686,17 +836,17 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
}
CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo());
- CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
- tmpProcessInfo->FolderPath = tempDir;
- tmpProcessInfo->FilePath = tempFilePath;
- tmpProcessInfo->NeedDelete = true;
- tmpProcessInfo->UsePassword = usePassword;
- tmpProcessInfo->Password = password;
-
- if (!tmpProcessInfo->FileInfo.Find(tempFilePath))
+ CTmpProcessInfo *tpi = tmpProcessInfoPtr.get();
+ tpi->FolderPath = tempDir;
+ tpi->FilePath = tempFilePath;
+ tpi->NeedDelete = true;
+ tpi->UsePassword = usePassword;
+ tpi->Password = password;
+
+ if (!tpi->FileInfo.Find(tempFilePath))
return;
- CTmpProcessInfoRelease tmpProcessInfoRelease(*tmpProcessInfo);
+ CTmpProcessInfoRelease tmpProcessInfoRelease(*tpi);
if (!tryExternal)
return;
@@ -704,20 +854,21 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
CProcess process;
HRESULT res;
if (editMode)
- res = StartEditApplication(tempFilePath, (HWND)*this, process);
+ res = StartEditApplication(fs2us(tempFilePath), (HWND)*this, process);
else
- res = StartApplication(tempDirNorm, tempFilePath, (HWND)*this, process);
+ res = StartApplication(fs2us(tempDirNorm), fs2us(tempFilePath), (HWND)*this, process);
if ((HANDLE)process == 0)
return;
- tmpProcessInfo->Window = (HWND)(*this);
- tmpProcessInfo->FullPathFolderPrefix = _currentFolderPrefix;
- tmpProcessInfo->ItemName = name;
- tmpProcessInfo->ProcessHandle = process.Detach();
+ tpi->Window = (HWND)(*this);
+ tpi->FullPathFolderPrefix = _currentFolderPrefix;
+ tpi->FileIndex = index;
+ tpi->RelPath = relPath;
+ tpi->Processes.AddProcess(process.Detach());
NWindows::CThread thread;
- if (thread.Create(MyThreadFunction, tmpProcessInfo) != S_OK)
+ if (thread.Create(MyThreadFunction, tpi) != S_OK)
throw 271824;
tempDirectory.DisableDeleting();
tmpProcessInfoPtr.release();
@@ -744,7 +895,7 @@ void DeleteOldTempFiles()
UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
searchWildCard += WCHAR(NName::kAnyStringWildcard);
NFind::CEnumeratorW enumerator(searchWildCard);
- NFind::CFileInfoW fileInfo;
+ NFind::CFileInfo fileInfo;
while(enumerator.Next(fileInfo))
{
if (!fileInfo.IsDir())
diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp
index 17cc3fcb..daa150c6 100755
--- a/CPP/7zip/UI/FileManager/PanelItems.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItems.cpp
@@ -416,7 +416,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
if (_currentFolderPrefix.IsEmpty())
{
int iconIndexTemp;
- GetRealIconIndex(itemName + WCHAR_PATH_SEPARATOR, attrib, iconIndexTemp);
+ GetRealIconIndex(us2fs(itemName) + FCHAR_PATH_SEPARATOR, attrib, iconIndexTemp);
item.iImage = iconIndexTemp;
}
else
@@ -450,6 +450,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
/*
_listView.UpdateWindow();
*/
+ Refresh_StatusBar();
return S_OK;
}
@@ -458,7 +459,7 @@ void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
indices.Clear();
/*
int itemIndex = -1;
- while ((itemIndex = _listView.GetNextItem(itemIndex, LVNI_SELECTED)) != -1)
+ while ((itemIndex = _listView.GetNextSelectedItem(itemIndex)) != -1)
{
LPARAM param;
if (_listView.GetItemParam(itemIndex, param))
@@ -481,7 +482,7 @@ void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
int focusedItem = _listView.GetFocusedItem();
if (focusedItem >= 0)
{
- if (_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
+ if (_listView.IsItemSelected(focusedItem))
{
int realIndex = GetRealItemIndex(focusedItem);
if (realIndex != kParentIndex)
@@ -565,8 +566,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
if (focusedItem >= 0)
{
int realIndex = GetRealItemIndex(focusedItem);
- if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0) &&
- _listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
+ if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0) && _listView.IsItemSelected(focusedItem))
indices.Insert(0, realIndex);
}
@@ -787,7 +787,6 @@ void CPanel::OnReload()
HRESULT res = RefreshListCtrlSaveFocused();
if (res != S_OK)
MessageBoxError(res);
- OnRefreshStatusBar();
}
void CPanel::OnTimer()
diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
index 2051b5c6..f28311a4 100755
--- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp
+++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
@@ -77,7 +77,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
if (_dontShowMode)
return 0;
- UINT32 realIndex = GetRealIndex(item);
+ UInt32 realIndex = GetRealIndex(item);
/*
if ((item.mask & LVIF_IMAGE) != 0)
{
@@ -113,7 +113,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
if (realIndex == kParentIndex)
return 0;
UString s;
- UINT32 subItemIndex = item.iSubItem;
+ UInt32 subItemIndex = item.iSubItem;
PROPID propID = _visibleProperties[subItemIndex].ID;
/*
{
@@ -222,7 +222,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
{
if (!_mySelectMode)
OnItemChanged((LPNMLISTVIEW)header);
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
}
return false;
}
@@ -248,7 +248,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
case LVN_KEYDOWN:
{
bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result);
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
return boolResult;
}
@@ -273,7 +273,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
break;
case NM_RCLICK:
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
break;
/*
@@ -301,7 +301,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
{
// we need SetFocusToList, if we drag-select items from other panel.
SetFocusToList();
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
if (_mySelectMode)
#ifndef UNDER_CE
if (g_ComCtl32Version >= MAKELONG(71, 4))
@@ -325,7 +325,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
case LVN_BEGINDRAG:
{
OnDrag((LPNMLISTVIEW)header);
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
break;
}
// case LVN_BEGINRDRAG:
@@ -390,9 +390,9 @@ bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result)
return false;
}
-void CPanel::OnRefreshStatusBar()
+void CPanel::Refresh_StatusBar()
{
- CRecordVector<UINT32> indices;
+ CRecordVector<UInt32> indices;
GetOperatedItemIndices(indices);
_statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, 0x02000301, NumberToString(indices.Size())));
diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp
index 549b28da..badf531b 100755
--- a/CPP/7zip/UI/FileManager/PanelMenu.cpp
+++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp
@@ -564,6 +564,7 @@ bool CPanel::InvokePluginCommand(int id,
CMINVOKECOMMANDINFOEX
#endif
commandInfo;
+ memset(&commandInfo, 0, sizeof(commandInfo));
commandInfo.cbSize = sizeof(commandInfo);
commandInfo.fMask = 0
#ifndef UNDER_CE
@@ -576,8 +577,8 @@ bool CPanel::InvokePluginCommand(int id,
CSysString currentFolderSys = GetSystemString(_currentFolderPrefix);
commandInfo.lpDirectory = (LPCSTR)(LPCTSTR)(currentFolderSys);
commandInfo.nShow = SW_SHOW;
- commandInfo.lpParameters = NULL;
#ifndef UNDER_CE
+ commandInfo.lpParametersW = NULL;
commandInfo.lpTitle = "";
commandInfo.lpVerbW = (LPCWSTR)(MAKEINTRESOURCEW(offset));
UString currentFolderUnicode = _currentFolderPrefix;
diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp
index 0c6d3122..9c109d0d 100755
--- a/CPP/7zip/UI/FileManager/PanelOperations.cpp
+++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp
@@ -284,6 +284,24 @@ BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
return FALSE;
}
+static UString GetLastPart(const UString name)
+{
+ int slashPos = name.ReverseFind(L'/');
+ #ifdef _WIN32
+ int slash1Pos = name.ReverseFind(L'\\');
+ slashPos = MyMax(slashPos, slash1Pos);
+ #endif
+ return name.Mid(slashPos + 1);
+}
+
+bool IsCorrectFsName(const UString name)
+{
+ const UString lastPart = GetLastPart(name);
+ return
+ lastPart != L"." &&
+ lastPart != L"..";
+}
+
BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
{
if (lpnmh->item.pszText == NULL)
@@ -295,6 +313,11 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
return FALSE;
}
const UString newName = lpnmh->item.pszText;
+ if (!IsCorrectFsName(newName))
+ {
+ MessageBoxError(E_INVALIDARG);
+ return FALSE;
+ }
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
SaveSelectedState(_selectedState);
@@ -353,6 +376,11 @@ void CPanel::CreateFolder()
return;
UString newName = comboDialog.Value;
+ if (!IsCorrectFsName(newName))
+ {
+ MessageBoxError(E_INVALIDARG);
+ return;
+ }
{
CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER);
diff --git a/CPP/7zip/UI/FileManager/PanelSelect.cpp b/CPP/7zip/UI/FileManager/PanelSelect.cpp
index 29cf576b..b31c2e9d 100755
--- a/CPP/7zip/UI/FileManager/PanelSelect.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSelect.cpp
@@ -78,7 +78,7 @@ void CPanel::OnInsert()
UINT state = (_listView.GetItemState(focusedItem, LVIS_CUT) == 0) ?
LVIS_CUT : 0;
_listView.SetItemState(focusedItem, state, LVIS_CUT);
- // _listView.SetItemState(focusedItem, LVIS_SELECTED, LVIS_SELECTED);
+ // _listView.SetItemState_Selected(focusedItem);
*/
int focusedItem = _listView.GetFocusedItem();
@@ -90,7 +90,7 @@ void CPanel::OnInsert()
_selectedStatusVector[realIndex] = isSelected;
if (!_mySelectMode)
- _listView.SetItemState(focusedItem, isSelected ? LVIS_SELECTED: 0, LVIS_SELECTED);
+ _listView.SetItemState_Selected(focusedItem, isSelected);
_listView.RedrawItem(focusedItem);
@@ -135,11 +135,7 @@ void CPanel::UpdateSelection()
{
int realIndex = GetRealItemIndex(i);
if (realIndex != kParentIndex)
- {
- UINT value = 0;
- value = _selectedStatusVector[realIndex] ? LVIS_SELECTED: 0;
- _listView.SetItemState(i, value, LVIS_SELECTED);
- }
+ _listView.SetItemState_Selected(i, _selectedStatusVector[realIndex]);
}
_enableItemChangeNotify = enableTemp;
}
@@ -174,7 +170,7 @@ void CPanel::SelectByType(bool selectMode)
bool isItemFolder = IsItemFolder(realIndex);
/*
- UINT32 numItems;
+ UInt32 numItems;
_folder->GetNumberOfItems(&numItems);
if ((UInt32)_selectedStatusVector.Size() != numItems)
throw 11111;
@@ -251,7 +247,7 @@ void CPanel::KillSelection()
int realIndex = GetRealItemIndex(focused);
if (realIndex != kParentIndex)
_selectedStatusVector[realIndex] = true;
- _listView.SetItemState(focused, LVIS_SELECTED, LVIS_SELECTED);
+ _listView.SetItemState_Selected(focused);
}
}
}
diff --git a/CPP/7zip/UI/FileManager/PanelSort.cpp b/CPP/7zip/UI/FileManager/PanelSort.cpp
index 186315b3..5ac04800 100755
--- a/CPP/7zip/UI/FileManager/PanelSort.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSort.cpp
@@ -63,8 +63,8 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
NCOM::CPropVariant prop1, prop2;
// Name must be first property
- panel->_folder->GetProperty((UINT32)lParam1, propID, &prop1);
- panel->_folder->GetProperty((UINT32)lParam2, propID, &prop2);
+ panel->_folder->GetProperty((UInt32)lParam1, propID, &prop1);
+ panel->_folder->GetProperty((UInt32)lParam2, propID, &prop2);
if (prop1.vt != prop2.vt)
{
return MyCompare(prop1.vt, prop2.vt);
diff --git a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
index 213c2d48..ba0bedf8 100755
--- a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
@@ -7,6 +7,7 @@
#include "Windows/Error.h"
#include "Windows/FileIO.h"
#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
#include "../GUI/ExtractRes.h"
@@ -89,8 +90,8 @@ class CThreadSplit: public CProgressThreadVirt
{
HRESULT ProcessVirt();
public:
- UString FilePath;
- UString VolBasePath;
+ FString FilePath;
+ FString VolBasePath;
UInt64 NumVolumes;
CRecordVector<UInt64> VolumeSizes;
};
@@ -136,15 +137,15 @@ HRESULT CThreadSplit::ProcessVirt()
needSize = processedSize;
if (curVolSize == 0)
{
- UString name = VolBasePath;
- name += L'.';
- name += seqName.GetNextName();
- sync.SetCurrentFileName(name);
+ FString name = VolBasePath;
+ name += FTEXT('.');
+ name += us2fs(seqName.GetNextName());
+ sync.SetCurrentFileName(fs2us(name));
sync.SetNumFilesCur(numFiles++);
if (!outFile.Create(name, false))
{
HRESULT res = GetLastError();
- ErrorPath1 = name;
+ SetErrorPath1(name);
return res;
}
}
@@ -206,8 +207,8 @@ void CApp::Split()
if (splitDialog.Create(srcPanel.GetParent()) == IDCANCEL)
return;
- NFile::NFind::CFileInfoW fileInfo;
- if (!fileInfo.Find(srcPath + itemName))
+ NFile::NFind::CFileInfo fileInfo;
+ if (!fileInfo.Find(us2fs(srcPath + itemName)))
{
srcPanel.MessageBoxMyError(L"Can not find file");
return;
@@ -230,7 +231,7 @@ void CApp::Split()
path = splitDialog.Path;
NFile::NName::NormalizeDirPathPrefix(path);
- if (!NFile::NDirectory::CreateComplexDirectory(path))
+ if (!NFile::NDirectory::CreateComplexDirectory(us2fs(path)))
{
srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
return;
@@ -253,8 +254,8 @@ void CApp::Split()
progressDialog.Sync.SetTitleFileName(itemName);
- spliter.FilePath = srcPath + itemName;
- spliter.VolBasePath = path + itemName;
+ spliter.FilePath = us2fs(srcPath + itemName);
+ spliter.VolBasePath = us2fs(path + itemName);
spliter.VolumeSizes = splitDialog.VolumeSizes;
// if (splitDialog.VolumeSizes.Size() == 0) return;
@@ -279,9 +280,9 @@ class CThreadCombine: public CProgressThreadVirt
{
HRESULT ProcessVirt();
public:
- UString InputDirPrefix;
- UStringVector Names;
- UString OutputPath;
+ FString InputDirPrefix;
+ FStringVector Names;
+ FString OutputPath;
UInt64 TotalSize;
};
@@ -291,7 +292,7 @@ HRESULT CThreadCombine::ProcessVirt()
if (!outFile.Create(OutputPath, false))
{
HRESULT res = GetLastError();
- ErrorPath1 = OutputPath;
+ SetErrorPath1(OutputPath);
return res;
}
@@ -306,21 +307,21 @@ HRESULT CThreadCombine::ProcessVirt()
for (int i = 0; i < Names.Size(); i++)
{
NFile::NIO::CInFile inFile;
- const UString nextName = InputDirPrefix + Names[i];
+ const FString nextName = InputDirPrefix + Names[i];
if (!inFile.Open(nextName))
{
HRESULT res = GetLastError();
- ErrorPath1 = nextName;
+ SetErrorPath1(nextName);
return res;
}
- sync.SetCurrentFileName(nextName);
+ sync.SetCurrentFileName(fs2us(nextName));
for (;;)
{
UInt32 processedSize;
if (!inFile.Read(buffer, kBufSize, processedSize))
{
HRESULT res = GetLastError();
- ErrorPath1 = nextName;
+ SetErrorPath1(nextName);
return res;
}
if (processedSize == 0)
@@ -329,7 +330,7 @@ HRESULT CThreadCombine::ProcessVirt()
if (!outFile.Write(buffer, needSize, processedSize))
{
HRESULT res = GetLastError();
- ErrorPath1 = OutputPath;
+ SetErrorPath1(OutputPath);
return res;
}
if (needSize != processedSize)
@@ -392,10 +393,10 @@ void CApp::Combine()
combiner.TotalSize = 0;
for (;;)
{
- NFile::NFind::CFileInfoW fileInfo;
- if (!fileInfo.Find(srcPath + nextName) || fileInfo.IsDir())
+ NFile::NFind::CFileInfo fileInfo;
+ if (!fileInfo.Find(us2fs(srcPath + nextName)) || fileInfo.IsDir())
break;
- combiner.Names.Add(nextName);
+ combiner.Names.Add(us2fs(nextName));
combiner.TotalSize += fileInfo.Size;
nextName = volSeqName.GetNextName();
}
@@ -419,12 +420,12 @@ void CApp::Combine()
int i;
for (i = 0; i < combiner.Names.Size() && i < 2; i++)
- AddInfoFileName(combiner.Names[i], info);
+ AddInfoFileName(fs2us(combiner.Names[i]), info);
if (i != combiner.Names.Size())
{
if (i + 1 != combiner.Names.Size())
AddInfoFileName(L"...", info);
- AddInfoFileName(combiner.Names.Back(), info);
+ AddInfoFileName(fs2us(combiner.Names.Back()), info);
}
{
@@ -441,7 +442,7 @@ void CApp::Combine()
}
NFile::NName::NormalizeDirPathPrefix(path);
- if (!NFile::NDirectory::CreateComplexDirectory(path))
+ if (!NFile::NDirectory::CreateComplexDirectory(us2fs(path)))
{
srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
return;
@@ -450,18 +451,17 @@ void CApp::Combine()
UString outName = volSeqName.UnchangedPart;
while (!outName.IsEmpty())
{
- int lastIndex = outName.Length() - 1;
- if (outName[lastIndex] != L'.')
+ if (outName.Back() != L'.')
break;
- outName.Delete(lastIndex);
+ outName.DeleteBack();
}
if (outName.IsEmpty())
outName = L"file";
- NFile::NFind::CFileInfoW fileInfo;
+ NFile::NFind::CFileInfo fileInfo;
UString destFilePath = path + outName;
- combiner.OutputPath = destFilePath;
- if (fileInfo.Find(destFilePath))
+ combiner.OutputPath = us2fs(destFilePath);
+ if (fileInfo.Find(combiner.OutputPath))
{
srcPanel.MessageBoxMyError(MyFormatNew(IDS_FILE_EXIST, 0x03020A04, destFilePath));
return;
@@ -477,7 +477,7 @@ void CApp::Combine()
progressDialog.MainTitle = progressWindowTitle;
progressDialog.MainAddTitle = title + UString(L" ");
- combiner.InputDirPrefix = srcPath;
+ combiner.InputDirPrefix = us2fs(srcPath);
// CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
// CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.cpp b/CPP/7zip/UI/FileManager/PasswordDialog.cpp
index eaf90a24..92826a1f 100755
--- a/CPP/7zip/UI/FileManager/PasswordDialog.cpp
+++ b/CPP/7zip/UI/FileManager/PasswordDialog.cpp
@@ -18,6 +18,17 @@ static CIDLangPair kIDLangPairs[] =
};
#endif
+void CPasswordDialog::ReadControls()
+{
+ _passwordControl.GetText(Password);
+ ShowPassword = IsButtonCheckedBool(IDC_CHECK_PASSWORD_SHOW);
+}
+
+void CPasswordDialog::SetTextSpec()
+{
+ _passwordControl.SetPasswordChar(ShowPassword ? 0: TEXT('*'));
+ _passwordControl.SetText(Password);
+}
bool CPasswordDialog::OnInit()
{
@@ -26,8 +37,8 @@ bool CPasswordDialog::OnInit()
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_passwordControl.Attach(GetItem(IDC_EDIT_PASSWORD));
- _passwordControl.SetText(Password);
- _passwordControl.SetPasswordChar(TEXT('*'));
+ CheckButton(IDC_CHECK_PASSWORD_SHOW, ShowPassword);
+ SetTextSpec();
return CModalDialog::OnInit();
}
@@ -35,10 +46,8 @@ bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
{
if (buttonID == IDC_CHECK_PASSWORD_SHOW)
{
- _passwordControl.SetPasswordChar(IsButtonCheckedBool(IDC_CHECK_PASSWORD_SHOW) ? 0: TEXT('*'));
- UString password;
- _passwordControl.GetText(password);
- _passwordControl.SetText(password);
+ ReadControls();
+ SetTextSpec();
return true;
}
return CDialog::OnButtonClicked(buttonID, buttonHWND);
@@ -46,6 +55,6 @@ bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
void CPasswordDialog::OnOK()
{
- _passwordControl.GetText(Password);
+ ReadControls();
CModalDialog::OnOK();
}
diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.h b/CPP/7zip/UI/FileManager/PasswordDialog.h
index e5a96073..1d903249 100755
--- a/CPP/7zip/UI/FileManager/PasswordDialog.h
+++ b/CPP/7zip/UI/FileManager/PasswordDialog.h
@@ -1,7 +1,7 @@
// PasswordDialog.h
-#ifndef __PASSWORDDIALOG_H
-#define __PASSWORDDIALOG_H
+#ifndef __PASSWORD_DIALOG_H
+#define __PASSWORD_DIALOG_H
#include "Windows/Control/Dialog.h"
#include "Windows/Control/Edit.h"
@@ -13,8 +13,12 @@ class CPasswordDialog: public NWindows::NControl::CModalDialog
virtual void OnOK();
virtual bool OnInit();
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ void SetTextSpec();
+ void ReadControls();
public:
UString Password;
+ bool ShowPassword;
+ CPasswordDialog(): ShowPassword(false) {}
INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_PASSWORD, parentWindow); }
};
diff --git a/CPP/7zip/UI/FileManager/PluginLoader.h b/CPP/7zip/UI/FileManager/PluginLoader.h
index 3cf15aa5..cb7d4d7c 100755
--- a/CPP/7zip/UI/FileManager/PluginLoader.h
+++ b/CPP/7zip/UI/FileManager/PluginLoader.h
@@ -5,6 +5,8 @@
#include "Windows/DLL.h"
+#include "IFolder.h"
+
typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject);
class CPluginLibrary: public NWindows::NDLL::CLibrary
@@ -17,7 +19,7 @@ public:
return GetLastError();
return createObject(&clsID, &IID_IFolderManager, (void **)manager);
}
- HRESULT LoadAndCreateManager(LPCWSTR filePath, REFGUID clsID, IFolderManager **manager)
+ HRESULT LoadAndCreateManager(CFSTR filePath, REFGUID clsID, IFolderManager **manager)
{
if (!Load(filePath))
return GetLastError();
diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.cpp b/CPP/7zip/UI/FileManager/ProgramLocation.cpp
index ce2d178e..50ca5ca5 100755
--- a/CPP/7zip/UI/FileManager/ProgramLocation.cpp
+++ b/CPP/7zip/UI/FileManager/ProgramLocation.cpp
@@ -1,24 +1,3 @@
// ProgramLocation.cpp
#include "StdAfx.h"
-
-#include "../../../../C/Types.h"
-
-#include "ProgramLocation.h"
-
-#include "Windows/DLL.h"
-
-using namespace NWindows;
-
-extern HINSTANCE g_hInstance;
-
-bool GetProgramFolderPath(UString &folder)
-{
- if (!NDLL::MyGetModuleFileName(g_hInstance, folder))
- return false;
- int pos = folder.ReverseFind(WCHAR_PATH_SEPARATOR);
- if (pos < 0)
- return false;
- folder = folder.Left(pos + 1);
- return true;
-}
diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.h b/CPP/7zip/UI/FileManager/ProgramLocation.h
index 55c56144..6bfb711e 100755
--- a/CPP/7zip/UI/FileManager/ProgramLocation.h
+++ b/CPP/7zip/UI/FileManager/ProgramLocation.h
@@ -3,8 +3,4 @@
#ifndef __PROGRAM_LOCATION_H
#define __PROGRAM_LOCATION_H
-#include "Common/MyString.h"
-
-bool GetProgramFolderPath(UString &folder); // normalized
-
#endif
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
index 3d878a61..bd77d20d 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
@@ -146,6 +146,7 @@ bool CProgressDialog::OnInit()
m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
_messageList.Attach(GetItem(IDC_PROGRESS_LIST));
+ _messageList.SetUnicodeFormat();
_wasCreated = true;
_dialogCreatedEvent.Set();
@@ -154,7 +155,6 @@ bool CProgressDialog::OnInit()
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
-
CWindow window(GetItem(IDC_BUTTON_PROGRESS_PRIORITY));
window.GetText(backgroundString);
backgroundedString = backgroundString;
@@ -171,11 +171,6 @@ bool CProgressDialog::OnInit()
SetPauseText();
SetPriorityText();
-
- #ifndef UNDER_CE
- _messageList.SetUnicodeFormat(true);
- #endif
-
_messageList.InsertColumn(0, L"", 30);
const UString s = LangStringSpec(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80);
@@ -957,10 +952,8 @@ UString HResultToMessage(HRESULT errorCode)
UString message;
if (errorCode == E_OUTOFMEMORY)
message = LangStringSpec(IDS_MEM_ERROR, 0x0200060B);
- else if (!NError::MyFormatMessage(errorCode, message))
- message.Empty();
- if (message.IsEmpty())
- message = L"Error";
+ else
+ message = NError::MyFormatMessageW(errorCode);
return message;
}
@@ -989,8 +982,8 @@ void CProgressThreadVirt::Process()
m = HResultToMessage(Result);
}
AddMessageToString(m, ErrorMessage);
- AddMessageToString(m, ErrorPath1);
- AddMessageToString(m, ErrorPath2);
+ AddMessageToString(m, fs2us(ErrorPath1));
+ AddMessageToString(m, fs2us(ErrorPath2));
if (m.IsEmpty())
{
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.h b/CPP/7zip/UI/FileManager/ProgressDialog2.h
index ed096f06..81a64e32 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.h
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.h
@@ -323,10 +323,10 @@ public:
class CProgressThreadVirt
{
+ FString ErrorPath1;
+ FString ErrorPath2;
protected:
UString ErrorMessage;
- UString ErrorPath1;
- UString ErrorPath2;
UString OkMessage;
UString OkMessageTitle;
@@ -350,6 +350,9 @@ public:
return 0;
}
+ void SetErrorPath1(const FString &path) { ErrorPath1 = path; }
+ void SetErrorPath2(const FString &path) { ErrorPath2 = path; }
+
HRESULT Create(const UString &title, HWND parentWindow = 0);
CProgressThreadVirt(): Result(E_FAIL), ThreadFinishedOK(false) {}
};
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h
index 21ac03c2..be5af607 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h
@@ -35,7 +35,11 @@
#define IDC_PROGRESS_ERRORS_VALUE 1031
#define IDC_PROGRESS_LIST 1032
+#ifdef UNDER_CE
#define MY_PROGRESS_VALUE_UNITS 44
+#else
+#define MY_PROGRESS_VALUE_UNITS 76
+#endif
#define MY_PROGRESS_LABEL_UNITS_MIN 60
#define MY_PROGRESS_LABEL_UNITS_START 90
#define MY_PROGRESS_PAD_UNITS 4
diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
index f7edbb4b..487b6060 100755
--- a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
@@ -2,234 +2,151 @@
#include "StdAfx.h"
-#include "RegistryAssociations.h"
-
#include "Common/IntToString.h"
#include "Common/StringConvert.h"
#include "Common/StringToInt.h"
#include "Windows/Registry.h"
-#include "Windows/Synchronization.h"
-#include "StringUtils.h"
+#include "RegistryAssociations.h"
using namespace NWindows;
using namespace NRegistry;
-namespace NRegistryAssociations {
+namespace NRegistryAssoc {
-static NSynchronization::CCriticalSection g_CriticalSection;
-
-#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR) TEXT("FM")
-
-/*
-
-static const TCHAR *kCUKeyPath = REG_PATH_FM;
-static const WCHAR *kExtPlugins = L"Plugins";
-static const TCHAR *kExtEnabled = TEXT("Enabled");
-
-#define kAssociations TEXT("Associations")
-#define kAssociationsPath REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) kAssociations
-
-bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo)
-{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey key;
- if (key.Open(HKEY_CURRENT_USER,
- CSysString(kAssociationsPath TEXT(STRING_PATH_SEPARATOR)) +
- GetSystemString(ext), KEY_READ) != ERROR_SUCCESS)
- return false;
- UString pluginsString;
- key.QueryValue(kExtPlugins, pluginsString);
- SplitString(pluginsString, extInfo.Plugins);
- return true;
-}
-
-void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
-{
- items.Clear();
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey associationsKey;
- if (associationsKey.Open(HKEY_CURRENT_USER, kAssociationsPath, KEY_READ) != ERROR_SUCCESS)
- return;
- CSysStringVector extNames;
- associationsKey.EnumKeys(extNames);
- for(int i = 0; i < extNames.Size(); i++)
- {
- const CSysString extName = extNames[i];
- CExtInfo extInfo;
- // extInfo.Enabled = false;
- extInfo.Ext = GetUnicodeString(extName);
- CKey key;
- if (key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS)
- return;
- UString pluginsString;
- key.QueryValue(kExtPlugins, pluginsString);
- SplitString(pluginsString, extInfo.Plugins);
- // if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS)
- // extInfo.Enabled = false;
- items.Add(extInfo);
- }
-}
-
-void WriteInternalAssociations(const CObjectVector<CExtInfo> &items)
-{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey mainKey;
- mainKey.Create(HKEY_CURRENT_USER, kCUKeyPath);
- mainKey.RecurseDeleteKey(kAssociations);
- CKey associationsKey;
- associationsKey.Create(mainKey, kAssociations);
- for(int i = 0; i < items.Size(); i++)
- {
- const CExtInfo &extInfo = items[i];
- CKey key;
- key.Create(associationsKey, GetSystemString(extInfo.Ext));
- key.SetValue(kExtPlugins, JoinStrings(extInfo.Plugins));
- // key.SetValue(kExtEnabled, extInfo.Enabled);
- }
-}
-*/
-
-///////////////////////////////////
-// External
+// static NSynchronization::CCriticalSection g_CriticalSection;
-static const TCHAR *kShellNewKeyName = TEXT("ShellNew");
-static const TCHAR *kShellNewDataValueName = TEXT("Data");
-
+static const TCHAR *kClasses = TEXT("Software\\Classes\\");
+// static const TCHAR *kShellNewKeyName = TEXT("ShellNew");
+// static const TCHAR *kShellNewDataValueName = TEXT("Data");
static const TCHAR *kDefaultIconKeyName = TEXT("DefaultIcon");
static const TCHAR *kShellKeyName = TEXT("shell");
static const TCHAR *kOpenKeyName = TEXT("open");
static const TCHAR *kCommandKeyName = TEXT("command");
static const TCHAR *k7zipPrefix = TEXT("7-Zip.");
-static CSysString GetExtensionKeyName(const CSysString &extension)
+static CSysString GetExtProgramKeyName(const CSysString &ext)
{
- return CSysString(TEXT(".")) + extension;
+ return CSysString(k7zipPrefix) + ext;
}
-static CSysString GetExtProgramKeyName(const CSysString &extension)
+static CSysString GetFullKeyPath(HKEY hkey, const CSysString &name)
{
- return CSysString(k7zipPrefix) + extension;
+ CSysString s;
+ if (hkey != HKEY_CLASSES_ROOT)
+ s = kClasses;
+ return s + name;
}
-static bool CheckShellExtensionInfo2(const CSysString &extension,
- CSysString programKeyName, UString &iconPath, int &iconIndex)
+static CSysString GetExtKeyPath(HKEY hkey, const CSysString &ext)
{
- iconIndex = -1;
- iconPath.Empty();
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey extKey;
- if (extKey.Open(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension), KEY_READ) != ERROR_SUCCESS)
- return false;
- if (extKey.QueryValue(NULL, programKeyName) != ERROR_SUCCESS)
- return false;
- UString s = GetUnicodeString(k7zipPrefix);
- if (s.CompareNoCase(GetUnicodeString(programKeyName.Left(s.Length()))) != 0)
- return false;
- CKey iconKey;
- if (extKey.Open(HKEY_CLASSES_ROOT, programKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS)
- return false;
- UString value;
- if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS)
+ return GetFullKeyPath(hkey, (TEXT(".")) + ext);
+}
+
+bool CShellExtInfo::ReadFromRegistry(HKEY hkey, const CSysString &ext)
+{
+ ProgramKey.Empty();
+ IconPath.Empty();
+ IconIndex = -1;
+ // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ {
+ CKey extKey;
+ if (extKey.Open(hkey, GetExtKeyPath(hkey, ext), KEY_READ) != ERROR_SUCCESS)
+ return false;
+ if (extKey.QueryValue(NULL, ProgramKey) != ERROR_SUCCESS)
+ return false;
+ }
{
- int pos = value.ReverseFind(L',');
- iconPath = value;
- if (pos >= 0)
+ CKey iconKey;
+ if (iconKey.Open(hkey, GetFullKeyPath(hkey, ProgramKey + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName), KEY_READ) == ERROR_SUCCESS)
{
- const wchar_t *end;
- UInt64 index = ConvertStringToUInt64((const wchar_t *)value + pos + 1, &end);
- if (*end == 0)
+ UString value;
+ if (iconKey.QueryValue(NULL, value) == ERROR_SUCCESS)
{
- iconIndex = (int)index;
- iconPath = value.Left(pos);
+ int pos = value.ReverseFind(L',');
+ IconPath = value;
+ if (pos >= 0)
+ {
+ const wchar_t *end;
+ Int64 index = ConvertStringToInt64((const wchar_t *)value + pos + 1, &end);
+ if (*end == 0)
+ {
+ IconIndex = (int)index;
+ IconPath = value.Left(pos);
+ }
+ }
}
}
}
return true;
}
-bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex)
-{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CSysString programKeyName;
- if (!CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex))
- return false;
- CKey extProgKey;
- return (extProgKey.Open(HKEY_CLASSES_ROOT, programKeyName, KEY_READ) == ERROR_SUCCESS);
-}
-
-static void DeleteShellExtensionKey(const CSysString &extension)
+bool CShellExtInfo::IsIt7Zip() const
{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey rootKey;
- rootKey.Attach(HKEY_CLASSES_ROOT);
- rootKey.RecurseDeleteKey(GetExtensionKeyName(extension));
- rootKey.Detach();
+ UString s = GetUnicodeString(k7zipPrefix);
+ return (s.CompareNoCase(GetUnicodeString(ProgramKey.Left(s.Length()))) == 0);
}
-static void DeleteShellExtensionProgramKey(const CSysString &extension)
+LONG DeleteShellExtensionInfo(HKEY hkey, const CSysString &ext)
{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CKey rootKey;
- rootKey.Attach(HKEY_CLASSES_ROOT);
- rootKey.RecurseDeleteKey(GetExtProgramKeyName(extension));
+ rootKey.Attach(hkey);
+ LONG res = rootKey.RecurseDeleteKey(GetExtKeyPath(hkey, ext));
+ // then we delete only 7-Zip.* key.
+ rootKey.RecurseDeleteKey(GetFullKeyPath(hkey, GetExtProgramKeyName(ext)));
rootKey.Detach();
+ return res;
}
-void DeleteShellExtensionInfo(const CSysString &extension)
-{
- CSysString programKeyName;
- UString iconPath;
- int iconIndex;
- if (CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex))
- DeleteShellExtensionKey(extension);
- DeleteShellExtensionProgramKey(extension);
-}
-
-void AddShellExtensionInfo(const CSysString &extension,
+LONG AddShellExtensionInfo(HKEY hkey,
+ const CSysString &ext,
const UString &programTitle,
const UString &programOpenCommand,
- const UString &iconPath, int iconIndex,
- const void *shellNewData, int shellNewDataSize)
+ const UString &iconPath, int iconIndex
+ // , const void *shellNewData, int shellNewDataSize
+ )
{
- DeleteShellExtensionKey(extension);
- DeleteShellExtensionProgramKey(extension);
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ LONG res = 0;
+ DeleteShellExtensionInfo(hkey, ext);
+ // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CSysString programKeyName;
{
- CSysString ext = extension;
+ CSysString ext2 = ext;
if (iconIndex < 0)
- ext = TEXT("*");
- programKeyName = GetExtProgramKeyName(ext);
+ ext2 = TEXT("*");
+ programKeyName = GetExtProgramKeyName(ext2);
}
{
CKey extKey;
- extKey.Create(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension));
+ res = extKey.Create(hkey, GetExtKeyPath(hkey, ext));
extKey.SetValue(NULL, programKeyName);
+ /*
if (shellNewData != NULL)
{
CKey shellNewKey;
shellNewKey.Create(extKey, kShellNewKeyName);
shellNewKey.SetValue(kShellNewDataValueName, shellNewData, shellNewDataSize);
}
+ */
}
CKey programKey;
- programKey.Create(HKEY_CLASSES_ROOT, programKeyName);
+ programKey.Create(hkey, GetFullKeyPath(hkey, programKeyName));
programKey.SetValue(NULL, programTitle);
{
CKey iconKey;
- iconKey.Create(programKey, kDefaultIconKeyName);
UString iconPathFull = iconPath;
if (iconIndex < 0)
iconIndex = 0;
// if (iconIndex >= 0)
{
- iconPathFull += L",";
+ iconPathFull += L',';
wchar_t s[16];
- ConvertUInt32ToString(iconIndex, s);
+ ConvertInt64ToString(iconIndex, s);
iconPathFull += s;
}
+ iconKey.Create(programKey, kDefaultIconKeyName);
iconKey.SetValue(NULL, iconPathFull);
}
@@ -243,70 +160,8 @@ void AddShellExtensionInfo(const CSysString &extension,
CKey commandKey;
commandKey.Create(openKey, kCommandKeyName);
-
commandKey.SetValue(NULL, programOpenCommand);
+ return res;
}
-///////////////////////////
-// ContextMenu
-/*
-
-static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-Zip");
-static const TCHAR *kContextMenuHandlerCLASSIDValue =
- TEXT("{23170F69-40C1-278A-1000-000100020000}");
-static const TCHAR *kRootKeyNameForFile = TEXT("*");
-static const TCHAR *kRootKeyNameForFolder = TEXT("Folder");
-
-static CSysString GetFullContextMenuKeyName(const CSysString &aKeyName)
- { return (aKeyName + kContextMenuKeyName); }
-
-static bool CheckContextMenuHandlerCommon(const CSysString &aKeyName)
-{
- NSynchronization::CCriticalSectionLock lock(&g_CriticalSection, true);
- CKey aKey;
- if (aKey.Open(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(aKeyName), KEY_READ)
- != ERROR_SUCCESS)
- return false;
- CSysString aValue;
- if (aKey.QueryValue(NULL, aValue) != ERROR_SUCCESS)
- return false;
- return (aValue.CompareNoCase(kContextMenuHandlerCLASSIDValue) == 0);
-}
-
-bool CheckContextMenuHandler()
-{
- return CheckContextMenuHandlerCommon(kRootKeyNameForFile) &&
- CheckContextMenuHandlerCommon(kRootKeyNameForFolder);
-}
-
-static void DeleteContextMenuHandlerCommon(const CSysString &aKeyName)
-{
- CKey rootKey;
- rootKey.Attach(HKEY_CLASSES_ROOT);
- rootKey.RecurseDeleteKey(GetFullContextMenuKeyName(aKeyName));
- rootKey.Detach();
-}
-
-void DeleteContextMenuHandler()
-{
- DeleteContextMenuHandlerCommon(kRootKeyNameForFile);
- DeleteContextMenuHandlerCommon(kRootKeyNameForFolder);
-}
-
-static void AddContextMenuHandlerCommon(const CSysString &aKeyName)
-{
- DeleteContextMenuHandlerCommon(aKeyName);
- NSynchronization::CCriticalSectionLock lock(&g_CriticalSection, true);
- CKey aKey;
- aKey.Create(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(aKeyName));
- aKey.SetValue(NULL, kContextMenuHandlerCLASSIDValue);
-}
-
-void AddContextMenuHandler()
-{
- AddContextMenuHandlerCommon(kRootKeyNameForFile);
- AddContextMenuHandlerCommon(kRootKeyNameForFolder);
-}
-*/
-
}
diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.h b/CPP/7zip/UI/FileManager/RegistryAssociations.h
index 5390b9db..0be8244e 100755
--- a/CPP/7zip/UI/FileManager/RegistryAssociations.h
+++ b/CPP/7zip/UI/FileManager/RegistryAssociations.h
@@ -1,46 +1,31 @@
// RegistryAssociations.h
-#ifndef __REGISTRYASSOCIATIONS_H
-#define __REGISTRYASSOCIATIONS_H
+#ifndef __REGISTRY_ASSOCIATIONS_H
+#define __REGISTRY_ASSOCIATIONS_H
#include "Common/MyString.h"
-namespace NRegistryAssociations {
+namespace NRegistryAssoc {
- /*
- struct CExtInfo
+ struct CShellExtInfo
{
- UString Ext;
- UStringVector Plugins;
- // bool Enabled;
- };
- bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo);
- void ReadInternalAssociations(CObjectVector<CExtInfo> &items);
- void WriteInternalAssociations(const CObjectVector<CExtInfo> &items);
- */
+ CSysString ProgramKey;
+ UString IconPath;
+ int IconIndex;
- bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex);
+ bool ReadFromRegistry(HKEY hkey, const CSysString &ext);
+ bool IsIt7Zip() const;
+ };
- // void ReadCompressionInfo(NZipSettings::NCompression::CInfo &anInfo,
- void DeleteShellExtensionInfo(const CSysString &extension);
+ LONG DeleteShellExtensionInfo(HKEY hkey, const CSysString &ext);
- void AddShellExtensionInfo(const CSysString &extension,
+ LONG AddShellExtensionInfo(HKEY hkey,
+ const CSysString &ext,
const UString &programTitle,
const UString &programOpenCommand,
- const UString &iconPath, int iconIndex,
- const void *shellNewData, int shellNewDataSize);
-
-
- ///////////////////////////
- // ContextMenu
- /*
- bool CheckContextMenuHandler();
- void AddContextMenuHandler();
- void DeleteContextMenuHandler();
- */
-
+ const UString &iconPath, int iconIndex
+ // , const void *shellNewData, int shellNewDataSize
+ );
}
-// bool GetProgramDirPrefix(CSysString &aFolder);
-
#endif
diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
index d49eaa6e..54254f1f 100755
--- a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
@@ -3,12 +3,11 @@
#include "StdAfx.h"
#include "Windows/DLL.h"
-#include "Windows/PropVariant.h"
#include "Windows/FileFind.h"
+#include "Windows/PropVariant.h"
-#include "ProgramLocation.h"
-#include "RegistryPlugins.h"
#include "IFolder.h"
+#include "RegistryPlugins.h"
using namespace NWindows;
using namespace NFile;
@@ -91,23 +90,20 @@ static bool ReadPluginInfo(CPluginInfo &pluginInfo, bool needCheckDll)
return true;
}
-UString GetProgramFolderPrefix();
-
void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
{
plugins.Clear();
- UString baseFolderPrefix;
- GetProgramFolderPath(baseFolderPrefix);
+ FString baseFolderPrefix = NDLL::GetModuleDirPrefix();
{
CPluginInfo pluginInfo;
- pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll";
+ pluginInfo.FilePath = baseFolderPrefix + FTEXT("7-zip.dll");
if (::ReadPluginInfo(pluginInfo, false))
plugins.Add(pluginInfo);
}
- UString folderPath = baseFolderPrefix + L"Plugins" WSTRING_PATH_SEPARATOR;
- NFind::CEnumeratorW enumerator(folderPath + L"*");
- NFind::CFileInfoW fileInfo;
+ FString folderPath = baseFolderPrefix + FTEXT("Plugins") FSTRING_PATH_SEPARATOR;
+ NFind::CEnumerator enumerator(folderPath + FCHAR_ANY_MASK);
+ NFind::CFileInfo fileInfo;
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDir())
diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.h b/CPP/7zip/UI/FileManager/RegistryPlugins.h
index 77055ac7..20f2ec34 100755
--- a/CPP/7zip/UI/FileManager/RegistryPlugins.h
+++ b/CPP/7zip/UI/FileManager/RegistryPlugins.h
@@ -1,7 +1,7 @@
// RegistryPlugins.h
-#ifndef __REGISTRYPLUGINS_H
-#define __REGISTRYPLUGINS_H
+#ifndef __REGISTRY_PLUGINS_H
+#define __REGISTRY_PLUGINS_H
#include "Common/MyString.h"
@@ -12,7 +12,7 @@ enum EPluginType
struct CPluginInfo
{
- UString FilePath;
+ FString FilePath;
EPluginType Type;
UString Name;
CLSID ClassID;
diff --git a/CPP/7zip/UI/FileManager/RootFolder.cpp b/CPP/7zip/UI/FileManager/RootFolder.cpp
index 0715a8be..a81f94c1 100755
--- a/CPP/7zip/UI/FileManager/RootFolder.cpp
+++ b/CPP/7zip/UI/FileManager/RootFolder.cpp
@@ -30,7 +30,7 @@ static const STATPROPSTG kProps[] =
UString RootFolder_GetName_Computer(int &iconIndex)
{
#ifdef UNDER_CE
- GetRealIconIndex(L"\\", FILE_ATTRIBUTE_DIRECTORY, iconIndex);
+ GetRealIconIndex(FTEXT("\\"), FILE_ATTRIBUTE_DIRECTORY, iconIndex);
#else
iconIndex = GetIconIndexForCSIDL(CSIDL_DRIVES);
#endif
@@ -123,7 +123,7 @@ UString GetMyDocsPath()
us = GetUnicodeString(s2);
}
#endif
- if (us.Length() > 0 && us[us.Length() - 1] != WCHAR_PATH_SEPARATOR)
+ if (us.Length() > 0 && us.Back() != WCHAR_PATH_SEPARATOR)
us += WCHAR_PATH_SEPARATOR;
return us;
}
@@ -159,7 +159,7 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde
{
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
subFolder = fsFolderSpec;
- RINOK(fsFolderSpec->Init(s, NULL));
+ RINOK(fsFolderSpec->Init(us2fs(s), NULL));
}
}
#endif
@@ -227,7 +227,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu
name2 += WCHAR_PATH_SEPARATOR;
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
subFolder = fsFolderSpec;
- if (fsFolderSpec->Init(name2, 0) != S_OK)
+ if (fsFolderSpec->Init(us2fs(name2), 0) != S_OK)
{
#ifndef UNDER_CE
if (name2[0] == WCHAR_PATH_SEPARATOR)
diff --git a/CPP/7zip/UI/FileManager/SettingsPage.cpp b/CPP/7zip/UI/FileManager/SettingsPage.cpp
index 10d063f7..866b0b2d 100755
--- a/CPP/7zip/UI/FileManager/SettingsPage.cpp
+++ b/CPP/7zip/UI/FileManager/SettingsPage.cpp
@@ -10,7 +10,6 @@
#include "HelpUtils.h"
#include "LangUtils.h"
-#include "ProgramLocation.h"
#include "RegistryUtils.h"
#include "SettingsPage.h"
diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
index e359ed2b..e537621e 100755
--- a/CPP/7zip/UI/FileManager/SysIconUtils.cpp
+++ b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
@@ -24,7 +24,7 @@ int GetIconIndexForCSIDL(int csidl)
SHGFI_PIDL | SHGFI_SYSICONINDEX);
IMalloc *pMalloc;
SHGetMalloc(&pMalloc);
- if(pMalloc)
+ if (pMalloc)
{
pMalloc->Free(pidl);
pMalloc->Release();
@@ -34,16 +34,6 @@ int GetIconIndexForCSIDL(int csidl)
return 0;
}
-DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex)
-{
- SHFILEINFO shellInfo;
- DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
- sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
- iconIndex = shellInfo.iIcon;
- return res;
-}
-
-
#ifndef _UNICODE
typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags);
@@ -70,28 +60,32 @@ static DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *ps
pszPath, attrib, psfi, cbFileInfo, uFlags);
}
-#ifndef _UNICODE
-// static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex)
+DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex)
{
- if(g_IsNT)
+ #ifndef _UNICODE
+ if (!g_IsNT)
{
- SHFILEINFOW shellInfo;
- DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
+ SHFILEINFO shellInfo;
+ DWORD_PTR res = ::SHGetFileInfo(fs2fas(path), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
iconIndex = shellInfo.iIcon;
return res;
}
else
- return GetRealIconIndex(UnicodeStringToMultiByte(path), attrib, iconIndex);
+ #endif
+ {
+ SHFILEINFOW shellInfo;
+ DWORD_PTR res = ::MySHGetFileInfoW(fs2us(path), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
}
-#endif
-DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib,
- int &iconIndex, UString &typeName)
+DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex, UString &typeName)
{
#ifndef _UNICODE
- if(!g_IsNT)
+ if (!g_IsNT)
{
SHFILEINFO shellInfo;
shellInfo.szTypeName[0] = 0;
diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.h b/CPP/7zip/UI/FileManager/SysIconUtils.h
index 5ba9c57f..129de781 100755
--- a/CPP/7zip/UI/FileManager/SysIconUtils.h
+++ b/CPP/7zip/UI/FileManager/SysIconUtils.h
@@ -39,10 +39,7 @@ public:
int GetIconIndex(DWORD attrib, const UString &fileName);
};
-DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex);
-#ifndef _UNICODE
-DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex);
-#endif
+DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex);
int GetIconIndexForCSIDL(int csidl);
inline HIMAGELIST GetSysImageList(bool smallIcons)
diff --git a/CPP/7zip/UI/FileManager/SystemPage.cpp b/CPP/7zip/UI/FileManager/SystemPage.cpp
index 3681992d..359656ea 100755
--- a/CPP/7zip/UI/FileManager/SystemPage.cpp
+++ b/CPP/7zip/UI/FileManager/SystemPage.cpp
@@ -1,172 +1,266 @@
// SystemPage.cpp
#include "StdAfx.h"
-#include "SystemPageRes.h"
-#include "SystemPage.h"
#include "Common/StringConvert.h"
-#include "Common/MyCom.h"
-#include "Windows/Defs.h"
-#include "Windows/Control/ListView.h"
-#include "Windows/FileFind.h"
+#include "Windows/DLL.h"
+#include "Windows/Error.h"
-#include "IFolder.h"
#include "HelpUtils.h"
+#include "IFolder.h"
#include "LangUtils.h"
-#include "PluginLoader.h"
-#include "ProgramLocation.h"
-#include "StringUtils.h"
-
#include "PropertyNameRes.h"
-#include "../Agent/Agent.h"
+#include "SystemPage.h"
+#include "SystemPageRes.h"
-using namespace NRegistryAssociations;
+static const CIDLangPair kIDLangPairs[] =
+{
+ { IDC_SYSTEM_STATIC_ASSOCIATE, 0x03010302}
+ // { IDC_SYSTEM_SELECT_ALL, 0x03000330}
+};
-const int kRefreshpluginsListMessage = WM_USER + 1;
-const int kUpdateDatabase = kRefreshpluginsListMessage + 1;
+static LPCWSTR kSystemTopic = L"FM/options.htm#system";
-static CIDLangPair kIDLangPairs[] =
+CSysString CModifiedExtInfo::GetString() const
{
- { IDC_SYSTEM_STATIC_ASSOCIATE, 0x03010302},
- { IDC_SYSTEM_SELECT_ALL, 0x03000330}
+ if (State == kExtState_7Zip)
+ return TEXT("7-Zip");
+ if (State == kExtState_Clear)
+ return TEXT("");
+ if (Other7Zip)
+ return TEXT("[7-Zip]");
+ return ProgramKey;
};
-static LPCWSTR kSystemTopic = L"FM/options.htm#system";
+int CSystemPage::AddIcon(const UString &iconPath, int iconIndex)
+{
+ if (iconPath.IsEmpty())
+ return -1;
+ if (iconIndex == -1)
+ iconIndex = 0;
+ HICON hicon;
+ #ifdef UNDER_CE
+ ExtractIconExW(iconPath, iconIndex, NULL, &hicon, 1);
+ if (!hicon)
+ #else
+ // we expand path from REG_EXPAND_SZ registry item.
+ UString path;
+ DWORD size = MAX_PATH + 10;
+ DWORD needLen = ::ExpandEnvironmentStringsW(iconPath, path.GetBuffer((int)size + 1), size);
+ path.ReleaseBuffer();
+ if (needLen == 0 || needLen >= size)
+ path = iconPath;
+ int num = ExtractIconExW(path, iconIndex, NULL, &hicon, 1);
+ if (num != 1 || !hicon)
+ #endif
+ return -1;
+ _imageList.AddIcon(hicon);
+ DestroyIcon(hicon);
+ return _numIcons++;
+}
+void CSystemPage::RefreshListItem(int group, int listIndex)
+{
+ const CAssoc &assoc = _items[GetRealIndex(listIndex)];
+ _listView.SetSubItem(listIndex, group + 1, assoc.Pair[group].GetString());
+ LVITEMW newItem;
+ memset(&newItem, 0, sizeof(newItem));
+ newItem.iItem = listIndex;
+ newItem.mask = LVIF_IMAGE;
+ newItem.iImage = assoc.GetIconIndex();
+ _listView.SetItem(&newItem);
+}
+
+void CSystemPage::ChangeState(int group, const CIntVector &indices)
+{
+ if (indices.IsEmpty())
+ return;
+
+ bool thereAreClearItems = false;
+ int counters[3] = { 0, 0, 0 };
+
+ int i;
+ for (i = 0; i < indices.Size(); i++)
+ {
+ const CModifiedExtInfo &mi = _items[GetRealIndex(indices[i])].Pair[group];
+ int state = kExtState_7Zip;
+ if (mi.State == kExtState_7Zip)
+ state = kExtState_Clear;
+ else if (mi.State == kExtState_Clear)
+ {
+ thereAreClearItems = true;
+ if (mi.Other)
+ state = kExtState_Other;
+ }
+ counters[state]++;
+ }
+
+ int state = kExtState_Clear;
+ if (counters[kExtState_Other] != 0)
+ state = kExtState_Other;
+ else if (counters[kExtState_7Zip] != 0)
+ state = kExtState_7Zip;
+
+ for (i = 0; i < indices.Size(); i++)
+ {
+ int listIndex = indices[i];
+ CAssoc &assoc = _items[GetRealIndex(listIndex)];
+ CModifiedExtInfo &mi = assoc.Pair[group];
+ bool change = false;
+ switch (state)
+ {
+ case kExtState_Clear: change = true; break;
+ case kExtState_Other: change = mi.Other; break;
+ default: change = !(mi.Other && thereAreClearItems); break;
+ }
+ if (change)
+ {
+ mi.State = state;
+ RefreshListItem(group, listIndex);
+ }
+ }
+ Changed();
+}
bool CSystemPage::OnInit()
{
- _initMode = true;
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ LangSetDlgItemsText((HWND)*this, kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+
+ _listView.Attach(GetItem(IDC_SYSTEM_LIST_ASSOCIATE));
+ _listView.SetUnicodeFormat();
+ DWORD newFlags = LVS_EX_FULLROWSELECT;
+ _listView.SetExtendedListViewStyle(newFlags, newFlags);
- _listViewExt.Attach(GetItem(IDC_SYSTEM_LIST_ASSOCIATE));
- _listViewPlugins.Attach(GetItem(IDC_SYSTEM_LIST_PLUGINS));
+ _numIcons = 0;
+ _imageList.Create(16, 16, ILC_MASK | ILC_COLOR32, 0, 0);
- /*
- CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
- NRegistryAssociations::CheckContextMenuHandler());
- */
+ _listView.SetImageList(_imageList, LVSIL_SMALL);
- UINT32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT;
- _listViewExt.SetExtendedListViewStyle(newFlags, newFlags);
- _listViewPlugins.SetExtendedListViewStyle(newFlags, newFlags);
+ _listView.InsertColumn(0, LangString(IDS_PROP_FILE_TYPE, 0x02000214), 72);
- _listViewExt.InsertColumn(0, LangString(IDS_PROP_EXTENSION, 0x02000205), 40);
- const UString s = LangString(IDS_PLUGIN, 0x03010310);
- _listViewExt.InsertColumn(1, s, 40);
+ CSysString s;
- _listViewPlugins.InsertColumn(0, s, 40);
+ #if NUM_EXT_GROUPS == 1
+ s = TEXT("Program");
+ #else
+ #ifndef UNDER_CE
+ DWORD size = 256;
+ BOOL res = GetUserName(s.GetBuffer(size), &size);
+ s.ReleaseBuffer();
+ if (!res)
+ #endif
+ s = TEXT("Current User");
+ #endif
- _extDatabase.Read();
+ LVCOLUMN ci;
+ ci.mask = LVCF_TEXT | LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
+ ci.cx = 100;
+ ci.pszText = (TCHAR *)(const TCHAR *)s;
+ ci.iSubItem = 1;
+ ci.fmt = LVCFMT_CENTER;
+ _listView.InsertColumn(1, &ci);
- for (int i = 0; i < _extDatabase.ExtBigItems.Size(); i++)
+ #if NUM_EXT_GROUPS > 1
{
- CExtInfoBig &extInfo = _extDatabase.ExtBigItems[i];
-
- int itemIndex = _listViewExt.InsertItem(i, (LPCWSTR)extInfo.Ext);
+ ci.iSubItem = 2;
+ ci.pszText = TEXT("All Users");
+ _listView.InsertColumn(2, &ci);
+ }
+ #endif
- UString iconPath;
- int iconIndex;
- extInfo.Associated = NRegistryAssociations::CheckShellExtensionInfo(GetSystemString(extInfo.Ext), iconPath, iconIndex);
- if (extInfo.Associated && !NWindows::NFile::NFind::DoesFileExist(iconPath))
- extInfo.Associated = false;
- _listViewExt.SetCheckState(itemIndex, extInfo.Associated);
+ _extDB.Read();
+ _items.Clear();
- SetMainPluginText(itemIndex, i);
+ for (int i = 0; i < _extDB.Exts.Size(); i++)
+ {
+ const CExtPlugins &extInfo = _extDB.Exts[i];
+
+ LVITEMW item;
+ item.iItem = i;
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ item.lParam = i;
+ item.iSubItem = 0;
+ // ListView always uses internal iImage that is 0 by default?
+ // so we always use LVIF_IMAGE.
+ item.iImage = -1;
+ item.pszText = (wchar_t *)(const wchar_t *)(LPCWSTR)extInfo.Ext;
+
+ CAssoc assoc;
+ const CPluginToIcon &plug = extInfo.Plugins[0];
+ assoc.SevenZipImageIndex = AddIcon(plug.IconPath, plug.IconIndex);
+
+ CSysString texts[NUM_EXT_GROUPS];
+ int g;
+ for (g = 0; g < NUM_EXT_GROUPS; g++)
+ {
+ CModifiedExtInfo &mi = assoc.Pair[g];
+ mi.ReadFromRegistry(GetHKey(g), GetSystemString(extInfo.Ext));
+ mi.SetState(plug.IconPath);
+ mi.ImageIndex = AddIcon(mi.IconPath, mi.IconIndex);
+ texts[g] = mi.GetString();
+ }
+ item.iImage = assoc.GetIconIndex();
+ int itemIndex = _listView.InsertItem(&item);
+ for (g = 0; g < NUM_EXT_GROUPS; g++)
+ _listView.SetSubItem(itemIndex, 1 + g, texts[g]);
+ _items.Add(assoc);
}
- // _listViewExt.SortItems();
- if (_listViewExt.GetItemCount() > 0)
- _listViewExt.SetItemState_FocusedSelected(0);
- RefreshPluginsList(-1);
- _initMode = false;
+ if (_listView.GetItemCount() > 0)
+ _listView.SetItemState(0, LVIS_FOCUSED, LVIS_FOCUSED);
return CPropertyPage::OnInit();
}
-void CSystemPage::SetMainPluginText(int itemIndex, int indexInDatabase)
-{
- _listViewExt.SetSubItem(itemIndex, 1, _extDatabase.GetMainPluginNameForExtItem(indexInDatabase));
-}
-
static UString GetProgramCommand()
{
- UString path = L"\"";
- UString folder;
- if (GetProgramFolderPath(folder))
- path += folder;
- path += L"7zFM.exe\" \"%1\"";
- return path;
-}
-
-static UString GetIconPath(const UString &filePath,
- const CLSID &clsID, const UString &extension, Int32 &iconIndex)
-{
- CPluginLibrary library;
- CMyComPtr<IFolderManager> folderManager;
- CMyComPtr<IFolderFolder> folder;
- if (filePath.IsEmpty())
- folderManager = new CArchiveFolderManager;
- else if (library.LoadAndCreateManager(filePath, clsID, &folderManager) != S_OK)
- return UString();
- CMyComBSTR extBSTR;
- if (folderManager->GetExtensions(&extBSTR) != S_OK)
- return UString();
- const UString ext2 = (const wchar_t *)extBSTR;
- UStringVector exts;
- SplitString(ext2, exts);
- for (int i = 0; i < exts.Size(); i++)
- {
- const UString &plugExt = exts[i];
- if (extension.CompareNoCase((const wchar_t *)plugExt) == 0)
- {
- CMyComBSTR iconPathTemp;
- if (folderManager->GetIconPath(plugExt, &iconPathTemp, &iconIndex) != S_OK)
- break;
- if (iconPathTemp != 0)
- return (const wchar_t *)iconPathTemp;
- }
- }
- return UString();
+ return L"\"" + fs2us(NWindows::NDLL::GetModuleDirPrefix()) + L"7zFM.exe\" \"%1\"";
}
LONG CSystemPage::OnApply()
{
- UpdateDatabase();
- _extDatabase.Save();
- UString command = GetProgramCommand();
+ const UString command = GetProgramCommand();
- for (int i = 0; i < _extDatabase.ExtBigItems.Size(); i++)
+ LONG res = 0;
+
+ for (int listIndex = 0; listIndex < _extDB.Exts.Size(); listIndex++)
{
- const CExtInfoBig &extInfo = _extDatabase.ExtBigItems[i];
- if (extInfo.Associated)
+ int realIndex = GetRealIndex(listIndex);
+ const CExtPlugins &extInfo = _extDB.Exts[realIndex];
+ CAssoc &assoc = _items[realIndex];
+
+ for (int g = 0; g < NUM_EXT_GROUPS; g++)
{
- UString title = extInfo.Ext + UString(L" Archive");
- UString command = GetProgramCommand();
- UString iconPath;
- Int32 iconIndex = -1;
- if (!extInfo.PluginsPairs.IsEmpty())
+ CModifiedExtInfo &mi = assoc.Pair[g];
+ HKEY key = GetHKey(g);
+ if (mi.OldState != mi.State)
{
- const CPluginInfo &plugin = _extDatabase.Plugins[extInfo.PluginsPairs[0].Index];
- iconPath = GetIconPath(plugin.FilePath, plugin.ClassID, extInfo.Ext, iconIndex);
+ LONG res2 = 0;
+ if (mi.State == kExtState_7Zip)
+ {
+ UString title = extInfo.Ext + UString(L" Archive");
+ const CPluginToIcon &plug = extInfo.Plugins[0];
+ res2 = NRegistryAssoc::AddShellExtensionInfo(key, GetSystemString(extInfo.Ext),
+ title, command, plug.IconPath, plug.IconIndex);
+ }
+ else if (mi.State == kExtState_Clear)
+ res2 = NRegistryAssoc::DeleteShellExtensionInfo(key, GetSystemString(extInfo.Ext));
+ if (res == 0)
+ res = res2;
+ if (res2 == 0)
+ mi.OldState = mi.State;
+ mi.State = mi.OldState;
+ RefreshListItem(g, listIndex);
}
- NRegistryAssociations::AddShellExtensionInfo(GetSystemString(extInfo.Ext),
- title, command, iconPath, iconIndex, NULL, 0);
}
- else
- NRegistryAssociations::DeleteShellExtensionInfo(GetSystemString(extInfo.Ext));
}
- /*
- if (IsButtonCheckedBool(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU))
- NRegistryAssociations::AddContextMenuHandler();
- else
- NRegistryAssociations::DeleteContextMenuHandler();
- */
#ifndef UNDER_CE
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
WasChanged = true;
#endif
+ if (res != 0)
+ MessageBoxW(*this, NWindows::NError::MyFormatMessageW(res), L"7-Zip", MB_ICONERROR);
return PSNRET_NOERROR;
}
@@ -175,228 +269,119 @@ void CSystemPage::OnNotifyHelp()
ShowHelpWindow(NULL, kSystemTopic);
}
-void CSystemPage::SelectAll()
-{
- int count = _listViewExt.GetItemCount();
- for (int i = 0; i < count; i++)
- _listViewExt.SetCheckState(i, true);
- UpdateDatabase();
-}
-
bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND)
{
- switch(buttonID)
+ switch (buttonID)
{
+ /*
case IDC_SYSTEM_SELECT_ALL:
- {
- SelectAll();
- Changed();
+ _listView.SelectAll();
+ return true;
+ */
+ case IDC_SYSTEM_BUTTON_CURRENT:
+ case IDC_SYSTEM_BUTTON_ALL:
+ ChangeState(buttonID == IDC_SYSTEM_BUTTON_CURRENT ? 0 : 1);
return true;
- }
}
return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
}
bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
{
- if (lParam->hwndFrom == HWND(_listViewExt))
+ if (lParam->hwndFrom == HWND(_listView))
{
- switch(lParam->code)
+ switch (lParam->code)
{
- case (LVN_ITEMCHANGED):
- return OnItemChanged((const NMLISTVIEW *)lParam);
- case NM_RCLICK:
- case NM_DBLCLK:
- case LVN_KEYDOWN:
- case NM_CLICK:
- case LVN_BEGINRDRAG:
- PostMessage(kRefreshpluginsListMessage, 0);
- PostMessage(kUpdateDatabase, 0);
- break;
- }
- }
- else if (lParam->hwndFrom == HWND(_listViewPlugins))
- {
- switch(lParam->code)
- {
- case NM_RCLICK:
- case NM_DBLCLK:
- // case LVN_KEYDOWN:
+ case NM_RETURN:
+ {
+ ChangeState(0);
+ return true;
+ }
+ break;
case NM_CLICK:
- case LVN_BEGINRDRAG:
- PostMessage(kUpdateDatabase, 0);
- break;
-
- case (LVN_ITEMCHANGED):
{
- OnItemChanged((const NMLISTVIEW *)lParam);
- PostMessage(kUpdateDatabase, 0);
+ #ifdef UNDER_CE
+ NMLISTVIEW *item = (NMLISTVIEW *)lParam;
+ #else
+ NMITEMACTIVATE *item = (NMITEMACTIVATE *)lParam;
+ if (item->uKeyFlags == 0)
+ #endif
+ {
+ int realIndex = GetRealIndex(item->iItem);
+ if (realIndex >= 0)
+ {
+ if (item->iSubItem >= 1 && item->iSubItem <= 2)
+ {
+ CIntVector indices;
+ indices.Add(item->iItem);
+ ChangeState(item->iSubItem < 2 ? 0 : 1, indices);
+ }
+ }
+ }
break;
}
case LVN_KEYDOWN:
{
- OnPluginsKeyDown((LPNMLVKEYDOWN)lParam);
- PostMessage(kUpdateDatabase, 0);
+ if (OnListKeyDown(LPNMLVKEYDOWN(lParam)))
+ return true;
break;
}
+ /*
+ case NM_RCLICK:
+ case NM_DBLCLK:
+ case LVN_BEGINRDRAG:
+ // PostMessage(kRefreshpluginsListMessage, 0);
+ PostMessage(kUpdateDatabase, 0);
+ break;
+ */
}
}
return CPropertyPage::OnNotify(controlID, lParam);
}
-bool CSystemPage::OnPluginsKeyDown(LPNMLVKEYDOWN keyDownInfo)
+void CSystemPage::ChangeState(int group)
{
- bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
- // bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
- switch(keyDownInfo->wVKey)
- {
- case VK_UP:
- {
- if (alt)
- MovePlugin(true);
- return true;
- }
- case VK_DOWN:
- {
- if (alt)
- MovePlugin(false);
- return true;
- }
- }
- return false;
+ CIntVector indices;
+ int itemIndex = -1;
+ while ((itemIndex = _listView.GetNextSelectedItem(itemIndex)) != -1)
+ indices.Add(itemIndex);
+ if (indices.IsEmpty())
+ for (int i = 0; i < _items.Size(); i++)
+ indices.Add(i);
+ ChangeState(group, indices);
}
-void CSystemPage::MovePlugin(bool upDirection)
+bool CSystemPage::OnListKeyDown(LPNMLVKEYDOWN keyDownInfo)
{
- int selectedPlugin = _listViewPlugins.GetSelectionMark();
- if (selectedPlugin < 0)
- return;
- int newIndex = selectedPlugin + (upDirection ? -1: 1);
- if (newIndex < 0 || newIndex >= _listViewPlugins.GetItemCount())
- return;
- int selectedExtIndex = GetSelectedExtIndex();
- if (selectedExtIndex < 0)
- return;
- CExtInfoBig &extInfo = _extDatabase.ExtBigItems[selectedExtIndex];
- CPluginEnabledPair pluginPairTemp = extInfo.PluginsPairs[newIndex];
- extInfo.PluginsPairs[newIndex] = extInfo.PluginsPairs[selectedPlugin];
- extInfo.PluginsPairs[selectedPlugin] = pluginPairTemp;
-
- SetMainPluginText(_listViewExt.GetSelectionMark(), selectedExtIndex);
- RefreshPluginsList(newIndex);
-
- Changed();
-}
-
-bool CSystemPage::OnItemChanged(const NMLISTVIEW *info)
-{
- if (_initMode)
- return true;
- if ((info->uChanged & LVIF_STATE) != 0)
- {
- UINT oldState = info->uOldState & LVIS_STATEIMAGEMASK;
- UINT newState = info->uNewState & LVIS_STATEIMAGEMASK;
- if (oldState != newState)
- Changed();
- }
- // PostMessage(kRefreshpluginsListMessage, 0);
- // RefreshPluginsList();
- return true;
-}
-
-bool CSystemPage::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch(message)
- {
- case kRefreshpluginsListMessage:
- RefreshPluginsList(-1);
- return true;
- case kUpdateDatabase:
- UpdateDatabase();
- return true;
- }
- return CPropertyPage::OnMessage(message, wParam, lParam);
-}
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
-void CSystemPage::UpdateDatabase()
-{
- int i;
- for (i = 0; i < _listViewExt.GetItemCount(); i++)
- {
- LPARAM param;
- if (!_listViewExt.GetItemParam(i, param))
- return;
- CExtInfoBig &extInfo = _extDatabase.ExtBigItems[(int)param];
- extInfo.Associated = _listViewExt.GetCheckState(i);
- }
+ if (alt)
+ return false;
- int selectedExtIndex = GetSelectedExtIndex();
- if (selectedExtIndex < 0)
- return;
-
- CExtInfoBig &extInfo = _extDatabase.ExtBigItems[selectedExtIndex];
- for (i = 0; i < _listViewPlugins.GetItemCount(); i++)
+ if ((ctrl && keyDownInfo->wVKey == 'A') ||
+ (!ctrl && keyDownInfo->wVKey == VK_MULTIPLY))
{
- extInfo.PluginsPairs[i].Enabled = _listViewPlugins.GetCheckState(i);
+ _listView.SelectAll();
+ return true;
}
-}
-
-
-
-int CSystemPage::GetSelectedExtIndex()
-{
- int selectedIndex = _listViewExt.GetSelectionMark();
- if (selectedIndex < 0)
- return -1;
- LPARAM param;
- if (!_listViewExt.GetItemParam(selectedIndex, param))
- return -1;
- return (int)param;
-}
-
-
-void CSystemPage::RefreshPluginsList(int selectIndex)
-{
- _listViewPlugins.DeleteAllItems();
- int selectedExtIndex = GetSelectedExtIndex();
- if (selectedExtIndex < 0)
- return;
- const CExtInfoBig &extInfo = _extDatabase.ExtBigItems[selectedExtIndex];
- _initMode = true;
- for (int i = 0; i < extInfo.PluginsPairs.Size(); i++)
+ switch (keyDownInfo->wVKey)
{
- CPluginEnabledPair pluginPair = extInfo.PluginsPairs[i];
- int itemIndex = _listViewPlugins.InsertItem(i, _extDatabase.Plugins[pluginPair.Index].Name);
- _listViewPlugins.SetCheckState(itemIndex, pluginPair.Enabled);
- }
- if (_listViewPlugins.GetItemCount() > 0)
- {
- if (selectIndex < 0)
- selectIndex = 0;
- _listViewPlugins.SetItemState_FocusedSelected(selectIndex);
+ case VK_SPACE:
+ case VK_ADD:
+ case VK_SUBTRACT:
+ case VK_SEPARATOR:
+ case VK_DIVIDE:
+ #ifndef UNDER_CE
+ case VK_OEM_PLUS:
+ case VK_OEM_MINUS:
+ #endif
+ if (!ctrl)
+ {
+ ChangeState(keyDownInfo->wVKey == VK_SPACE ? 0 : 1);
+ return true;
+ }
}
- _initMode = false;
+ return false;
}
-
-
-
-/*
-static BYTE kZipShellNewData[] =
- { 0x50-1, 0x4B, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0 };
-
-static BYTE kRarShellNewData[] =
- { 0x52-1, 0x61, 0x72, 0x21, 0x1A, 7, 0, 0xCF, 0x90, 0x73, 0, 0, 0x0D, 0, 0, 0, 0, 0, 0, 0};
-
-class CSignatureMaker
-{
-public:
- CSignatureMaker()
- {
- kZipShellNewData[0]++;
- kRarShellNewData[0]++;
- };
-};
-
-static CSignatureMaker g_SignatureMaker;
-*/
diff --git a/CPP/7zip/UI/FileManager/SystemPage.h b/CPP/7zip/UI/FileManager/SystemPage.h
index 967731fd..a4b4ab92 100755
--- a/CPP/7zip/UI/FileManager/SystemPage.h
+++ b/CPP/7zip/UI/FileManager/SystemPage.h
@@ -3,39 +3,117 @@
#ifndef __SYSTEM_PAGE_H
#define __SYSTEM_PAGE_H
-#include "Windows/Control/PropertyPage.h"
+#include "Windows/Control/ImageList.h"
#include "Windows/Control/ListView.h"
+#include "Windows/Control/PropertyPage.h"
#include "FilePlugins.h"
+#include "RegistryAssociations.h"
+
+enum EExtState
+{
+ kExtState_Clear = 0,
+ kExtState_Other,
+ kExtState_7Zip
+};
+
+struct CModifiedExtInfo: public NRegistryAssoc::CShellExtInfo
+{
+ int OldState;
+ int State;
+ int ImageIndex;
+ bool Other;
+ bool Other7Zip;
+
+ CModifiedExtInfo(): ImageIndex(-1) {}
+
+ CSysString GetString() const;
+
+ void SetState(const UString &iconPath)
+ {
+ State = kExtState_Clear;
+ Other = false;
+ Other7Zip = false;
+ if (!ProgramKey.IsEmpty())
+ {
+ State = kExtState_Other;
+ Other = true;
+ if (IsIt7Zip())
+ {
+ Other7Zip = (iconPath.CompareNoCase(IconPath) != 0);
+ if (!Other7Zip)
+ {
+ State = kExtState_7Zip;
+ Other = false;
+ }
+ }
+ }
+ OldState = State;
+ };
+};
+
+struct CAssoc
+{
+ CModifiedExtInfo Pair[2];
+ int SevenZipImageIndex;
+
+ int GetIconIndex() const
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ const CModifiedExtInfo &pair = Pair[i];
+ if (pair.State == kExtState_Clear)
+ continue;
+ if (pair.State == kExtState_7Zip)
+ return SevenZipImageIndex;
+ if (pair.ImageIndex != -1)
+ return pair.ImageIndex;
+ }
+ return -1;
+ }
+};
+
+#ifdef UNDER_CE
+ #define NUM_EXT_GROUPS 1
+#else
+ #define NUM_EXT_GROUPS 2
+#endif
class CSystemPage: public NWindows::NControl::CPropertyPage
{
- bool _initMode;
- CExtDatabase _extDatabase;
+ CExtDatabase _extDB;
+ CObjectVector<CAssoc> _items;
- NWindows::NControl::CListView _listViewExt;
- NWindows::NControl::CListView _listViewPlugins;
+ int _numIcons;
+ NWindows::NControl::CImageList _imageList;
+ NWindows::NControl::CListView _listView;
- void SetMainPluginText(int itemIndex, int indexInDatabase);
+ const HKEY GetHKey(int group) const
+ {
+ #if NUM_EXT_GROUPS == 1
+ return HKEY_CLASSES_ROOT;
+ #else
+ return group == 0 ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
+ #endif
+ }
- int GetSelectedExtIndex();
- void RefreshPluginsList(int selectIndex);
- void MovePlugin(bool upDirection);
- void UpdateDatabase();
- void SelectAll();
+ int AddIcon(const UString &path, int iconIndex);
+ int GetRealIndex(int listIndex) const { return listIndex; }
+ void RefreshListItem(int group, int listIndex);
+ void ChangeState(int group, const CIntVector &indices);
+ void ChangeState(int group);
+ bool OnListKeyDown(LPNMLVKEYDOWN keyDownInfo);
+
public:
bool WasChanged;
CSystemPage(): WasChanged(false) {}
- virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+
virtual bool OnInit();
virtual void OnNotifyHelp();
virtual bool OnNotify(UINT controlID, LPNMHDR lParam);
- virtual bool OnItemChanged(const NMLISTVIEW *info);
-
virtual LONG OnApply();
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
- bool OnPluginsKeyDown(LPNMLVKEYDOWN keyDownInfo);
};
#endif
diff --git a/CPP/7zip/UI/FileManager/SystemPage.rc b/CPP/7zip/UI/FileManager/SystemPage.rc
index 52e60d19..49581c9b 100755
--- a/CPP/7zip/UI/FileManager/SystemPage.rc
+++ b/CPP/7zip/UI/FileManager/SystemPage.rc
@@ -2,16 +2,18 @@
#include "../../GuiCommon.rc"
#define xc 200
-#define yc 200
+#define yc 250
IDD_SYSTEM MY_PAGE
CAPTION "System"
BEGIN
LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8
+ PUSHBUTTON "+", IDC_SYSTEM_BUTTON_CURRENT, 72, m + 12, 40, bys
+ PUSHBUTTON "+", IDC_SYSTEM_BUTTON_ALL, 140, m + 12, 40, bys
CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32",
- LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
- m, m + 12, xc, (yc - m - 12 - 1 - bys)
- PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, (ys - m - bys), 90, bys
+ LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
+ m, m + 32, xc, (yc - m - 32 - 1)
+; PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, m + 12, 60, bys
END
#ifdef UNDER_CE
@@ -28,10 +30,11 @@ IDD_SYSTEM_2 MY_PAGE
CAPTION "System"
BEGIN
LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8
+ PUSHBUTTON "+", IDC_SYSTEM_BUTTON_CURRENT, 60, m + 12, 40, bys
CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32",
- LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
- m, m + 12, xc, (yc - m - 12 - 1 - bys - 8)
- PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, (ys - m - bys - 8), 90, bys
+ LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
+ m, m + 32, xc, (yc - m - 32 - 1 - 8)
+; PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, m + 12, 60, bys
END
#endif
diff --git a/CPP/7zip/UI/FileManager/SystemPageRes.h b/CPP/7zip/UI/FileManager/SystemPageRes.h
index b60b4533..133996e7 100755
--- a/CPP/7zip/UI/FileManager/SystemPageRes.h
+++ b/CPP/7zip/UI/FileManager/SystemPageRes.h
@@ -4,5 +4,7 @@
// #define IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU 1010
#define IDC_SYSTEM_STATIC_ASSOCIATE 1020
#define IDC_SYSTEM_LIST_ASSOCIATE 1021
-#define IDC_SYSTEM_LIST_PLUGINS 1022
-#define IDC_SYSTEM_SELECT_ALL 1023
+// #define IDC_SYSTEM_LIST_PLUGINS 1022
+// #define IDC_SYSTEM_SELECT_ALL 1023
+#define IDC_SYSTEM_BUTTON_CURRENT 1024
+#define IDC_SYSTEM_BUTTON_ALL 1025
diff --git a/CPP/7zip/UI/FileManager/resource.h b/CPP/7zip/UI/FileManager/resource.h
index 13c8e0e7..cdb77edf 100755
--- a/CPP/7zip/UI/FileManager/resource.h
+++ b/CPP/7zip/UI/FileManager/resource.h
@@ -52,6 +52,7 @@
#define IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 463
#define IDM_OPTIONS 510
#define IDM_BENCHMARK 511
+#define IDM_BENCHMARK2 512
#define IDM_HELP_CONTENTS 610
#define IDM_ABOUT 620
#define IDS_BOOKMARK 720
diff --git a/CPP/7zip/UI/FileManager/resource.rc b/CPP/7zip/UI/FileManager/resource.rc
index 833cb374..2952ce5a 100755
--- a/CPP/7zip/UI/FileManager/resource.rc
+++ b/CPP/7zip/UI/FileManager/resource.rc
@@ -95,6 +95,9 @@ BEGIN
BEGIN
MENUITEM "&Options...", IDM_OPTIONS
MENUITEM "&Benchmark", IDM_BENCHMARK
+ #ifdef UNDER_CE
+ MENUITEM "&Benchmark2", IDM_BENCHMARK2
+ #endif
#ifndef UNDER_CE
END
POPUP "&Help"
diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
index e4d6c019..8ca87f8f 100755
--- a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
+++ b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
@@ -4,6 +4,7 @@
#include "Common/IntToString.h"
#include "Common/MyException.h"
+#include "Common/StringConvert.h"
#include "Windows/Error.h"
#include "Windows/System.h"
@@ -85,6 +86,25 @@ bool CBenchmarkDialog::OnInit()
Sync.Init();
+ if (TotalMode)
+ {
+ _consoleEdit.Attach(GetItem(IDC_BENCHMARK2_EDIT));
+ LOGFONT f;
+ memset(&f, 0, sizeof(f));
+ f.lfHeight = 14;
+ f.lfWidth = 0;
+ f.lfWeight = FW_DONTCARE;
+ f.lfCharSet = DEFAULT_CHARSET;
+ f.lfOutPrecision = OUT_DEFAULT_PRECIS;
+ f.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ f.lfQuality = DEFAULT_QUALITY;
+
+ f.lfPitchAndFamily = FIXED_PITCH;
+ MyStringCopy(f.lfFaceName, TEXT(""));
+ _font.Create(&f);
+ if (_font._font)
+ _consoleEdit.SendMessage(WM_SETFONT, (WPARAM)_font._font, TRUE);
+ }
UInt32 numCPUs = NSystem::GetNumberOfProcessors();
if (numCPUs < 1)
@@ -101,8 +121,8 @@ bool CBenchmarkDialog::OnInit()
int cur = 0;
for (UInt32 num = 1; num <= numCPUs * 2;)
{
- TCHAR s[40];
- ConvertUInt64ToString(num, s);
+ TCHAR s[16];
+ ConvertUInt32ToString(num, s);
int index = (int)m_NumThreads.AddString(s);
m_NumThreads.SetItemData(index, num);
if (num <= Sync.NumThreads)
@@ -143,8 +163,8 @@ bool CBenchmarkDialog::OnInit()
UInt32 dictionary = (1 << i) + (j << (i - 1));
if (dictionary > kMaxDicSize)
continue;
- TCHAR s[40];
- ConvertUInt64ToString((dictionary >> 20), s);
+ TCHAR s[16];
+ ConvertUInt32ToString((dictionary >> 20), s);
lstrcat(s, kMB);
int index = (int)m_Dictionary.AddString(s);
m_Dictionary.SetItemData(index, dictionary);
@@ -158,10 +178,47 @@ bool CBenchmarkDialog::OnInit()
Sync._startEvent.Set();
_timer = SetTimer(kTimerID, kTimerElapse);
- NormalizePosition();
+ if (TotalMode)
+ NormalizeSize(true);
+ else
+ NormalizePosition();
return CModalDialog::OnInit();
}
+bool CBenchmarkDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
+{
+ if (!TotalMode)
+ return false;
+ int mx, my;
+ GetMargins(8, mx, my);
+ int bx1, bx2, by;
+ GetItemSizes(IDCANCEL, bx1, by);
+ GetItemSizes(IDHELP, bx2, by);
+ int y = ySize - my - by;
+ int x = xSize - mx - bx1;
+
+ InvalidateRect(NULL);
+
+ MoveItem(IDCANCEL, x, y, bx1, by);
+ MoveItem(IDHELP, x - mx - bx2, y, bx2, by);
+ if (_consoleEdit)
+ {
+ int yPos = ySize - my - by;
+ RECT rect;
+ GetClientRectOfItem(IDC_BENCHMARK2_EDIT, rect);
+ int y = rect.top;
+ int ySize2 = yPos - my - y;
+ const int kMinYSize = 20;
+ int xx = xSize - mx * 2;
+ if (ySize2 < kMinYSize)
+ {
+ ySize2 = kMinYSize;
+ }
+ _consoleEdit.Move(mx, y, xx, ySize2);
+ }
+ return false;
+}
+
UInt32 CBenchmarkDialog::GetNumberOfThreads()
{
return (UInt32)m_NumThreads.GetItemData(m_NumThreads.GetCurSel());
@@ -209,7 +266,7 @@ void CBenchmarkDialog::OnChangeSettings()
EnableItem(IDC_BUTTON_STOP, true);
UInt32 dictionary = OnChangeDictionary();
TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 };
- ConvertUInt64ToString(NSystem::GetNumberOfProcessors(), s + 2);
+ ConvertUInt32ToString(NSystem::GetNumberOfProcessors(), s + 2);
SetItemText(IDC_BENCHMARK_HARDWARE_THREADS, s);
for (int i = 0; i < sizeof(g_IDs) / sizeof(g_IDs[0]); i++)
SetItemText(g_IDs[i], kProcessingString);
@@ -305,15 +362,32 @@ void CBenchmarkDialog::PrintResults(
rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, size * info.NumIterations);
PrintRating(rating, ratingID);
- PrintRating(GetRatingPerUsage(info, rating), rpuID);
- PrintUsage(GetUsage(info), usageID);
+ PrintRating(info.GetRatingPerUsage(rating), rpuID);
+ PrintUsage(info.GetUsage(), usageID);
}
bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
{
- PrintTime();
+ bool printTime = true;
+ if (TotalMode)
+ {
+ if (Sync.WasStopped())
+ printTime = false;
+ }
+ if (printTime)
+ PrintTime();
NWindows::NSynchronization::CCriticalSectionLock lock(Sync.CS);
+ if (TotalMode)
+ {
+ if (Sync.TextWasChanged)
+ {
+ _consoleEdit.SetText(GetSystemString(Sync.Text));
+ Sync.TextWasChanged = false;
+ }
+ return true;
+ }
+
TCHAR s[40];
ConvertUInt64ToString((Sync.ProcessedSize >> 20), s);
lstrcat(s, kMB);
@@ -377,9 +451,11 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
Sync.DecompressingInfo.PackSize, 1);
PrintRating((comprRating + decomprRating) / 2, IDC_BENCHMARK_TOTAL_RATING_VALUE);
PrintRating((
- GetRatingPerUsage(Sync.CompressingInfo, comprRating) +
- GetRatingPerUsage(Sync.DecompressingInfo, decomprRating)) / 2, IDC_BENCHMARK_TOTAL_RPU_VALUE);
- PrintUsage((GetUsage(Sync.CompressingInfo) + GetUsage(Sync.DecompressingInfo)) / 2, IDC_BENCHMARK_TOTAL_USAGE_VALUE);
+ Sync.CompressingInfo.GetRatingPerUsage(comprRating) +
+ Sync.DecompressingInfo.GetRatingPerUsage(decomprRating)) / 2, IDC_BENCHMARK_TOTAL_RPU_VALUE);
+ PrintUsage(
+ (Sync.CompressingInfo.GetUsage() +
+ Sync.DecompressingInfo.GetUsage()) / 2, IDC_BENCHMARK_TOTAL_USAGE_VALUE);
}
}
return true;
@@ -414,7 +490,6 @@ bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
struct CThreadBenchmark
{
CBenchmarkDialog *BenchmarkDialog;
- UInt64 _startTime;
DECL_EXTERNAL_CODECS_VARS
// UInt32 dictionarySize;
// UInt32 numThreads;
@@ -478,6 +553,35 @@ HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
return S_OK;
}
+struct CBenchCallback2: public IBenchPrintCallback
+{
+ CProgressSyncInfo *Sync;
+
+ void Print(const char *s);
+ void NewLine();
+ HRESULT CheckBreak();
+};
+
+void CBenchCallback2::Print(const char *s)
+{
+ NSynchronization::CCriticalSectionLock lock(Sync->CS);
+ Sync->Text += s;
+ Sync->TextWasChanged = true;
+}
+
+void CBenchCallback2::NewLine()
+{
+ Print("\xD\n");
+}
+
+HRESULT CBenchCallback2::CheckBreak()
+{
+ if (Sync->Changed || Sync->Paused || Sync->Stopped)
+ return E_ABORT;
+ return S_OK;
+}
+
+
HRESULT CThreadBenchmark::Process()
{
CProgressSyncInfo &sync = BenchmarkDialog->Sync;
@@ -508,12 +612,44 @@ HRESULT CThreadBenchmark::Process()
CBenchCallback callback;
callback.dictionarySize = dictionarySize;
callback.Sync = &sync;
+ CBenchCallback2 callback2;
+ callback2.Sync = &sync;
HRESULT result;
try
{
- result = LzmaBench(
- EXTERNAL_CODECS_VARS
- numThreads, dictionarySize, &callback);
+ CObjectVector<CProperty> props;
+ if (BenchmarkDialog->TotalMode)
+ {
+ props = BenchmarkDialog->Props;
+ }
+ else
+ {
+ {
+ CProperty prop;
+ prop.Name = L"mt";
+ wchar_t s[16];
+ ConvertUInt32ToString(numThreads, s);
+ prop.Value = s;
+ props.Add(prop);
+ }
+ {
+ CProperty prop;
+ prop.Name = L"d";
+ wchar_t s[16];
+ ConvertUInt32ToString(dictionarySize, s);
+ prop.Name += s;
+ prop.Name += 'b';
+ props.Add(prop);
+ }
+ }
+ result = Bench(EXTERNAL_CODECS_VARS
+ BenchmarkDialog->TotalMode ? &callback2 : NULL,
+ BenchmarkDialog->TotalMode ? NULL : &callback,
+ props, 1, false);
+ if (BenchmarkDialog->TotalMode)
+ {
+ sync.Stop();
+ }
}
catch(...)
{
@@ -561,7 +697,7 @@ HRESULT CThreadBenchmark::Process()
HRESULT Benchmark(
DECL_EXTERNAL_CODECS_LOC_VARS
- UInt32 numThreads, UInt32 dictionarySize, HWND hwndParent)
+ const CObjectVector<CProperty> props, HWND hwndParent)
{
CThreadBenchmark benchmarker;
#ifdef EXTERNAL_CODECS
@@ -569,13 +705,21 @@ HRESULT Benchmark(
benchmarker._externalCodecs = *externalCodecs;
#endif
- CBenchmarkDialog benchmarkDialog;
- benchmarkDialog.Sync.DictionarySize = dictionarySize;
- benchmarkDialog.Sync.NumThreads = numThreads;
+ CBenchmarkDialog bd;
+ bd.Props = props;
+ bd.TotalMode = false;
+ for (int i = 0; i < props.Size(); i++)
+ {
+ const CProperty &prop = props[i];
+ if (prop.Name.CompareNoCase(L"m") == 0 && prop.Value == L"*")
+ bd.TotalMode = true;
+ }
+ bd.Sync.DictionarySize = (UInt32)-1;
+ bd.Sync.NumThreads = (UInt32)-1;
+ benchmarker.BenchmarkDialog = &bd;
- benchmarker.BenchmarkDialog = &benchmarkDialog;
NWindows::CThread thread;
RINOK(thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker));
- benchmarkDialog.Create(hwndParent);
+ bd.Create(hwndParent);
return thread.Wait();
}
diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.h b/CPP/7zip/UI/GUI/BenchmarkDialog.h
index 2b6216fd..b3ab9dcb 100755
--- a/CPP/7zip/UI/GUI/BenchmarkDialog.h
+++ b/CPP/7zip/UI/GUI/BenchmarkDialog.h
@@ -5,6 +5,7 @@
#include "Windows/Synchronization.h"
#include "Windows/Control/ComboBox.h"
+#include "Windows/Control/Edit.h"
#include "../Common/Bench.h"
@@ -37,6 +38,9 @@ public:
CBenchInfo2 DecompressingInfoTemp;
CBenchInfo2 DecompressingInfo;
+ AString Text;
+ bool TextWasChanged;
+
CProgressSyncInfo()
{
if (_startEvent.Create() != S_OK)
@@ -56,6 +60,9 @@ public:
NumPasses = 0;
// NumErrors = 0;
+
+ Text.Empty();
+ TextWasChanged = true;
}
void Stop()
{
@@ -85,14 +92,33 @@ public:
void WaitCreating() { _startEvent.Lock(); }
};
+struct CMyFont
+{
+ HFONT _font;
+ CMyFont(): _font(NULL) {}
+ ~CMyFont()
+ {
+ if (_font)
+ DeleteObject(_font);
+ }
+ void Create(const LOGFONT *lplf)
+ {
+ _font = CreateFontIndirect(lplf);
+ }
+};
+
+
class CBenchmarkDialog:
public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox m_Dictionary;
NWindows::NControl::CComboBox m_NumThreads;
+ NWindows::NControl::CEdit _consoleEdit;
UINT_PTR _timer;
UINT32 _startTime;
+ CMyFont _font;
+ bool OnSize(WPARAM /* wParam */, int xSize, int ySize);
bool OnTimer(WPARAM timerID, LPARAM callback);
virtual bool OnInit();
void OnRestartButton();
@@ -115,12 +141,14 @@ class CBenchmarkDialog:
void OnChangeSettings();
public:
CProgressSyncInfo Sync;
+ bool TotalMode;
+ CObjectVector<CProperty> Props;
- CBenchmarkDialog(): _timer(0) {}
+ CBenchmarkDialog(): _timer(0), TotalMode(false) {}
INT_PTR Create(HWND wndParent = 0)
{
BIG_DIALOG_SIZE(332, 228);
- return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_BENCHMARK), wndParent);
+ return CModalDialog::Create(TotalMode ? IDD_DIALOG_BENCHMARK_TOTAL : SIZED_DIALOG(IDD_DIALOG_BENCHMARK), wndParent);
}
void MessageBoxError(LPCWSTR message)
{
@@ -130,6 +158,6 @@ public:
HRESULT Benchmark(
DECL_EXTERNAL_CODECS_LOC_VARS
- UInt32 numThreads, UInt32 dictionarySize, HWND hwndParent = NULL);
+ const CObjectVector<CProperty> props, HWND hwndParent = NULL);
#endif
diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.rc b/CPP/7zip/UI/GUI/BenchmarkDialog.rc
index b77bac5f..6b17a12a 100755
--- a/CPP/7zip/UI/GUI/BenchmarkDialog.rc
+++ b/CPP/7zip/UI/GUI/BenchmarkDialog.rc
@@ -41,6 +41,12 @@
#define g3xs 36
#define g3x (m + g2xs)
+#undef GROUP_Y_SIZE
+#ifdef UNDER_CE
+#define GROUP_Y_SIZE 8
+#else
+#define GROUP_Y_SIZE 40
+#endif
IDD_DIALOG_BENCHMARK DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
CAPTION "Benchmark"
@@ -66,7 +72,7 @@ BEGIN
RTEXT "Rating / Usage", IDC_BENCHMARK_RPU_LABEL, xRpu, 54, sRpu, 8
RTEXT "Rating", IDC_BENCHMARK_RATING_LABEL, xRating, 54, sRating, 8
- GROUPBOX "Compressing", IDC_BENCHMARK_COMPRESSING, m, 64, xc, 40
+ GROUPBOX "Compressing", IDC_BENCHMARK_COMPRESSING, m, 64, xc, GROUP_Y_SIZE
LTEXT "Current", IDC_BENCHMARK_CURRENT, g4x, 76, sLabel, 8
RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE, xUsage, 76, sUsage, 8
@@ -80,7 +86,7 @@ BEGIN
RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU2, xRpu, 89, sRpu, 8
RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING2, xRating, 89, sRating, 8
- GROUPBOX "Decompressing", IDC_BENCHMARK_DECOMPRESSING, m, 111, xc, 40
+ GROUPBOX "Decompressing", IDC_BENCHMARK_DECOMPRESSING, m, 111, xc, GROUP_Y_SIZE
LTEXT "Current", IDC_BENCHMARK_CURRENT2, g4x, 123, sLabel, 8
RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE, xUsage, 123, sUsage, 8
@@ -94,7 +100,7 @@ BEGIN
RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU2, xRpu, 136, sRpu, 8
RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING2, xRating, 136, sRating, 8
- GROUPBOX "Total Rating", IDC_BENCHMARK_TOTAL_RATING, xTotalRating, 163, sTotalRating, 38
+ GROUPBOX "Total Rating", IDC_BENCHMARK_TOTAL_RATING, xTotalRating, 163, sTotalRating, GROUP_Y_SIZE
RTEXT "0", IDC_BENCHMARK_TOTAL_USAGE_VALUE, xUsage, 181, sUsage, 8
RTEXT "0", IDC_BENCHMARK_TOTAL_RPU_VALUE, xRpu, 181, sRpu, 8
RTEXT "0", IDC_BENCHMARK_TOTAL_RATING_VALUE, xRating, 181, sRating, 8
@@ -225,3 +231,18 @@ BEGIN
END
#endif
+
+#include "../../GuiCommon.rc"
+
+#define xc 360
+#define yc 260
+
+IDD_DIALOG_BENCHMARK_TOTAL MY_RESIZE_DIALOG
+CAPTION "Benchmark"
+{
+ LTEXT "Elapsed time:", IDC_BENCHMARK_ELAPSED, m, m, 58, 8
+ RTEXT "00:00:00", IDC_BENCHMARK_ELAPSED_VALUE, m + 58, m, 38, 8
+ EDITTEXT IDC_BENCHMARK2_EDIT, m, m + 14, xc, yc - bys - m - 14, ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL | WS_VSCROLL | WS_HSCROLL
+ PUSHBUTTON "&Help", IDHELP, bx2, by, bxs, bys
+ PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
+}
diff --git a/CPP/7zip/UI/GUI/BenchmarkDialogRes.h b/CPP/7zip/UI/GUI/BenchmarkDialogRes.h
index 2488bd1c..cf009df3 100755
--- a/CPP/7zip/UI/GUI/BenchmarkDialogRes.h
+++ b/CPP/7zip/UI/GUI/BenchmarkDialogRes.h
@@ -1,5 +1,7 @@
#define IDD_DIALOG_BENCHMARK 550
#define IDD_DIALOG_BENCHMARK_2 650
+#define IDD_DIALOG_BENCHMARK_TOTAL 750
+#define IDD_DIALOG_BENCHMARK_TOTAL_2 750
#define IDC_BUTTON_STOP 1001
#define IDC_BUTTON_RESTART 1002
#define IDC_BENCHMARK_DICTIONARY 1010
@@ -53,3 +55,5 @@
#define IDC_BENCHMARK_SIZE_VALUE 1063
#define IDC_BENCHMARK_PASSES 1066
#define IDC_BENCHMARK_PASSES_VALUE 1067
+
+#define IDC_BENCHMARK2_EDIT 1090
diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp
index da2b7924..2723f515 100755
--- a/CPP/7zip/UI/GUI/CompressDialog.cpp
+++ b/CPP/7zip/UI/GUI/CompressDialog.cpp
@@ -351,7 +351,10 @@ namespace NCompressDialog
#ifndef UNDER_CE
NDirectory::MySetCurrentDirectory(CurrentDirPrefix);
#endif
- return MyGetFullPathName(ArchiveName, result);
+ FString resultF;
+ bool res = MyGetFullPathName(us2fs(ArchiveName), resultF);
+ result = fs2us(resultF);
+ return res;
}
}
@@ -1236,6 +1239,7 @@ bool CCompressDialog::GetOrderMode()
switch (GetMethodID())
{
case kPPMd:
+ case kPPMdZip:
return true;
}
return false;
diff --git a/CPP/7zip/UI/GUI/CompressDialog.h b/CPP/7zip/UI/GUI/CompressDialog.h
index 86f7b173..7b0067fa 100755
--- a/CPP/7zip/UI/GUI/CompressDialog.h
+++ b/CPP/7zip/UI/GUI/CompressDialog.h
@@ -49,7 +49,7 @@ namespace NCompressDialog
UString ArchiveName; // in: Relative for ; out: abs
- UString CurrentDirPrefix;
+ FString CurrentDirPrefix;
bool KeepName;
bool GetFullPathName(UString &result) const;
diff --git a/CPP/7zip/UI/GUI/CompressDialog.rc b/CPP/7zip/UI/GUI/CompressDialog.rc
index 5f622c76..5a71b043 100755
--- a/CPP/7zip/UI/GUI/CompressDialog.rc
+++ b/CPP/7zip/UI/GUI/CompressDialog.rc
@@ -36,6 +36,16 @@
#define yOpt 72
#define yPsw 128
+#undef GROUP_Y_SIZE
+#undef GROUP_Y_SIZE_ENCRYPT
+#ifdef UNDER_CE
+#define GROUP_Y_SIZE 8
+#define GROUP_Y_SIZE_ENCRYPT 8
+#else
+#define GROUP_Y_SIZE 48
+#define GROUP_Y_SIZE_ENCRYPT 128
+#endif
+
IDD_DIALOG_COMPRESS MY_DIALOG
CAPTION "Add to Archive"
BEGIN
@@ -82,13 +92,13 @@ BEGIN
LTEXT "&Update mode:",IDC_STATIC_COMPRESS_UPDATE_MODE, g4x, 39, g4xs, 8
COMBOBOX IDC_COMPRESS_COMBO_UPDATE_MODE, g4x, 51, g4xs, 80, MY_COMBO
- GROUPBOX "Options",IDC_STATIC_COMPRESS_OPTIONS, g4x, yOpt, g4xs, 48
+ GROUPBOX "Options",IDC_STATIC_COMPRESS_OPTIONS, g4x, yOpt, g4xs, GROUP_Y_SIZE
CONTROL "Create SF&X archive",IDC_COMPRESS_SFX, MY_CHECKBOX,
g4x2, yOpt + 14, g4xs2, 10
CONTROL "Compress shared files",IDC_COMPRESS_SHARED, MY_CHECKBOX,
g4x2, yOpt + 30, g4xs2, 10
- GROUPBOX "Encryption",IDC_COMPRESS_ENCRYPTION, g4x, yPsw, g4xs, 127
+ GROUPBOX "Encryption", IDC_COMPRESS_ENCRYPTION, g4x, yPsw, g4xs, GROUP_Y_SIZE_ENCRYPT
LTEXT "Enter password:",IDC_STATIC_COMPRESS_PASSWORD1, g4x2, yPsw + 14, g4xs2, 8
EDITTEXT IDC_COMPRESS_EDIT_PASSWORD1, g4x2, yPsw + 26, g4xs2, 14, ES_PASSWORD | ES_AUTOHSCROLL
diff --git a/CPP/7zip/UI/GUI/ExtractDialog.cpp b/CPP/7zip/UI/GUI/ExtractDialog.cpp
index 94556639..64ae445e 100755
--- a/CPP/7zip/UI/GUI/ExtractDialog.cpp
+++ b/CPP/7zip/UI/GUI/ExtractDialog.cpp
@@ -352,4 +352,3 @@ void CExtractDialog::OnHelp()
CModalDialog::OnHelp();
}
#endif
-
diff --git a/CPP/7zip/UI/GUI/ExtractDialog.rc b/CPP/7zip/UI/GUI/ExtractDialog.rc
index db8a5b24..ec4c20c2 100755
--- a/CPP/7zip/UI/GUI/ExtractDialog.rc
+++ b/CPP/7zip/UI/GUI/ExtractDialog.rc
@@ -18,6 +18,13 @@
#define g2xs (xc - g1xs - gSpace)
#define g2xs2 (g2xs - m - m)
+#undef GROUP_Y_SIZE
+#ifdef UNDER_CE
+#define GROUP_Y_SIZE 8
+#else
+#define GROUP_Y_SIZE 56
+#endif
+
IDD_DIALOG_EXTRACT MY_DIALOG
CAPTION "Extract"
BEGIN
@@ -31,11 +38,7 @@ BEGIN
LTEXT "Overwrite mode:", IDC_EXTRACT_OVERWRITE_MODE, m, m + 68, g1xs, 8
COMBOBOX IDC_EXTRACT_COMBO_OVERWRITE_MODE, m, m + 80, g1xs, 140, MY_COMBO
- #ifdef UNDER_CE
- LTEXT "Password", IDC_EXTRACT_PASSWORD, g2x, m + 36, g2xs, 8
- #else
- GROUPBOX "Password", IDC_EXTRACT_PASSWORD, g2x, m + 36, g2xs, 56
- #endif
+ GROUPBOX "Password", IDC_EXTRACT_PASSWORD, g2x, m + 36, g2xs, GROUP_Y_SIZE
EDITTEXT IDC_EXTRACT_EDIT_PASSWORD, g2x2, m + 50, g2xs2, 14, ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Show Password", IDC_EXTRACT_CHECK_SHOW_PASSWORD, MY_CHECKBOX, g2x2, m + 72, g2xs2, 10
diff --git a/CPP/7zip/UI/GUI/ExtractGUI.cpp b/CPP/7zip/UI/GUI/ExtractGUI.cpp
index a976833c..9d39bffd 100755
--- a/CPP/7zip/UI/GUI/ExtractGUI.cpp
+++ b/CPP/7zip/UI/GUI/ExtractGUI.cpp
@@ -8,6 +8,7 @@
#include "Windows/Error.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
#include "Windows/Thread.h"
#include "../FileManager/ExtractCallback.h"
@@ -128,7 +129,7 @@ HRESULT ExtractGUI(
if (!options.TestMode)
{
- UString outputDir = options.OutputDir;
+ FString outputDir = options.OutputDir;
#ifndef UNDER_CE
if (outputDir.IsEmpty())
NFile::NDirectory::MyGetCurrentDirectory(outputDir);
@@ -136,20 +137,22 @@ HRESULT ExtractGUI(
if (showDialog)
{
CExtractDialog dialog;
- if (!NFile::NDirectory::MyGetFullPathName(outputDir, dialog.DirectoryPath))
+ FString outputDirFull;
+ if (!NFile::NDirectory::MyGetFullPathName(outputDir, outputDirFull))
{
ShowErrorMessage(kIncorrectOutDir);
messageWasDisplayed = true;
return E_FAIL;
}
- NFile::NName::NormalizeDirPathPrefix(dialog.DirectoryPath);
+ NFile::NName::NormalizeDirPathPrefix(outputDirFull);
+ dialog.DirectoryPath = fs2us(outputDirFull);
// dialog.OverwriteMode = options.OverwriteMode;
// dialog.PathMode = options.PathMode;
if (dialog.Create(hwndParent) != IDOK)
return E_ABORT;
- outputDir = dialog.DirectoryPath;
+ outputDir = us2fs(dialog.DirectoryPath);
options.OverwriteMode = dialog.OverwriteMode;
options.PathMode = dialog.PathMode;
#ifndef _SFX
diff --git a/CPP/7zip/UI/GUI/GUI.cpp b/CPP/7zip/UI/GUI/GUI.cpp
index 377c7841..0a40b58e 100755
--- a/CPP/7zip/UI/GUI/GUI.cpp
+++ b/CPP/7zip/UI/GUI/GUI.cpp
@@ -121,7 +121,7 @@ static int Main2()
#ifdef EXTERNAL_CODECS
codecs, &externalCodecs,
#endif
- options.NumThreads, options.DictionarySize);
+ options.Properties);
if (res != S_OK)
throw CSystemException(res);
}
@@ -146,7 +146,7 @@ static int Main2()
eo.TestMode = options.Command.IsTestMode();
eo.CalcCrc = options.CalcCrc;
#if !defined(_7ZIP_ST) && !defined(_SFX)
- eo.Properties = options.ExtractProperties;
+ eo.Properties = options.Properties;
#endif
bool messageWasDisplayed = false;
@@ -280,4 +280,3 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
return NExitCode::kFatalError;
}
}
-
diff --git a/CPP/7zip/UI/GUI/GUI.dsp b/CPP/7zip/UI/GUI/GUI.dsp
index d54e944f..382f592e 100755
--- a/CPP/7zip/UI/GUI/GUI.dsp
+++ b/CPP/7zip/UI/GUI/GUI.dsp
@@ -585,6 +585,14 @@ SOURCE=..\..\Common\FilterCoder.h
# End Source File
# Begin Source File
+SOURCE=..\..\Common\MethodProps.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MethodProps.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Common\ProgressUtils.cpp
# End Source File
# Begin Source File
diff --git a/CPP/7zip/UI/GUI/UpdateGUI.cpp b/CPP/7zip/UI/GUI/UpdateGUI.cpp
index 7ee74fc8..ec56492f 100755
--- a/CPP/7zip/UI/GUI/UpdateGUI.cpp
+++ b/CPP/7zip/UI/GUI/UpdateGUI.cpp
@@ -10,6 +10,7 @@
#include "Windows/Error.h"
#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
#include "Windows/Thread.h"
#include "../Common/WorkDir.h"
@@ -17,7 +18,6 @@
#include "../Explorer/MyMessages.h"
#include "../FileManager/LangUtils.h"
-#include "../FileManager/ProgramLocation.h"
#include "../FileManager/StringUtils.h"
#include "../FileManager/resourceGui.h"
@@ -29,7 +29,7 @@
using namespace NWindows;
using namespace NFile;
-static const wchar_t *kDefaultSfxModule = L"7z.sfx";
+static CFSTR kDefaultSfxModule = FTEXT("7z.sfx");
static const wchar_t *kSFXExtension = L"exe";
extern void AddMessageToString(UString &dest, const UString &src);
@@ -52,8 +52,8 @@ HRESULT CThreadUpdating::ProcessVirt()
HRESULT res = UpdateArchive(codecs, *WildcardCensor, *Options,
ei, UpdateCallbackGUI, UpdateCallbackGUI);
ErrorMessage = ei.Message;
- ErrorPath1 = ei.FileName;
- ErrorPath2 = ei.FileName2;
+ SetErrorPath1(ei.FileName);
+ SetErrorPath2(ei.FileName2);
if (ei.SystemError != S_OK && ei.SystemError != E_FAIL && ei.SystemError != E_ABORT)
return ei.SystemError;
return res;
@@ -197,7 +197,7 @@ static HRESULT ShowDialog(
{
if (options.Commands.Size() != 1)
throw "It must be one command";
- UString currentDirPrefix;
+ FString currentDirPrefix;
#ifndef UNDER_CE
{
if (!NDirectory::MyGetCurrentDirectory(currentDirPrefix))
@@ -207,7 +207,7 @@ static HRESULT ShowDialog(
#endif
bool oneFile = false;
- NFind::CFileInfoW fileInfo;
+ NFind::CFileInfo fileInfo;
UString name;
if (censor.Pairs.Size() > 0)
{
@@ -224,7 +224,7 @@ static HRESULT ShowDialog(
name += WCHAR_PATH_SEPARATOR;
name += item.PathParts[i];
}
- if (fileInfo.Find(name))
+ if (fileInfo.Find(us2fs(name)))
{
if (censor.Pairs.Size() == 1 && pair.Head.IncludeItems.Size() == 1)
oneFile = !fileInfo.IsDir();
@@ -253,7 +253,7 @@ static HRESULT ShowDialog(
// di.ArchiveName = options.ArchivePath.GetFinalPath();
di.ArchiveName = options.ArchivePath.GetPathWithoutExt();
- dialog.OriginalFileName = options.ArchivePath.Prefix + fileInfo.Name;
+ dialog.OriginalFileName = options.ArchivePath.Prefix + fs2us(fileInfo.Name);
di.CurrentDirPrefix = currentDirPrefix;
di.SFXMode = options.SfxMode;
@@ -338,9 +338,10 @@ static HRESULT ShowDialog(
options.WorkingDir.Empty();
if (workDirInfo.Mode != NWorkDir::NMode::kCurrent)
{
- UString fullPath;
- NDirectory::MyGetFullPathName(di.ArchiveName, fullPath);
- options.WorkingDir = GetWorkDir(workDirInfo, fullPath);
+ FString fullPath;
+ NDirectory::MyGetFullPathName(us2fs(di.ArchiveName), fullPath);
+ FString namePart;
+ options.WorkingDir = GetWorkDir(workDirInfo, fullPath, namePart);
NDirectory::CreateComplexDirectory(options.WorkingDir);
}
return S_OK;
@@ -362,9 +363,7 @@ HRESULT UpdateGUI(
}
if (options.SfxMode && options.SfxModule.IsEmpty())
{
- UString folder;
- if (!GetProgramFolderPath(folder))
- folder.Empty();
+ FString folder = NWindows::NDLL::GetModuleDirPrefix();
options.SfxModule = folder + kDefaultSfxModule;
}
diff --git a/CPP/7zip/UI/GUI/makefile b/CPP/7zip/UI/GUI/makefile
index fdedb44a..cd2c2f55 100755
--- a/CPP/7zip/UI/GUI/makefile
+++ b/CPP/7zip/UI/GUI/makefile
@@ -6,7 +6,7 @@ CFLAGS = $(CFLAGS) -I ../../../ \
!IFDEF UNDER_CE
LIBS = $(LIBS) ceshell.lib Commctrl.lib
!ELSE
-LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib
+LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib gdi32.lib
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE -D_7ZIP_LARGE_PAGES
!ENDIF
@@ -63,6 +63,7 @@ WIN_CTRL_OBJS = \
$O\FilePathAutoRename.obj \
$O\FileStreams.obj \
$O\FilterCoder.obj \
+ $O\MethodProps.obj \
$O\ProgressUtils.obj \
$O\StreamUtils.obj \