mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 15:14:59 -06:00
9.06 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
829409452d
commit
c99f3ebdd6
@@ -206,8 +206,8 @@ public:
|
||||
#endif
|
||||
|
||||
const CArc &GetArc() { return _archiveLink.Arcs.Back(); }
|
||||
IInArchive *GetArchive() { return GetArc().Archive; }
|
||||
bool CanUpdate() const { return _archiveLink.Arcs.Size() == 1; }
|
||||
IInArchive *GetArchive() { if ( _archiveLink.Arcs.IsEmpty()) return 0; return GetArc().Archive; }
|
||||
bool CanUpdate() const { return _archiveLink.Arcs.Size() <= 1; }
|
||||
};
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
@@ -16,7 +15,6 @@
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "../Common/EnumDirItems.h"
|
||||
#include "../Common/HandlerLoader.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
#include "../Common/UpdateCallback.h"
|
||||
#include "../Common/UpdatePair.h"
|
||||
@@ -208,7 +206,7 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
if (GetArchive())
|
||||
{
|
||||
RINOK(ReadItems());
|
||||
EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", arcItems);
|
||||
EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", arcItems);
|
||||
}
|
||||
|
||||
CRecordVector<CUpdatePair2> updatePairs2;
|
||||
|
||||
@@ -6,8 +6,16 @@
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
static inline UINT GetCurrentFileCodePage()
|
||||
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
return CP_ACP;
|
||||
#else
|
||||
return AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CArchiveFolderManager::LoadFormats()
|
||||
{
|
||||
@@ -61,21 +69,25 @@ STDMETHODIMP CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *ext
|
||||
return StringToBstr(_codecs.Formats[formatIndex].GetAllExtensions(), extensions);
|
||||
}
|
||||
*/
|
||||
|
||||
static void AddIconExt(const CCodecIcons &lib, UString &dest)
|
||||
{
|
||||
for (int j = 0; j < lib.IconPairs.Size(); j++)
|
||||
{
|
||||
if (!dest.IsEmpty())
|
||||
dest += L' ';
|
||||
dest += lib.IconPairs[j].Ext;
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions)
|
||||
{
|
||||
LoadFormats();
|
||||
*extensions = 0;
|
||||
UString res;
|
||||
for (int i = 0; i < _codecs->Libs.Size(); i++)
|
||||
{
|
||||
const CCodecLib &lib = _codecs->Libs[i];
|
||||
for (int j = 0; j < lib.IconPairs.Size(); j++)
|
||||
{
|
||||
if (!res.IsEmpty())
|
||||
res += L' ';
|
||||
res += lib.IconPairs[j].Ext;
|
||||
}
|
||||
}
|
||||
AddIconExt(_codecs->Libs[i], res);
|
||||
AddIconExt(_codecs->InternalIcons, res);
|
||||
return StringToBstr(res, extensions);
|
||||
}
|
||||
|
||||
@@ -87,13 +99,21 @@ STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPa
|
||||
for (int i = 0; i < _codecs->Libs.Size(); i++)
|
||||
{
|
||||
const CCodecLib &lib = _codecs->Libs[i];
|
||||
int ii = lib.FindIconIndex(ext);
|
||||
if (ii >= 0)
|
||||
int ii;
|
||||
if (lib.FindIconIndex(ext, ii))
|
||||
{
|
||||
*iconIndex = ii;
|
||||
return StringToBstr(GetUnicodeString(lib.Path, GetCurrentFileCodePage()), iconPath);
|
||||
}
|
||||
}
|
||||
int ii;
|
||||
if (_codecs->InternalIcons.FindIconIndex(ext, ii))
|
||||
{
|
||||
*iconIndex = ii;
|
||||
UString path;
|
||||
NWindows::NDLL::MyGetModuleFileName(g_hInstance, path);
|
||||
return StringToBstr(path, iconPath);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
ReadWorkDirInfo(workDirInfo);
|
||||
workDirInfo.Load();
|
||||
UString archiveFilePath = _agentSpec->_archiveFilePath;
|
||||
UString workDir = GetWorkDir(workDirInfo, archiveFilePath);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "../Common/ExtractMode.h"
|
||||
#include "../Common/IFileExtractCallback.h"
|
||||
|
||||
#define FOLDER_ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 0x01, x)
|
||||
#define FOLDER_ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 0x01, x)
|
||||
#define FOLDER_ARCHIVE_INTERFACE(i, x) FOLDER_ARCHIVE_INTERFACE_SUB(i, IUnknown, x)
|
||||
|
||||
#define INTERFACE_IArchiveFolder(x) \
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/NtCheck.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
@@ -46,19 +47,6 @@ typedef UINT32 (WINAPI * CreateObjectFunc)(
|
||||
const GUID *interfaceID,
|
||||
void **outObject);
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static inline bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void PrintString(const UString &s)
|
||||
{
|
||||
@@ -660,51 +648,57 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Main function
|
||||
|
||||
int MY_CDECL main(int argc, char* argv[])
|
||||
#define NT_CHECK_FAIL_ACTION PrintError("Unsupported Windows version"); return 1;
|
||||
|
||||
int MY_CDECL main(int numArgs, const char *args[])
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
#endif
|
||||
NT_CHECK
|
||||
|
||||
PrintStringLn(kCopyrightString);
|
||||
|
||||
if (argc < 3)
|
||||
if (numArgs < 3)
|
||||
{
|
||||
PrintStringLn(kHelpString);
|
||||
return 1;
|
||||
}
|
||||
NWindows::NDLL::CLibrary library;
|
||||
if (!library.Load(TEXT(kDllName)))
|
||||
NWindows::NDLL::CLibrary lib;
|
||||
if (!lib.Load(TEXT(kDllName)))
|
||||
{
|
||||
PrintError("Can not load library");
|
||||
PrintError("Can not load 7-zip library");
|
||||
return 1;
|
||||
}
|
||||
CreateObjectFunc createObjectFunc = (CreateObjectFunc)library.GetProcAddress("CreateObject");
|
||||
CreateObjectFunc createObjectFunc = (CreateObjectFunc)lib.GetProc("CreateObject");
|
||||
if (createObjectFunc == 0)
|
||||
{
|
||||
PrintError("Can not get CreateObject");
|
||||
return 1;
|
||||
}
|
||||
|
||||
AString command = argv[1];
|
||||
command.MakeLower();
|
||||
UString archiveName = GetUnicodeString(argv[2], CP_OEMCP);
|
||||
if (command.Compare("a") == 0)
|
||||
char c;
|
||||
{
|
||||
AString command = args[1];
|
||||
if (command.Length() != 1)
|
||||
{
|
||||
PrintError("incorrect command");
|
||||
return 1;
|
||||
}
|
||||
c = MyCharLower(command[0]);
|
||||
}
|
||||
UString archiveName = GetUnicodeString(args[2]);
|
||||
if (c == 'a')
|
||||
{
|
||||
// create archive command
|
||||
if (argc < 4)
|
||||
if (numArgs < 4)
|
||||
{
|
||||
PrintStringLn(kHelpString);
|
||||
return 1;
|
||||
}
|
||||
CObjectVector<CDirItem> dirItems;
|
||||
int i;
|
||||
for (i = 3; i < argc; i++)
|
||||
for (i = 3; i < numArgs; i++)
|
||||
{
|
||||
CDirItem di;
|
||||
UString name = GetUnicodeString(argv[i], CP_OEMCP);
|
||||
UString name = GetUnicodeString(args[i]);
|
||||
|
||||
NFile::NFind::CFileInfoW fi;
|
||||
if (!fi.Find(name))
|
||||
@@ -743,6 +737,30 @@ int MY_CDECL main(int argc, char* argv[])
|
||||
// updateCallbackSpec->PasswordIsDefined = true;
|
||||
// updateCallbackSpec->Password = L"1";
|
||||
|
||||
/*
|
||||
{
|
||||
const wchar_t *names[] =
|
||||
{
|
||||
L"s",
|
||||
L"x"
|
||||
};
|
||||
const int kNumProps = sizeof(names) / sizeof(names[0]);
|
||||
NWindows::NCOM::CPropVariant values[kNumProps] =
|
||||
{
|
||||
false, // solid mode OFF
|
||||
(UInt32)9 // compression level = 9 - ultra
|
||||
};
|
||||
CMyComPtr<ISetProperties> setProperties;
|
||||
outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties);
|
||||
if (!setProperties)
|
||||
{
|
||||
PrintError("ISetProperties unsupported");
|
||||
return 1;
|
||||
}
|
||||
RINOK(setProperties->SetProperties(names, values, kNumProps));
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT result = outArchive->UpdateItems(outFileStream, dirItems.Size(), updateCallback);
|
||||
updateCallbackSpec->Finilize();
|
||||
if (result != S_OK)
|
||||
@@ -760,16 +778,16 @@ int MY_CDECL main(int argc, char* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
if (argc != 3)
|
||||
if (numArgs != 3)
|
||||
{
|
||||
PrintStringLn(kHelpString);
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool listCommand;
|
||||
if (command.Compare("l") == 0)
|
||||
if (c == 'l')
|
||||
listCommand = true;
|
||||
else if (command.Compare("x") == 0)
|
||||
else if (c == 'x')
|
||||
listCommand = false;
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
PROG = 7z.exe
|
||||
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib
|
||||
MY_CONSOLE = 1
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
|
||||
CONSOLE_OBJS = \
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef UNDER_CE
|
||||
#include <io.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Common/ListFileUtils.h"
|
||||
@@ -26,6 +28,12 @@
|
||||
|
||||
extern bool g_CaseSensitive;
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
#define MY_IS_TERMINAL(x) false;
|
||||
|
||||
#else
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
#define MY_isatty_fileno(x) _isatty(_fileno(x))
|
||||
#else
|
||||
@@ -34,6 +42,8 @@ extern bool g_CaseSensitive;
|
||||
|
||||
#define MY_IS_TERMINAL(x) (MY_isatty_fileno(x) != 0);
|
||||
|
||||
#endif
|
||||
|
||||
using namespace NCommandLineParser;
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
@@ -250,26 +260,21 @@ static bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &c
|
||||
// ------------------------------------------------------------------
|
||||
// filenames functions
|
||||
|
||||
static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
|
||||
static void AddNameToCensor(NWildcard::CCensor &wildcardCensor,
|
||||
const UString &name, bool include, NRecursedType::EEnum type)
|
||||
{
|
||||
bool isWildCard = DoesNameContainWildCard(name);
|
||||
bool recursed = false;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case NRecursedType::kWildCardOnlyRecursed:
|
||||
recursed = isWildCard;
|
||||
recursed = DoesNameContainWildCard(name);
|
||||
break;
|
||||
case NRecursedType::kRecursed:
|
||||
recursed = true;
|
||||
break;
|
||||
case NRecursedType::kNonRecursed:
|
||||
recursed = false;
|
||||
break;
|
||||
}
|
||||
wildcardCensor.AddItem(include, name, recursed);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
|
||||
@@ -279,15 +284,7 @@ static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
|
||||
if (!ReadNamesFromListFile(fileName, names, codePage))
|
||||
throw kIncorrectListFile;
|
||||
for (int i = 0; i < names.Size(); i++)
|
||||
if (!AddNameToCensor(wildcardCensor, names[i], include, type))
|
||||
throw kIncorrectWildCardInListFile;
|
||||
}
|
||||
|
||||
static void AddCommandLineWildCardToCensr(NWildcard::CCensor &wildcardCensor,
|
||||
const UString &name, bool include, NRecursedType::EEnum recursedType)
|
||||
{
|
||||
if (!AddNameToCensor(wildcardCensor, name, include, recursedType))
|
||||
throw kIncorrectWildCardInCommandLine;
|
||||
AddNameToCensor(wildcardCensor, names[i], include, type);
|
||||
}
|
||||
|
||||
static void AddToCensorFromNonSwitchesStrings(
|
||||
@@ -297,14 +294,14 @@ static void AddToCensorFromNonSwitchesStrings(
|
||||
bool thereAreSwitchIncludes, UINT codePage)
|
||||
{
|
||||
if (nonSwitchStrings.Size() == startIndex && (!thereAreSwitchIncludes))
|
||||
AddCommandLineWildCardToCensr(wildcardCensor, kUniversalWildcard, true, type);
|
||||
AddNameToCensor(wildcardCensor, kUniversalWildcard, true, type);
|
||||
for (int i = startIndex; i < nonSwitchStrings.Size(); i++)
|
||||
{
|
||||
const UString &s = nonSwitchStrings[i];
|
||||
if (s[0] == kFileListID)
|
||||
AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type, codePage);
|
||||
else
|
||||
AddCommandLineWildCardToCensr(wildcardCensor, s, true, type);
|
||||
AddNameToCensor(wildcardCensor, s, true, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,9 +327,9 @@ static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
|
||||
UInt32 dataSize = (UInt32)dataSize64;
|
||||
{
|
||||
CFileMapping fileMapping;
|
||||
if (!fileMapping.Open(FILE_MAP_READ, false, GetSystemString(mappingName)))
|
||||
if (fileMapping.Open(FILE_MAP_READ, GetSystemString(mappingName)) != 0)
|
||||
ThrowException("Can not open mapping");
|
||||
LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_READ, 0, dataSize);
|
||||
LPVOID data = fileMapping.Map(FILE_MAP_READ, 0, dataSize);
|
||||
if (data == NULL)
|
||||
ThrowException("MapViewOfFile error");
|
||||
try
|
||||
@@ -347,8 +344,7 @@ static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
|
||||
wchar_t c = curData[i];
|
||||
if (c == L'\0')
|
||||
{
|
||||
AddCommandLineWildCardToCensr(wildcardCensor,
|
||||
name, include, commonRecursedType);
|
||||
AddNameToCensor(wildcardCensor, name, include, commonRecursedType);
|
||||
name.Empty();
|
||||
}
|
||||
else
|
||||
@@ -398,7 +394,7 @@ static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
|
||||
ThrowUserErrorException();
|
||||
UString tail = name.Mid(pos + 1);
|
||||
if (name[pos] == kImmediateNameID)
|
||||
AddCommandLineWildCardToCensr(wildcardCensor, tail, include, recursedType);
|
||||
AddNameToCensor(wildcardCensor, tail, include, recursedType);
|
||||
else if (name[pos] == kFileListID)
|
||||
AddToCensorFromListFile(wildcardCensor, tail, include, recursedType, codePage);
|
||||
#ifdef _WIN32
|
||||
@@ -764,6 +760,52 @@ static bool ConvertStringToUInt32(const wchar_t *s, UInt32 &v)
|
||||
return true;
|
||||
}
|
||||
|
||||
void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor,
|
||||
UStringVector &sortedPaths,
|
||||
UStringVector &sortedFullPaths)
|
||||
{
|
||||
UStringVector paths;
|
||||
{
|
||||
CDirItems dirItems;
|
||||
{
|
||||
UStringVector errorPaths;
|
||||
CRecordVector<DWORD> errorCodes;
|
||||
HRESULT res = EnumerateItems(wildcardCensor, dirItems, NULL, errorPaths, errorCodes);
|
||||
if (res != S_OK || errorPaths.Size() > 0)
|
||||
throw "cannot find archive";
|
||||
}
|
||||
for (int i = 0; i < dirItems.Items.Size(); i++)
|
||||
{
|
||||
const CDirItem &dirItem = dirItems.Items[i];
|
||||
if (!dirItem.IsDir())
|
||||
paths.Add(dirItems.GetPhyPath(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (paths.Size() == 0)
|
||||
throw "there is no such archive";
|
||||
|
||||
UStringVector fullPaths;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < paths.Size(); i++)
|
||||
{
|
||||
UString fullPath;
|
||||
NFile::NDirectory::MyGetFullPathName(paths[i], fullPath);
|
||||
fullPaths.Add(fullPath);
|
||||
}
|
||||
CIntVector indices;
|
||||
SortFileNames(fullPaths, indices);
|
||||
sortedPaths.Reserve(indices.Size());
|
||||
sortedFullPaths.Reserve(indices.Size());
|
||||
for (i = 0; i < indices.Size(); i++)
|
||||
{
|
||||
int index = indices[i];
|
||||
sortedPaths.Add(paths[index]);
|
||||
sortedFullPaths.Add(fullPaths[index]);
|
||||
}
|
||||
}
|
||||
|
||||
void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
{
|
||||
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
|
||||
@@ -844,16 +886,14 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
NWildcard::CCensor archiveWildcardCensor;
|
||||
|
||||
if (parser[NKey::kArInclude].ThereIs)
|
||||
{
|
||||
AddSwitchWildCardsToCensor(archiveWildcardCensor,
|
||||
parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage);
|
||||
}
|
||||
parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage);
|
||||
if (parser[NKey::kArExclude].ThereIs)
|
||||
AddSwitchWildCardsToCensor(archiveWildcardCensor,
|
||||
parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage);
|
||||
parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage);
|
||||
|
||||
if (thereIsArchiveName)
|
||||
AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);
|
||||
AddNameToCensor(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);
|
||||
|
||||
#ifdef _WIN32
|
||||
ConvertToLongNames(archiveWildcardCensor);
|
||||
@@ -869,50 +909,11 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
UStringVector archivePaths;
|
||||
|
||||
{
|
||||
CDirItems dirItems;
|
||||
{
|
||||
UStringVector errorPaths;
|
||||
CRecordVector<DWORD> errorCodes;
|
||||
HRESULT res = EnumerateItems(archiveWildcardCensor, dirItems, NULL, errorPaths, errorCodes);
|
||||
if (res != S_OK || errorPaths.Size() > 0)
|
||||
throw "cannot find archive";
|
||||
}
|
||||
for (int i = 0; i < dirItems.Items.Size(); i++)
|
||||
{
|
||||
const CDirItem &dirItem = dirItems.Items[i];
|
||||
if (!dirItem.IsDir())
|
||||
archivePaths.Add(dirItems.GetPhyPath(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (archivePaths.Size() == 0)
|
||||
throw "there is no such archive";
|
||||
|
||||
UStringVector archivePathsFull;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < archivePaths.Size(); i++)
|
||||
{
|
||||
UString fullPath;
|
||||
NFile::NDirectory::MyGetFullPathName(archivePaths[i], fullPath);
|
||||
archivePathsFull.Add(fullPath);
|
||||
}
|
||||
CIntVector indices;
|
||||
SortFileNames(archivePathsFull, indices);
|
||||
options.ArchivePathsSorted.Reserve(indices.Size());
|
||||
options.ArchivePathsFullSorted.Reserve(indices.Size());
|
||||
for (i = 0; i < indices.Size(); i++)
|
||||
{
|
||||
options.ArchivePathsSorted.Add(archivePaths[indices[i]]);
|
||||
options.ArchivePathsFullSorted.Add(archivePathsFull[indices[i]]);
|
||||
EnumerateDirItemsAndSort(archiveWildcardCensor,
|
||||
options.ArchivePathsSorted,
|
||||
options.ArchivePathsFullSorted);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isExtractGroupCommand)
|
||||
{
|
||||
SetMethodOptions(parser, options.ExtractProperties);
|
||||
@@ -926,8 +927,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
|
||||
options.OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
|
||||
if (parser[NKey::kOverwrite].ThereIs)
|
||||
options.OverwriteMode =
|
||||
k_OverwriteModes[parser[NKey::kOverwrite].PostCharIndex];
|
||||
options.OverwriteMode = k_OverwriteModes[parser[NKey::kOverwrite].PostCharIndex];
|
||||
else if (options.YesToAll)
|
||||
options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// ArchiveCommandLine.h
|
||||
|
||||
#ifndef __ARCHIVECOMMANDLINE_H
|
||||
#define __ARCHIVECOMMANDLINE_H
|
||||
#ifndef __ARCHIVE_COMMAND_LINE_H
|
||||
#define __ARCHIVE_COMMAND_LINE_H
|
||||
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/CommandLineParser.h"
|
||||
#include "Common/Wildcard.h"
|
||||
|
||||
#include "Extract.h"
|
||||
#include "Update.h"
|
||||
@@ -104,4 +104,8 @@ public:
|
||||
void Parse2(CArchiveCommandLineOptions &options);
|
||||
};
|
||||
|
||||
void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor,
|
||||
UStringVector &sortedPaths,
|
||||
UStringVector &sortedFullPaths);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -75,9 +75,12 @@ struct CInFileStreamVol: public CInFileStream
|
||||
CMyComPtr<IArchiveOpenCallback> OpenCallbackRef;
|
||||
~CInFileStreamVol()
|
||||
{
|
||||
int index = OpenCallbackImp->FindName(Name);
|
||||
if (index >= 0)
|
||||
OpenCallbackImp->FileNames.Delete(index);
|
||||
if (OpenCallbackRef)
|
||||
{
|
||||
int index = OpenCallbackImp->FindName(Name);
|
||||
if (index >= 0)
|
||||
OpenCallbackImp->FileNames.Delete(index);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileMapping.h"
|
||||
#include "Windows/Process.h"
|
||||
#include "Windows/Synchronization.h"
|
||||
|
||||
#include "../FileManager/ProgramLocation.h"
|
||||
@@ -16,253 +17,170 @@
|
||||
|
||||
#include "CompressCall.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif _UNICODE
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
#define MY_TRY_BEGIN try {
|
||||
#define MY_TRY_FINISH } \
|
||||
catch(...) { ErrorMessageHRESULT(E_FAIL); return E_FAIL; }
|
||||
|
||||
static LPCWSTR kShowDialogSwitch = L" -ad";
|
||||
static LPCWSTR kEmailSwitch = L" -seml.";
|
||||
static LPCWSTR kMapSwitch = L" -i#";
|
||||
static LPCWSTR kArchiveNoNameSwitch = L" -an";
|
||||
static LPCWSTR kIncludeSwitch = L" -i";
|
||||
static LPCWSTR kArchiveTypeSwitch = L" -t";
|
||||
static LPCWSTR kArchiveMapSwitch = L" -ai#";
|
||||
static LPCWSTR kArcIncludeSwitches = L" -an -ai";
|
||||
static LPCWSTR kStopSwitchParsing = L" --";
|
||||
static LPCWSTR kLargePagesDisable = L" -slp-";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void ErrorMessageHRESULT(HRESULT res, LPCWSTR s = NULL)
|
||||
{
|
||||
UString s2 = HResultToMessage(res);
|
||||
if (s)
|
||||
{
|
||||
s2 += L'\n';
|
||||
s2 += s;
|
||||
}
|
||||
ErrorMessage(s2);
|
||||
}
|
||||
|
||||
static HRESULT MyCreateProcess(LPCWSTR imageName, const UString ¶ms,
|
||||
LPCWSTR curDir, bool waitFinish,
|
||||
NSynchronization::CBaseEvent *event)
|
||||
{
|
||||
CProcess process;
|
||||
WRes res = process.Create(imageName, params, curDir);
|
||||
if (res != 0)
|
||||
{
|
||||
ErrorMessageHRESULT(res, imageName);
|
||||
return res;
|
||||
}
|
||||
if (waitFinish)
|
||||
process.Wait();
|
||||
else if (event != NULL)
|
||||
{
|
||||
HANDLE handles[] = { process, *event };
|
||||
::WaitForMultipleObjects(sizeof(handles) / sizeof(handles[0]), handles, FALSE, INFINITE);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void AddLagePagesSwitch(UString ¶ms)
|
||||
{
|
||||
if (!ReadLockMemoryEnable())
|
||||
params += kLargePagesDisable;
|
||||
}
|
||||
|
||||
HRESULT MyCreateProcess(const UString ¶ms,
|
||||
LPCWSTR curDir, bool waitFinish,
|
||||
NWindows::NSynchronization::CBaseEvent *event)
|
||||
{
|
||||
const UString params2 = params;
|
||||
PROCESS_INFORMATION processInformation;
|
||||
BOOL result;
|
||||
#ifndef _UNICODE
|
||||
if (!g_IsNT)
|
||||
{
|
||||
STARTUPINFOA startupInfo;
|
||||
startupInfo.cb = sizeof(startupInfo);
|
||||
startupInfo.lpReserved = 0;
|
||||
startupInfo.lpDesktop = 0;
|
||||
startupInfo.lpTitle = 0;
|
||||
startupInfo.dwFlags = 0;
|
||||
startupInfo.cbReserved2 = 0;
|
||||
startupInfo.lpReserved2 = 0;
|
||||
|
||||
CSysString curDirA;
|
||||
if (curDir != 0)
|
||||
curDirA = GetSystemString(curDir);
|
||||
result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params),
|
||||
NULL, NULL, FALSE, 0, NULL,
|
||||
((curDir != 0) ? (LPCSTR)curDirA: 0),
|
||||
&startupInfo, &processInformation);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
STARTUPINFOW startupInfo;
|
||||
startupInfo.cb = sizeof(startupInfo);
|
||||
startupInfo.lpReserved = 0;
|
||||
startupInfo.lpDesktop = 0;
|
||||
startupInfo.lpTitle = 0;
|
||||
startupInfo.dwFlags = 0;
|
||||
startupInfo.cbReserved2 = 0;
|
||||
startupInfo.lpReserved2 = 0;
|
||||
|
||||
result = ::CreateProcessW(NULL, (LPWSTR)(LPCWSTR)params,
|
||||
NULL, NULL, FALSE, 0, NULL,
|
||||
curDir,
|
||||
&startupInfo, &processInformation);
|
||||
}
|
||||
if (result == 0)
|
||||
return ::GetLastError();
|
||||
else
|
||||
{
|
||||
::CloseHandle(processInformation.hThread);
|
||||
if (waitFinish)
|
||||
WaitForSingleObject(processInformation.hProcess, INFINITE);
|
||||
else if (event != NULL)
|
||||
{
|
||||
HANDLE handles[] = {processInformation.hProcess, *event };
|
||||
::WaitForMultipleObjects(sizeof(handles) / sizeof(handles[0]),
|
||||
handles, FALSE, INFINITE);
|
||||
}
|
||||
::CloseHandle(processInformation.hProcess);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static UString GetQuotedString(const UString &s)
|
||||
{
|
||||
return UString(L"\"") + s + UString(L"\"");
|
||||
}
|
||||
|
||||
static UString Get7zGuiPath()
|
||||
{
|
||||
UString path;
|
||||
UString folder;
|
||||
if (GetProgramFolderPath(folder))
|
||||
path += folder;
|
||||
path += L"7zG.exe";
|
||||
return GetQuotedString(path);
|
||||
GetProgramFolderPath(path);
|
||||
return path + L"7zG.exe";
|
||||
}
|
||||
|
||||
static HRESULT CreateTempEvent(const wchar_t *name,
|
||||
NSynchronization::CManualResetEvent &event, UString &eventName)
|
||||
class CRandNameGenerator
|
||||
{
|
||||
CRandom random;
|
||||
random.Init(GetTickCount());
|
||||
for (;;)
|
||||
CRandom _random;
|
||||
public:
|
||||
CRandNameGenerator() { _random.Init(); }
|
||||
UString GenerateName()
|
||||
{
|
||||
int number = random.Generate();
|
||||
wchar_t temp[16];
|
||||
ConvertUInt32ToString((UInt32)number, temp);
|
||||
eventName = name;
|
||||
eventName += temp;
|
||||
RINOK(event.CreateWithName(false, GetSystemString(eventName)));
|
||||
if (::GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
return S_OK;
|
||||
event.Close();
|
||||
ConvertUInt32ToString((UInt32)_random.Generate(), temp);
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static HRESULT CreateMap(const UStringVector &names,
|
||||
const UString &id,
|
||||
CFileMapping &fileMapping, NSynchronization::CManualResetEvent &event,
|
||||
UString ¶ms)
|
||||
{
|
||||
UInt32 extraSize = 2;
|
||||
UInt32 dataSize = 0;
|
||||
UInt32 totalSize = 1;
|
||||
for (int i = 0; i < names.Size(); i++)
|
||||
dataSize += (names[i].Length() + 1) * sizeof(wchar_t);
|
||||
UInt32 totalSize = extraSize + dataSize;
|
||||
totalSize += (names[i].Length() + 1);
|
||||
totalSize *= sizeof(wchar_t);
|
||||
|
||||
CRandNameGenerator random;
|
||||
|
||||
UString mappingName;
|
||||
|
||||
CRandom random;
|
||||
random.Init(GetTickCount());
|
||||
for (;;)
|
||||
{
|
||||
int number = random.Generate();
|
||||
wchar_t temp[16];
|
||||
ConvertUInt32ToString(UInt32(number), temp);
|
||||
mappingName = id;
|
||||
mappingName += L"Mapping";
|
||||
mappingName += temp;
|
||||
if (!fileMapping.Create(INVALID_HANDLE_VALUE, NULL,
|
||||
PAGE_READWRITE, totalSize, GetSystemString(mappingName)))
|
||||
return E_FAIL;
|
||||
if (::GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
mappingName = L"7zMap" + random.GenerateName();
|
||||
|
||||
WRes res = fileMapping.Create(PAGE_READWRITE, totalSize, GetSystemString(mappingName));
|
||||
if (fileMapping.IsCreated() && res == 0)
|
||||
break;
|
||||
if (res != ERROR_ALREADY_EXISTS)
|
||||
return res;
|
||||
fileMapping.Close();
|
||||
}
|
||||
|
||||
UString eventName;
|
||||
RINOK(CreateTempEvent(id + L"MappingEndEvent", event, eventName));
|
||||
for (;;)
|
||||
{
|
||||
eventName = L"7zEvent" + random.GenerateName();
|
||||
WRes res = event.CreateWithName(false, GetSystemString(eventName));
|
||||
if (event.IsCreated() && res == 0)
|
||||
break;
|
||||
if (res != ERROR_ALREADY_EXISTS)
|
||||
return res;
|
||||
event.Close();
|
||||
}
|
||||
|
||||
params += L'#';
|
||||
params += mappingName;
|
||||
params += L":";
|
||||
wchar_t string[16];
|
||||
ConvertUInt32ToString(totalSize, string);
|
||||
params += string;
|
||||
params += L':';
|
||||
wchar_t temp[16];
|
||||
ConvertUInt32ToString(totalSize, temp);
|
||||
params += temp;
|
||||
|
||||
params += L":";
|
||||
params += L':';
|
||||
params += eventName;
|
||||
|
||||
LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_WRITE, 0, totalSize);
|
||||
LPVOID data = fileMapping.Map(FILE_MAP_WRITE, 0, totalSize);
|
||||
if (data == NULL)
|
||||
return E_FAIL;
|
||||
CFileUnmapper unmapper(data);
|
||||
{
|
||||
wchar_t *curData = (wchar_t *)data;
|
||||
*curData = 0;
|
||||
curData++;
|
||||
wchar_t *cur = (wchar_t *)data;
|
||||
*cur++ = 0;
|
||||
for (int i = 0; i < names.Size(); i++)
|
||||
{
|
||||
const UString &s = names[i];
|
||||
memcpy(curData, (const wchar_t *)s, s.Length() * sizeof(wchar_t));
|
||||
curData += s.Length();
|
||||
*curData++ = L'\0';
|
||||
int len = s.Length() + 1;
|
||||
memcpy(cur, (const wchar_t *)s, len * sizeof(wchar_t));
|
||||
cur += len;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CompressFiles(
|
||||
const UString &curDir,
|
||||
const UString &archiveName,
|
||||
const UString &archiveType,
|
||||
const UString &arcPathPrefix,
|
||||
const UString &arcName,
|
||||
const UString &arcType,
|
||||
const UStringVector &names,
|
||||
// const UString &outFolder,
|
||||
bool email,
|
||||
bool showDialog,
|
||||
bool waitFinish)
|
||||
bool email, bool showDialog, bool waitFinish)
|
||||
{
|
||||
/*
|
||||
UString curDir;
|
||||
if (names.Size() > 0)
|
||||
{
|
||||
NFile::NDirectory::GetOnlyDirPrefix(names[0], curDir);
|
||||
}
|
||||
*/
|
||||
UString params;
|
||||
params = Get7zGuiPath();
|
||||
params += L" a";
|
||||
params += kMapSwitch;
|
||||
// params += _fileNames[0];
|
||||
|
||||
UInt32 extraSize = 2;
|
||||
UInt32 dataSize = 0;
|
||||
for (int i = 0; i < names.Size(); i++)
|
||||
dataSize += (names[i].Length() + 1) * sizeof(wchar_t);
|
||||
UInt32 totalSize = extraSize + dataSize;
|
||||
|
||||
UString mappingName;
|
||||
MY_TRY_BEGIN
|
||||
UString params = L'a';
|
||||
|
||||
CFileMapping fileMapping;
|
||||
CRandom random;
|
||||
random.Init(GetTickCount());
|
||||
for (;;)
|
||||
{
|
||||
int number = random.Generate();
|
||||
wchar_t temp[16];
|
||||
ConvertUInt32ToString(UInt32(number), temp);
|
||||
mappingName = L"7zCompressMapping";
|
||||
mappingName += temp;
|
||||
if (!fileMapping.Create(INVALID_HANDLE_VALUE, NULL,
|
||||
PAGE_READWRITE, totalSize, GetSystemString(mappingName)))
|
||||
{
|
||||
// MyMessageBox(IDS_ERROR, 0x02000605);
|
||||
return E_FAIL;
|
||||
}
|
||||
if (::GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
break;
|
||||
fileMapping.Close();
|
||||
}
|
||||
|
||||
NSynchronization::CManualResetEvent event;
|
||||
UString eventName;
|
||||
RINOK(CreateTempEvent(L"7zCompressMappingEndEvent", event, eventName));
|
||||
params += kIncludeSwitch;
|
||||
RINOK(CreateMap(names, fileMapping, event, params));
|
||||
|
||||
params += mappingName;
|
||||
params += L":";
|
||||
wchar_t string[16];
|
||||
ConvertUInt32ToString(totalSize, string);
|
||||
params += string;
|
||||
|
||||
params += L":";
|
||||
params += eventName;
|
||||
|
||||
if (!archiveType.IsEmpty())
|
||||
if (!arcType.IsEmpty())
|
||||
{
|
||||
params += kArchiveTypeSwitch;
|
||||
params += archiveType;
|
||||
params += arcType;
|
||||
}
|
||||
|
||||
if (email)
|
||||
@@ -274,71 +192,33 @@ HRESULT CompressFiles(
|
||||
AddLagePagesSwitch(params);
|
||||
|
||||
params += kStopSwitchParsing;
|
||||
params += L" ";
|
||||
params += L' ';
|
||||
|
||||
params += GetQuotedString(archiveName);
|
||||
params += GetQuotedString(
|
||||
#ifdef UNDER_CE
|
||||
arcPathPrefix +
|
||||
#endif
|
||||
arcName);
|
||||
|
||||
LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_WRITE, 0, totalSize);
|
||||
if (data == NULL)
|
||||
{
|
||||
// MyMessageBox(IDS_ERROR, 0x02000605);
|
||||
return E_FAIL;
|
||||
}
|
||||
try
|
||||
{
|
||||
wchar_t *curData = (wchar_t *)data;
|
||||
*curData = 0;
|
||||
curData++;
|
||||
for (int i = 0; i < names.Size(); i++)
|
||||
{
|
||||
const UString &unicodeString = names[i];
|
||||
memcpy(curData, (const wchar_t *)unicodeString ,
|
||||
unicodeString .Length() * sizeof(wchar_t));
|
||||
curData += unicodeString.Length();
|
||||
*curData++ = L'\0';
|
||||
}
|
||||
// MessageBox(0, params, 0, 0);
|
||||
RINOK(MyCreateProcess(params,
|
||||
(curDir.IsEmpty()? 0: (LPCWSTR)curDir),
|
||||
waitFinish, &event));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
UnmapViewOfFile(data);
|
||||
throw;
|
||||
}
|
||||
UnmapViewOfFile(data);
|
||||
|
||||
|
||||
/*
|
||||
CThreadCompressMain *compressor = new CThreadCompressMain();;
|
||||
compressor->FileNames = _fileNames;
|
||||
CThread thread;
|
||||
if (!thread.Create(CThreadCompressMain::MyThreadFunction, compressor))
|
||||
throw 271824;
|
||||
*/
|
||||
return S_OK;
|
||||
return MyCreateProcess(Get7zGuiPath(), params,
|
||||
(arcPathPrefix.IsEmpty()? 0: (LPCWSTR)arcPathPrefix), waitFinish, &event);
|
||||
MY_TRY_FINISH
|
||||
}
|
||||
|
||||
static HRESULT ExtractGroupCommand(const UStringVector &archivePaths,
|
||||
const UString ¶ms)
|
||||
static HRESULT ExtractGroupCommand(const UStringVector &arcPaths, UString ¶ms)
|
||||
{
|
||||
UString params2 = params;
|
||||
AddLagePagesSwitch(params2);
|
||||
params2 += kArchiveNoNameSwitch;
|
||||
params2 += kArchiveMapSwitch;
|
||||
AddLagePagesSwitch(params);
|
||||
params += kArcIncludeSwitches;
|
||||
CFileMapping fileMapping;
|
||||
NSynchronization::CManualResetEvent event;
|
||||
RINOK(CreateMap(archivePaths, L"7zExtract", fileMapping, event, params2));
|
||||
return MyCreateProcess(params2, 0, false, &event);
|
||||
RINOK(CreateMap(arcPaths, fileMapping, event, params));
|
||||
return MyCreateProcess(Get7zGuiPath(), params, 0, false, &event);
|
||||
}
|
||||
|
||||
HRESULT ExtractArchives(const UStringVector &archivePaths,
|
||||
const UString &outFolder, bool showDialog)
|
||||
HRESULT ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog)
|
||||
{
|
||||
UString params;
|
||||
params = Get7zGuiPath();
|
||||
params += L" x";
|
||||
MY_TRY_BEGIN
|
||||
UString params = L'x';
|
||||
if (!outFolder.IsEmpty())
|
||||
{
|
||||
params += L" -o";
|
||||
@@ -346,21 +226,21 @@ HRESULT ExtractArchives(const UStringVector &archivePaths,
|
||||
}
|
||||
if (showDialog)
|
||||
params += kShowDialogSwitch;
|
||||
return ExtractGroupCommand(archivePaths, params);
|
||||
return ExtractGroupCommand(arcPaths, params);
|
||||
MY_TRY_FINISH
|
||||
}
|
||||
|
||||
HRESULT TestArchives(const UStringVector &archivePaths)
|
||||
HRESULT TestArchives(const UStringVector &arcPaths)
|
||||
{
|
||||
UString params;
|
||||
params = Get7zGuiPath();
|
||||
params += L" t";
|
||||
return ExtractGroupCommand(archivePaths, params);
|
||||
MY_TRY_BEGIN
|
||||
UString params = L't';
|
||||
return ExtractGroupCommand(arcPaths, params);
|
||||
MY_TRY_FINISH
|
||||
}
|
||||
|
||||
HRESULT Benchmark()
|
||||
{
|
||||
UString params;
|
||||
params = Get7zGuiPath();
|
||||
params += L" b";
|
||||
return MyCreateProcess(params, 0, false, NULL);
|
||||
MY_TRY_BEGIN
|
||||
return MyCreateProcess(Get7zGuiPath(), L'b', 0, false, NULL);
|
||||
MY_TRY_FINISH
|
||||
}
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
// CompressCall.h
|
||||
|
||||
#ifndef __COMPRESSCALL_H
|
||||
#define __COMPRESSCALL_H
|
||||
#ifndef __COMPRESS_CALL_H
|
||||
#define __COMPRESS_CALL_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
#include "Windows/Synchronization.h"
|
||||
|
||||
HRESULT MyCreateProcess(const UString ¶ms,
|
||||
LPCWSTR lpCurrentDirectory, bool waitFinish,
|
||||
NWindows::NSynchronization::CBaseEvent *event);
|
||||
UString GetQuotedString(const UString &s);
|
||||
|
||||
extern HWND g_HWND;
|
||||
UString HResultToMessage(HRESULT errorCode);
|
||||
|
||||
HRESULT CompressFiles(
|
||||
const UString &curDir,
|
||||
const UString &archiveName,
|
||||
const UString &archiveType,
|
||||
const UString &arcPathPrefix,
|
||||
const UString &arcName,
|
||||
const UString &arcType,
|
||||
const UStringVector &names,
|
||||
// const UString &outFolder,
|
||||
bool email, bool showDialog, bool waitFinish);
|
||||
|
||||
HRESULT ExtractArchives(
|
||||
const UStringVector &archivePaths,
|
||||
const UString &outFolder, bool showDialog);
|
||||
|
||||
HRESULT TestArchives(const UStringVector &archivePaths);
|
||||
|
||||
HRESULT ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog);
|
||||
HRESULT TestArchives(const UStringVector &arcPaths);
|
||||
HRESULT Benchmark();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
173
CPP/7zip/UI/Common/CompressCall2.cpp
Executable file
173
CPP/7zip/UI/Common/CompressCall2.cpp
Executable file
@@ -0,0 +1,173 @@
|
||||
// CompressCall.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyException.h"
|
||||
|
||||
#include "../../UI/common/ArchiveCommandLine.h"
|
||||
|
||||
#include "../../UI/GUI/BenchmarkDialog.h"
|
||||
#include "../../UI/GUI/ExtractGUI.h"
|
||||
#include "../../UI/GUI/UpdateGUI.h"
|
||||
|
||||
#include "../../UI/GUI/ExtractRes.h"
|
||||
|
||||
#include "CompressCall.h"
|
||||
|
||||
#define MY_TRY_BEGIN try {
|
||||
#define MY_TRY_FINISH } \
|
||||
catch(CSystemException &e) { result = e.ErrorCode; } \
|
||||
catch(...) { result = E_FAIL; } \
|
||||
if (result != S_OK && result != E_ABORT) \
|
||||
ErrorMessageHRESULT(result);
|
||||
|
||||
#define CREATE_CODECS \
|
||||
CCodecs *codecs = new CCodecs; \
|
||||
CMyComPtr<IUnknown> compressCodecsInfo = codecs; \
|
||||
result = codecs->Load(); \
|
||||
if (result != S_OK) \
|
||||
throw CSystemException(result);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void ErrorMessageHRESULT(HRESULT res)
|
||||
{
|
||||
ErrorMessage(HResultToMessage(res));
|
||||
}
|
||||
|
||||
static void ErrorLangMessage(UINT resourceID, UInt32 langID)
|
||||
{
|
||||
ErrorMessage(LangString(resourceID, langID));
|
||||
}
|
||||
|
||||
HRESULT CompressFiles(
|
||||
const UString &arcPathPrefix,
|
||||
const UString &arcName,
|
||||
const UString &arcType,
|
||||
const UStringVector &names,
|
||||
bool email, bool showDialog, bool /* waitFinish */)
|
||||
{
|
||||
HRESULT result;
|
||||
MY_TRY_BEGIN
|
||||
CREATE_CODECS
|
||||
|
||||
CUpdateCallbackGUI callback;
|
||||
|
||||
callback.Init();
|
||||
|
||||
CUpdateOptions uo;
|
||||
uo.EMailMode = email;
|
||||
uo.SetAddActionCommand();
|
||||
|
||||
CIntVector formatIndices;
|
||||
if (!codecs->FindFormatForArchiveType(arcType, formatIndices))
|
||||
{
|
||||
ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE, 0x0200060D);
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!uo.Init(codecs, formatIndices, arcPathPrefix + arcName))
|
||||
{
|
||||
ErrorLangMessage(IDS_UPDATE_NOT_SUPPORTED, 0x02000601);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
NWildcard::CCensor censor;
|
||||
for (int i = 0; i < names.Size(); i++)
|
||||
censor.AddItem(true, names[i], false);
|
||||
|
||||
bool messageWasDisplayed = false;
|
||||
result = UpdateGUI(codecs, censor, uo, showDialog, messageWasDisplayed, &callback, g_HWND);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
if (result != E_ABORT && messageWasDisplayed)
|
||||
return E_FAIL;
|
||||
throw CSystemException(result);
|
||||
}
|
||||
if (callback.FailedFiles.Size() > 0)
|
||||
{
|
||||
if (!messageWasDisplayed)
|
||||
throw CSystemException(E_FAIL);
|
||||
return E_FAIL;
|
||||
}
|
||||
MY_TRY_FINISH
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT ExtractGroupCommand(const UStringVector &arcPaths,
|
||||
bool showDialog, const UString &outFolder, bool testMode)
|
||||
{
|
||||
HRESULT result;
|
||||
MY_TRY_BEGIN
|
||||
CREATE_CODECS
|
||||
|
||||
CExtractOptions eo;
|
||||
eo.OutputDir = outFolder;
|
||||
eo.TestMode = testMode;
|
||||
|
||||
CExtractCallbackImp *ecs = new CExtractCallbackImp;
|
||||
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
|
||||
|
||||
ecs->Init();
|
||||
|
||||
// eo.CalcCrc = options.CalcCrc;
|
||||
|
||||
UStringVector arcPathsSorted;
|
||||
UStringVector arcFullPathsSorted;
|
||||
{
|
||||
NWildcard::CCensor acrCensor;
|
||||
for (int i = 0; i < arcPaths.Size(); i++)
|
||||
acrCensor.AddItem(true, arcPaths[i], false);
|
||||
EnumerateDirItemsAndSort(acrCensor, arcPathsSorted, arcFullPathsSorted);
|
||||
}
|
||||
|
||||
CIntVector formatIndices;
|
||||
|
||||
NWildcard::CCensor censor;
|
||||
censor.AddItem(true, L"*", false);
|
||||
|
||||
bool messageWasDisplayed = false;
|
||||
result = ExtractGUI(codecs, formatIndices, arcPathsSorted, arcFullPathsSorted,
|
||||
censor.Pairs.Front().Head, eo, showDialog, messageWasDisplayed, ecs, g_HWND);
|
||||
if (result != S_OK)
|
||||
{
|
||||
if (result != E_ABORT && messageWasDisplayed)
|
||||
return E_FAIL;
|
||||
throw CSystemException(result);
|
||||
}
|
||||
return ecs->IsOK() ? S_OK : E_FAIL;
|
||||
MY_TRY_FINISH
|
||||
return result;
|
||||
}
|
||||
|
||||
HRESULT ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog)
|
||||
{
|
||||
return ExtractGroupCommand(arcPaths, showDialog, outFolder, false);
|
||||
}
|
||||
|
||||
HRESULT TestArchives(const UStringVector &arcPaths)
|
||||
{
|
||||
return ExtractGroupCommand(arcPaths, true, UString(), true);
|
||||
}
|
||||
|
||||
HRESULT Benchmark()
|
||||
{
|
||||
HRESULT result;
|
||||
MY_TRY_BEGIN
|
||||
CREATE_CODECS
|
||||
result = Benchmark(
|
||||
#ifdef EXTERNAL_LZMA
|
||||
codecs,
|
||||
#endif
|
||||
(UInt32)-1, (UInt32)-1, g_HWND);
|
||||
MY_TRY_FINISH
|
||||
return result;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// HandlerLoader.h
|
||||
|
||||
#ifndef __HANDLERLOADER_H
|
||||
#define __HANDLERLOADER_H
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "Windows/DLL.h"
|
||||
|
||||
typedef UInt32 (WINAPI * CreateObjectFunc)(
|
||||
const GUID *clsID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject);
|
||||
|
||||
class CHandlerLoader: public NWindows::NDLL::CLibrary
|
||||
{
|
||||
public:
|
||||
HRESULT CreateHandler(LPCWSTR filepath, REFGUID clsID,
|
||||
void **archive, bool outHandler)
|
||||
{
|
||||
if (!Load(filepath))
|
||||
return GetLastError();
|
||||
CreateObjectFunc createObject = (CreateObjectFunc)
|
||||
GetProcAddress("CreateObject");
|
||||
if (createObject == NULL)
|
||||
{
|
||||
HRESULT res = ::GetLastError();
|
||||
Free();
|
||||
return res;
|
||||
}
|
||||
HRESULT res = createObject(&clsID,
|
||||
outHandler ? &IID_IOutArchive : &IID_IInArchive, (void **)archive);
|
||||
if (res != 0)
|
||||
Free();
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -111,12 +111,12 @@ static HRESULT GetCoderClass(GetMethodPropertyFunc getMethodProperty, UInt32 ind
|
||||
HRESULT CCodecs::LoadCodecs()
|
||||
{
|
||||
CCodecLib &lib = Libs.Back();
|
||||
lib.GetMethodProperty = (GetMethodPropertyFunc)lib.Lib.GetProcAddress("GetMethodProperty");
|
||||
lib.GetMethodProperty = (GetMethodPropertyFunc)lib.Lib.GetProc("GetMethodProperty");
|
||||
if (lib.GetMethodProperty == NULL)
|
||||
return S_OK;
|
||||
|
||||
UInt32 numMethods = 1;
|
||||
GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)lib.Lib.GetProcAddress("GetNumberOfMethods");
|
||||
GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)lib.Lib.GetProc("GetNumberOfMethods");
|
||||
if (getNumberOfMethodsFunc != NULL)
|
||||
{
|
||||
RINOK(getNumberOfMethodsFunc(&numMethods));
|
||||
@@ -210,10 +210,11 @@ static void SplitString(const UString &srcString, UStringVector &destStrings)
|
||||
destStrings.Add(s);
|
||||
}
|
||||
|
||||
void CArcInfoEx::AddExts(const wchar_t* ext, const wchar_t* addExt)
|
||||
void CArcInfoEx::AddExts(const wchar_t *ext, const wchar_t *addExt)
|
||||
{
|
||||
UStringVector exts, addExts;
|
||||
SplitString(ext, exts);
|
||||
if (ext != 0)
|
||||
SplitString(ext, exts);
|
||||
if (addExt != 0)
|
||||
SplitString(addExt, addExts);
|
||||
for (int i = 0; i < exts.Size(); i++)
|
||||
@@ -236,19 +237,16 @@ HRESULT CCodecs::LoadFormats()
|
||||
{
|
||||
const NDLL::CLibrary &lib = Libs.Back().Lib;
|
||||
GetHandlerPropertyFunc getProp = 0;
|
||||
GetHandlerPropertyFunc2 getProp2 = (GetHandlerPropertyFunc2)
|
||||
lib.GetProcAddress("GetHandlerProperty2");
|
||||
GetHandlerPropertyFunc2 getProp2 = (GetHandlerPropertyFunc2)lib.GetProc("GetHandlerProperty2");
|
||||
if (getProp2 == NULL)
|
||||
{
|
||||
getProp = (GetHandlerPropertyFunc)
|
||||
lib.GetProcAddress("GetHandlerProperty");
|
||||
getProp = (GetHandlerPropertyFunc)lib.GetProc("GetHandlerProperty");
|
||||
if (getProp == NULL)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
UInt32 numFormats = 1;
|
||||
GetNumberOfFormatsFunc getNumberOfFormats = (GetNumberOfFormatsFunc)
|
||||
lib.GetProcAddress("GetNumberOfFormats");
|
||||
GetNumberOfFormatsFunc getNumberOfFormats = (GetNumberOfFormatsFunc)lib.GetProc("GetNumberOfFormats");
|
||||
if (getNumberOfFormats != NULL)
|
||||
{
|
||||
RINOK(getNumberOfFormats(&numFormats));
|
||||
@@ -294,37 +292,48 @@ HRESULT CCodecs::LoadFormats()
|
||||
}
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
void CCodecLib::LoadIcons()
|
||||
void CCodecIcons::LoadIcons(HMODULE m)
|
||||
{
|
||||
UString iconTypes = MyLoadStringW((HMODULE)Lib, kIconTypesResId);
|
||||
UString iconTypes = MyLoadStringW(m, kIconTypesResId);
|
||||
UStringVector pairs;
|
||||
SplitString(iconTypes, pairs);
|
||||
for (int i = 0; i < pairs.Size(); i++)
|
||||
{
|
||||
const UString &s = pairs[i];
|
||||
int pos = s.Find(L':');
|
||||
if (pos < 0)
|
||||
continue;
|
||||
CIconPair iconPair;
|
||||
const wchar_t *end;
|
||||
UString num = s.Mid(pos + 1);
|
||||
iconPair.IconIndex = (UInt32)ConvertStringToUInt64(num, &end);
|
||||
if (*end != L'\0')
|
||||
continue;
|
||||
iconPair.IconIndex = -1;
|
||||
if (pos < 0)
|
||||
pos = s.Length();
|
||||
else
|
||||
{
|
||||
UString num = s.Mid(pos + 1);
|
||||
if (!num.IsEmpty())
|
||||
{
|
||||
const wchar_t *end;
|
||||
iconPair.IconIndex = (UInt32)ConvertStringToUInt64(num, &end);
|
||||
if (*end != L'\0')
|
||||
continue;
|
||||
}
|
||||
}
|
||||
iconPair.Ext = s.Left(pos);
|
||||
IconPairs.Add(iconPair);
|
||||
}
|
||||
}
|
||||
|
||||
int CCodecLib::FindIconIndex(const UString &ext) const
|
||||
bool CCodecIcons::FindIconIndex(const UString &ext, int &iconIndex) const
|
||||
{
|
||||
iconIndex = -1;
|
||||
for (int i = 0; i < IconPairs.Size(); i++)
|
||||
{
|
||||
const CIconPair &pair = IconPairs[i];
|
||||
if (ext.CompareNoCase(pair.Ext) == 0)
|
||||
return pair.IconIndex;
|
||||
{
|
||||
iconIndex = pair.IconIndex;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -335,8 +344,9 @@ extern "C"
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT CCodecs::LoadDll(const CSysString &dllPath)
|
||||
HRESULT CCodecs::LoadDll(const CSysString &dllPath, bool needCheckDll)
|
||||
{
|
||||
if (needCheckDll)
|
||||
{
|
||||
NDLL::CLibrary library;
|
||||
if (!library.LoadEx(dllPath, LOAD_LIBRARY_AS_DATAFILE))
|
||||
@@ -358,13 +368,13 @@ HRESULT CCodecs::LoadDll(const CSysString &dllPath)
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
if (g_LargePageSize != 0)
|
||||
{
|
||||
SetLargePageModeFunc setLargePageMode = (SetLargePageModeFunc)lib.Lib.GetProcAddress("SetLargePageMode");
|
||||
SetLargePageModeFunc setLargePageMode = (SetLargePageModeFunc)lib.Lib.GetProc("SetLargePageMode");
|
||||
if (setLargePageMode != 0)
|
||||
setLargePageMode();
|
||||
}
|
||||
#endif
|
||||
|
||||
lib.CreateObject = (CreateObjectFunc)lib.Lib.GetProcAddress("CreateObject");
|
||||
lib.CreateObject = (CreateObjectFunc)lib.Lib.GetProc("CreateObject");
|
||||
if (lib.CreateObject != 0)
|
||||
{
|
||||
int startSize = Codecs.Size();
|
||||
@@ -391,7 +401,7 @@ HRESULT CCodecs::LoadDllsFromFolder(const CSysString &folderPrefix)
|
||||
{
|
||||
if (fi.IsDir())
|
||||
continue;
|
||||
RINOK(LoadDll(folderPrefix + fi.Name));
|
||||
RINOK(LoadDll(folderPrefix + fi.Name, true));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -408,6 +418,10 @@ static inline void SetBuffer(CByteBuffer &bb, const Byte *data, int size)
|
||||
|
||||
HRESULT CCodecs::Load()
|
||||
{
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
InternalIcons.LoadIcons(g_hInstance);
|
||||
#endif
|
||||
|
||||
Formats.Clear();
|
||||
#ifdef EXTERNAL_CODECS
|
||||
Codecs.Clear();
|
||||
@@ -430,7 +444,7 @@ HRESULT CCodecs::Load()
|
||||
}
|
||||
#ifdef EXTERNAL_CODECS
|
||||
const CSysString baseFolder = GetBaseFolderPrefixFromRegistry();
|
||||
RINOK(LoadDll(baseFolder + kMainDll));
|
||||
RINOK(LoadDll(baseFolder + kMainDll, false));
|
||||
RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName TEXT(STRING_PATH_SEPARATOR)));
|
||||
RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName TEXT(STRING_PATH_SEPARATOR)));
|
||||
#endif
|
||||
|
||||
@@ -102,21 +102,31 @@ typedef UInt32 (WINAPI *GetMethodPropertyFunc)(UInt32 index, PROPID propID, PROP
|
||||
typedef UInt32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *interfaceID, void **outObject);
|
||||
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
struct CCodecIcons
|
||||
{
|
||||
struct CIconPair
|
||||
{
|
||||
UString Ext;
|
||||
int IconIndex;
|
||||
};
|
||||
CObjectVector<CIconPair> IconPairs;
|
||||
void LoadIcons(HMODULE m);
|
||||
bool FindIconIndex(const UString &ext, int &iconIndex) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct CCodecLib
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
: public CCodecIcons
|
||||
#endif
|
||||
{
|
||||
NWindows::NDLL::CLibrary Lib;
|
||||
GetMethodPropertyFunc GetMethodProperty;
|
||||
CreateObjectFunc CreateObject;
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
struct CIconPair
|
||||
{
|
||||
UString Ext;
|
||||
UInt32 IconIndex;
|
||||
};
|
||||
CSysString Path;
|
||||
CObjectVector<CIconPair> IconPairs;
|
||||
void LoadIcons();
|
||||
int FindIconIndex(const UString &ext) const;
|
||||
void LoadIcons() { CCodecIcons::LoadIcons((HMODULE)Lib); }
|
||||
#endif
|
||||
CCodecLib(): GetMethodProperty(0) {}
|
||||
};
|
||||
@@ -134,9 +144,14 @@ public:
|
||||
#ifdef EXTERNAL_CODECS
|
||||
CObjectVector<CCodecLib> Libs;
|
||||
CObjectVector<CDllCodecInfo> Codecs;
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
CCodecIcons InternalIcons;
|
||||
#endif
|
||||
|
||||
HRESULT LoadCodecs();
|
||||
HRESULT LoadFormats();
|
||||
HRESULT LoadDll(const CSysString &path);
|
||||
HRESULT LoadDll(const CSysString &path, bool needCheckDll);
|
||||
HRESULT LoadDllsFromFolder(const CSysString &folderPrefix);
|
||||
|
||||
HRESULT CreateArchiveHandler(const CArcInfoEx &ai, void **archive, bool outHandler) const
|
||||
|
||||
@@ -94,6 +94,15 @@ static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UNDER_CE
|
||||
static const int kNumHashBytes = 1;
|
||||
#define HASH_VAL(buf, pos) ((buf)[pos])
|
||||
#else
|
||||
static const int kNumHashBytes = 2;
|
||||
#define HASH_VAL(buf, pos) ((buf)[pos] | ((UInt32)(buf)[pos + 1] << 8))
|
||||
#endif
|
||||
|
||||
|
||||
HRESULT CArc::OpenStream(
|
||||
CCodecs *codecs,
|
||||
int formatIndex,
|
||||
@@ -144,30 +153,33 @@ HRESULT CArc::OpenStream(
|
||||
return S_FALSE;
|
||||
|
||||
const Byte *buf = byteBuffer;
|
||||
Byte hash[1 << 16];
|
||||
memset(hash, 0xFF, 1 << 16);
|
||||
CByteBuffer hashBuffer;
|
||||
const UInt32 kNumVals = 1 << (kNumHashBytes * 8);
|
||||
hashBuffer.SetCapacity(kNumVals);
|
||||
Byte *hash = hashBuffer;
|
||||
memset(hash, 0xFF, kNumVals);
|
||||
Byte prevs[256];
|
||||
if (orderIndices.Size() > 255)
|
||||
if (orderIndices.Size() >= 256)
|
||||
return S_FALSE;
|
||||
int i;
|
||||
for (i = 0; i < orderIndices.Size(); i++)
|
||||
{
|
||||
const CArcInfoEx &ai = codecs->Formats[orderIndices[i]];
|
||||
const CByteBuffer &sig = ai.StartSignature;
|
||||
if (sig.GetCapacity() < 2)
|
||||
if (sig.GetCapacity() < kNumHashBytes)
|
||||
continue;
|
||||
UInt32 v = sig[0] | ((UInt32)sig[1] << 8);
|
||||
UInt32 v = HASH_VAL(sig, 0);
|
||||
prevs[i] = hash[v];
|
||||
hash[v] = (Byte)i;
|
||||
}
|
||||
|
||||
processedSize--;
|
||||
processedSize -= (kNumHashBytes - 1);
|
||||
for (UInt32 pos = 0; pos < processedSize; pos++)
|
||||
{
|
||||
for (; pos < processedSize && hash[buf[pos] | ((UInt32)buf[pos + 1] << 8)] == 0xFF; pos++);
|
||||
for (; pos < processedSize && hash[HASH_VAL(buf, pos)] == 0xFF; pos++);
|
||||
if (pos == processedSize)
|
||||
break;
|
||||
UInt32 v = buf[pos] | ((UInt32)buf[pos + 1] << 8);
|
||||
UInt32 v = HASH_VAL(buf, pos);
|
||||
Byte *ptr = &hash[v];
|
||||
int i = *ptr;
|
||||
do
|
||||
@@ -175,14 +187,15 @@ HRESULT CArc::OpenStream(
|
||||
int index = orderIndices[i];
|
||||
const CArcInfoEx &ai = codecs->Formats[index];
|
||||
const CByteBuffer &sig = ai.StartSignature;
|
||||
if (sig.GetCapacity() != 0 && pos + sig.GetCapacity() <= processedSize + 1)
|
||||
if (TestSignature(buf + pos, sig, sig.GetCapacity()))
|
||||
{
|
||||
orderIndices2.Add(index);
|
||||
orderIndices[i] = 0xFF;
|
||||
*ptr = prevs[i];
|
||||
}
|
||||
ptr = &prevs[i];
|
||||
if (sig.GetCapacity() != 0 && pos + sig.GetCapacity() <= processedSize + (kNumHashBytes - 1) &&
|
||||
TestSignature(buf + pos, sig, sig.GetCapacity()))
|
||||
{
|
||||
orderIndices2.Add(index);
|
||||
orderIndices[i] = 0xFF;
|
||||
*ptr = prevs[i];
|
||||
}
|
||||
else
|
||||
ptr = &prevs[i];
|
||||
i = *ptr;
|
||||
}
|
||||
while (i != 0xFF);
|
||||
@@ -323,6 +336,15 @@ HRESULT CArc::OpenStreamOrFile(
|
||||
stream = fileStream;
|
||||
}
|
||||
|
||||
/*
|
||||
if (callback)
|
||||
{
|
||||
UInt64 fileSize;
|
||||
RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
|
||||
RINOK(callback->SetTotal(NULL, &fileSize))
|
||||
}
|
||||
*/
|
||||
|
||||
return OpenStream(codecs, formatIndex, stream, seqStream, callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -439,7 +439,7 @@ static HRESULT Compress(
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.FileName = realPath;
|
||||
errorInfo.Message = L"Can not open file";
|
||||
errorInfo.Message = L"7-Zip cannot open file";
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
@@ -472,7 +472,7 @@ static HRESULT Compress(
|
||||
if (!sfxStreamSpec->Open(sfxModule))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"Can't open sfx module";
|
||||
errorInfo.Message = L"7-Zip cannot open SFX module";
|
||||
errorInfo.FileName = sfxModule;
|
||||
return E_FAIL;
|
||||
}
|
||||
@@ -490,7 +490,7 @@ static HRESULT Compress(
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.FileName = realPath;
|
||||
errorInfo.Message = L"Can not open file";
|
||||
errorInfo.Message = L"7-Zip cannot open file";
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
@@ -606,17 +606,14 @@ static HRESULT UpdateWithItemLists(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
class CCurrentDirRestorer
|
||||
{
|
||||
UString m_CurrentDirectory;
|
||||
UString _path;
|
||||
public:
|
||||
CCurrentDirRestorer()
|
||||
{ NFile::NDirectory::MyGetCurrentDirectory(m_CurrentDirectory); }
|
||||
~CCurrentDirRestorer()
|
||||
{ RestoreDirectory();}
|
||||
bool RestoreDirectory()
|
||||
{ return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(m_CurrentDirectory)); }
|
||||
CCurrentDirRestorer() { NFile::NDirectory::MyGetCurrentDirectory(_path); }
|
||||
~CCurrentDirRestorer() { RestoreDirectory();}
|
||||
bool RestoreDirectory() { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(_path)); }
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -662,13 +659,19 @@ HRESULT UpdateArchive(
|
||||
options.MethodMode.Properties.Add(property);
|
||||
if (options.SfxModule.IsEmpty())
|
||||
{
|
||||
errorInfo.Message = L"sfx file is not specified";
|
||||
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
|
||||
{
|
||||
errorInfo.Message = L"can't find specified sfx module";
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"7-Zip cannot find specified SFX module";
|
||||
errorInfo.FileName = name;
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
@@ -744,7 +747,6 @@ HRESULT UpdateArchive(
|
||||
{
|
||||
if (res != E_ABORT)
|
||||
errorInfo.Message = L"Scanning error";
|
||||
// errorInfo.FileName = errorPath;
|
||||
return res;
|
||||
}
|
||||
RINOK(callback->FinishScanning());
|
||||
@@ -804,7 +806,7 @@ HRESULT UpdateArchive(
|
||||
if (NFind::DoesFileOrDirExist(path))
|
||||
{
|
||||
errorInfo.SystemError = 0;
|
||||
errorInfo.Message = L"File already exists";
|
||||
errorInfo.Message = L"The file already exists";
|
||||
errorInfo.FileName = path;
|
||||
return E_FAIL;
|
||||
}
|
||||
@@ -839,14 +841,14 @@ HRESULT UpdateArchive(
|
||||
if (!NDirectory::DeleteFileAlways(archiveName))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"delete file error";
|
||||
errorInfo.Message = L"7-Zip cannot delete the file";
|
||||
errorInfo.FileName = archiveName;
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!NDirectory::MyMoveFile(tempPath, archiveName))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"move file error";
|
||||
errorInfo.Message = L"7-Zip cannot move the file";
|
||||
errorInfo.FileName = tempPath;
|
||||
errorInfo.FileName2 = archiveName;
|
||||
return E_FAIL;
|
||||
@@ -858,22 +860,21 @@ HRESULT UpdateArchive(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
if (options.EMailMode)
|
||||
{
|
||||
NDLL::CLibrary mapiLib;
|
||||
if (!mapiLib.Load(TEXT("Mapi32.dll")))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"can not load Mapi32.dll";
|
||||
errorInfo.Message = L"7-Zip cannot load Mapi32.dll";
|
||||
return E_FAIL;
|
||||
}
|
||||
MY_LPMAPISENDDOCUMENTS fnSend = (MY_LPMAPISENDDOCUMENTS)
|
||||
mapiLib.GetProcAddress("MAPISendDocuments");
|
||||
MY_LPMAPISENDDOCUMENTS fnSend = (MY_LPMAPISENDDOCUMENTS)mapiLib.GetProc("MAPISendDocuments");
|
||||
if (fnSend == 0)
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"can not find MAPISendDocuments function";
|
||||
errorInfo.Message = L"7-Zip cannot find MAPISendDocuments function";
|
||||
return E_FAIL;
|
||||
}
|
||||
UStringVector fullPaths;
|
||||
@@ -885,6 +886,7 @@ HRESULT UpdateArchive(
|
||||
if (!NFile::NDirectory::MyGetFullPathName(ap.GetFinalPath(), arcPath))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"GetFullPathName error";
|
||||
return E_FAIL;
|
||||
}
|
||||
fullPaths.Add(arcPath);
|
||||
|
||||
@@ -122,6 +122,15 @@ struct CUpdateOptions
|
||||
EMailRemoveAfter(false),
|
||||
OpenShareForWrite(false)
|
||||
{};
|
||||
|
||||
void SetAddActionCommand()
|
||||
{
|
||||
Commands.Clear();
|
||||
CUpdateArchiveCommand c;
|
||||
c.ActionSet = NUpdateArchive::kAddActionSet;
|
||||
Commands.Add(c);
|
||||
}
|
||||
|
||||
CRecordVector<UInt64> VolumesSizes;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,31 +2,28 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "WorkDir.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Wildcard.h"
|
||||
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
|
||||
static inline UINT GetCurrentCodePage()
|
||||
{ return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
#include "WorkDir.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NName;
|
||||
|
||||
UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
|
||||
{
|
||||
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'\\')
|
||||
{
|
||||
UINT driveType = GetDriveType(GetSystemString(prefix, GetCurrentCodePage()));
|
||||
UINT driveType = GetDriveType(GetSystemString(prefix, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP));
|
||||
if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE)
|
||||
mode = workDirInfo.Mode;
|
||||
}
|
||||
@@ -38,6 +35,7 @@ UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
|
||||
mode = NZipSettings::NWorkDir::NMode::kCurrent;
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
switch(mode)
|
||||
{
|
||||
case NWorkDir::NMode::kCurrent:
|
||||
@@ -47,18 +45,15 @@ UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
|
||||
case NWorkDir::NMode::kSpecified:
|
||||
{
|
||||
UString tempDir = workDirInfo.Path;
|
||||
NormalizeDirPathPrefix(tempDir);
|
||||
NName::NormalizeDirPathPrefix(tempDir);
|
||||
return tempDir;
|
||||
}
|
||||
default:
|
||||
{
|
||||
UString tempDir;
|
||||
if(!NFile::NDirectory::MyGetTempPath(tempDir))
|
||||
if (!NDirectory::MyGetTempPath(tempDir))
|
||||
throw 141717;
|
||||
return tempDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,142 +2,101 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ZipRegistry.h"
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Synchronization.h"
|
||||
#include "Windows/Registry.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Registry.h"
|
||||
#include "Windows/Synchronization.h"
|
||||
|
||||
#include "ZipRegistry.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NRegistry;
|
||||
|
||||
static const TCHAR *kCUBasePath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP");
|
||||
static NSynchronization::CCriticalSection g_CS;
|
||||
#define CS_LOCK NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
|
||||
static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection;
|
||||
static const TCHAR *kCuPrefix = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR);
|
||||
|
||||
//////////////////////
|
||||
// ExtractionInfo
|
||||
static CSysString GetKeyPath(const CSysString &path) { return kCuPrefix + path; }
|
||||
|
||||
static const TCHAR *kExtractionKeyName = TEXT("Extraction");
|
||||
|
||||
static const TCHAR *kExtractionPathHistoryKeyName = TEXT("PathHistory");
|
||||
static const TCHAR *kExtractionExtractModeValueName = TEXT("ExtarctMode");
|
||||
static const TCHAR *kExtractionOverwriteModeValueName = TEXT("OverwriteMode");
|
||||
static const TCHAR *kExtractionShowPasswordValueName = TEXT("ShowPassword");
|
||||
|
||||
static CSysString GetKeyPath(const CSysString &path)
|
||||
static LONG OpenMainKey(CKey &key, LPCTSTR keyName)
|
||||
{
|
||||
return CSysString(kCUBasePath) + CSysString(CHAR_PATH_SEPARATOR) + path;
|
||||
return key.Open(HKEY_CURRENT_USER, GetKeyPath(keyName), KEY_READ);
|
||||
}
|
||||
|
||||
void SaveExtractionInfo(const NExtract::CInfo &info)
|
||||
static LONG CreateMainKey(CKey &key, LPCTSTR keyName)
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey extractionKey;
|
||||
extractionKey.Create(HKEY_CURRENT_USER, GetKeyPath(kExtractionKeyName));
|
||||
extractionKey.RecurseDeleteKey(kExtractionPathHistoryKeyName);
|
||||
{
|
||||
CKey pathHistoryKey;
|
||||
pathHistoryKey.Create(extractionKey, kExtractionPathHistoryKeyName);
|
||||
for(int i = 0; i < info.Paths.Size(); i++)
|
||||
{
|
||||
wchar_t numberString[16];
|
||||
ConvertUInt32ToString(i, numberString);
|
||||
pathHistoryKey.SetValue(numberString, info.Paths[i]);
|
||||
}
|
||||
}
|
||||
extractionKey.SetValue(kExtractionExtractModeValueName, UInt32(info.PathMode));
|
||||
extractionKey.SetValue(kExtractionOverwriteModeValueName, UInt32(info.OverwriteMode));
|
||||
extractionKey.SetValue(kExtractionShowPasswordValueName, info.ShowPassword);
|
||||
return key.Create(HKEY_CURRENT_USER, GetKeyPath(keyName));
|
||||
}
|
||||
|
||||
void ReadExtractionInfo(NExtract::CInfo &info)
|
||||
namespace NExtract
|
||||
{
|
||||
info.Paths.Clear();
|
||||
info.PathMode = NExtract::NPathMode::kCurrentPathnames;
|
||||
info.OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
|
||||
info.ShowPassword = false;
|
||||
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey extractionKey;
|
||||
if(extractionKey.Open(HKEY_CURRENT_USER, GetKeyPath(kExtractionKeyName), KEY_READ) != ERROR_SUCCESS)
|
||||
static const TCHAR *kKeyName = TEXT("Extraction");
|
||||
|
||||
static const TCHAR *kExtractMode = TEXT("ExtractMode");
|
||||
static const TCHAR *kOverwriteMode = TEXT("OverwriteMode");
|
||||
static const TCHAR *kShowPassword = TEXT("ShowPassword");
|
||||
static const TCHAR *kPathHistory = TEXT("PathHistory");
|
||||
|
||||
void CInfo::Save() const
|
||||
{
|
||||
CS_LOCK
|
||||
CKey key;
|
||||
CreateMainKey(key, kKeyName);
|
||||
key.SetValue(kExtractMode, (UInt32)PathMode);
|
||||
key.SetValue(kOverwriteMode, (UInt32)OverwriteMode);
|
||||
key.SetValue(kShowPassword, ShowPassword);
|
||||
key.RecurseDeleteKey(kPathHistory);
|
||||
key.SetValue_Strings(kPathHistory, Paths);
|
||||
}
|
||||
|
||||
|
||||
void CInfo::Load()
|
||||
{
|
||||
PathMode = NPathMode::kCurrentPathnames;
|
||||
OverwriteMode = NOverwriteMode::kAskBefore;
|
||||
ShowPassword = false;
|
||||
Paths.Clear();
|
||||
|
||||
CS_LOCK
|
||||
CKey key;
|
||||
if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
{
|
||||
CKey pathHistoryKey;
|
||||
if(pathHistoryKey.Open(extractionKey, kExtractionPathHistoryKeyName, KEY_READ) ==
|
||||
ERROR_SUCCESS)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
wchar_t numberString[16];
|
||||
ConvertUInt32ToString(info.Paths.Size(), numberString);
|
||||
UString path;
|
||||
if (pathHistoryKey.QueryValue(numberString, path) != ERROR_SUCCESS)
|
||||
break;
|
||||
info.Paths.Add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
UInt32 extractModeIndex;
|
||||
if (extractionKey.QueryValue(kExtractionExtractModeValueName, extractModeIndex) == ERROR_SUCCESS)
|
||||
{
|
||||
switch (extractModeIndex)
|
||||
{
|
||||
case NExtract::NPathMode::kFullPathnames:
|
||||
case NExtract::NPathMode::kCurrentPathnames:
|
||||
case NExtract::NPathMode::kNoPathnames:
|
||||
info.PathMode = NExtract::NPathMode::EEnum(extractModeIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
UInt32 overwriteModeIndex;
|
||||
if (extractionKey.QueryValue(kExtractionOverwriteModeValueName, overwriteModeIndex) == ERROR_SUCCESS)
|
||||
{
|
||||
switch (overwriteModeIndex)
|
||||
{
|
||||
case NExtract::NOverwriteMode::kAskBefore:
|
||||
case NExtract::NOverwriteMode::kWithoutPrompt:
|
||||
case NExtract::NOverwriteMode::kSkipExisting:
|
||||
case NExtract::NOverwriteMode::kAutoRename:
|
||||
case NExtract::NOverwriteMode::kAutoRenameExisting:
|
||||
info.OverwriteMode = NExtract::NOverwriteMode::EEnum(overwriteModeIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (extractionKey.QueryValue(kExtractionShowPasswordValueName,
|
||||
info.ShowPassword) != ERROR_SUCCESS)
|
||||
info.ShowPassword = false;
|
||||
key.GetValue_Strings(kPathHistory, Paths);
|
||||
UInt32 v;
|
||||
if (key.QueryValue(kExtractMode, v) == ERROR_SUCCESS && v <= NPathMode::kNoPathnames)
|
||||
PathMode = (NPathMode::EEnum)v;
|
||||
if (key.QueryValue(kOverwriteMode, v) == ERROR_SUCCESS && v <= NOverwriteMode::kAutoRenameExisting)
|
||||
OverwriteMode = (NOverwriteMode::EEnum)v;
|
||||
key.GetValue_IfOk(kShowPassword, ShowPassword);
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// CompressionInfo
|
||||
}
|
||||
|
||||
static const TCHAR *kCompressionKeyName = TEXT("Compression");
|
||||
namespace NCompression
|
||||
{
|
||||
|
||||
static const TCHAR *kCompressionHistoryArchivesKeyName = TEXT("ArcHistory");
|
||||
static const TCHAR *kCompressionLevelValueName = TEXT("Level");
|
||||
static const TCHAR *kCompressionLastFormatValueName = TEXT("Archiver");
|
||||
static const TCHAR *kCompressionShowPasswordValueName = TEXT("ShowPassword");
|
||||
static const TCHAR *kCompressionEncryptHeadersValueName = TEXT("EncryptHeaders");
|
||||
static const TCHAR *kKeyName = TEXT("Compression");
|
||||
|
||||
static const TCHAR *kCompressionOptionsKeyName = TEXT("Options");
|
||||
// static const TCHAR *kSolid = TEXT("Solid");
|
||||
// static const TCHAR *kMultiThread = TEXT("Multithread");
|
||||
static const TCHAR *kArcHistory = TEXT("ArcHistory");
|
||||
static const WCHAR *kArchiver = L"Archiver";
|
||||
static const TCHAR *kShowPassword = TEXT("ShowPassword");
|
||||
static const TCHAR *kEncryptHeaders = TEXT("EncryptHeaders");
|
||||
|
||||
static const WCHAR *kCompressionOptions = L"Options";
|
||||
static const TCHAR *kCompressionLevel = TEXT("Level");
|
||||
static const WCHAR *kCompressionMethod = L"Method";
|
||||
static const TCHAR *kOptionsKeyName = TEXT("Options");
|
||||
|
||||
static const TCHAR *kLevel = TEXT("Level");
|
||||
static const TCHAR *kDictionary = TEXT("Dictionary");
|
||||
static const TCHAR *kOrder = TEXT("Order");
|
||||
static const TCHAR *kBlockSize = TEXT("BlockSize");
|
||||
static const TCHAR *kNumThreads = TEXT("NumThreads");
|
||||
static const WCHAR *kMethod = L"Method";
|
||||
static const WCHAR *kOptions = L"Options";
|
||||
static const WCHAR *kEncryptionMethod = L"EncryptionMethod";
|
||||
static const TCHAR *kCompressionDictionary = TEXT("Dictionary");
|
||||
static const TCHAR *kCompressionOrder = TEXT("Order");
|
||||
static const TCHAR *kCompressionNumThreads = TEXT("NumThreads");
|
||||
static const TCHAR *kCompressionBlockSize = TEXT("BlockSize");
|
||||
|
||||
|
||||
static void SetRegString(CKey &key, const WCHAR *name, const UString &value)
|
||||
{
|
||||
@@ -164,254 +123,171 @@ static void GetRegString(CKey &key, const WCHAR *name, UString &value)
|
||||
static void GetRegUInt32(CKey &key, const TCHAR *name, UInt32 &value)
|
||||
{
|
||||
if (key.QueryValue(name, value) != ERROR_SUCCESS)
|
||||
value = UInt32(-1);
|
||||
value = (UInt32)-1;
|
||||
}
|
||||
|
||||
void SaveCompressionInfo(const NCompression::CInfo &info)
|
||||
void CInfo::Save() const
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CS_LOCK
|
||||
|
||||
CKey compressionKey;
|
||||
compressionKey.Create(HKEY_CURRENT_USER, GetKeyPath(kCompressionKeyName));
|
||||
compressionKey.RecurseDeleteKey(kCompressionHistoryArchivesKeyName);
|
||||
{
|
||||
CKey historyArchivesKey;
|
||||
historyArchivesKey.Create(compressionKey, kCompressionHistoryArchivesKeyName);
|
||||
for(int i = 0; i < info.HistoryArchives.Size(); i++)
|
||||
{
|
||||
wchar_t numberString[16];
|
||||
ConvertUInt32ToString(i, numberString);
|
||||
historyArchivesKey.SetValue(numberString, info.HistoryArchives[i]);
|
||||
}
|
||||
}
|
||||
CKey key;
|
||||
CreateMainKey(key, kKeyName);
|
||||
key.SetValue(kLevel, (UInt32)Level);
|
||||
key.SetValue(kArchiver, ArcType);
|
||||
key.SetValue(kShowPassword, ShowPassword);
|
||||
key.SetValue(kEncryptHeaders, EncryptHeaders);
|
||||
key.RecurseDeleteKey(kArcHistory);
|
||||
key.SetValue_Strings(kArcHistory, ArcPaths);
|
||||
|
||||
// compressionKey.SetValue(kSolid, info.Solid);
|
||||
// compressionKey.SetValue(kMultiThread, info.MultiThread);
|
||||
compressionKey.RecurseDeleteKey(kCompressionOptionsKeyName);
|
||||
key.RecurseDeleteKey(kOptionsKeyName);
|
||||
{
|
||||
CKey optionsKey;
|
||||
optionsKey.Create(compressionKey, kCompressionOptionsKeyName);
|
||||
for(int i = 0; i < info.FormatOptionsVector.Size(); i++)
|
||||
optionsKey.Create(key, kOptionsKeyName);
|
||||
for (int i = 0; i < Formats.Size(); i++)
|
||||
{
|
||||
const NCompression::CFormatOptions &fo = info.FormatOptionsVector[i];
|
||||
CKey formatKey;
|
||||
formatKey.Create(optionsKey, fo.FormatID);
|
||||
const CFormatOptions &fo = Formats[i];
|
||||
CKey fk;
|
||||
fk.Create(optionsKey, fo.FormatID);
|
||||
|
||||
SetRegString(formatKey, kCompressionOptions, fo.Options);
|
||||
SetRegString(formatKey, kCompressionMethod, fo.Method);
|
||||
SetRegString(formatKey, kEncryptionMethod, fo.EncryptionMethod);
|
||||
SetRegUInt32(fk, kLevel, fo.Level);
|
||||
SetRegUInt32(fk, kDictionary, fo.Dictionary);
|
||||
SetRegUInt32(fk, kOrder, fo.Order);
|
||||
SetRegUInt32(fk, kBlockSize, fo.BlockLogSize);
|
||||
SetRegUInt32(fk, kNumThreads, fo.NumThreads);
|
||||
|
||||
SetRegUInt32(formatKey, kCompressionLevel, fo.Level);
|
||||
SetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary);
|
||||
SetRegUInt32(formatKey, kCompressionOrder, fo.Order);
|
||||
SetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize);
|
||||
SetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads);
|
||||
SetRegString(fk, kMethod, fo.Method);
|
||||
SetRegString(fk, kOptions, fo.Options);
|
||||
SetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
|
||||
}
|
||||
}
|
||||
|
||||
compressionKey.SetValue(kCompressionLevelValueName, UInt32(info.Level));
|
||||
compressionKey.SetValue(kCompressionLastFormatValueName, GetSystemString(info.ArchiveType));
|
||||
|
||||
compressionKey.SetValue(kCompressionShowPasswordValueName, info.ShowPassword);
|
||||
compressionKey.SetValue(kCompressionEncryptHeadersValueName, info.EncryptHeaders);
|
||||
// compressionKey.SetValue(kCompressionMaximizeValueName, info.Maximize);
|
||||
}
|
||||
|
||||
void ReadCompressionInfo(NCompression::CInfo &info)
|
||||
void CInfo::Load()
|
||||
{
|
||||
info.HistoryArchives.Clear();
|
||||
ArcPaths.Clear();
|
||||
Formats.Clear();
|
||||
|
||||
// info.Solid = true;
|
||||
// info.MultiThread = IsMultiProcessor();
|
||||
info.FormatOptionsVector.Clear();
|
||||
Level = 5;
|
||||
ArcType = L"7z";
|
||||
ShowPassword = false;
|
||||
EncryptHeaders = false;
|
||||
|
||||
info.Level = 5;
|
||||
info.ArchiveType = L"7z";
|
||||
// definedStatus.Maximize = false;
|
||||
info.ShowPassword = false;
|
||||
info.EncryptHeaders = false;
|
||||
CS_LOCK
|
||||
CKey key;
|
||||
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey compressionKey;
|
||||
|
||||
if(compressionKey.Open(HKEY_CURRENT_USER,
|
||||
GetKeyPath(kCompressionKeyName), KEY_READ) != ERROR_SUCCESS)
|
||||
if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
{
|
||||
CKey historyArchivesKey;
|
||||
if(historyArchivesKey.Open(compressionKey, kCompressionHistoryArchivesKeyName, KEY_READ) ==
|
||||
ERROR_SUCCESS)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
wchar_t numberString[16];
|
||||
ConvertUInt32ToString(info.HistoryArchives.Size(), numberString);
|
||||
UString path;
|
||||
if (historyArchivesKey.QueryValue(numberString, path) != ERROR_SUCCESS)
|
||||
break;
|
||||
info.HistoryArchives.Add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
key.GetValue_Strings(kArcHistory, ArcPaths);
|
||||
|
||||
/*
|
||||
bool solid = false;
|
||||
if (compressionKey.QueryValue(kSolid, solid) == ERROR_SUCCESS)
|
||||
info.Solid = solid;
|
||||
bool multiThread = false;
|
||||
if (compressionKey.QueryValue(kMultiThread, multiThread) == ERROR_SUCCESS)
|
||||
info.MultiThread = multiThread;
|
||||
*/
|
||||
|
||||
{
|
||||
CKey optionsKey;
|
||||
if(optionsKey.Open(compressionKey, kCompressionOptionsKeyName, KEY_READ) ==
|
||||
ERROR_SUCCESS)
|
||||
if (optionsKey.Open(key, kOptionsKeyName, KEY_READ) == ERROR_SUCCESS)
|
||||
{
|
||||
CSysStringVector formatIDs;
|
||||
optionsKey.EnumKeys(formatIDs);
|
||||
for(int i = 0; i < formatIDs.Size(); i++)
|
||||
for (int i = 0; i < formatIDs.Size(); i++)
|
||||
{
|
||||
CKey formatKey;
|
||||
NCompression::CFormatOptions fo;
|
||||
CKey fk;
|
||||
CFormatOptions fo;
|
||||
fo.FormatID = formatIDs[i];
|
||||
if(formatKey.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS)
|
||||
if (fk.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS)
|
||||
{
|
||||
GetRegString(formatKey, kCompressionOptions, fo.Options);
|
||||
GetRegString(formatKey, kCompressionMethod, fo.Method);
|
||||
GetRegString(formatKey, kEncryptionMethod, fo.EncryptionMethod);
|
||||
GetRegString(fk, kOptions, fo.Options);
|
||||
GetRegString(fk, kMethod, fo.Method);
|
||||
GetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
|
||||
|
||||
GetRegUInt32(formatKey, kCompressionLevel, fo.Level);
|
||||
GetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary);
|
||||
GetRegUInt32(formatKey, kCompressionOrder, fo.Order);
|
||||
GetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize);
|
||||
GetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads);
|
||||
GetRegUInt32(fk, kLevel, fo.Level);
|
||||
GetRegUInt32(fk, kDictionary, fo.Dictionary);
|
||||
GetRegUInt32(fk, kOrder, fo.Order);
|
||||
GetRegUInt32(fk, kBlockSize, fo.BlockLogSize);
|
||||
GetRegUInt32(fk, kNumThreads, fo.NumThreads);
|
||||
|
||||
info.FormatOptionsVector.Add(fo);
|
||||
Formats.Add(fo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 level;
|
||||
if (compressionKey.QueryValue(kCompressionLevelValueName, level) == ERROR_SUCCESS)
|
||||
info.Level = level;
|
||||
CSysString archiveType;
|
||||
if (compressionKey.QueryValue(kCompressionLastFormatValueName, archiveType) == ERROR_SUCCESS)
|
||||
info.ArchiveType = GetUnicodeString(archiveType);
|
||||
if (compressionKey.QueryValue(kCompressionShowPasswordValueName,
|
||||
info.ShowPassword) != ERROR_SUCCESS)
|
||||
info.ShowPassword = false;
|
||||
if (compressionKey.QueryValue(kCompressionEncryptHeadersValueName,
|
||||
info.EncryptHeaders) != ERROR_SUCCESS)
|
||||
info.EncryptHeaders = false;
|
||||
/*
|
||||
if (compressionKey.QueryValue(kCompressionLevelValueName, info.Maximize) == ERROR_SUCCESS)
|
||||
definedStatus.Maximize = true;
|
||||
*/
|
||||
UString a;
|
||||
if (key.QueryValue(kArchiver, a) == ERROR_SUCCESS)
|
||||
ArcType = a;
|
||||
key.GetValue_IfOk(kLevel, Level);
|
||||
key.GetValue_IfOk(kShowPassword, ShowPassword);
|
||||
key.GetValue_IfOk(kEncryptHeaders, EncryptHeaders);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// WorkDirInfo
|
||||
}
|
||||
|
||||
static const TCHAR *kOptionsInfoKeyName = TEXT("Options");
|
||||
|
||||
static const TCHAR *kWorkDirTypeValueName = TEXT("WorkDirType");
|
||||
static const WCHAR *kWorkDirPathValueName = L"WorkDirPath";
|
||||
static const TCHAR *kTempRemovableOnlyValueName = TEXT("TempRemovableOnly");
|
||||
static const TCHAR *kCascadedMenuValueName = TEXT("CascadedMenu");
|
||||
static const TCHAR *kContextMenuValueName = TEXT("ContextMenu");
|
||||
|
||||
void SaveWorkDirInfo(const NWorkDir::CInfo &info)
|
||||
namespace NWorkDir
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey optionsKey;
|
||||
optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName));
|
||||
optionsKey.SetValue(kWorkDirTypeValueName, UInt32(info.Mode));
|
||||
optionsKey.SetValue(kWorkDirPathValueName, info.Path);
|
||||
optionsKey.SetValue(kTempRemovableOnlyValueName, info.ForRemovableOnly);
|
||||
static const TCHAR *kWorkDirType = TEXT("WorkDirType");
|
||||
static const WCHAR *kWorkDirPath = L"WorkDirPath";
|
||||
static const TCHAR *kTempRemovableOnly = TEXT("TempRemovableOnly");
|
||||
|
||||
|
||||
void CInfo::Save()const
|
||||
{
|
||||
CS_LOCK
|
||||
CKey key;
|
||||
CreateMainKey(key, kOptionsInfoKeyName);
|
||||
key.SetValue(kWorkDirType, (UInt32)Mode);
|
||||
key.SetValue(kWorkDirPath, Path);
|
||||
key.SetValue(kTempRemovableOnly, ForRemovableOnly);
|
||||
}
|
||||
|
||||
void ReadWorkDirInfo(NWorkDir::CInfo &info)
|
||||
void CInfo::Load()
|
||||
{
|
||||
info.SetDefault();
|
||||
SetDefault();
|
||||
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey optionsKey;
|
||||
if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS)
|
||||
CS_LOCK
|
||||
CKey key;
|
||||
if (OpenMainKey(key, kOptionsInfoKeyName) != ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
UInt32 dirType;
|
||||
if (optionsKey.QueryValue(kWorkDirTypeValueName, dirType) != ERROR_SUCCESS)
|
||||
if (key.QueryValue(kWorkDirType, dirType) != ERROR_SUCCESS)
|
||||
return;
|
||||
switch (dirType)
|
||||
{
|
||||
case NWorkDir::NMode::kSystem:
|
||||
case NWorkDir::NMode::kCurrent:
|
||||
case NWorkDir::NMode::kSpecified:
|
||||
info.Mode = NWorkDir::NMode::EEnum(dirType);
|
||||
case NMode::kSystem:
|
||||
case NMode::kCurrent:
|
||||
case NMode::kSpecified:
|
||||
Mode = (NMode::EEnum)dirType;
|
||||
}
|
||||
UString sysWorkDir;
|
||||
if (optionsKey.QueryValue(kWorkDirPathValueName, sysWorkDir) != ERROR_SUCCESS)
|
||||
if (key.QueryValue(kWorkDirPath, Path) != ERROR_SUCCESS)
|
||||
{
|
||||
info.Path.Empty();
|
||||
if (info.Mode == NWorkDir::NMode::kSpecified)
|
||||
info.Mode = NWorkDir::NMode::kSystem;
|
||||
Path.Empty();
|
||||
if (Mode == NMode::kSpecified)
|
||||
Mode = NMode::kSystem;
|
||||
}
|
||||
info.Path = GetUnicodeString(sysWorkDir);
|
||||
if (optionsKey.QueryValue(kTempRemovableOnlyValueName, info.ForRemovableOnly) != ERROR_SUCCESS)
|
||||
info.SetForRemovableOnlyDefault();
|
||||
key.GetValue_IfOk(kTempRemovableOnly, ForRemovableOnly);
|
||||
}
|
||||
|
||||
static void SaveOption(const TCHAR *value, bool enabled)
|
||||
}
|
||||
|
||||
static const TCHAR *kCascadedMenu = TEXT("CascadedMenu");
|
||||
static const TCHAR *kContextMenu = TEXT("ContextMenu");
|
||||
|
||||
void CContextMenuInfo::Save() const
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey optionsKey;
|
||||
optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName));
|
||||
optionsKey.SetValue(value, enabled);
|
||||
CS_LOCK
|
||||
CKey key;
|
||||
CreateMainKey(key, kOptionsInfoKeyName);
|
||||
key.SetValue(kCascadedMenu, Cascaded);
|
||||
key.SetValue(kContextMenu, Flags);
|
||||
}
|
||||
|
||||
static bool ReadOption(const TCHAR *value, bool defaultValue)
|
||||
void CContextMenuInfo::Load()
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey optionsKey;
|
||||
if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS)
|
||||
return defaultValue;
|
||||
bool enabled;
|
||||
if (optionsKey.QueryValue(value, enabled) != ERROR_SUCCESS)
|
||||
return defaultValue;
|
||||
return enabled;
|
||||
Cascaded = true;
|
||||
Flags = (UInt32)-1;
|
||||
CS_LOCK
|
||||
CKey key;
|
||||
if (OpenMainKey(key, kOptionsInfoKeyName) != ERROR_SUCCESS)
|
||||
return;
|
||||
key.GetValue_IfOk(kCascadedMenu, Cascaded);
|
||||
key.GetValue_IfOk(kContextMenu, Flags);
|
||||
}
|
||||
|
||||
void SaveCascadedMenu(bool show)
|
||||
{ SaveOption(kCascadedMenuValueName, show); }
|
||||
bool ReadCascadedMenu()
|
||||
{ return ReadOption(kCascadedMenuValueName, true); }
|
||||
|
||||
|
||||
static void SaveValue(const TCHAR *value, UInt32 valueToWrite)
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey optionsKey;
|
||||
optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName));
|
||||
optionsKey.SetValue(value, valueToWrite);
|
||||
}
|
||||
|
||||
static bool ReadValue(const TCHAR *value, UInt32 &result)
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey optionsKey;
|
||||
if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS)
|
||||
return false;
|
||||
return (optionsKey.QueryValue(value, result) == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
void SaveContextMenuStatus(UInt32 value)
|
||||
{ SaveValue(kContextMenuValueName, value); }
|
||||
|
||||
bool ReadContextMenuStatus(UInt32 &value)
|
||||
{ return ReadValue(kContextMenuValueName, value); }
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// ZipRegistry.h
|
||||
|
||||
#ifndef __ZIPREGISTRY_H
|
||||
#define __ZIPREGISTRY_H
|
||||
#ifndef __ZIP_REGISTRY_H
|
||||
#define __ZIP_REGISTRY_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
#include "Common/Types.h"
|
||||
|
||||
#include "ExtractMode.h"
|
||||
|
||||
namespace NExtract
|
||||
@@ -13,49 +14,56 @@ namespace NExtract
|
||||
{
|
||||
NPathMode::EEnum PathMode;
|
||||
NOverwriteMode::EEnum OverwriteMode;
|
||||
UStringVector Paths;
|
||||
bool ShowPassword;
|
||||
UStringVector Paths;
|
||||
|
||||
void Save() const;
|
||||
void Load();
|
||||
};
|
||||
}
|
||||
|
||||
namespace NCompression {
|
||||
|
||||
namespace NCompression
|
||||
{
|
||||
struct CFormatOptions
|
||||
{
|
||||
CSysString FormatID;
|
||||
UString Options;
|
||||
UString Method;
|
||||
UString EncryptionMethod;
|
||||
UInt32 Level;
|
||||
UInt32 Dictionary;
|
||||
UInt32 Order;
|
||||
UInt32 BlockLogSize;
|
||||
UInt32 NumThreads;
|
||||
|
||||
CSysString FormatID;
|
||||
UString Method;
|
||||
UString Options;
|
||||
UString EncryptionMethod;
|
||||
|
||||
void ResetForLevelChange()
|
||||
{
|
||||
BlockLogSize = NumThreads = Level = Dictionary = Order = UInt32(-1);
|
||||
Method.Empty();
|
||||
// EncryptionMethod.Empty();
|
||||
// Options.Empty();
|
||||
// EncryptionMethod.Empty();
|
||||
}
|
||||
CFormatOptions() { ResetForLevelChange(); }
|
||||
};
|
||||
|
||||
struct CInfo
|
||||
{
|
||||
UStringVector HistoryArchives;
|
||||
UInt32 Level;
|
||||
UString ArchiveType;
|
||||
|
||||
CObjectVector<CFormatOptions> FormatOptionsVector;
|
||||
|
||||
bool ShowPassword;
|
||||
bool EncryptHeaders;
|
||||
UString ArcType;
|
||||
UStringVector ArcPaths;
|
||||
|
||||
CObjectVector<CFormatOptions> Formats;
|
||||
|
||||
void Save() const;
|
||||
void Load();
|
||||
};
|
||||
}
|
||||
|
||||
namespace NWorkDir{
|
||||
|
||||
namespace NWorkDir
|
||||
{
|
||||
namespace NMode
|
||||
{
|
||||
enum EEnum
|
||||
@@ -70,6 +78,7 @@ namespace NWorkDir{
|
||||
NMode::EEnum Mode;
|
||||
UString Path;
|
||||
bool ForRemovableOnly;
|
||||
|
||||
void SetForRemovableOnlyDefault() { ForRemovableOnly = true; }
|
||||
void SetDefault()
|
||||
{
|
||||
@@ -77,22 +86,20 @@ namespace NWorkDir{
|
||||
Path.Empty();
|
||||
SetForRemovableOnlyDefault();
|
||||
}
|
||||
|
||||
void Save() const;
|
||||
void Load();
|
||||
};
|
||||
}
|
||||
|
||||
void SaveExtractionInfo(const NExtract::CInfo &info);
|
||||
void ReadExtractionInfo(NExtract::CInfo &info);
|
||||
|
||||
void SaveCompressionInfo(const NCompression::CInfo &info);
|
||||
void ReadCompressionInfo(NCompression::CInfo &info);
|
||||
struct CContextMenuInfo
|
||||
{
|
||||
bool Cascaded;
|
||||
UInt32 Flags;
|
||||
|
||||
void SaveWorkDirInfo(const NWorkDir::CInfo &info);
|
||||
void ReadWorkDirInfo(NWorkDir::CInfo &info);
|
||||
|
||||
void SaveCascadedMenu(bool enabled);
|
||||
bool ReadCascadedMenu();
|
||||
|
||||
void SaveContextMenuStatus(UInt32 value);
|
||||
bool ReadContextMenuStatus(UInt32 &value);
|
||||
void Save() const;
|
||||
void Load();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -284,6 +284,10 @@ SOURCE=..\..\..\Windows\MemoryLock.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\NtCheck.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -9,6 +9,7 @@ static const int kBreakAbortThreshold = 2;
|
||||
|
||||
namespace NConsoleClose {
|
||||
|
||||
#ifndef UNDER_CE
|
||||
static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
|
||||
{
|
||||
if (ctrlType == CTRL_LOGOFF_EVENT)
|
||||
@@ -32,14 +33,19 @@ static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
|
||||
return FALSE;
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
bool TestBreakSignal()
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
return false;
|
||||
#else
|
||||
/*
|
||||
if (g_BreakCounter > 0)
|
||||
return true;
|
||||
*/
|
||||
return (g_BreakCounter > 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CheckCtrlBreak()
|
||||
@@ -50,14 +56,18 @@ void CheckCtrlBreak()
|
||||
|
||||
CCtrlHandlerSetter::CCtrlHandlerSetter()
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
if(!SetConsoleCtrlHandler(HandlerRoutine, TRUE))
|
||||
throw "SetConsoleCtrlHandler fails";
|
||||
#endif
|
||||
}
|
||||
|
||||
CCtrlHandlerSetter::~CCtrlHandlerSetter()
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
if(!SetConsoleCtrlHandler(HandlerRoutine, FALSE))
|
||||
throw "SetConsoleCtrlHandler fails";
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -433,6 +433,7 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
|
||||
for (int i = 0; i < numArcs; i++)
|
||||
{
|
||||
const UString &archiveName = arcPaths[i];
|
||||
UInt64 arcPackSize = 0;
|
||||
if (!stdInMode)
|
||||
{
|
||||
NFile::NFind::CFileInfoW fi;
|
||||
@@ -442,6 +443,7 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
|
||||
numErrors++;
|
||||
continue;
|
||||
}
|
||||
arcPackSize = fi.Size;
|
||||
}
|
||||
|
||||
CArchiveLink archiveLink;
|
||||
@@ -583,6 +585,14 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
|
||||
totalPackSize += packSize;
|
||||
totalUnPackSize += unpackSize;
|
||||
}
|
||||
|
||||
if (!stdInMode && totalPackSizePointer == 0)
|
||||
{
|
||||
if (archiveLink.VolumePaths.Size() != 0)
|
||||
arcPackSize += archiveLink.VolumesSize;
|
||||
totalPackSize = arcPackSize;
|
||||
totalPackSizePointer = &totalPackSize;
|
||||
}
|
||||
if (enableHeaders && !techMode)
|
||||
{
|
||||
fieldPrinter.PrintTitleLines();
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES)
|
||||
#include "../../../../C/Alloc.h"
|
||||
#endif
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
|
||||
#include "Common/CommandLineParser.h"
|
||||
@@ -11,17 +15,11 @@
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/StringToInt.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
#ifdef _WIN32
|
||||
#include "Windows/MemoryLock.h"
|
||||
#endif
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../../IPassword.h"
|
||||
|
||||
#include "../Common/ArchiveCommandLine.h"
|
||||
#include "../Common/ExitCode.h"
|
||||
#include "../Common/Extract.h"
|
||||
@@ -29,8 +27,6 @@
|
||||
#include "../Common/LoadCodecs.h"
|
||||
#endif
|
||||
#include "../Common/PropIDUtils.h"
|
||||
#include "../Common/Update.h"
|
||||
#include "../Common/UpdateAction.h"
|
||||
|
||||
#include "../../Compress/LZMA_Alone/LzmaBenchCon.h"
|
||||
|
||||
@@ -41,10 +37,6 @@
|
||||
|
||||
#include "../../MyVersion.h"
|
||||
|
||||
#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES)
|
||||
#include "../../../../C/Alloc.h"
|
||||
#endif
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NCommandLineParser;
|
||||
@@ -117,8 +109,9 @@ static const char *kHelpString =
|
||||
// exception messages
|
||||
|
||||
static const char *kEverythingIsOk = "Everything is Ok";
|
||||
static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode::kUserError
|
||||
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";
|
||||
|
||||
@@ -128,19 +121,19 @@ static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExit
|
||||
throw code;
|
||||
}
|
||||
|
||||
static void PrintHelpAndExit(CStdOutStream &s) // yyy
|
||||
static void PrintHelpAndExit(CStdOutStream &s)
|
||||
{
|
||||
s << kHelpString;
|
||||
ShowMessageAndThrowException(s, kUserErrorMessage, NExitCode::kUserError);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
static void GetArguments(int numArguments, const char *arguments[], UStringVector &parts)
|
||||
static void GetArguments(int numArgs, const char *args[], UStringVector &parts)
|
||||
{
|
||||
parts.Clear();
|
||||
for(int i = 0; i < numArguments; i++)
|
||||
for (int i = 0; i < numArgs; i++)
|
||||
{
|
||||
UString s = MultiByteToUnicodeString(arguments[i]);
|
||||
UString s = MultiByteToUnicodeString(args[i]);
|
||||
parts.Add(s);
|
||||
}
|
||||
}
|
||||
@@ -177,15 +170,13 @@ static inline char GetHex(Byte value)
|
||||
return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
|
||||
}
|
||||
|
||||
const char *kUnsupportedArcTypeMessage = "Unsupported archive type";
|
||||
|
||||
int Main2(
|
||||
#ifndef _WIN32
|
||||
int numArguments, const char *arguments[]
|
||||
int numArgs, const char *args[]
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
SetFileApisToOEM();
|
||||
#endif
|
||||
|
||||
@@ -193,7 +184,7 @@ int Main2(
|
||||
#ifdef _WIN32
|
||||
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
|
||||
#else
|
||||
GetArguments(numArguments, arguments, commandStrings);
|
||||
GetArguments(numArgs, args, commandStrings);
|
||||
#endif
|
||||
|
||||
if (commandStrings.Size() == 1)
|
||||
|
||||
@@ -2,85 +2,54 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
// #include <locale.h>
|
||||
#include "Common/MyException.h"
|
||||
#include "Common/StdOutStream.h"
|
||||
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/NtCheck.h"
|
||||
|
||||
#include "Common/StdOutStream.h"
|
||||
#include "Common/NewHandler.h"
|
||||
#include "Common/MyException.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "../Common/ExitCode.h"
|
||||
#include "../Common/ArchiveCommandLine.h"
|
||||
#include "../Common/ExitCode.h"
|
||||
|
||||
#include "ConsoleClose.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
CStdOutStream *g_StdStream = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
#endif
|
||||
#if !defined(_UNICODE) || !defined(_WIN64)
|
||||
static inline bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int Main2(
|
||||
#ifndef _WIN32
|
||||
int numArguments, const char *arguments[]
|
||||
int numArgs, const char *args[]
|
||||
#endif
|
||||
);
|
||||
|
||||
static const char *kExceptionErrorMessage = "\n\nError:\n";
|
||||
static const char *kUserBreak = "\nBreak signaled\n";
|
||||
|
||||
static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required memory!\n";
|
||||
static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n";
|
||||
static const char *kInternalExceptionMessage = "\n\nInternal Error #";
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION (*g_StdStream) << "Unsupported Windows version"; return NExitCode::kFatalError;
|
||||
|
||||
int MY_CDECL main
|
||||
(
|
||||
#ifndef _WIN32
|
||||
int numArguments, const char *arguments[]
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
int numArgs, const char *args[]
|
||||
#endif
|
||||
)
|
||||
{
|
||||
g_StdStream = &g_StdOut;
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef _UNICODE
|
||||
#ifndef _WIN64
|
||||
if (!IsItWindowsNT())
|
||||
{
|
||||
(*g_StdStream) << "This program requires Windows NT/2000/2003/2008/XP/Vista";
|
||||
return NExitCode::kFatalError;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// setlocale(LC_COLLATE, ".OCP");
|
||||
NT_CHECK
|
||||
|
||||
NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
|
||||
int res = 0;
|
||||
try
|
||||
{
|
||||
res = Main2(
|
||||
#ifndef _WIN32
|
||||
numArguments, arguments
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
numArgs, args
|
||||
#endif
|
||||
);
|
||||
}
|
||||
catch(const CNewException &)
|
||||
@@ -112,8 +81,7 @@ int numArguments, const char *arguments[]
|
||||
}
|
||||
UString message;
|
||||
NError::MyFormatMessage(systemError.ErrorCode, message);
|
||||
(*g_StdStream) << endl << endl << "System error:" << endl <<
|
||||
message << endl;
|
||||
(*g_StdStream) << endl << endl << "System error:" << endl << message << endl;
|
||||
return (NExitCode::kFatalError);
|
||||
}
|
||||
catch(NExitCode::EEnum &exitCode)
|
||||
|
||||
@@ -23,13 +23,18 @@ static const char *kHelpQuestionMessage =
|
||||
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
|
||||
{
|
||||
(*outStream) << kFirstQuestionMessage;
|
||||
for(;;)
|
||||
for (;;)
|
||||
{
|
||||
(*outStream) << kHelpQuestionMessage;
|
||||
AString scannedString = g_StdIn.ScanStringUntilNewLine();
|
||||
scannedString.Trim();
|
||||
if(!scannedString.IsEmpty())
|
||||
switch(::MyCharUpper(scannedString[0]))
|
||||
if (!scannedString.IsEmpty())
|
||||
switch(
|
||||
::MyCharUpper(
|
||||
#ifdef UNDER_CE
|
||||
(wchar_t)
|
||||
#endif
|
||||
scannedString[0]))
|
||||
{
|
||||
case kYes:
|
||||
return NUserAnswerMode::kYes;
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
PROG = 7z.exe
|
||||
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib
|
||||
MY_CONSOLE = 1
|
||||
CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DCOMPRESS_MT \
|
||||
-DWIN_LONG_PATH \
|
||||
-DEXTERNAL_LZMA \
|
||||
-DEXTERNAL_CODECS \
|
||||
-DBREAK_HANDLER \
|
||||
-DBENCH_MT \
|
||||
-D_7ZIP_LARGE_PAGES \
|
||||
-DSUPPORT_DEVICE_FILE \
|
||||
|
||||
!IFNDEF UNDER_CE
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE
|
||||
!ENDIF
|
||||
|
||||
|
||||
CONSOLE_OBJS = \
|
||||
$O\ConsoleClose.obj \
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/Memory.h"
|
||||
#include "Windows/Menu.h"
|
||||
#include "Windows/Process.h"
|
||||
#include "Windows/Shell.h"
|
||||
|
||||
#include "../Common/ArchiveName.h"
|
||||
@@ -32,8 +33,10 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
///////////////////////////////
|
||||
// IShellExtInit
|
||||
|
||||
#ifndef UNDER_CE
|
||||
#define EMAIL_SUPPORT 1
|
||||
#endif
|
||||
|
||||
extern LONG g_DllRefCount;
|
||||
|
||||
@@ -42,10 +45,11 @@ CZipContextMenu::~CZipContextMenu() { InterlockedDecrement(&g_DllRefCount); }
|
||||
|
||||
HRESULT CZipContextMenu::GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames)
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
fileNames.Clear();
|
||||
if(dataObject == NULL)
|
||||
if (dataObject == NULL)
|
||||
return E_FAIL;
|
||||
FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
|
||||
FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
|
||||
NCOM::CStgMedium stgMedium;
|
||||
HRESULT result = dataObject->GetData(&fmte, &stgMedium);
|
||||
if (result != S_OK)
|
||||
@@ -56,18 +60,20 @@ HRESULT CZipContextMenu::GetFileNames(LPDATAOBJECT dataObject, UStringVector &fi
|
||||
NMemory::CGlobalLock globalLock(stgMedium->hGlobal);
|
||||
drop.Attach((HDROP)globalLock.GetPointer());
|
||||
drop.QueryFileNames(fileNames);
|
||||
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder,
|
||||
LPDATAOBJECT dataObject, HKEY /* hkeyProgID */)
|
||||
// IShellExtInit
|
||||
|
||||
STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT dataObject, HKEY /* hkeyProgID */)
|
||||
{
|
||||
// OutputDebugString(TEXT("::Initialize\r\n"));
|
||||
_dropMode = false;
|
||||
_dropPath.Empty();
|
||||
if (pidlFolder != 0)
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
if (NShell::GetPathFromIDList(pidlFolder, _dropPath))
|
||||
{
|
||||
// OutputDebugString(path);
|
||||
@@ -76,6 +82,7 @@ STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder,
|
||||
_dropMode = !_dropPath.IsEmpty();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
_dropPath.Empty();
|
||||
}
|
||||
|
||||
@@ -225,8 +232,7 @@ int FindCommand(CZipContextMenu::ECommandInternalID &id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CZipContextMenu::FillCommand(ECommandInternalID id,
|
||||
UString &mainString, CCommandMapItem &commandMapItem)
|
||||
void CZipContextMenu::FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem)
|
||||
{
|
||||
int i = FindCommand(id);
|
||||
if (i < 0)
|
||||
@@ -299,11 +305,6 @@ static UString GetReducedString(const UString &s)
|
||||
return s.Left(kFirstPartSize) + UString(L" ... ") + s.Right(kMaxSize - kFirstPartSize);
|
||||
}
|
||||
|
||||
static UString GetQuotedString(const UString &s)
|
||||
{
|
||||
return UString(L'\"') + s + UString(L'\"');
|
||||
}
|
||||
|
||||
static UString GetQuotedReducedString(const UString &s)
|
||||
{
|
||||
UString s2 = GetReducedString(s);
|
||||
@@ -335,31 +336,35 @@ static const char *kExtractExludeExtensions =
|
||||
" xml xsd xsl xslt"
|
||||
" ";
|
||||
|
||||
static bool DoNeedExtract(const UString &name)
|
||||
static bool FindExt(const char *p, const UString &name)
|
||||
{
|
||||
int extPos = name.ReverseFind('.');
|
||||
if (extPos < 0)
|
||||
return true;
|
||||
return false;
|
||||
UString ext = name.Mid(extPos + 1);
|
||||
ext.MakeLower();
|
||||
AString ext2 = UnicodeStringToMultiByte(ext);
|
||||
const char *p = kExtractExludeExtensions;
|
||||
for (int i = 0; p[i] != 0;)
|
||||
{
|
||||
int j;
|
||||
for (j = i; p[j] != ' '; j++);
|
||||
if (ext2.Length() == j - i && memcmp(p + i, (const char *)ext2, ext2.Length()) == 0)
|
||||
return false;
|
||||
return true;
|
||||
i = j + 1;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool DoNeedExtract(const UString &name)
|
||||
{
|
||||
return !FindExt(kExtractExludeExtensions, name);
|
||||
}
|
||||
|
||||
STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
UINT commandIDFirst, UINT commandIDLast, UINT flags)
|
||||
{
|
||||
LoadLangOneTime();
|
||||
if(_fileNames.Size() == 0)
|
||||
if (_fileNames.Size() == 0)
|
||||
return E_FAIL;
|
||||
UINT currentCommandID = commandIDFirst;
|
||||
if ((flags & 0x000F) != CMF_NORMAL &&
|
||||
@@ -372,13 +377,14 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
CMenu popupMenu;
|
||||
CMenuDestroyer menuDestroyer;
|
||||
|
||||
bool cascadedMenu = ReadCascadedMenu();
|
||||
CContextMenuInfo ci;
|
||||
ci.Load();
|
||||
MENUITEMINFO menuItem;
|
||||
UINT subIndex = indexMenu;
|
||||
if (cascadedMenu)
|
||||
if (ci.Cascaded)
|
||||
{
|
||||
CCommandMapItem commandMapItem;
|
||||
if(!popupMenu.CreatePopup())
|
||||
if (!popupMenu.CreatePopup())
|
||||
return E_FAIL;
|
||||
menuDestroyer.Attach(popupMenu);
|
||||
commandMapItem.CommandInternalID = kCommandNULL;
|
||||
@@ -394,12 +400,10 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
popupMenu.Attach(hMenu);
|
||||
}
|
||||
|
||||
UINT32 contextMenuFlags;
|
||||
if (!ReadContextMenuStatus(contextMenuFlags))
|
||||
contextMenuFlags = NContextMenuFlags::GetDefaultFlags();
|
||||
UInt32 contextMenuFlags = ci.Flags;
|
||||
|
||||
UString mainString;
|
||||
if(_fileNames.Size() == 1 && currentCommandID + 6 <= commandIDLast)
|
||||
if (_fileNames.Size() == 1 && currentCommandID + 6 <= commandIDLast)
|
||||
{
|
||||
const UString &fileName = _fileNames.Front();
|
||||
UString folderPrefix;
|
||||
@@ -417,11 +421,39 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
FillCommand(kOpen, mainString, commandMapItem);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
|
||||
_commandMap.Add(commandMapItem);
|
||||
|
||||
/*
|
||||
if (FindExt(" exe dll ", fileInfo.Name))
|
||||
{
|
||||
CMenu subMenu;
|
||||
if (subMenu.CreatePopup())
|
||||
{
|
||||
CMenuItem menuItem;
|
||||
menuItem.fType = MFT_STRING;
|
||||
menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
|
||||
menuItem.wID = currentCommandID++;
|
||||
menuItem.hSubMenu = subMenu;
|
||||
menuItem.StringValue = LangString(IDS_CONTEXT_OPEN, 0x02000103);
|
||||
popupMenu.InsertItem(subIndex++, true, menuItem);
|
||||
const wchar_t *exts[] = { L"7z", L"cab", L"rar", L"zip", L"pe" };
|
||||
for (int i = 0; i < sizeof(exts) / sizeof(exts[0]); i++)
|
||||
{
|
||||
CCommandMapItem commandMapItem;
|
||||
FillCommand(kOpenAs, mainString, commandMapItem);
|
||||
mainString = exts[i];
|
||||
commandMapItem.ArchiveType = mainString;
|
||||
MyInsertMenu(subMenu, subIndex++, currentCommandID++, mainString);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
subMenu.Detach();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(_fileNames.Size() > 0 && currentCommandID + 10 <= commandIDLast)
|
||||
if (_fileNames.Size() > 0 && currentCommandID + 10 <= commandIDLast)
|
||||
{
|
||||
bool needExtract = false;
|
||||
for(int i = 0; i < _fileNames.Size(); i++)
|
||||
@@ -516,7 +548,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
|
||||
#ifdef EMAIL_SUPPORT
|
||||
// CompressEmail
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompressEmail) != 0 && !_dropMode)
|
||||
{
|
||||
@@ -526,6 +558,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
#endif
|
||||
|
||||
// CompressTo7z
|
||||
if (contextMenuFlags & NContextMenuFlags::kCompressTo7z)
|
||||
@@ -544,6 +577,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
#ifdef EMAIL_SUPPORT
|
||||
// CompressTo7zEmail
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompressTo7zEmail) != 0 && !_dropMode)
|
||||
{
|
||||
@@ -556,6 +590,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
#endif
|
||||
|
||||
// CompressToZip
|
||||
if (contextMenuFlags & NContextMenuFlags::kCompressToZip)
|
||||
@@ -574,6 +609,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
#ifdef EMAIL_SUPPORT
|
||||
// CompressToZipEmail
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompressToZipEmail) != 0 && !_dropMode)
|
||||
{
|
||||
@@ -586,6 +622,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -593,7 +630,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
// PRB: Duplicate Menu Items In the File Menu For a Shell Context Menu Extension
|
||||
// ID: Q214477
|
||||
|
||||
if (cascadedMenu)
|
||||
if (ci.Cascaded)
|
||||
{
|
||||
CMenuItem menuItem;
|
||||
menuItem.fType = MFT_STRING;
|
||||
@@ -614,21 +651,16 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
int CZipContextMenu::FindVerb(const UString &verb)
|
||||
{
|
||||
for(int i = 0; i < _commandMap.Size(); i++)
|
||||
if(_commandMap[i].Verb.Compare(verb) == 0)
|
||||
if (_commandMap[i].Verb.Compare(verb) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern const char *kShellFolderClassIDString;
|
||||
|
||||
|
||||
static UString GetProgramCommand()
|
||||
static UString Get7zFmPath()
|
||||
{
|
||||
UString path;
|
||||
UString folder;
|
||||
if (GetProgramFolderPath(folder))
|
||||
path = folder;
|
||||
return GetQuotedString(path + L"7zFM.exe");
|
||||
GetProgramFolderPath(path);
|
||||
return path + L"7zFM.exe";
|
||||
}
|
||||
|
||||
STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
|
||||
@@ -638,22 +670,24 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
|
||||
|
||||
// It's fix for bug: crashing in XP. See example in MSDN: "Creating Context Menu Handlers".
|
||||
|
||||
#ifndef UNDER_CE
|
||||
if (commandInfo->cbSize == sizeof(CMINVOKECOMMANDINFOEX) &&
|
||||
(commandInfo->fMask & CMIC_MASK_UNICODE) != 0)
|
||||
{
|
||||
LPCMINVOKECOMMANDINFOEX commandInfoEx = (LPCMINVOKECOMMANDINFOEX)commandInfo;
|
||||
if(HIWORD(commandInfoEx->lpVerbW) == 0)
|
||||
if (HIWORD(commandInfoEx->lpVerbW) == 0)
|
||||
commandOffset = LOWORD(commandInfo->lpVerb);
|
||||
else
|
||||
commandOffset = FindVerb(commandInfoEx->lpVerbW);
|
||||
}
|
||||
else
|
||||
if(HIWORD(commandInfo->lpVerb) == 0)
|
||||
#endif
|
||||
if (HIWORD(commandInfo->lpVerb) == 0)
|
||||
commandOffset = LOWORD(commandInfo->lpVerb);
|
||||
else
|
||||
commandOffset = FindVerb(GetUnicodeString(commandInfo->lpVerb));
|
||||
|
||||
if(commandOffset < 0 || commandOffset >= _commandMap.Size())
|
||||
if (commandOffset < 0 || commandOffset >= _commandMap.Size())
|
||||
return E_FAIL;
|
||||
|
||||
const CCommandMapItem commandMapItem = _commandMap[commandOffset];
|
||||
@@ -665,19 +699,15 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
|
||||
{
|
||||
case kOpen:
|
||||
{
|
||||
UString params;
|
||||
params = GetProgramCommand();
|
||||
params += L' ';
|
||||
params += GetQuotedString(_fileNames[0]);
|
||||
MyCreateProcess(params, 0, false, 0);
|
||||
UString params = GetQuotedString(_fileNames[0]);
|
||||
MyCreateProcess(Get7zFmPath(), params);
|
||||
break;
|
||||
}
|
||||
case kExtract:
|
||||
case kExtractHere:
|
||||
case kExtractTo:
|
||||
{
|
||||
ExtractArchives(_fileNames, commandMapItem.Folder,
|
||||
(commandInternalID == kExtract));
|
||||
ExtractArchives(_fileNames, commandMapItem.Folder, (commandInternalID == kExtract));
|
||||
break;
|
||||
}
|
||||
case kTest:
|
||||
@@ -708,19 +738,19 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ShowErrorMessageRes(IDS_ERROR, 0x02000605);
|
||||
::MessageBoxW(0, L"Error", L"7-Zip", MB_ICONERROR);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void MyCopyString(void *dest, const wchar_t *src, bool writeInUnicode)
|
||||
{
|
||||
if(writeInUnicode)
|
||||
if (writeInUnicode)
|
||||
{
|
||||
MyStringCopy((wchar_t *)dest, src);
|
||||
}
|
||||
else
|
||||
lstrcpyA((char *)dest, GetAnsiString(src));
|
||||
MyStringCopy((char *)dest, (const char *)GetAnsiString(src));
|
||||
}
|
||||
|
||||
STDMETHODIMP CZipContextMenu::GetCommandString(UINT_PTR commandOffset, UINT uType,
|
||||
@@ -729,23 +759,47 @@ STDMETHODIMP CZipContextMenu::GetCommandString(UINT_PTR commandOffset, UINT uTyp
|
||||
int cmdOffset = (int)commandOffset;
|
||||
switch(uType)
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
case GCS_VALIDATE:
|
||||
#else
|
||||
case GCS_VALIDATEA:
|
||||
case GCS_VALIDATEW:
|
||||
if(cmdOffset < 0 || cmdOffset >= _commandMap.Size())
|
||||
#endif
|
||||
if (cmdOffset < 0 || cmdOffset >= _commandMap.Size())
|
||||
return S_FALSE;
|
||||
else
|
||||
return S_OK;
|
||||
}
|
||||
if(cmdOffset < 0 || cmdOffset >= _commandMap.Size())
|
||||
if (cmdOffset < 0 || cmdOffset >= _commandMap.Size())
|
||||
return E_FAIL;
|
||||
if(uType == GCS_HELPTEXTA || uType == GCS_HELPTEXTW)
|
||||
#ifdef UNDER_CE
|
||||
if (uType == GCS_HELPTEXT)
|
||||
#else
|
||||
if (uType == GCS_HELPTEXTA || uType == GCS_HELPTEXTW)
|
||||
#endif
|
||||
{
|
||||
MyCopyString(pszName, _commandMap[cmdOffset].HelpString, uType == GCS_HELPTEXTW);
|
||||
MyCopyString(pszName, _commandMap[cmdOffset].HelpString,
|
||||
#ifdef UNDER_CE
|
||||
true
|
||||
#else
|
||||
uType == GCS_HELPTEXTW
|
||||
#endif
|
||||
);
|
||||
return NO_ERROR;
|
||||
}
|
||||
if(uType == GCS_VERBA || uType == GCS_VERBW)
|
||||
#ifdef UNDER_CE
|
||||
if (uType == GCS_VERB)
|
||||
#else
|
||||
if (uType == GCS_VERBA || uType == GCS_VERBW)
|
||||
#endif
|
||||
{
|
||||
MyCopyString(pszName, _commandMap[cmdOffset].Verb, uType == GCS_VERBW);
|
||||
MyCopyString(pszName, _commandMap[cmdOffset].Verb,
|
||||
#ifdef UNDER_CE
|
||||
true
|
||||
#else
|
||||
uType == GCS_VERBW
|
||||
#endif
|
||||
);
|
||||
return NO_ERROR;
|
||||
}
|
||||
return E_FAIL;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// ContextMenu.h
|
||||
|
||||
#ifndef __CONTEXTMENU_H
|
||||
#define __CONTEXTMENU_H
|
||||
#ifndef __CONTEXT_MENU_H
|
||||
#define __CONTEXT_MENU_H
|
||||
|
||||
// {23170F69-40C1-278A-1000-000100020000}
|
||||
DEFINE_GUID(CLSID_CZipContextMenu,
|
||||
@@ -19,7 +19,6 @@ class CZipContextMenu:
|
||||
public IInitContextMenu,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum ECommandInternalID
|
||||
@@ -50,21 +49,13 @@ public:
|
||||
|
||||
MY_UNKNOWN_IMP3_MT(IContextMenu, IShellExtInit, IInitContextMenu)
|
||||
|
||||
///////////////////////////////
|
||||
// IShellExtInit
|
||||
STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT dataObject, HKEY hkeyProgID);
|
||||
|
||||
STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder,
|
||||
LPDATAOBJECT dataObject, HKEY hkeyProgID);
|
||||
|
||||
/////////////////////////////
|
||||
// IContextMenu
|
||||
|
||||
STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu,
|
||||
UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
|
||||
STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
|
||||
STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici);
|
||||
STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved,
|
||||
LPSTR pszName, UINT cchMax);
|
||||
|
||||
STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);
|
||||
|
||||
// IInitContextMenu
|
||||
STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UINT32 numFiles);
|
||||
@@ -73,11 +64,12 @@ private:
|
||||
bool _dropMode;
|
||||
UString _dropPath;
|
||||
CObjectVector<CCommandMapItem> _commandMap;
|
||||
|
||||
HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames);
|
||||
|
||||
int FindVerb(const UString &verb);
|
||||
|
||||
void FillCommand(ECommandInternalID id, UString &mainString,
|
||||
CCommandMapItem &commandMapItem);
|
||||
void FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem);
|
||||
public:
|
||||
CZipContextMenu();
|
||||
~CZipContextMenu();
|
||||
|
||||
@@ -8,30 +8,38 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
// #include <locale.h>
|
||||
#include "Common/MyInitGuid.h"
|
||||
|
||||
#include <initguid.h>
|
||||
#include <windows.h>
|
||||
#include <ShlGuid.h>
|
||||
#include <OleCtl.h>
|
||||
|
||||
#include "Common/ComTry.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/NtCheck.h"
|
||||
#include "Windows/Registry.h"
|
||||
|
||||
#include "../FileManager/LangUtils.h"
|
||||
#include "../FileManager/IFolder.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
|
||||
#include "ContextMenu.h"
|
||||
#include "OptionsDialog.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
#endif
|
||||
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.
|
||||
|
||||
@@ -85,29 +93,23 @@ STDMETHODIMP CShellExtClassFactory::LockServer(BOOL /* fLock */)
|
||||
return S_OK; // Check it
|
||||
}
|
||||
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION return FALSE;
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
|
||||
BOOL WINAPI DllMain(
|
||||
#ifdef UNDER_CE
|
||||
HANDLE hInstance
|
||||
#else
|
||||
HINSTANCE hInstance
|
||||
#endif
|
||||
, DWORD dwReason, LPVOID)
|
||||
{
|
||||
// setlocale(LC_COLLATE, ".ACP");
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
// ODS("In DLLMain, DLL_PROCESS_ATTACH\r\n");
|
||||
#ifdef _UNICODE
|
||||
if (!IsItWindowsNT())
|
||||
return FALSE;
|
||||
#else
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
NT_CHECK
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
@@ -153,10 +155,16 @@ static BOOL GetStringFromIID(CLSID clsid, LPTSTR s, int size)
|
||||
LPWSTR pwsz;
|
||||
if (StringFromIID(clsid, &pwsz) != S_OK)
|
||||
return FALSE;
|
||||
if(!pwsz)
|
||||
if (!pwsz)
|
||||
return FALSE;
|
||||
#ifdef UNICODE
|
||||
lstrcpyn(s, pwsz, size);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
s[i] = pwsz[i];
|
||||
if (pwsz[i] == 0)
|
||||
break;
|
||||
}
|
||||
s[size - 1] = 0;
|
||||
#else
|
||||
WideCharToMultiByte(CP_ACP, 0, pwsz, -1, s, size, NULL, NULL);
|
||||
#endif
|
||||
@@ -192,18 +200,20 @@ static BOOL RegisterServer(CLSID clsid, LPCWSTR title)
|
||||
};
|
||||
|
||||
//register the CLSID entries
|
||||
for(int i = 0; clsidEntries[i].hRootKey; i++)
|
||||
for (int i = 0; clsidEntries[i].hRootKey; i++)
|
||||
{
|
||||
TCHAR subKey[MAX_PATH];
|
||||
wsprintf(subKey, clsidEntries[i].SubKey, clsidString);
|
||||
const CRegItem &r = clsidEntries[i];
|
||||
wsprintf(subKey, r.SubKey, clsidString);
|
||||
NRegistry::CKey key;
|
||||
if (key.Create(clsidEntries[i].hRootKey, subKey, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR)
|
||||
if (key.Create(r.hRootKey, subKey, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR)
|
||||
return FALSE;
|
||||
key.SetValue(clsidEntries[i].ValueName, clsidEntries[i].Data);
|
||||
}
|
||||
|
||||
if(IsItWindowsNT())
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
if (IsItWindowsNT())
|
||||
#endif
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if (key.Create(HKEY_LOCAL_MACHINE, kApprovedKeyPath, NULL,
|
||||
@@ -231,7 +241,9 @@ static BOOL UnregisterServer(CLSID clsid)
|
||||
wsprintf (subKey, kClsidMask, clsidString);
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, subKey);
|
||||
|
||||
if(IsItWindowsNT())
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
if (IsItWindowsNT())
|
||||
#endif
|
||||
{
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, kApprovedKeyPath, 0, KEY_SET_VALUE, &hKey) == NOERROR)
|
||||
@@ -247,45 +259,3 @@ STDAPI DllUnregisterServer(void)
|
||||
{
|
||||
return UnregisterServer(CLSID_CZipContextMenu) ? S_OK: SELFREG_E_CLASS;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
LoadLangOneTime();
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID == CLSID_CSevenZipOptions)
|
||||
{
|
||||
if (*interfaceID == IID_IPluginOptions)
|
||||
{
|
||||
CMyComPtr<IPluginOptions> options = new CSevenZipOptions;
|
||||
*outObject = options.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDAPI GetPluginProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
::VariantClear((tagVARIANT *)value);
|
||||
switch(propID)
|
||||
{
|
||||
case NPlugin::kName:
|
||||
if ((value->bstrVal = ::SysAllocString(L"7-Zip")) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
case NPlugin::kOptionsClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CSevenZipOptions, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,3 @@ EXPORTS
|
||||
DllGetClassObject PRIVATE
|
||||
DllRegisterServer PRIVATE
|
||||
DllUnregisterServer PRIVATE
|
||||
|
||||
CreateObject PRIVATE
|
||||
GetPluginProperty PRIVATE
|
||||
|
||||
@@ -233,34 +233,6 @@ SOURCE=.\MyMessages.cpp
|
||||
SOURCE=.\MyMessages.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Dialogs"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FoldersPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FoldersPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FoldersPageRes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SystemPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SystemPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SystemPageRes.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "FileManager"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
@@ -523,6 +495,14 @@ SOURCE=..\..\..\Windows\Menu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Process.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Process.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Registry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -568,14 +548,6 @@ SOURCE=.\ContextMenuFlags.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OptionsDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OptionsDialog.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\RegistryContextMenu.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#include "FoldersPageRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 196
|
||||
#define ySize2 140
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
|
||||
#define marg2 marg
|
||||
#define marg3 10
|
||||
#define gPos (marg + marg2)
|
||||
#define gSize (xSize2 - marg2 - marg2)
|
||||
#define gPos2 (gPos + marg3)
|
||||
|
||||
|
||||
IDD_FOLDERS DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE
|
||||
CAPTION "Folders"
|
||||
MY_FONT
|
||||
BEGIN
|
||||
GROUPBOX "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, marg, marg, xSize2, 98
|
||||
CONTROL "&System temp folder", IDC_FOLDERS_WORK_RADIO_SYSTEM, "Button", BS_AUTORADIOBUTTON | WS_GROUP,
|
||||
gPos, 20, gSize, 10
|
||||
CONTROL "&Current", IDC_FOLDERS_WORK_RADIO_CURRENT, "Button", BS_AUTORADIOBUTTON,
|
||||
gPos, 34, gSize, 10
|
||||
CONTROL "Specified:", IDC_FOLDERS_WORK_RADIO_SPECIFIED, "Button", BS_AUTORADIOBUTTON,
|
||||
gPos, 48, gSize, 10
|
||||
EDITTEXT IDC_FOLDERS_WORK_EDIT_PATH, gPos2, 63, gSize - marg3 - bDotsSize - 10, 14, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "...", IDC_FOLDERS_WORK_BUTTON_PATH, xSize - marg - marg2 - bDotsSize, 63, bDotsSize, bYSize
|
||||
CONTROL "Use for removable drives only", IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
|
||||
gPos, 87, gSize, 10
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_FOLDERS_SET_WORK_PATH_TITLE "Specify a location for temporary archive files."
|
||||
END
|
||||
@@ -2,27 +2,29 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "OptionsDialog.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/Control/PropertyPage.h"
|
||||
|
||||
#include "../FileManager/DialogSize.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
|
||||
#include "FoldersPage.h"
|
||||
#include "FoldersPageRes.h"
|
||||
#include "SystemPage.h"
|
||||
#include "SystemPageRes.h"
|
||||
#include "OptionsDialog.h"
|
||||
#include "MenuPage.h"
|
||||
#include "MenuPageRes.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static INT_PTR OptionsDialog(HWND hwndOwner)
|
||||
{
|
||||
CSystemPage systemPage;
|
||||
CMenuPage systemPage;
|
||||
CFoldersPage foldersPage;
|
||||
UINT32 langIDs[] = { 0x01000300, 0x01000200};
|
||||
UINT pageIDs[] = { IDD_SYSTEM, IDD_FOLDERS};
|
||||
|
||||
BIG_DIALOG_SIZE(200, 200);
|
||||
UINT pageIDs[] = { SIZED_DIALOG(IDD_MENU), SIZED_DIALOG(IDD_FOLDERS) };
|
||||
NControl::CPropertyPage *pagePinters[] = { &systemPage, &foldersPage };
|
||||
CObjectVector<NControl::CPageInfo> pages;
|
||||
const int kNumPages = sizeof(langIDs) / sizeof(langIDs[0]);
|
||||
@@ -43,7 +45,7 @@ STDMETHODIMP CSevenZipOptions::PluginOptions(HWND hWnd,
|
||||
{
|
||||
/*
|
||||
CComBSTR programPath;
|
||||
RETUEN_IF_NOT_S_OK(callback->GetProgramPath(programName)));
|
||||
RINOK(callback->GetProgramPath(programName)));
|
||||
*/
|
||||
OptionsDialog(hWnd);
|
||||
return S_OK;
|
||||
@@ -67,5 +69,3 @@ STDMETHODIMP CSevenZipOptions::GetFileExtensions(BSTR * /* extensions */)
|
||||
*/
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "RegistryContextMenu.h"
|
||||
#include "Windows/COM.h"
|
||||
#include "Windows/Synchronization.h"
|
||||
#include "Windows/Registry.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Synchronization.h"
|
||||
|
||||
#include "RegistryContextMenu.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NCOM;
|
||||
using namespace NRegistry;
|
||||
|
||||
namespace NZipRootRegistry {
|
||||
|
||||
static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection;
|
||||
|
||||
///////////////////////////
|
||||
// ContextMenu
|
||||
#ifndef UNDER_CE
|
||||
|
||||
static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-ZIP");
|
||||
static const TCHAR *kDragDropMenuKeyName = TEXT("\\shellex\\DragDropHandlers\\7-ZIP");
|
||||
static NSynchronization::CCriticalSection g_CS;
|
||||
|
||||
static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-Zip");
|
||||
static const TCHAR *kDragDropMenuKeyName = TEXT("\\shellex\\DragDropHandlers\\7-Zip");
|
||||
|
||||
static const TCHAR *kExtensionCLSID = TEXT("{23170F69-40C1-278A-1000-000100020000}");
|
||||
|
||||
@@ -37,7 +34,7 @@ static CSysString GetFullDragDropMenuKeyName(const CSysString &keyName)
|
||||
|
||||
static bool CheckHandlerCommon(const CSysString &keyName)
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CLASSES_ROOT, keyName, KEY_READ) != ERROR_SUCCESS)
|
||||
return false;
|
||||
@@ -89,7 +86,7 @@ void DeleteContextMenuHandler()
|
||||
static void AddContextMenuHandlerCommon(const CSysString &keyName)
|
||||
{
|
||||
DeleteContextMenuHandlerCommon(keyName);
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
CKey key;
|
||||
key.Create(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(keyName));
|
||||
key.SetValue(NULL, kExtensionCLSID);
|
||||
@@ -98,7 +95,7 @@ static void AddContextMenuHandlerCommon(const CSysString &keyName)
|
||||
static void AddDragDropMenuHandlerCommon(const CSysString &keyName)
|
||||
{
|
||||
DeleteDragDropMenuHandlerCommon(keyName);
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
CKey key;
|
||||
key.Create(HKEY_CLASSES_ROOT, GetFullDragDropMenuKeyName(keyName));
|
||||
key.SetValue(NULL, kExtensionCLSID);
|
||||
@@ -114,4 +111,6 @@ void AddContextMenuHandler()
|
||||
AddDragDropMenuHandlerCommon(kRootKeyNameForDrive);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
// RegistryContextMenu.h
|
||||
|
||||
#ifndef __REGISTRYCONTEXTMENU_H
|
||||
#define __REGISTRYCONTEXTMENU_H
|
||||
#ifndef __REGISTRY_CONTEXT_MENU_H
|
||||
#define __REGISTRY_CONTEXT_MENU_H
|
||||
|
||||
namespace NZipRootRegistry {
|
||||
|
||||
#ifndef UNDER_CE
|
||||
bool CheckContextMenuHandler();
|
||||
void AddContextMenuHandler();
|
||||
void DeleteContextMenuHandler();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,11 +15,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <mbstring.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <shlguid.h>
|
||||
#include <regstr.h>
|
||||
|
||||
#include "Common/NewHandler.h"
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#include "SystemPageRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 196
|
||||
#define ySize2 164
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
|
||||
IDD_SYSTEM DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE
|
||||
CAPTION "System"
|
||||
MY_FONT
|
||||
BEGIN
|
||||
CONTROL "Integrate 7-Zip to shell context menu", IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
|
||||
"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
|
||||
marg, marg, xSize2, 10
|
||||
CONTROL "Cascaded context menu", IDC_SYSTEM_CASCADED_MENU,
|
||||
"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
|
||||
marg, 21, xSize2, 10
|
||||
LTEXT "Context menu items:", IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS,
|
||||
marg, 37, xSize2, 8
|
||||
CONTROL "List1", IDC_SYSTEM_OPTIONS_LIST, "SysListView32",
|
||||
LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,
|
||||
marg, 50, xSize2, ySize - marg - 50
|
||||
END
|
||||
@@ -1,18 +1,20 @@
|
||||
PROG = 7-zip.dll
|
||||
DEF_FILE = Explorer.def
|
||||
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib htmlhelp.lib shell32.lib comctl32.lib ole32.lib comdlg32.lib
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -Ob2 \
|
||||
CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DLANG \
|
||||
-DWIN_LONG_PATH \
|
||||
|
||||
!IFDEF UNDER_CE
|
||||
LIBS = $(LIBS) Commctrl.lib
|
||||
!ELSE
|
||||
LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH
|
||||
!ENDIF
|
||||
|
||||
EXPLORER_OBJS = \
|
||||
$O\DllExports.obj \
|
||||
$O\ContextMenu.obj \
|
||||
$O\MyMessages.obj \
|
||||
$O\OptionsDialog.obj \
|
||||
$O\RegistryContextMenu.obj \
|
||||
$O\SystemPage.obj \
|
||||
$O\FoldersPage.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\IntToString.obj \
|
||||
@@ -35,12 +37,20 @@ WIN_OBJS = \
|
||||
$O\FileIO.obj \
|
||||
$O\FileName.obj \
|
||||
$O\Menu.obj \
|
||||
$O\Process.obj \
|
||||
$O\Registry.obj \
|
||||
$O\ResourceString.obj \
|
||||
$O\Shell.obj \
|
||||
$O\Synchronization.obj \
|
||||
$O\Window.obj \
|
||||
|
||||
!IFDEF UNDER_CE
|
||||
|
||||
WIN_OBJS = $(WIN_OBJS) \
|
||||
$O\CommonDialog.obj \
|
||||
|
||||
!ENDIF
|
||||
|
||||
WIN_CTRL_OBJS = \
|
||||
$O\Dialog.obj \
|
||||
$O\ListView.obj \
|
||||
|
||||
@@ -26,6 +26,3 @@
|
||||
|
||||
#define IDS_CONTEXT_FOLDER 170
|
||||
#define IDS_CONTEXT_ARCHIVE 171
|
||||
|
||||
#define IDS_ERROR 100
|
||||
#define IDS_CONFIG_DIALOG_CAPTION 102
|
||||
|
||||
@@ -1,38 +1,8 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
#include "resource.h"
|
||||
#include "resource2.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("7-Zip Shell Extension", "7-zip")
|
||||
|
||||
1 24 "7-zip.dll.manifest"
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_CONTEXT_EXTRACT "Extract files..."
|
||||
IDS_CONTEXT_EXTRACT_HELP "Extracts files from the selected archive."
|
||||
IDS_CONTEXT_COMPRESS "Add to archive..."
|
||||
IDS_CONTEXT_COMPRESS_HELP "Adds the selected items to archive."
|
||||
IDS_CONTEXT_OPEN "Open archive"
|
||||
IDS_CONTEXT_OPEN_HELP "Opens the selected archive."
|
||||
IDS_CONTEXT_TEST "Test archive"
|
||||
IDS_CONTEXT_TEST_HELP "Tests integrity of the selected archive."
|
||||
IDS_CONTEXT_CAPTION_HELP "7-Zip commands"
|
||||
IDS_CONTEXT_POPUP_CAPTION "7-Zip"
|
||||
IDS_CONTEXT_EXTRACT_HERE "Extract Here"
|
||||
IDS_CONTEXT_EXTRACT_HERE_HELP "Extracts files from the selected archive to current folder."
|
||||
IDS_CONTEXT_EXTRACT_TO "Extract to {0}"
|
||||
IDS_CONTEXT_EXTRACT_TO_HELP "Extracts files to subfolder."
|
||||
IDS_CONTEXT_COMPRESS_TO "Add to {0}"
|
||||
IDS_CONTEXT_COMPRESS_TO_HELP "Adds the selected items to archive."
|
||||
IDS_CONTEXT_COMPRESS_EMAIL "Compress and email..."
|
||||
IDS_CONTEXT_COMPRESS_EMAIL_HELP "Compresses the selected items to archive and sends archive via email."
|
||||
IDS_CONTEXT_COMPRESS_TO_EMAIL "Compress to {0} and email"
|
||||
IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP "Compresses the selected items to archive and sends archive via email."
|
||||
IDS_CONTEXT_FOLDER "<Folder>"
|
||||
IDS_CONTEXT_ARCHIVE "<Archive>"
|
||||
IDS_ERROR "Error"
|
||||
IDS_CONFIG_DIALOG_CAPTION "7-Zip Options"
|
||||
END
|
||||
|
||||
#include "FoldersPage.rc"
|
||||
#include "SystemPage.rc"
|
||||
|
||||
#ifndef UNDER_CE
|
||||
1 24 MOVEABLE PURE "7-zip.dll.manifest"
|
||||
#endif
|
||||
|
||||
27
CPP/7zip/UI/Explorer/resource2.rc
Executable file
27
CPP/7zip/UI/Explorer/resource2.rc
Executable file
@@ -0,0 +1,27 @@
|
||||
#include "resource.h"
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_CONTEXT_EXTRACT "Extract files..."
|
||||
IDS_CONTEXT_EXTRACT_HELP "Extracts files from the selected archive."
|
||||
IDS_CONTEXT_COMPRESS "Add to archive..."
|
||||
IDS_CONTEXT_COMPRESS_HELP "Adds the selected items to archive."
|
||||
IDS_CONTEXT_OPEN "Open archive"
|
||||
IDS_CONTEXT_OPEN_HELP "Opens the selected archive."
|
||||
IDS_CONTEXT_TEST "Test archive"
|
||||
IDS_CONTEXT_TEST_HELP "Tests integrity of the selected archive."
|
||||
IDS_CONTEXT_CAPTION_HELP "7-Zip commands"
|
||||
IDS_CONTEXT_POPUP_CAPTION "7-Zip"
|
||||
IDS_CONTEXT_EXTRACT_HERE "Extract Here"
|
||||
IDS_CONTEXT_EXTRACT_HERE_HELP "Extracts files from the selected archive to current folder."
|
||||
IDS_CONTEXT_EXTRACT_TO "Extract to {0}"
|
||||
IDS_CONTEXT_EXTRACT_TO_HELP "Extracts files to subfolder."
|
||||
IDS_CONTEXT_COMPRESS_TO "Add to {0}"
|
||||
IDS_CONTEXT_COMPRESS_TO_HELP "Adds the selected items to archive."
|
||||
IDS_CONTEXT_COMPRESS_EMAIL "Compress and email..."
|
||||
IDS_CONTEXT_COMPRESS_EMAIL_HELP "Compresses the selected items to archive and sends archive via email."
|
||||
IDS_CONTEXT_COMPRESS_TO_EMAIL "Compress to {0} and email"
|
||||
IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP "Compresses the selected items to archive and sends archive via email."
|
||||
IDS_CONTEXT_FOLDER "<Folder>"
|
||||
IDS_CONTEXT_ARCHIVE "<Archive>"
|
||||
END
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
#include "Common/DynamicBuffer.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "Windows/Console.h"
|
||||
#include "Windows/Error.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NFar {
|
||||
@@ -16,12 +16,12 @@ namespace NFar {
|
||||
CStartupInfo g_StartupInfo;
|
||||
|
||||
void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo,
|
||||
const CSysString &pliginNameForRegestry)
|
||||
const CSysString &pluginNameForRegestry)
|
||||
{
|
||||
m_Data = pluginStartupInfo;
|
||||
m_RegistryPath = pluginStartupInfo.RootKey;
|
||||
m_RegistryPath += '\\';
|
||||
m_RegistryPath += pliginNameForRegestry;
|
||||
m_RegistryPath = GetSystemString(pluginStartupInfo.RootKey);
|
||||
m_RegistryPath += TEXT('\\');
|
||||
m_RegistryPath += pluginNameForRegestry;
|
||||
}
|
||||
|
||||
const char *CStartupInfo::GetMsgString(int messageId)
|
||||
@@ -164,7 +164,7 @@ void CStartupInfo::RestoreScreen(HANDLE handle)
|
||||
m_Data.RestoreScreen(handle);
|
||||
}
|
||||
|
||||
const char kRegestryKeyDelimiter = '\'';
|
||||
const TCHAR kRegestryKeyDelimiter = TEXT('\'');
|
||||
|
||||
CSysString CStartupInfo::GetFullKeyName(const CSysString &keyName) const
|
||||
{
|
||||
@@ -355,8 +355,8 @@ int CStartupInfo::Menu(
|
||||
item.Checked = 0;
|
||||
item.Separator = 0;
|
||||
item.Selected = (i == selectedItem);
|
||||
AString reducedString = items[i].Left(sizeof(item.Text) / sizeof(item.Text[0]) - 1);
|
||||
MyStringCopy(item.Text, (const char *)reducedString);
|
||||
CSysString reducedString = items[i].Left(sizeof(item.Text) / sizeof(item.Text[0]) - 1);
|
||||
MyStringCopy(item.Text, (const char *)GetOemString(reducedString));
|
||||
farMenuItems.Add(item);
|
||||
}
|
||||
return Menu(flags, title, helpTopic, &farMenuItems.Front(), farMenuItems.Size());
|
||||
@@ -396,7 +396,7 @@ static AString DWORDToString(DWORD number)
|
||||
|
||||
void PrintErrorMessage(const char *message, int code)
|
||||
{
|
||||
CSysString tmp = message;
|
||||
AString tmp = message;
|
||||
tmp += " #";
|
||||
tmp += DWORDToString(code);
|
||||
g_StartupInfo.ShowMessage(tmp);
|
||||
@@ -404,7 +404,7 @@ void PrintErrorMessage(const char *message, int code)
|
||||
|
||||
void PrintErrorMessage(const char *message, const char *text)
|
||||
{
|
||||
CSysString tmp = message;
|
||||
AString tmp = message;
|
||||
tmp += ":\n";
|
||||
tmp += text;
|
||||
g_StartupInfo.ShowMessageLines(tmp);
|
||||
@@ -442,10 +442,10 @@ bool WasEscPressed()
|
||||
|
||||
void ShowErrorMessage(DWORD errorCode)
|
||||
{
|
||||
AString message;
|
||||
CSysString message;
|
||||
NError::MyFormatMessage(errorCode, message);
|
||||
message.Replace("\x0D", "");
|
||||
message.Replace("\x0A", " ");
|
||||
message.Replace(TEXT("\x0D"), TEXT(""));
|
||||
message.Replace(TEXT("\x0A"), TEXT(" "));
|
||||
g_StartupInfo.ShowMessage(SystemStringToOemString(message));
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class CStartupInfo
|
||||
|
||||
public:
|
||||
void Init(const PluginStartupInfo &pluginStartupInfo,
|
||||
const CSysString &pliginNameForRegestry);
|
||||
const CSysString &pluginNameForRegestry);
|
||||
const char *GetMsgString(int messageId);
|
||||
int ShowMessage(unsigned int flags, const char *helpTopic,
|
||||
const char **items, int numItems, int numButtons);
|
||||
|
||||
@@ -2,89 +2,40 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
// #include <locale.h>
|
||||
#include <initguid.h>
|
||||
#include "Common/MyInitGuid.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/DynamicBuffer.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Defs.h"
|
||||
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileIO.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/NtCheck.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "../Common/DefaultName.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
#include "ProgressBox.h"
|
||||
#include "FarUtils.h"
|
||||
#include "Messages.h"
|
||||
#include "Plugin.h"
|
||||
#include "ProgressBox.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
static const char *kCommandPrefix = "7-zip";
|
||||
|
||||
static const char *kRegisrtryMainKeyName = "";
|
||||
|
||||
static const char *kRegisrtryValueNameEnabled = "UsedByDefault3";
|
||||
static const char *kHelpTopicConfig = "Config";
|
||||
static bool kPluginEnabledDefault = true;
|
||||
|
||||
static const char *kHelpTopicConfig = "Config";
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void WINAPI SetStartupInfo(struct PluginStartupInfo *info);
|
||||
HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char *Data,
|
||||
unsigned int DataSize);
|
||||
HANDLE WINAPI OpenPlugin(int openFrom, int item);
|
||||
void WINAPI ClosePlugin(HANDLE plugin);
|
||||
int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems,
|
||||
int *itemsNumber, int OpMode);
|
||||
void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber);
|
||||
int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, char *destPath, int opMode);
|
||||
int WINAPI SetDirectory(HANDLE plugin, char *dir, int opMode);
|
||||
void WINAPI GetPluginInfo(struct PluginInfo *info);
|
||||
int WINAPI Configure(int itemNumber);
|
||||
void WINAPI GetOpenPluginInfo(HANDLE plugin, struct OpenPluginInfo *info);
|
||||
int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, int opMode);
|
||||
int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems,
|
||||
int itemsNumber, int opMode);
|
||||
int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState);
|
||||
};
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION return FALSE;
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
NT_CHECK
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -96,7 +47,7 @@ static struct COptions
|
||||
|
||||
static const char *kPliginNameForRegestry = "7-ZIP";
|
||||
|
||||
void WINAPI SetStartupInfo(struct PluginStartupInfo *info)
|
||||
EXTERN_C void WINAPI SetStartupInfo(struct PluginStartupInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
g_StartupInfo.Init(*info, kPliginNameForRegestry);
|
||||
@@ -289,8 +240,7 @@ STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
|
||||
IInStream **inStream)
|
||||
STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
@@ -443,8 +393,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
|
||||
return (HANDLE)(plugin);
|
||||
}
|
||||
|
||||
HANDLE WINAPI OpenFilePlugin(char *name,
|
||||
const unsigned char * /* data */, unsigned int /* dataSize */)
|
||||
EXTERN_C HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char * /* data */, unsigned int /* dataSize */)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
if (name == NULL || (!g_Options.Enabled))
|
||||
@@ -456,7 +405,7 @@ HANDLE WINAPI OpenFilePlugin(char *name,
|
||||
MY_TRY_END2("OpenFilePlugin", INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
HANDLE WINAPI OpenPlugin(int openFrom, int item)
|
||||
EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, int item)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
if(openFrom == OPEN_COMMANDLINE)
|
||||
@@ -504,30 +453,28 @@ HANDLE WINAPI OpenPlugin(int openFrom, int item)
|
||||
MY_TRY_END2("OpenPlugin", INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
void WINAPI ClosePlugin(HANDLE plugin)
|
||||
EXTERN_C void WINAPI ClosePlugin(HANDLE plugin)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
delete (CPlugin *)plugin;
|
||||
MY_TRY_END1("ClosePlugin");
|
||||
}
|
||||
|
||||
int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems,
|
||||
int *itemsNumber,int opMode)
|
||||
EXTERN_C int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems, int *itemsNumber, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->GetFindData(panelItems, itemsNumber, opMode));
|
||||
MY_TRY_END2("GetFindData", FALSE);
|
||||
}
|
||||
|
||||
void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber)
|
||||
EXTERN_C void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
((CPlugin *)plugin)->FreeFindData(panelItems, itemsNumber);
|
||||
MY_TRY_END1("FreeFindData");
|
||||
}
|
||||
|
||||
int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
EXTERN_C int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, char *destPath, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
@@ -535,14 +482,14 @@ int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
MY_TRY_END2("GetFiles", NFileOperationReturnCode::kError);
|
||||
}
|
||||
|
||||
int WINAPI SetDirectory(HANDLE plugin, char *dir, int opMode)
|
||||
EXTERN_C int WINAPI SetDirectory(HANDLE plugin, char *dir, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->SetDirectory(dir, opMode));
|
||||
MY_TRY_END2("SetDirectory", FALSE);
|
||||
}
|
||||
|
||||
void WINAPI GetPluginInfo(struct PluginInfo *info)
|
||||
EXTERN_C void WINAPI GetPluginInfo(struct PluginInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
|
||||
@@ -564,7 +511,7 @@ void WINAPI GetPluginInfo(struct PluginInfo *info)
|
||||
MY_TRY_END1("GetPluginInfo");
|
||||
}
|
||||
|
||||
int WINAPI Configure(int /* itemNumber */)
|
||||
EXTERN_C int WINAPI Configure(int /* itemNumber */)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
|
||||
@@ -601,30 +548,28 @@ int WINAPI Configure(int /* itemNumber */)
|
||||
MY_TRY_END2("Configure", FALSE);
|
||||
}
|
||||
|
||||
void WINAPI GetOpenPluginInfo(HANDLE plugin,struct OpenPluginInfo *info)
|
||||
EXTERN_C void WINAPI GetOpenPluginInfo(HANDLE plugin,struct OpenPluginInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
((CPlugin *)plugin)->GetOpenPluginInfo(info);
|
||||
MY_TRY_END1("GetOpenPluginInfo");
|
||||
}
|
||||
|
||||
int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, int opMode)
|
||||
EXTERN_C int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber, int move, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->PutFiles(panelItems, itemsNumber, move, opMode));
|
||||
MY_TRY_END2("PutFiles", NFileOperationReturnCode::kError);
|
||||
}
|
||||
|
||||
int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems,
|
||||
int itemsNumber, int opMode)
|
||||
EXTERN_C int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems, int itemsNumber, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->DeleteFiles(panelItems, itemsNumber, opMode));
|
||||
MY_TRY_END2("DeleteFiles", FALSE);
|
||||
}
|
||||
|
||||
int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState)
|
||||
EXTERN_C int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return (((CPlugin *)plugin)->ProcessKey(key, controlState));
|
||||
|
||||
@@ -2,40 +2,33 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Wildcard.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
#include "../Common/PropIDUtils.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
#include "Messages.h"
|
||||
#include "Plugin.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
CPlugin::CPlugin(const UString &fileName,
|
||||
IInFolderArchive *archiveHandler,
|
||||
UString archiveTypeName
|
||||
):
|
||||
m_ArchiveHandler(archiveHandler),
|
||||
m_FileName(fileName),
|
||||
_archiveTypeName(archiveTypeName)
|
||||
CPlugin::CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName):
|
||||
m_ArchiveHandler(archiveHandler),
|
||||
m_FileName(fileName),
|
||||
_archiveTypeName(archiveTypeName)
|
||||
{
|
||||
if (!m_FileInfo.Find(m_FileName))
|
||||
throw "error";
|
||||
archiveHandler->BindToRootFolder(&_folder);
|
||||
}
|
||||
|
||||
CPlugin::~CPlugin()
|
||||
{
|
||||
}
|
||||
CPlugin::~CPlugin() {}
|
||||
|
||||
static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex,
|
||||
PROPID propID, FILETIME &fileTime)
|
||||
@@ -59,6 +52,17 @@ static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex,
|
||||
#define kDotsReplaceString "[[..]]"
|
||||
#define kDotsReplaceStringU L"[[..]]"
|
||||
|
||||
static void CopyStrLimited(char *dest, const AString &src, int len)
|
||||
{
|
||||
len--;
|
||||
if (src.Length() < len)
|
||||
len = src.Length();
|
||||
memcpy(dest, src, sizeof(dest[0]) * len);
|
||||
dest[len] = 0;
|
||||
}
|
||||
|
||||
#define COPY_STR_LIMITED(dest, src) CopyStrLimited(dest, src, sizeof(dest) / sizeof(dest[0]))
|
||||
|
||||
void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
@@ -69,14 +73,10 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
|
||||
throw 272340;
|
||||
|
||||
CSysString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
|
||||
const int kFileNameSizeMax = (int)(sizeof(panelItem.FindData.cFileName) / sizeof(panelItem.FindData.cFileName[0]) - 1);
|
||||
if (oemString.Length() > kFileNameSizeMax)
|
||||
oemString = oemString.Left(kFileNameSizeMax);
|
||||
|
||||
if (oemString == "..")
|
||||
oemString = kDotsReplaceString;
|
||||
|
||||
MyStringCopy(panelItem.FindData.cFileName, (const char *)oemString);
|
||||
COPY_STR_LIMITED(panelItem.FindData.cFileName, oemString);
|
||||
panelItem.FindData.cAlternateFileName[0] = 0;
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidAttrib, &prop) != S_OK)
|
||||
@@ -138,8 +138,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
|
||||
panelItem.Reserved[2] = 0;
|
||||
}
|
||||
|
||||
int CPlugin::GetFindData(PluginPanelItem **panelItems,
|
||||
int *itemsNumber, int opMode)
|
||||
int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode)
|
||||
{
|
||||
// CScreenRestorer screenRestorer;
|
||||
if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
|
||||
@@ -177,8 +176,7 @@ int CPlugin::GetFindData(PluginPanelItem **panelItems,
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
void CPlugin::FreeFindData(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber)
|
||||
void CPlugin::FreeFindData(struct PluginPanelItem *panelItems, int itemsNumber)
|
||||
{
|
||||
for (int i = 0; i < itemsNumber; i++)
|
||||
if (panelItems[i].Description != NULL)
|
||||
@@ -186,7 +184,6 @@ void CPlugin::FreeFindData(struct PluginPanelItem *panelItems,
|
||||
delete []panelItems;
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::EnterToDirectory(const UString &dirName)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
@@ -510,12 +507,10 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS| OPIF_USEHIGHLIGHTING|
|
||||
OPIF_ADDDOTS | OPIF_COMPAREFATTIME;
|
||||
|
||||
UINT codePage = ::AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
|
||||
MyStringCopy(m_FileNameBuffer, (const char *)UnicodeStringToMultiByte(m_FileName, codePage));
|
||||
COPY_STR_LIMITED(m_FileNameBuffer, UnicodeStringToMultiByte(m_FileName, CP_OEMCP));
|
||||
info->HostFile = m_FileNameBuffer; // test it it is not static
|
||||
|
||||
MyStringCopy(m_CurrentDirBuffer, (const char *)UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP));
|
||||
COPY_STR_LIMITED(m_CurrentDirBuffer, UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP));
|
||||
info->CurDir = m_CurrentDirBuffer;
|
||||
|
||||
info->Format = kPluginFormatName;
|
||||
@@ -540,7 +535,7 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
m_PannelTitle += m_CurrentDir;
|
||||
}
|
||||
|
||||
MyStringCopy(m_PannelTitleBuffer, (const char *)UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP));
|
||||
COPY_STR_LIMITED(m_PannelTitleBuffer, UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP));
|
||||
info->PanelTitle = m_PannelTitleBuffer;
|
||||
|
||||
memset(m_InfoLines, 0, sizeof(m_InfoLines));
|
||||
@@ -572,8 +567,8 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
continue;
|
||||
|
||||
InfoPanelLine &item = m_InfoLines[numItems++];
|
||||
MyStringCopy(item.Text, (const char *)GetNameOfProp2(propID, name));
|
||||
MyStringCopy(item.Data, (const char *)PropToString2(prop, propID));
|
||||
COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name));
|
||||
COPY_STR_LIMITED(item.Data, PropToString2(prop, propID));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -614,8 +609,8 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
if (getProps->GetArchiveProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY)
|
||||
continue;
|
||||
InfoPanelLine &item = m_InfoLines[numItems++];
|
||||
MyStringCopy(item.Text, (const char *)GetNameOfProp2(propID, name));
|
||||
MyStringCopy(item.Data, (const char *)PropToString2(prop, propID));
|
||||
COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name));
|
||||
COPY_STR_LIMITED(item.Data, PropToString2(prop, propID));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,8 @@ class CPlugin
|
||||
PanelMode PanelMode;
|
||||
void AddColumn(PROPID aPropID);
|
||||
|
||||
|
||||
void EnterToDirectory(const UString &aDirName);
|
||||
|
||||
void GetPathParts(UStringVector &aPathParts);
|
||||
void EnterToDirectory(const UString &dirName);
|
||||
void GetPathParts(UStringVector &pathParts);
|
||||
void GetCurrentDir();
|
||||
public:
|
||||
UString m_FileName;
|
||||
@@ -45,55 +43,46 @@ public:
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
CMyComPtr<IFolderFolder> _folder;
|
||||
|
||||
// CArchiverInfo m_ArchiverInfo;
|
||||
UString _archiveTypeName;
|
||||
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
|
||||
CPlugin(const UString &fileName,
|
||||
// const UString &aDefaultName,
|
||||
IInFolderArchive *archiveHandler,
|
||||
UString archiveTypeName
|
||||
);
|
||||
CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName);
|
||||
~CPlugin();
|
||||
|
||||
void ReadValueSafe(PROPID aPropID, NWindows::NCOM::CPropVariant aPropVariant);
|
||||
void ReadPluginPanelItem(PluginPanelItem &aPanelItem, UINT32 anItemIndex);
|
||||
|
||||
int GetFindData(PluginPanelItem **pPanelItem,int *pItemsNumber,int OpMode);
|
||||
void FreeFindData(PluginPanelItem *PanelItem,int ItemsNumber);
|
||||
int SetDirectory(const char *aDir, int opMode);
|
||||
void GetOpenPluginInfo(struct OpenPluginInfo *anInfo);
|
||||
|
||||
int DeleteFiles(PluginPanelItem *aPanelItems, int itemsNumber, int opMode);
|
||||
void ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex);
|
||||
|
||||
int GetFindData(PluginPanelItem **panelItems,int *itemsNumber,int opMode);
|
||||
void FreeFindData(PluginPanelItem *panelItem,int ItemsNumber);
|
||||
int SetDirectory(const char *aszDir, int opMode);
|
||||
void GetOpenPluginInfo(struct OpenPluginInfo *info);
|
||||
int DeleteFiles(PluginPanelItem *panelItems, int itemsNumber, int opMode);
|
||||
|
||||
HRESULT ExtractFiles(
|
||||
bool decompressAllItems,
|
||||
const UINT32 *indices,
|
||||
UINT32 numIndices,
|
||||
const UInt32 *indices,
|
||||
UInt32 numIndices,
|
||||
bool silent,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const UString &destPath,
|
||||
bool passwordIsDefined, const UString &password);
|
||||
|
||||
NFar::NFileOperationReturnCode::EEnum GetFiles(struct PluginPanelItem *aPanelItem, int itemsNumber,
|
||||
int move, char *destPath, int opMode);
|
||||
NFar::NFileOperationReturnCode::EEnum GetFiles(struct PluginPanelItem *panelItem, int itemsNumber,
|
||||
int move, char *destPath, int opMode);
|
||||
|
||||
NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *aPanelItems,
|
||||
int itemsNumber, int move, const char *_aDestPath, int opMode, bool aShowBox);
|
||||
NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, const char *_aDestPath, int opMode, bool showBox);
|
||||
|
||||
NFar::NFileOperationReturnCode::EEnum PutFiles(struct PluginPanelItem *aPanelItems, int itemsNumber,
|
||||
int move, int opMode);
|
||||
NFar::NFileOperationReturnCode::EEnum PutFiles(struct PluginPanelItem *panelItems, int itemsNumber,
|
||||
int move, int opMode);
|
||||
|
||||
HRESULT ShowAttributesWindow();
|
||||
|
||||
int ProcessKey(int aKey, unsigned int aControlState);
|
||||
int ProcessKey(int key, unsigned int controlState);
|
||||
};
|
||||
|
||||
HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &aPluginPanelItems);
|
||||
HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,21 +2,14 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Plugin.h"
|
||||
#include "Messages.h"
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
#include "../Common/WorkDir.h"
|
||||
|
||||
#include "Messages.h"
|
||||
#include "Plugin.h"
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
using namespace NFar;
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
@@ -24,8 +17,7 @@ using namespace NDirectory;
|
||||
|
||||
static LPCWSTR kTempArchivePrefix = L"7zA";
|
||||
|
||||
int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
|
||||
int opMode)
|
||||
int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
{
|
||||
if (numItems == 0)
|
||||
return FALSE;
|
||||
@@ -48,8 +40,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
|
||||
char msg[1024];
|
||||
if (numItems == 1)
|
||||
{
|
||||
sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteFile),
|
||||
panelItems[0].FindData.cFileName);
|
||||
sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteFile), panelItems[0].FindData.cFileName);
|
||||
msgItems[1] = msg;
|
||||
}
|
||||
else if (numItems > 1)
|
||||
@@ -77,7 +68,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
|
||||
}
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
ReadWorkDirInfo(workDirInfo);
|
||||
workDirInfo.Load();
|
||||
|
||||
UString workDir = GetWorkDir(workDirInfo, m_FileName);
|
||||
CreateComplexDirectory(workDir);
|
||||
@@ -101,8 +92,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
|
||||
GetPathParts(pathVector);
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
HRESULT result = m_ArchiveHandler.QueryInterface(
|
||||
IID_IOutFolderArchive, &outArchive);
|
||||
HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive);
|
||||
if(result != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
|
||||
@@ -109,7 +109,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
{
|
||||
const int kPathIndex = 2;
|
||||
|
||||
ReadExtractionInfo(extractionInfo);
|
||||
extractionInfo.Load();
|
||||
|
||||
const int kPathModeRadioIndex = 4;
|
||||
const int kOverwriteModeRadioIndex = kPathModeRadioIndex + 4;
|
||||
@@ -230,7 +230,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
SaveExtractionInfo(extractionInfo);
|
||||
extractionInfo.Save();
|
||||
|
||||
if (dialogItems[kFilesModeIndex].Selected)
|
||||
extractSelectedFiles = true;
|
||||
|
||||
@@ -78,7 +78,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
const int kXMid = 38;
|
||||
|
||||
NCompression::CInfo compressionInfo;
|
||||
ReadCompressionInfo(compressionInfo);
|
||||
compressionInfo.Load();
|
||||
|
||||
int methodIndex = 0;
|
||||
int i;
|
||||
@@ -145,16 +145,16 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
else if (dialogItems[kModeRadioIndex + 1].Selected)
|
||||
actionSet = &kUpdateActionSet;
|
||||
else if (dialogItems[kModeRadioIndex + 2].Selected)
|
||||
actionSet = &kFreshActionSet;
|
||||
actionSet = &kFreshActionSet;
|
||||
else if (dialogItems[kModeRadioIndex + 3].Selected)
|
||||
actionSet = &kSynchronizeActionSet;
|
||||
actionSet = &kSynchronizeActionSet;
|
||||
else
|
||||
throw 51751;
|
||||
|
||||
SaveCompressionInfo(compressionInfo);
|
||||
compressionInfo.Save();
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
ReadWorkDirInfo(workDirInfo);
|
||||
workDirInfo.Load();
|
||||
UString workDir = GetWorkDir(workDirInfo, m_FileName);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
@@ -425,8 +425,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
}
|
||||
|
||||
NCompression::CInfo compressionInfo;
|
||||
// CZipRegistryManager aZipRegistryManager;
|
||||
ReadCompressionInfo(compressionInfo);
|
||||
compressionInfo.Load();
|
||||
|
||||
int archiverIndex = 0;
|
||||
|
||||
@@ -442,7 +441,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
{
|
||||
if (archiverIndex == -1)
|
||||
archiverIndex = i;
|
||||
if (arcInfo.Name.CompareNoCase(compressionInfo.ArchiveType) == 0)
|
||||
if (arcInfo.Name.CompareNoCase(compressionInfo.ArcType) == 0)
|
||||
archiverIndex = i;
|
||||
}
|
||||
}
|
||||
@@ -647,11 +646,11 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
}
|
||||
|
||||
const CArcInfoEx &archiverInfoFinal = codecs->Formats[archiverIndex];
|
||||
compressionInfo.ArchiveType = archiverInfoFinal.Name;
|
||||
SaveCompressionInfo(compressionInfo);
|
||||
compressionInfo.ArcType = archiverInfoFinal.Name;
|
||||
compressionInfo.Save();
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
ReadWorkDirInfo(workDirInfo);
|
||||
workDirInfo.Load();
|
||||
|
||||
UString fullArchiveName;
|
||||
if (!MyGetFullPathName(archiveName, fullArchiveName))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
PROG = 7-ZipFar.dll
|
||||
DEF_FILE = Far.def
|
||||
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib ole32.lib
|
||||
CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DWIN_LONG_PATH \
|
||||
-DEXTERNAL_CODECS
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "AboutDialogRes.h"
|
||||
#include "AboutDialog.h"
|
||||
#include "HelpUtils.h"
|
||||
#include "LangUtils.h"
|
||||
@@ -18,15 +17,17 @@ static CIDLangPair kIDLangPairs[] =
|
||||
#define MY_HOME_PAGE TEXT("http://www.7-zip.org/")
|
||||
|
||||
static LPCTSTR kHomePageURL = MY_HOME_PAGE;
|
||||
/*
|
||||
static LPCTSTR kRegisterPageURL = MY_HOME_PAGE TEXT("register.html");
|
||||
static LPCTSTR kSupportPageURL = MY_HOME_PAGE TEXT("support.html");
|
||||
|
||||
*/
|
||||
static LPCWSTR kHelpTopic = L"start.htm";
|
||||
|
||||
bool CAboutDialog::OnInit()
|
||||
{
|
||||
LangSetWindowText(HWND(*this), 0x01000100);
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
NormalizePosition();
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
@@ -35,26 +36,29 @@ void CAboutDialog::OnHelp()
|
||||
ShowHelpWindow(NULL, kHelpTopic);
|
||||
}
|
||||
|
||||
static void MyShellExecute(LPCTSTR url)
|
||||
{
|
||||
::ShellExecute(NULL, NULL, url, NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
bool CAboutDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
{
|
||||
LPCTSTR url;
|
||||
switch(buttonID)
|
||||
{
|
||||
case IDC_ABOUT_BUTTON_HOMEPAGE:
|
||||
::MyShellExecute(kHomePageURL);
|
||||
break;
|
||||
case IDC_ABOUT_BUTTON_REGISTER:
|
||||
::MyShellExecute(kRegisterPageURL);
|
||||
break;
|
||||
case IDC_ABOUT_BUTTON_SUPPORT:
|
||||
::MyShellExecute(kSupportPageURL);
|
||||
break;
|
||||
case IDC_ABOUT_BUTTON_HOMEPAGE: url = kHomePageURL; break;
|
||||
/*
|
||||
case IDC_ABOUT_BUTTON_REGISTER: url = kRegisterPageURL; break;
|
||||
case IDC_ABOUT_BUTTON_SUPPORT: url = kSupportPageURL; break;
|
||||
*/
|
||||
default:
|
||||
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
|
||||
}
|
||||
|
||||
#ifdef UNDER_CE
|
||||
SHELLEXECUTEINFO s;
|
||||
memset(&s, 0, sizeof(s));
|
||||
s.cbSize = sizeof(s);
|
||||
s.lpFile = url;
|
||||
::ShellExecuteEx(&s);
|
||||
#else
|
||||
::ShellExecute(NULL, NULL, url, NULL, NULL, SW_SHOWNORMAL);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,40 +2,25 @@
|
||||
#include "../../GuiCommon.rc"
|
||||
#include "../../MyVersion.h"
|
||||
|
||||
#define xSize2 224
|
||||
#define ySize2 158
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
#define xc 144
|
||||
#define yc 144
|
||||
|
||||
#define bXPos (xSize - marg - bXSize)
|
||||
#define bYPos (ySize - marg - bYSize)
|
||||
#define y 80
|
||||
|
||||
#undef b2XSize
|
||||
#undef b2XPos
|
||||
#undef infoYPos
|
||||
#undef infoYSize
|
||||
IDI_LOGO ICON "../../UI/FileManager/7zipLogo.ico"
|
||||
|
||||
#define b2XSize 94
|
||||
#define b2XPos (xSize - marg - b2XSize)
|
||||
#define gSpace 2
|
||||
#define gSize (xSize2 - gSpace - b2XSize)
|
||||
#ifndef SS_REALSIZEIMAGE
|
||||
#define SS_REALSIZEIMAGE 0x800
|
||||
#endif
|
||||
|
||||
#define infoYPos 91
|
||||
#define infoYSize (ySize2 - infoYPos - bYSize - 2)
|
||||
|
||||
IDI_LOGO ICON "7zipLogo.ico"
|
||||
|
||||
IDD_ABOUT DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
|
||||
IDD_ABOUT MY_DIALOG
|
||||
CAPTION "About 7-Zip"
|
||||
MY_FONT
|
||||
BEGIN
|
||||
PUSHBUTTON "OK", IDOK, bXPos, bYPos, bXSize, bYSize
|
||||
PUSHBUTTON "www.7-zip.org", IDC_ABOUT_BUTTON_HOMEPAGE, b2XPos, 7, b2XSize, bYSize
|
||||
PUSHBUTTON "Support", IDC_ABOUT_BUTTON_SUPPORT, b2XPos, 30, b2XSize, bYSize
|
||||
PUSHBUTTON "Register", IDC_ABOUT_BUTTON_REGISTER, b2XPos, 53, b2XSize, bYSize
|
||||
ICON IDI_LOGO, -1, marg, marg, 20, 20, SS_REALSIZEIMAGE
|
||||
LTEXT MY_7ZIP_VERSION, -1, marg, 54, gSize, 9
|
||||
LTEXT MY_COPYRIGHT, -1, marg, 67, gSize, 17
|
||||
{
|
||||
DEFPUSHBUTTON "OK", IDOK, bx1, by, bxs, bys
|
||||
PUSHBUTTON "www.7-zip.org", IDC_ABOUT_BUTTON_HOMEPAGE, bx2, by, bxs, bys
|
||||
ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE
|
||||
LTEXT MY_7ZIP_VERSION, -1, m, 54, xc, 8
|
||||
LTEXT MY_COPYRIGHT, -1, m, 67, xc, 8
|
||||
LTEXT "7-Zip is free software. However, you can support development of 7-Zip by registering.",
|
||||
IDC_ABOUT_STATIC_REGISTER_INFO, marg, infoYPos, xSize2, infoYSize
|
||||
END
|
||||
IDC_ABOUT_STATIC_REGISTER_INFO, m, y, xc, (by - y - 1)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define IDD_ABOUT 100
|
||||
#define IDD_ABOUT 507
|
||||
#define IDI_LOGO 138
|
||||
#define IDC_ABOUT_STATIC_REGISTER_INFO 1010
|
||||
#define IDC_ABOUT_BUTTON_HOMEPAGE 1020
|
||||
|
||||
@@ -71,15 +71,14 @@ void CApp::SetListSettings()
|
||||
extendedStyle |= LVS_EX_GRIDLINES;
|
||||
bool mySelectionMode = ReadAlternativeSelection();
|
||||
|
||||
/*
|
||||
if (ReadSingleClick())
|
||||
{
|
||||
extendedStyle |= LVS_EX_ONECLICKACTIVATE
|
||||
| LVS_EX_TRACKSELECT;
|
||||
extendedStyle |= LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT;
|
||||
/*
|
||||
if (ReadUnderline())
|
||||
extendedStyle |= LVS_EX_UNDERLINEHOT;
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
for (int i = 0; i < kNumPanelsMax; i++)
|
||||
{
|
||||
@@ -104,6 +103,10 @@ void CApp::SetShowSystemMenu()
|
||||
ShowSystemMenu = ReadShowSystemMenu();
|
||||
}
|
||||
|
||||
#ifndef ILC_COLOR32
|
||||
#define ILC_COLOR32 0x0020
|
||||
#endif
|
||||
|
||||
HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted)
|
||||
{
|
||||
if (PanelsCreated[panelIndex])
|
||||
@@ -124,24 +127,23 @@ HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &arch
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void CreateToolbar(
|
||||
HWND parent,
|
||||
static void CreateToolbar(HWND parent,
|
||||
NWindows::NControl::CImageList &imageList,
|
||||
NWindows::NControl::CToolBar &toolBar,
|
||||
bool LargeButtons)
|
||||
bool largeButtons)
|
||||
{
|
||||
toolBar.Attach(::CreateWindowEx(0,
|
||||
TOOLBARCLASSNAME,
|
||||
NULL, 0
|
||||
toolBar.Attach(::CreateWindowEx(0, TOOLBARCLASSNAME, NULL, 0
|
||||
| WS_CHILD
|
||||
| WS_VISIBLE
|
||||
| TBSTYLE_FLAT
|
||||
| TBSTYLE_TOOLTIPS
|
||||
| WS_CHILD
|
||||
| CCS_NOPARENTALIGN
|
||||
| CCS_NORESIZE
|
||||
| CCS_NODIVIDER
|
||||
| TBSTYLE_WRAPABLE
|
||||
// | TBSTYLE_AUTOSIZE
|
||||
// | CCS_ADJUSTABLE
|
||||
// | CCS_NORESIZE
|
||||
#ifdef UNDER_CE
|
||||
| CCS_NODIVIDER
|
||||
| CCS_NOPARENTALIGN
|
||||
#endif
|
||||
,0,0,0,0, parent, NULL, g_hInstance, NULL));
|
||||
|
||||
// TB_BUTTONSTRUCTSIZE message, which is required for
|
||||
@@ -149,8 +151,8 @@ static void CreateToolbar(
|
||||
toolBar.ButtonStructSize();
|
||||
|
||||
imageList.Create(
|
||||
LargeButtons ? 48: 24,
|
||||
LargeButtons ? 36: 24,
|
||||
largeButtons ? 48: 24,
|
||||
largeButtons ? 36: 24,
|
||||
ILC_MASK | ILC_COLOR32, 0, 0);
|
||||
toolBar.SetImageList(0, imageList);
|
||||
}
|
||||
@@ -162,7 +164,7 @@ struct CButtonInfo
|
||||
UINT Bitmap2ResID;
|
||||
UINT StringResID;
|
||||
UInt32 LangID;
|
||||
UString GetText() const { return LangString(StringResID, LangID); };
|
||||
UString GetText() const { return LangString(StringResID, LangID); }
|
||||
};
|
||||
|
||||
static CButtonInfo g_StandardButtons[] =
|
||||
@@ -206,17 +208,13 @@ static void SetButtonText(int commandID, UString &s)
|
||||
static void AddButton(
|
||||
NControl::CImageList &imageList,
|
||||
NControl::CToolBar &toolBar,
|
||||
CButtonInfo &butInfo,
|
||||
bool showText,
|
||||
bool large)
|
||||
CButtonInfo &butInfo, bool showText, bool large)
|
||||
{
|
||||
TBBUTTON but;
|
||||
but.iBitmap = 0;
|
||||
but.idCommand = butInfo.CommandID;
|
||||
but.fsState = TBSTATE_ENABLED;
|
||||
but.fsStyle = BTNS_BUTTON
|
||||
// | BTNS_AUTOSIZE
|
||||
;
|
||||
but.fsStyle = TBSTYLE_BUTTON;
|
||||
but.dwData = 0;
|
||||
|
||||
UString s = butInfo.GetText();
|
||||
@@ -241,110 +239,54 @@ static void AddButton(
|
||||
#endif
|
||||
}
|
||||
|
||||
static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar)
|
||||
{
|
||||
SIZE size;
|
||||
toolBar.GetMaxSize(&size);
|
||||
|
||||
RECT rect;
|
||||
toolBar.GetWindowRect(&rect);
|
||||
|
||||
REBARBANDINFO rbBand;
|
||||
rbBand.cbSize = sizeof(REBARBANDINFO); // Required
|
||||
rbBand.fMask = RBBIM_STYLE
|
||||
| RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
|
||||
rbBand.fStyle = RBBS_CHILDEDGE; // RBBS_NOGRIPPER;
|
||||
rbBand.cxMinChild = size.cx; // rect.right - rect.left;
|
||||
rbBand.cyMinChild = size.cy; // rect.bottom - rect.top;
|
||||
rbBand.cyChild = rbBand.cyMinChild;
|
||||
rbBand.cx = rbBand.cxMinChild;
|
||||
rbBand.cxIdeal = rbBand.cxMinChild;
|
||||
rbBand.hwndChild = toolBar;
|
||||
reBar.InsertBand(-1, &rbBand);
|
||||
}
|
||||
|
||||
void CApp::ReloadToolbars()
|
||||
{
|
||||
if (!_rebar)
|
||||
return;
|
||||
HWND parent = _rebar;
|
||||
_buttonsImageList.Destroy();
|
||||
_toolBar.Destroy();
|
||||
|
||||
while (_rebar.GetBandCount() > 0)
|
||||
_rebar.DeleteBand(0);
|
||||
|
||||
_archiveToolBar.Destroy();
|
||||
_archiveButtonsImageList.Destroy();
|
||||
|
||||
_standardButtonsImageList.Destroy();
|
||||
_standardToolBar.Destroy();
|
||||
|
||||
if (ShowArchiveToolbar)
|
||||
if (ShowArchiveToolbar || ShowStandardToolbar)
|
||||
{
|
||||
CreateToolbar(parent, _archiveButtonsImageList, _archiveToolBar, LargeButtons);
|
||||
for (int i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++)
|
||||
AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i],
|
||||
ShowButtonsLables, LargeButtons);
|
||||
AddBand(_rebar, _archiveToolBar);
|
||||
}
|
||||
CreateToolbar(_window, _buttonsImageList, _toolBar, LargeButtons);
|
||||
int i;
|
||||
if (ShowArchiveToolbar)
|
||||
for (i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++)
|
||||
AddButton(_buttonsImageList, _toolBar, g_ArchiveButtons[i], ShowButtonsLables, LargeButtons);
|
||||
if (ShowStandardToolbar)
|
||||
for (i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++)
|
||||
AddButton(_buttonsImageList, _toolBar, g_StandardButtons[i], ShowButtonsLables, LargeButtons);
|
||||
|
||||
if (ShowStandardToolbar)
|
||||
{
|
||||
CreateToolbar(parent, _standardButtonsImageList, _standardToolBar, LargeButtons);
|
||||
for (int i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++)
|
||||
AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i],
|
||||
ShowButtonsLables, LargeButtons);
|
||||
AddBand(_rebar, _standardToolBar);
|
||||
_toolBar.AutoSize();
|
||||
}
|
||||
}
|
||||
|
||||
void CApp::ReloadRebar(HWND hwnd)
|
||||
void CApp::SaveToolbarChanges()
|
||||
{
|
||||
_rebar.Destroy();
|
||||
if (!ShowArchiveToolbar && !ShowStandardToolbar)
|
||||
return;
|
||||
if (g_ComCtl32Version >= MAKELONG(71, 4))
|
||||
{
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
_rebar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
|
||||
REBARCLASSNAME,
|
||||
NULL,
|
||||
WS_VISIBLE
|
||||
| WS_BORDER
|
||||
| WS_CHILD
|
||||
| WS_CLIPCHILDREN
|
||||
| WS_CLIPSIBLINGS
|
||||
// | CCS_NODIVIDER
|
||||
// | CCS_NOPARENTALIGN // it's bead for moveing of two bands
|
||||
// | CCS_TOP
|
||||
| RBS_VARHEIGHT
|
||||
| RBS_BANDBORDERS
|
||||
// | RBS_AUTOSIZE
|
||||
,0,0,0,0, hwnd, NULL, g_hInstance, NULL));
|
||||
}
|
||||
if (_rebar == 0)
|
||||
return;
|
||||
REBARINFO rbi;
|
||||
rbi.cbSize = sizeof(REBARINFO); // Required when using this struct.
|
||||
rbi.fMask = 0;
|
||||
rbi.himl = (HIMAGELIST)NULL;
|
||||
_rebar.SetBarInfo(&rbi);
|
||||
SaveToolbar();
|
||||
ReloadToolbars();
|
||||
MoveSubWindows();
|
||||
}
|
||||
|
||||
void MyLoadMenu();
|
||||
|
||||
HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted)
|
||||
{
|
||||
_window.Attach(hwnd);
|
||||
#ifdef UNDER_CE
|
||||
_commandBar.Create(g_hInstance, hwnd, 1);
|
||||
#endif
|
||||
MyLoadMenu();
|
||||
#ifdef UNDER_CE
|
||||
_commandBar.AutoSize();
|
||||
#endif
|
||||
|
||||
ReadToolbar();
|
||||
ReloadRebar(hwnd);
|
||||
ReloadToolbars();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < kNumPanelsMax; i++)
|
||||
PanelsCreated[i] = false;
|
||||
|
||||
_window.Attach(hwnd);
|
||||
AppState.Read();
|
||||
SetListSettings();
|
||||
SetShowSystemMenu();
|
||||
@@ -380,8 +322,6 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &ar
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
extern void MoveSubWindows(HWND hWnd);
|
||||
|
||||
HRESULT CApp::SwitchOnOffOnePanel()
|
||||
{
|
||||
if (NumPanels == 1)
|
||||
@@ -398,7 +338,7 @@ HRESULT CApp::SwitchOnOffOnePanel()
|
||||
Panels[1 - LastFocusedPanel].Enable(false);
|
||||
Panels[1 - LastFocusedPanel].Show(SW_HIDE);
|
||||
}
|
||||
MoveSubWindows(_window);
|
||||
MoveSubWindows();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -647,14 +587,16 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
destPath = srcPanel._currentFolderPrefix + destPath;
|
||||
}
|
||||
|
||||
#ifndef UNDER_CE
|
||||
if (destPath.Length() > 0 && destPath[0] == '\\')
|
||||
if (destPath.Length() == 1 || destPath[1] != '\\')
|
||||
{
|
||||
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind(WCHAR_PATH_SEPARATOR) == destPath.Length() - 1) ||
|
||||
if (indices.Size() > 1 || (!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) ||
|
||||
NFind::DoesDirExist(destPath))
|
||||
{
|
||||
NDirectory::CreateComplexDirectory(destPath);
|
||||
@@ -831,26 +773,13 @@ int CApp::GetFocusedPanelIndex() const
|
||||
hwnd = GetParent(hwnd);
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
static UString g_ToolTipBuffer;
|
||||
static CSysString g_ToolTipBufferSys;
|
||||
|
||||
void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
|
||||
{
|
||||
if (pnmh->hwndFrom == _rebar)
|
||||
{
|
||||
switch(pnmh->code)
|
||||
{
|
||||
case RBN_HEIGHTCHANGE:
|
||||
{
|
||||
MoveSubWindows(g_HWND);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pnmh->code == TTN_GETDISPINFO)
|
||||
{
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
#ifndef __APP_H
|
||||
#define __APP_H
|
||||
|
||||
#include "Panel.h"
|
||||
#include "AppState.h"
|
||||
#include "Windows/Control/CommandBar.h"
|
||||
#include "Windows/Control/ImageList.h"
|
||||
|
||||
#include "AppState.h"
|
||||
#include "Panel.h"
|
||||
|
||||
class CApp;
|
||||
|
||||
extern CApp g_App;
|
||||
@@ -14,8 +16,6 @@ extern HWND g_HWND;
|
||||
|
||||
const int kNumPanelsMax = 2;
|
||||
|
||||
extern void MoveSubWindows(HWND hWnd);
|
||||
|
||||
enum
|
||||
{
|
||||
kAddCommand = kToolbarStartID,
|
||||
@@ -77,12 +77,10 @@ class CDropTarget:
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP1_MT(IDropTarget)
|
||||
STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState,
|
||||
POINTL pt, DWORD *effect);
|
||||
STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect);
|
||||
STDMETHOD(DragOver)(DWORD keyState, POINTL pt, DWORD * effect);
|
||||
STDMETHOD(DragLeave)();
|
||||
STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState,
|
||||
POINTL pt, DWORD *effect);
|
||||
STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect);
|
||||
|
||||
CDropTarget():
|
||||
TargetPanelIndex(-1),
|
||||
@@ -119,16 +117,18 @@ public:
|
||||
CPanel Panels[kNumPanelsMax];
|
||||
bool PanelsCreated[kNumPanelsMax];
|
||||
|
||||
NWindows::NControl::CImageList _archiveButtonsImageList;
|
||||
NWindows::NControl::CImageList _standardButtonsImageList;
|
||||
NWindows::NControl::CImageList _buttonsImageList;
|
||||
|
||||
NWindows::NControl::CReBar _rebar;
|
||||
NWindows::NControl::CToolBar _archiveToolBar;
|
||||
NWindows::NControl::CToolBar _standardToolBar;
|
||||
#ifdef UNDER_CE
|
||||
NWindows::NControl::CCommandBar _commandBar;
|
||||
#endif
|
||||
NWindows::NControl::CToolBar _toolBar;
|
||||
|
||||
CDropTarget *_dropTargetSpec;
|
||||
CMyComPtr<IDropTarget> _dropTarget;
|
||||
|
||||
CApp(): _window(0), NumPanels(2), LastFocusedPanel(0) {}
|
||||
|
||||
void CreateDragTarget()
|
||||
{
|
||||
_dropTargetSpec = new CDropTarget();
|
||||
@@ -165,94 +165,53 @@ public:
|
||||
void Save();
|
||||
void Release();
|
||||
|
||||
|
||||
/*
|
||||
void SetFocus(int panelIndex)
|
||||
{ Panels[panelIndex].SetFocusToList(); }
|
||||
*/
|
||||
void SetFocusToLastItem()
|
||||
{ Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); }
|
||||
|
||||
// void SetFocus(int panelIndex) { Panels[panelIndex].SetFocusToList(); }
|
||||
void SetFocusToLastItem() { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); }
|
||||
int GetFocusedPanelIndex() const { return LastFocusedPanel; }
|
||||
|
||||
bool IsPanelVisible(int index) const { return (NumPanels > 1 || index == LastFocusedPanel); }
|
||||
|
||||
/*
|
||||
void SetCurrentIndex()
|
||||
{ CurrentPanel = GetFocusedPanelIndex(); }
|
||||
*/
|
||||
|
||||
CApp(): NumPanels(2), LastFocusedPanel(0) {}
|
||||
CPanel &GetFocusedPanel()
|
||||
{ return Panels[GetFocusedPanelIndex()]; }
|
||||
CPanel &GetFocusedPanel() { return Panels[GetFocusedPanelIndex()]; }
|
||||
|
||||
// File Menu
|
||||
void OpenItem()
|
||||
{ GetFocusedPanel().OpenSelectedItems(true); }
|
||||
void OpenItemInside()
|
||||
{ GetFocusedPanel().OpenFocusedItemAsInternal(); }
|
||||
void OpenItemOutside()
|
||||
{ GetFocusedPanel().OpenSelectedItems(false); }
|
||||
void EditItem()
|
||||
{ GetFocusedPanel().EditItem(); }
|
||||
void Rename()
|
||||
{ GetFocusedPanel().RenameFile(); }
|
||||
void CopyTo()
|
||||
{ OnCopy(false, false, GetFocusedPanelIndex()); }
|
||||
void MoveTo()
|
||||
{ OnCopy(true, false, GetFocusedPanelIndex()); }
|
||||
void Delete(bool toRecycleBin)
|
||||
{ GetFocusedPanel().DeleteItems(toRecycleBin); }
|
||||
void OpenItem() { GetFocusedPanel().OpenSelectedItems(true); }
|
||||
void OpenItemInside() { GetFocusedPanel().OpenFocusedItemAsInternal(); }
|
||||
void OpenItemOutside() { GetFocusedPanel().OpenSelectedItems(false); }
|
||||
void EditItem() { GetFocusedPanel().EditItem(); }
|
||||
void Rename() { GetFocusedPanel().RenameFile(); }
|
||||
void CopyTo() { OnCopy(false, false, GetFocusedPanelIndex()); }
|
||||
void MoveTo() { OnCopy(true, false, GetFocusedPanelIndex()); }
|
||||
void Delete(bool toRecycleBin) { GetFocusedPanel().DeleteItems(toRecycleBin); }
|
||||
void CalculateCrc();
|
||||
void DiffFiles();
|
||||
void Split();
|
||||
void Combine();
|
||||
void Properties()
|
||||
{ GetFocusedPanel().Properties(); }
|
||||
void Comment()
|
||||
{ GetFocusedPanel().ChangeComment(); }
|
||||
void Properties() { GetFocusedPanel().Properties(); }
|
||||
void Comment() { GetFocusedPanel().ChangeComment(); }
|
||||
|
||||
void CreateFolder()
|
||||
{ GetFocusedPanel().CreateFolder(); }
|
||||
void CreateFile()
|
||||
{ GetFocusedPanel().CreateFile(); }
|
||||
void CreateFolder() { GetFocusedPanel().CreateFolder(); }
|
||||
void CreateFile() { GetFocusedPanel().CreateFile(); }
|
||||
|
||||
// Edit
|
||||
void EditCut()
|
||||
{ GetFocusedPanel().EditCut(); }
|
||||
void EditCopy()
|
||||
{ GetFocusedPanel().EditCopy(); }
|
||||
void EditPaste()
|
||||
{ GetFocusedPanel().EditPaste(); }
|
||||
void EditCut() { GetFocusedPanel().EditCut(); }
|
||||
void EditCopy() { GetFocusedPanel().EditCopy(); }
|
||||
void EditPaste() { GetFocusedPanel().EditPaste(); }
|
||||
|
||||
void SelectAll(bool selectMode)
|
||||
{ GetFocusedPanel().SelectAll(selectMode); }
|
||||
void InvertSelection()
|
||||
{ GetFocusedPanel().InvertSelection(); }
|
||||
void SelectSpec(bool selectMode)
|
||||
{ GetFocusedPanel().SelectSpec(selectMode); }
|
||||
void SelectByType(bool selectMode)
|
||||
{ GetFocusedPanel().SelectByType(selectMode); }
|
||||
void SelectAll(bool selectMode) { GetFocusedPanel().SelectAll(selectMode); }
|
||||
void InvertSelection() { GetFocusedPanel().InvertSelection(); }
|
||||
void SelectSpec(bool selectMode) { GetFocusedPanel().SelectSpec(selectMode); }
|
||||
void SelectByType(bool selectMode) { GetFocusedPanel().SelectByType(selectMode); }
|
||||
|
||||
void RefreshStatusBar()
|
||||
{ GetFocusedPanel().RefreshStatusBar(); }
|
||||
void RefreshStatusBar() { GetFocusedPanel().RefreshStatusBar(); }
|
||||
|
||||
void SetListViewMode(UINT32 index)
|
||||
{ GetFocusedPanel().SetListViewMode(index); }
|
||||
UINT32 GetListViewMode()
|
||||
{ return GetFocusedPanel().GetListViewMode(); }
|
||||
void SetListViewMode(UINT32 index) { GetFocusedPanel().SetListViewMode(index); }
|
||||
UINT32 GetListViewMode() { return GetFocusedPanel().GetListViewMode(); }
|
||||
PROPID GetSortID() { return GetFocusedPanel().GetSortID(); }
|
||||
|
||||
void SortItemsWithPropID(PROPID propID)
|
||||
{ GetFocusedPanel().SortItemsWithPropID(propID); }
|
||||
void SortItemsWithPropID(PROPID propID) { GetFocusedPanel().SortItemsWithPropID(propID); }
|
||||
|
||||
void OpenRootFolder()
|
||||
{ GetFocusedPanel().OpenDrivesFolder(); }
|
||||
void OpenParentFolder()
|
||||
{ GetFocusedPanel().OpenParentFolder(); }
|
||||
void FoldersHistory()
|
||||
{ GetFocusedPanel().FoldersHistory(); }
|
||||
void RefreshView()
|
||||
{ GetFocusedPanel().OnReload(); }
|
||||
void OpenRootFolder() { GetFocusedPanel().OpenDrivesFolder(); }
|
||||
void OpenParentFolder() { GetFocusedPanel().OpenParentFolder(); }
|
||||
void FoldersHistory() { GetFocusedPanel().FoldersHistory(); }
|
||||
void RefreshView() { GetFocusedPanel().OnReload(); }
|
||||
void RefreshAllPanels()
|
||||
{
|
||||
for (int i = 0; i < NumPanels; i++)
|
||||
@@ -263,18 +222,29 @@ public:
|
||||
Panels[index].OnReload();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void SysIconsWereChanged()
|
||||
{
|
||||
for (int i = 0; i < NumPanels; i++)
|
||||
{
|
||||
int index = i;
|
||||
if (NumPanels == 1)
|
||||
index = LastFocusedPanel;
|
||||
Panels[index].SysIconsWereChanged();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void SetListSettings();
|
||||
void SetShowSystemMenu();
|
||||
HRESULT SwitchOnOffOnePanel();
|
||||
bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); }
|
||||
void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); }
|
||||
|
||||
void OpenBookmark(int index)
|
||||
{ GetFocusedPanel().OpenBookmark(index); }
|
||||
void SetBookmark(int index)
|
||||
{ GetFocusedPanel().SetBookmark(index); }
|
||||
void OpenBookmark(int index) { GetFocusedPanel().OpenBookmark(index); }
|
||||
void SetBookmark(int index) { GetFocusedPanel().SetBookmark(index); }
|
||||
|
||||
void ReloadRebar(HWND hwnd);
|
||||
void ReloadToolbars();
|
||||
void ReadToolbar()
|
||||
{
|
||||
@@ -293,33 +263,28 @@ public:
|
||||
if (ShowArchiveToolbar) mask |= 8;
|
||||
SaveToolbarsMask(mask);
|
||||
}
|
||||
|
||||
void SaveToolbarChanges();
|
||||
|
||||
void SwitchStandardToolbar()
|
||||
{
|
||||
ShowStandardToolbar = !ShowStandardToolbar;
|
||||
SaveToolbar();
|
||||
ReloadRebar(g_HWND);
|
||||
MoveSubWindows(_window);
|
||||
SaveToolbarChanges();
|
||||
}
|
||||
void SwitchArchiveToolbar()
|
||||
{
|
||||
ShowArchiveToolbar = !ShowArchiveToolbar;
|
||||
SaveToolbar();
|
||||
ReloadRebar(g_HWND);
|
||||
MoveSubWindows(_window);
|
||||
SaveToolbarChanges();
|
||||
}
|
||||
void SwitchButtonsLables()
|
||||
{
|
||||
ShowButtonsLables = !ShowButtonsLables;
|
||||
SaveToolbar();
|
||||
ReloadRebar(g_HWND);
|
||||
MoveSubWindows(_window);
|
||||
SaveToolbarChanges();
|
||||
}
|
||||
void SwitchLargeButtons()
|
||||
{
|
||||
LargeButtons = !LargeButtons;
|
||||
SaveToolbar();
|
||||
ReloadRebar(g_HWND);
|
||||
MoveSubWindows(_window);
|
||||
SaveToolbarChanges();
|
||||
}
|
||||
|
||||
void AddToArchive() { GetFocusedPanel().AddToArchive(); }
|
||||
@@ -332,6 +297,8 @@ public:
|
||||
void RefreshTitle(bool always = false);
|
||||
void RefreshTitleAlways() { RefreshTitle(true); }
|
||||
void RefreshTitle(int panelIndex, bool always = false);
|
||||
|
||||
void MoveSubWindows();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
514
CPP/7zip/UI/FileManager/BrowseDialog.cpp
Executable file
514
CPP/7zip/UI/FileManager/BrowseDialog.cpp
Executable file
@@ -0,0 +1,514 @@
|
||||
// BrowseDialog.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
#include "BrowseDialog.h"
|
||||
#include "LangUtils.h"
|
||||
#include "PropertyNameRes.h"
|
||||
|
||||
#ifndef _SFX
|
||||
#include "RegistryUtils.h"
|
||||
#endif
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
extern bool g_LVN_ITEMACTIVATE_Support;
|
||||
|
||||
static const int kParentIndex = -1;
|
||||
|
||||
#ifdef LANG
|
||||
static CIDLangPair kIDLangPairs[] =
|
||||
{
|
||||
{ IDOK, 0x02000702 },
|
||||
{ IDCANCEL, 0x02000710 }
|
||||
};
|
||||
#endif
|
||||
|
||||
static bool GetParentPath(const UString &path2, UString &dest, UString &focused)
|
||||
{
|
||||
UString path = path2;
|
||||
dest.Empty();
|
||||
if (path.IsEmpty())
|
||||
return false;
|
||||
if (path.Back() == WCHAR_PATH_SEPARATOR)
|
||||
path.DeleteBack();
|
||||
if (path.IsEmpty())
|
||||
return false;
|
||||
int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
if (pos < 0 || path.Back() == WCHAR_PATH_SEPARATOR)
|
||||
return false;
|
||||
focused = path.Mid(pos + 1);
|
||||
dest = path.Left(pos + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBrowseDialog::OnInit()
|
||||
{
|
||||
#ifdef LANG
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
#endif
|
||||
if (!Title.IsEmpty())
|
||||
SetText(Title);
|
||||
_list.Attach(GetItem(IDC_BROWSE_LIST));
|
||||
|
||||
#ifndef UNDER_CE
|
||||
_list.SetUnicodeFormat(true);
|
||||
#endif
|
||||
|
||||
#ifndef _SFX
|
||||
if (ReadSingleClick())
|
||||
_list.SetExtendedListViewStyle(LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT);
|
||||
_showDots = ReadShowDots();
|
||||
#endif
|
||||
|
||||
_list.SetImageList(GetSysImageList(true), LVSIL_SMALL);
|
||||
_list.SetImageList(GetSysImageList(false), LVSIL_NORMAL);
|
||||
|
||||
_list.InsertColumn(0, LangStringSpec(IDS_PROP_NAME, 0x02000204), 100);
|
||||
_list.InsertColumn(1, LangStringSpec(IDS_PROP_MTIME, 0x0200020C), 100);
|
||||
{
|
||||
LV_COLUMNW column;
|
||||
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
|
||||
column.fmt = LVCFMT_RIGHT;
|
||||
column.iSubItem = 2;
|
||||
UString s = LangStringSpec(IDS_PROP_SIZE, 0x02000207);
|
||||
column.pszText = (wchar_t *)(const wchar_t *)s;
|
||||
_list.InsertColumn(2, &column);
|
||||
|
||||
// _list.InsertColumn(2, LangStringSpec(IDS_PROP_SIZE, 0x02000207), 100);
|
||||
}
|
||||
|
||||
_list.InsertItem(0, L"12345678901234567");
|
||||
_list.SetSubItem(0, 1, L"2009-09-09");
|
||||
_list.SetSubItem(0, 2, L"9999 MB");
|
||||
for (int i = 0; i < 3; i++)
|
||||
_list.SetColumnWidthAuto(i);
|
||||
_list.DeleteAllItems();
|
||||
|
||||
UString selectedName;
|
||||
if (!FolderMode)
|
||||
{
|
||||
int pos = Path.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
if (pos >= 0 && Path.Back() != WCHAR_PATH_SEPARATOR)
|
||||
{
|
||||
selectedName = Path.Mid(pos + 1);
|
||||
Path = Path.Left(pos + 1);
|
||||
}
|
||||
}
|
||||
_ascending = true;
|
||||
_sortIndex = 0;
|
||||
|
||||
NormalizeSize();
|
||||
|
||||
while (Reload(Path, selectedName) != S_OK)
|
||||
{
|
||||
UString parent;
|
||||
if (!GetParentPath(Path, parent, selectedName))
|
||||
break;
|
||||
selectedName.Empty();
|
||||
Path = parent;
|
||||
}
|
||||
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
bool CBrowseDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
|
||||
{
|
||||
int mx, my;
|
||||
{
|
||||
RECT rect;
|
||||
GetClientRectOfItem(IDC_BROWSE_PARENT, rect);
|
||||
mx = rect.left;
|
||||
my = rect.top;
|
||||
}
|
||||
InvalidateRect(NULL);
|
||||
|
||||
{
|
||||
RECT rect;
|
||||
GetClientRectOfItem(IDC_BROWSE_PATH, rect);
|
||||
MoveItem(IDC_BROWSE_PATH, rect.left, rect.top, xSize - mx - rect.left, RECT_SIZE_Y(rect));
|
||||
}
|
||||
|
||||
int bx1, bx2, by;
|
||||
GetItemSizes(IDCANCEL, bx1, by);
|
||||
GetItemSizes(IDOK, bx2, by);
|
||||
int y = ySize - my - by;
|
||||
int x = xSize - mx - bx1;
|
||||
MoveItem(IDCANCEL, x, y, bx1, by);
|
||||
MoveItem(IDOK, x - mx - bx2, y, bx2, by);
|
||||
|
||||
{
|
||||
RECT rect;
|
||||
GetClientRectOfItem(IDC_BROWSE_LIST, rect);
|
||||
_list.Move(rect.left, rect.top, xSize - mx - rect.left, y - my - rect.top);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static UString ConvertSizeToStringShort(UInt64 value)
|
||||
{
|
||||
wchar_t s[32];
|
||||
wchar_t c = L'\0', c2 = L'\0';
|
||||
if (value < (UInt64)10000)
|
||||
{
|
||||
c = L'\0';
|
||||
c2 = L'\0';
|
||||
}
|
||||
else if (value < ((UInt64)10000 << 10))
|
||||
{
|
||||
value >>= 10;
|
||||
c = L'K';
|
||||
}
|
||||
else if (value < ((UInt64)10000 << 20))
|
||||
{
|
||||
value >>= 20;
|
||||
c = L'M';
|
||||
}
|
||||
else
|
||||
{
|
||||
value >>= 30;
|
||||
c = L'G';
|
||||
}
|
||||
ConvertUInt64ToString(value, s);
|
||||
int p = MyStringLen(s);
|
||||
if (c != 0)
|
||||
s[p++] = L' ';
|
||||
s[p++] = c;
|
||||
s[p++] = c2;
|
||||
s[p++] = L'\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
bool isDir1 = f1.IsDir();
|
||||
bool isDir2 = f2.IsDir();
|
||||
|
||||
if (isDir1 && !isDir2) return -1;
|
||||
if (isDir2 && !isDir1) return 1;
|
||||
|
||||
int result = 0;
|
||||
switch(_sortIndex)
|
||||
{
|
||||
case 0: result = f1.Name.CompareNoCase(f2.Name); break;
|
||||
case 1: result = CompareFileTime(&f1.MTime, &f2.MTime); break;
|
||||
case 2: result = MyCompare(f1.Size, f2.Size); break;
|
||||
}
|
||||
return _ascending ? result: (-result);
|
||||
}
|
||||
|
||||
static int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
|
||||
{
|
||||
if (lpData == NULL)
|
||||
return 0;
|
||||
return ((CBrowseDialog*)lpData)->CompareItems(lParam1, lParam2);
|
||||
}
|
||||
|
||||
static HRESULT GetNormalizedError()
|
||||
{
|
||||
HRESULT errorCode = GetLastError();
|
||||
return (errorCode == 0) ? 1 : errorCode;
|
||||
}
|
||||
|
||||
HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selectedName)
|
||||
{
|
||||
CEnumeratorW enumerator(pathPrefix + L'*');
|
||||
CObjectVector<CFileInfoW> files;
|
||||
for (;;)
|
||||
{
|
||||
bool found;
|
||||
CFileInfoW fi;
|
||||
if (!enumerator.Next(fi, found))
|
||||
return GetNormalizedError();
|
||||
if (!found)
|
||||
break;
|
||||
files.Add(fi);
|
||||
}
|
||||
|
||||
Path = pathPrefix;
|
||||
|
||||
_files = files;
|
||||
|
||||
SetItemText(IDC_BROWSE_PATH, Path);
|
||||
_list.SetRedraw(false);
|
||||
_list.DeleteAllItems();
|
||||
|
||||
if (!Path.IsEmpty() && Path.Back() != WCHAR_PATH_SEPARATOR)
|
||||
Path += WCHAR_PATH_SEPARATOR;
|
||||
|
||||
LVITEMW item;
|
||||
|
||||
int index = 0;
|
||||
int cursorIndex = -1;
|
||||
|
||||
#ifndef _SFX
|
||||
if (_showDots)
|
||||
{
|
||||
UString itemName = L"..";
|
||||
item.iItem = index;
|
||||
if (selectedName.IsEmpty())
|
||||
cursorIndex = item.iItem;
|
||||
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
|
||||
int subItem = 0;
|
||||
item.iSubItem = subItem++;
|
||||
item.lParam = kParentIndex;
|
||||
item.pszText = (wchar_t *)(const wchar_t *)itemName;
|
||||
item.iImage = _extToIconMap.GetIconIndex(FILE_ATTRIBUTE_DIRECTORY, Path);
|
||||
if (item.iImage < 0)
|
||||
item.iImage = 0;
|
||||
_list.InsertItem(&item);
|
||||
_list.SetSubItem(index, subItem++, L"");
|
||||
_list.SetSubItem(index, subItem++, L"");
|
||||
index++;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < _files.Size(); i++)
|
||||
{
|
||||
const CFileInfoW &fi = _files[i];
|
||||
item.iItem = index;
|
||||
if (fi.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);
|
||||
if (item.iImage < 0)
|
||||
item.iImage = 0;
|
||||
_list.InsertItem(&item);
|
||||
{
|
||||
FILETIME ft;
|
||||
UString s;
|
||||
if (FileTimeToLocalFileTime(&fi.MTime, &ft))
|
||||
s = ConvertFileTimeToString(ft, false, false);
|
||||
_list.SetSubItem(index, subItem++, s);
|
||||
}
|
||||
{
|
||||
UString s;
|
||||
if (!fi.IsDir())
|
||||
s = ConvertSizeToStringShort(fi.Size);
|
||||
_list.SetSubItem(index, subItem++, s);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (_list.GetItemCount() > 0 && cursorIndex >= 0)
|
||||
_list.SetItemState_FocusedSelected(cursorIndex);
|
||||
_list.SortItems(CompareItems2, (LPARAM)this);
|
||||
if (_list.GetItemCount() > 0 && cursorIndex < 0)
|
||||
_list.SetItemState(0, LVIS_FOCUSED, LVIS_FOCUSED);
|
||||
_list.EnsureVisible(_list.GetFocusedItem(), false);
|
||||
_list.SetRedraw(true);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CBrowseDialog::Reload()
|
||||
{
|
||||
UString selectedCur;
|
||||
int index = _list.GetNextSelectedItem(-1);
|
||||
if (index >= 0)
|
||||
{
|
||||
int fileIndex = GetRealItemIndex(index);
|
||||
if (fileIndex != kParentIndex)
|
||||
selectedCur = _files[fileIndex].Name;
|
||||
}
|
||||
return Reload(Path, selectedCur);
|
||||
}
|
||||
|
||||
void CBrowseDialog::OpenParentFolder()
|
||||
{
|
||||
UString parent, selected;
|
||||
if (GetParentPath(Path, parent, selected))
|
||||
Reload(parent, selected);
|
||||
}
|
||||
|
||||
extern UString HResultToMessage(HRESULT errorCode);
|
||||
|
||||
bool CBrowseDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
|
||||
{
|
||||
if (header->hwndFrom != _list)
|
||||
return false;
|
||||
switch(header->code)
|
||||
{
|
||||
case LVN_ITEMACTIVATE:
|
||||
if (g_LVN_ITEMACTIVATE_Support)
|
||||
{
|
||||
OnItemEnter();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case NM_DBLCLK:
|
||||
case NM_RETURN: // probabably it's unused
|
||||
if (!g_LVN_ITEMACTIVATE_Support)
|
||||
{
|
||||
OnItemEnter();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case LVN_COLUMNCLICK:
|
||||
{
|
||||
int index = LPNMLISTVIEW(header)->iSubItem;
|
||||
if (index == _sortIndex)
|
||||
_ascending = !_ascending;
|
||||
else
|
||||
{
|
||||
_ascending = (index == 0);
|
||||
_sortIndex = index;
|
||||
}
|
||||
Reload();
|
||||
return false;
|
||||
}
|
||||
case LVN_KEYDOWN:
|
||||
{
|
||||
LRESULT result;
|
||||
bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result);
|
||||
return boolResult;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBrowseDialog::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result)
|
||||
{
|
||||
bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
|
||||
result = 0;
|
||||
|
||||
switch(keyDownInfo->wVKey)
|
||||
{
|
||||
case VK_BACK:
|
||||
OpenParentFolder();
|
||||
return true;
|
||||
case 'R':
|
||||
if (ctrl)
|
||||
{
|
||||
Reload();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBrowseDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
{
|
||||
switch(buttonID)
|
||||
{
|
||||
case IDC_BROWSE_PARENT:
|
||||
OpenParentFolder();
|
||||
return true;
|
||||
}
|
||||
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
|
||||
}
|
||||
|
||||
void CBrowseDialog::ShowError(LPCWSTR s) { MessageBoxW(*this, s, L"7-Zip", MB_ICONERROR); }
|
||||
|
||||
void CBrowseDialog::ShowSelectError()
|
||||
{
|
||||
ShowError(FolderMode ?
|
||||
L"You must select some folder":
|
||||
L"You must select some file");
|
||||
}
|
||||
|
||||
void CBrowseDialog::FinishOnOK()
|
||||
{
|
||||
int index = _list.GetNextSelectedItem(-1);
|
||||
if (index < 0)
|
||||
{
|
||||
if (!FolderMode)
|
||||
{
|
||||
ShowSelectError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int fileIndex = GetRealItemIndex(index);
|
||||
if (fileIndex == kParentIndex)
|
||||
{
|
||||
OpenParentFolder();
|
||||
return;
|
||||
}
|
||||
const CFileInfoW &file = _files[fileIndex];
|
||||
if (file.IsDir() != FolderMode)
|
||||
{
|
||||
ShowSelectError();
|
||||
return;
|
||||
}
|
||||
Path += file.Name;
|
||||
}
|
||||
End(IDOK);
|
||||
}
|
||||
|
||||
void CBrowseDialog::OnItemEnter()
|
||||
{
|
||||
int index = _list.GetNextSelectedItem(-1);
|
||||
if (index < 0)
|
||||
return;
|
||||
int fileIndex = GetRealItemIndex(index);
|
||||
if (fileIndex == kParentIndex)
|
||||
OpenParentFolder();
|
||||
else
|
||||
{
|
||||
const CFileInfoW &file = _files[fileIndex];
|
||||
if (!file.IsDir())
|
||||
{
|
||||
if (!FolderMode)
|
||||
FinishOnOK();
|
||||
else
|
||||
ShowSelectError();
|
||||
return;
|
||||
}
|
||||
HRESULT res = Reload(Path + file.Name + WCHAR_PATH_SEPARATOR, L"");
|
||||
if (res != S_OK)
|
||||
ShowError(HResultToMessage(res));
|
||||
}
|
||||
}
|
||||
|
||||
void CBrowseDialog::OnOK()
|
||||
{
|
||||
if (GetFocus() == _list)
|
||||
{
|
||||
OnItemEnter();
|
||||
return;
|
||||
}
|
||||
FinishOnOK();
|
||||
}
|
||||
|
||||
static bool MyBrowse(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath, bool folderMode)
|
||||
{
|
||||
CBrowseDialog dialog;
|
||||
dialog.Title = title;
|
||||
dialog.Path = initialFolder;
|
||||
dialog.FolderMode = folderMode;
|
||||
if (dialog.Create(owner) != IDOK)
|
||||
return false;
|
||||
resultPath = dialog.Path;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath)
|
||||
{
|
||||
return MyBrowse(owner, title, initialFolder, resultPath, true);
|
||||
}
|
||||
|
||||
bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR initialFolder, LPCWSTR, UString &resultPath)
|
||||
{
|
||||
return MyBrowse(owner, title, initialFolder, resultPath, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
77
CPP/7zip/UI/FileManager/BrowseDialog.h
Executable file
77
CPP/7zip/UI/FileManager/BrowseDialog.h
Executable file
@@ -0,0 +1,77 @@
|
||||
// BrowseDialog.h
|
||||
|
||||
#ifndef __BROWSE_DIALOG_H
|
||||
#define __BROWSE_DIALOG_H
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
#include "Windows/FileFind.h"
|
||||
|
||||
#include "Windows/Control/Dialog.h"
|
||||
#include "Windows/Control/ListView.h"
|
||||
|
||||
#include "BrowseDialogRes.h"
|
||||
#include "SysIconUtils.h"
|
||||
|
||||
class CBrowseDialog: public NWindows::NControl::CModalDialog
|
||||
{
|
||||
NWindows::NControl::CListView _list;
|
||||
CObjectVector<NWindows::NFile::NFind::CFileInfoW> _files;
|
||||
CExtToIconMap _extToIconMap;
|
||||
int _sortIndex;
|
||||
bool _ascending;
|
||||
bool _showDots;
|
||||
|
||||
virtual bool OnInit();
|
||||
virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
|
||||
virtual bool OnNotify(UINT controlID, LPNMHDR header);
|
||||
virtual void OnOK();
|
||||
|
||||
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
|
||||
virtual bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
|
||||
|
||||
void FinishOnOK();
|
||||
HRESULT Reload(const UString &pathPrefix, const UString &selectedName);
|
||||
HRESULT Reload();
|
||||
void OpenParentFolder();
|
||||
|
||||
void OnItemEnter();
|
||||
|
||||
int GetRealItemIndex(int indexInListView) const
|
||||
{
|
||||
LPARAM param;
|
||||
if (!_list.GetItemParam(indexInListView, param))
|
||||
return (int)-1;
|
||||
return (int)param;
|
||||
}
|
||||
|
||||
void ShowError(LPCWSTR s);
|
||||
void ShowSelectError();
|
||||
public:
|
||||
UString Title;
|
||||
UString Path;
|
||||
bool FolderMode;
|
||||
|
||||
CBrowseDialog(): FolderMode(true), _showDots(false) {}
|
||||
|
||||
INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_BROWSE, parent); }
|
||||
int CompareItems(LPARAM lParam1, LPARAM lParam2);
|
||||
};
|
||||
|
||||
bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath);
|
||||
bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR initialFolder, LPCWSTR s, UString &resultPath);
|
||||
|
||||
#else
|
||||
|
||||
#include "Windows/CommonDialog.h"
|
||||
#include "Windows/Shell.h"
|
||||
|
||||
#define MyBrowseForFolder(h, title, initialFolder, resultPath) \
|
||||
NShell::BrowseForFolder(h, title, initialFolder, resultPath)
|
||||
|
||||
#define MyBrowseForFile(h, title, initialFolder, s, resultPath) \
|
||||
MyGetOpenFileName(h, title, initialFolder, s, resultPath)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
17
CPP/7zip/UI/FileManager/BrowseDialog.rc
Executable file
17
CPP/7zip/UI/FileManager/BrowseDialog.rc
Executable file
@@ -0,0 +1,17 @@
|
||||
#include "BrowseDialogRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xc 180
|
||||
#define yc 160
|
||||
|
||||
IDD_DIALOG_BROWSE MY_RESIZE_DIALOG
|
||||
CAPTION "7-Zip: Browse"
|
||||
{
|
||||
LTEXT "", IDC_BROWSE_PATH, m + 20, m + 3, xc - 20, 8
|
||||
CONTROL "List1", IDC_BROWSE_LIST, "SysListView32",
|
||||
LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,
|
||||
m, m + 16, xc, yc - bys - m - 16
|
||||
PUSHBUTTON "OK", IDOK, bx2, by, bxs, bys
|
||||
PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
|
||||
PUSHBUTTON "..", IDC_BROWSE_PARENT, m, m, 16, 14
|
||||
}
|
||||
4
CPP/7zip/UI/FileManager/BrowseDialogRes.h
Executable file
4
CPP/7zip/UI/FileManager/BrowseDialogRes.h
Executable file
@@ -0,0 +1,4 @@
|
||||
#define IDD_DIALOG_BROWSE 509
|
||||
#define IDC_BROWSE_LIST 1000
|
||||
#define IDC_BROWSE_PATH 1001
|
||||
#define IDC_BROWSE_PARENT 1002
|
||||
@@ -2,16 +2,10 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <initguid.h>
|
||||
#include "Common/MyInitGuid.h"
|
||||
|
||||
#include "IFolder.h"
|
||||
#include "../../IPassword.h"
|
||||
#include "PluginInterface.h"
|
||||
#include "ExtractCallback.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
// {23170F69-40C1-278A-1000-000100020000}
|
||||
DEFINE_GUID(CLSID_CZipContextMenu,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
|
||||
|
||||
@@ -43,9 +43,28 @@ bool CComboDialog::OnInit()
|
||||
_comboBox.SetText(Value);
|
||||
for(int i = 0; i < Strings.Size(); i++)
|
||||
_comboBox.AddString(Strings[i]);
|
||||
NormalizeSize();
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
bool CComboDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
|
||||
{
|
||||
int mx, my;
|
||||
GetMargins(8, mx, my);
|
||||
int bx1, bx2, by;
|
||||
GetItemSizes(IDCANCEL, bx1, by);
|
||||
GetItemSizes(IDOK, bx2, by);
|
||||
int y = ySize - my - by;
|
||||
int x = xSize - mx - bx1;
|
||||
|
||||
InvalidateRect(NULL);
|
||||
|
||||
MoveItem(IDCANCEL, x, y, bx1, by);
|
||||
MoveItem(IDOK, x - mx - bx2, y, bx2, by);
|
||||
ChangeSubWindowSizeX(_comboBox, xSize - mx * 2);
|
||||
return false;
|
||||
}
|
||||
|
||||
void CComboDialog::OnOK()
|
||||
{
|
||||
_comboBox.GetText(Value);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// ComboDialog.h
|
||||
|
||||
#ifndef __COMBODIALOG_H
|
||||
#define __COMBODIALOG_H
|
||||
#ifndef __COMBO_DIALOG_H
|
||||
#define __COMBO_DIALOG_H
|
||||
|
||||
#include "Windows/Control/Dialog.h"
|
||||
#include "Windows/Control/ComboBox.h"
|
||||
#include "Windows/Control/Dialog.h"
|
||||
|
||||
#include "ComboDialogRes.h"
|
||||
|
||||
class CComboDialog: public NWindows::NControl::CModalDialog
|
||||
@@ -12,6 +13,7 @@ class CComboDialog: public NWindows::NControl::CModalDialog
|
||||
NWindows::NControl::CComboBox _comboBox;
|
||||
virtual void OnOK();
|
||||
virtual bool OnInit();
|
||||
virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
|
||||
public:
|
||||
// bool Sorted;
|
||||
UString Title;
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
#include "ComboDialogRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 233
|
||||
#define ySize2 57
|
||||
#define xc 240
|
||||
#define yc 64
|
||||
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
|
||||
#define bYPos (ySize - marg - bYSize)
|
||||
#define b1XPos (xSize - marg - bXSize)
|
||||
#define b2XPos (b1XPos - 10 - bXSize)
|
||||
|
||||
|
||||
IDD_DIALOG_COMBO DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
|
||||
IDD_DIALOG_COMBO MY_RESIZE_DIALOG
|
||||
CAPTION "Combo"
|
||||
MY_FONT
|
||||
BEGIN
|
||||
LTEXT "", IDC_COMBO_STATIC, marg, marg, xSize2, 8
|
||||
COMBOBOX IDC_COMBO_COMBO, marg, 20, xSize2, 65, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
|
||||
|
||||
DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize
|
||||
PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize
|
||||
END
|
||||
{
|
||||
LTEXT "", IDC_COMBO_STATIC, m, m, xc, 8
|
||||
COMBOBOX IDC_COMBO_COMBO, m, 20, xc, 65, MY_COMBO_WITH_EDIT
|
||||
OK_CANCEL
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define IDD_DIALOG_COMBO 200
|
||||
#define IDD_DIALOG_COMBO 505
|
||||
|
||||
#define IDC_COMBO_STATIC 1000
|
||||
#define IDC_COMBO_COMBO 1001
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// CopyDialog.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "CopyDialog.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/FileName.h"
|
||||
|
||||
#include "Windows/Control/Static.h"
|
||||
#include "Windows/Shell.h"
|
||||
#include "Windows/FileName.h"
|
||||
|
||||
#include "BrowseDialog.h"
|
||||
#include "CopyDialog.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "LangUtils.h"
|
||||
@@ -34,13 +34,53 @@ bool CCopyDialog::OnInit()
|
||||
NControl::CStatic staticContol;
|
||||
staticContol.Attach(GetItem(IDC_COPY_STATIC));
|
||||
staticContol.SetText(Static);
|
||||
#ifdef UNDER_CE
|
||||
// we do it, since WinCE selects Value\something instead of Value !!!!
|
||||
_path.AddString(Value);
|
||||
#endif
|
||||
for (int i = 0; i < Strings.Size(); i++)
|
||||
_path.AddString(Strings[i]);
|
||||
_path.SetText(Value);
|
||||
SetItemText(IDC_COPY_INFO, Info);
|
||||
NormalizeSize(true);
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
|
||||
{
|
||||
int mx, my;
|
||||
GetMargins(8, mx, my);
|
||||
int bx1, bx2, by;
|
||||
GetItemSizes(IDCANCEL, bx1, by);
|
||||
GetItemSizes(IDOK, bx2, by);
|
||||
int y = ySize - my - by;
|
||||
int x = xSize - mx - bx1;
|
||||
|
||||
InvalidateRect(NULL);
|
||||
|
||||
{
|
||||
RECT rect;
|
||||
GetClientRectOfItem(IDC_COPY_SET_PATH, rect);
|
||||
int bx = rect.right - rect.left;
|
||||
MoveItem(IDC_COPY_SET_PATH, xSize - mx - bx, rect.top, bx, rect.bottom - rect.top);
|
||||
ChangeSubWindowSizeX(_path, xSize - mx - mx - bx - mx);
|
||||
}
|
||||
|
||||
{
|
||||
RECT rect;
|
||||
GetClientRectOfItem(IDC_COPY_INFO, rect);
|
||||
NControl::CStatic staticContol;
|
||||
staticContol.Attach(GetItem(IDC_COPY_INFO));
|
||||
int yPos = rect.top;
|
||||
staticContol.Move(mx, yPos, xSize - mx * 2, y - 2 - yPos);
|
||||
}
|
||||
|
||||
MoveItem(IDCANCEL, x, y, bx1, by);
|
||||
MoveItem(IDOK, x - mx - bx2, y, bx2, by);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
{
|
||||
switch(buttonID)
|
||||
@@ -57,18 +97,10 @@ void CCopyDialog::OnButtonSetPath()
|
||||
UString currentPath;
|
||||
_path.GetText(currentPath);
|
||||
|
||||
/*
|
||||
#ifdef LANG
|
||||
UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
|
||||
#else
|
||||
UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
|
||||
#endif
|
||||
*/
|
||||
UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209);
|
||||
// UString title = L"Specify a location for output folder";
|
||||
|
||||
UString resultPath;
|
||||
if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
|
||||
if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath))
|
||||
return;
|
||||
NFile::NName::NormalizeDirPathPrefix(resultPath);
|
||||
_path.SetCurSel(-1);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// CopyDialog.h
|
||||
|
||||
#ifndef __COPYDIALOG_H
|
||||
#define __COPYDIALOG_H
|
||||
#ifndef __COPY_DIALOG_H
|
||||
#define __COPY_DIALOG_H
|
||||
|
||||
#include "Windows/Control/Dialog.h"
|
||||
#include "Windows/Control/ComboBox.h"
|
||||
#include "Windows/Control/Dialog.h"
|
||||
|
||||
#include "CopyDialogRes.h"
|
||||
|
||||
const int kCopyDialog_NumInfoLines = 11;
|
||||
@@ -14,15 +15,15 @@ class CCopyDialog: public NWindows::NControl::CModalDialog
|
||||
NWindows::NControl::CComboBox _path;
|
||||
virtual void OnOK();
|
||||
virtual bool OnInit();
|
||||
virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
|
||||
void OnButtonSetPath();
|
||||
bool OnButtonClicked(int buttonID, HWND buttonHWND);
|
||||
public:
|
||||
UString Title;
|
||||
UString Static;
|
||||
UString Value;
|
||||
UStringVector Strings;
|
||||
|
||||
UString Info;
|
||||
UStringVector Strings;
|
||||
|
||||
INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); }
|
||||
};
|
||||
|
||||
@@ -1,32 +1,17 @@
|
||||
#include "CopyDialogRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#undef infoSize
|
||||
#define infoSize 100
|
||||
#define xc 320
|
||||
#define yc 144
|
||||
|
||||
#define xSize2 346
|
||||
#define ySize2 (infoSize + 50)
|
||||
#define y 40
|
||||
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
|
||||
#define bYPos (ySize - marg - bYSize)
|
||||
#define b1XPos (xSize - marg - bXSize)
|
||||
#define b2XPos (b1XPos - 10 - bXSize)
|
||||
|
||||
IDD_DIALOG_COPY DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
|
||||
IDD_DIALOG_COPY MY_RESIZE_DIALOG
|
||||
CAPTION "Copy"
|
||||
MY_FONT
|
||||
BEGIN
|
||||
LTEXT "", IDC_COPY_STATIC, marg, marg, xSize2, 8
|
||||
COMBOBOX IDC_COPY_COMBO, marg, 20, xSize2 - bDotsSize - 12, 65, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "...", IDC_COPY_SET_PATH, (xSize - marg - bDotsSize), 20, bDotsSize, 14, WS_GROUP
|
||||
LTEXT "", IDC_COPY_INFO, marg, bYPos - (infoSize + 2), xSize2, infoSize, SS_NOPREFIX | SS_LEFTNOWORDWRAP
|
||||
DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize
|
||||
PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_SET_FOLDER "Specify a location for output folder."
|
||||
END
|
||||
{
|
||||
LTEXT "", IDC_COPY_STATIC, m, m, xc, 8
|
||||
COMBOBOX IDC_COPY_COMBO, m, 20, xc - bxsDots - m, 65, MY_COMBO_WITH_EDIT
|
||||
PUSHBUTTON "...", IDC_COPY_SET_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP
|
||||
LTEXT "", IDC_COPY_INFO, m, y, xc, by - y - 1, SS_NOPREFIX | SS_LEFTNOWORDWRAP
|
||||
OK_CANCEL
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define IDD_DIALOG_COPY 202
|
||||
#define IDD_DIALOG_COPY 506
|
||||
|
||||
#define IDC_COPY_STATIC 1000
|
||||
#define IDC_COPY_COMBO 1001
|
||||
|
||||
16
CPP/7zip/UI/FileManager/DialogSize.h
Executable file
16
CPP/7zip/UI/FileManager/DialogSize.h
Executable file
@@ -0,0 +1,16 @@
|
||||
// DialogSize.h
|
||||
|
||||
#ifndef __DIALOG_SIZE_H
|
||||
#define __DIALOG_SIZE_H
|
||||
|
||||
#include "Windows/Control/Dialog.h"
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define BIG_DIALOG_SIZE(x, y) bool isBig = NWindows::NControl::IsDialogSizeOK(x, y);
|
||||
#define SIZED_DIALOG(big) (isBig ? big : big ## _2)
|
||||
#else
|
||||
#define BIG_DIALOG_SIZE(x, y)
|
||||
#define SIZED_DIALOG(big) big
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,20 +1,14 @@
|
||||
// EditPage.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "EditPageRes.h"
|
||||
|
||||
#include "EditPage.h"
|
||||
#include "EditPageRes.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/CommonDialog.h"
|
||||
// #include "Windows/FileFind.h"
|
||||
// #include "Windows/FileDir.h"
|
||||
|
||||
#include "RegistryUtils.h"
|
||||
#include "BrowseDialog.h"
|
||||
#include "HelpUtils.h"
|
||||
#include "LangUtils.h"
|
||||
#include "ProgramLocation.h"
|
||||
#include "RegistryUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -38,9 +32,6 @@ bool CEditPage::OnInit()
|
||||
|
||||
LONG CEditPage::OnApply()
|
||||
{
|
||||
// int selectedIndex = _langCombo.GetCurSel();
|
||||
// int pathIndex = _langCombo.GetItemData(selectedIndex);
|
||||
// ReloadLang();
|
||||
UString editorPath;
|
||||
_editorEdit.GetText(editorPath);
|
||||
SaveRegEditor(editorPath);
|
||||
@@ -49,33 +40,27 @@ LONG CEditPage::OnApply()
|
||||
|
||||
void CEditPage::OnNotifyHelp()
|
||||
{
|
||||
ShowHelpWindow(NULL, kEditTopic); // change it
|
||||
ShowHelpWindow(NULL, kEditTopic);
|
||||
}
|
||||
|
||||
bool CEditPage::OnButtonClicked(int aButtonID, HWND aButtonHWND)
|
||||
bool CEditPage::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
{
|
||||
switch(aButtonID)
|
||||
switch (buttonID)
|
||||
{
|
||||
case IDC_EDIT_BUTTON_SET:
|
||||
{
|
||||
OnSetEditorButton();
|
||||
// if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, aResultPath))
|
||||
// return;
|
||||
UString editorPath;
|
||||
_editorEdit.GetText(editorPath);
|
||||
UString resPath;
|
||||
if (MyBrowseForFile(HWND(*this), 0, editorPath, L"*.exe", resPath))
|
||||
{
|
||||
_editorEdit.SetText(resPath);
|
||||
// Changed();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return CPropertyPage::OnButtonClicked(aButtonID, aButtonHWND);
|
||||
}
|
||||
|
||||
void CEditPage::OnSetEditorButton()
|
||||
{
|
||||
UString editorPath;
|
||||
_editorEdit.GetText(editorPath);
|
||||
UString resPath;
|
||||
if(!MyGetOpenFileName(HWND(*this), 0, editorPath, L"*.exe", resPath))
|
||||
return;
|
||||
_editorEdit.SetText(resPath);
|
||||
// Changed();
|
||||
return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
|
||||
}
|
||||
|
||||
bool CEditPage::OnCommand(int code, int itemID, LPARAM param)
|
||||
@@ -87,5 +72,3 @@ bool CEditPage::OnCommand(int code, int itemID, LPARAM param)
|
||||
}
|
||||
return CPropertyPage::OnCommand(code, itemID, param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// EditPage.h
|
||||
|
||||
#ifndef __EDITPAGE_H
|
||||
#define __EDITPAGE_H
|
||||
#ifndef __EDIT_PAGE_H
|
||||
#define __EDIT_PAGE_H
|
||||
|
||||
#include "Windows/Control/PropertyPage.h"
|
||||
#include "Windows/Control/Edit.h"
|
||||
@@ -9,13 +9,12 @@
|
||||
class CEditPage: public NWindows::NControl::CPropertyPage
|
||||
{
|
||||
NWindows::NControl::CEdit _editorEdit;
|
||||
void OnSetEditorButton();
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
virtual void OnNotifyHelp();
|
||||
virtual bool OnCommand(int code, int itemID, LPARAM param);
|
||||
virtual LONG OnApply();
|
||||
virtual bool OnButtonClicked(int aButtonID, HWND aButtonHWND);
|
||||
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
#include "EditPageRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 196
|
||||
#define ySize2 140
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
#define xc SMALL_PAGE_SIZE_X
|
||||
#define yc 60
|
||||
|
||||
IDD_EDIT DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE
|
||||
IDD_EDIT MY_PAGE
|
||||
CAPTION "Editor"
|
||||
MY_FONT
|
||||
BEGIN
|
||||
LTEXT "&Editor:", IDC_EDIT_STATIC_EDITOR, marg, marg, xSize2, 8
|
||||
EDITTEXT IDC_EDIT_EDIT_EDITOR, marg, 20, xSize2 - 12 - bDotsSize, 14, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "...", IDC_EDIT_BUTTON_SET, (xSize - marg - bDotsSize), 20, bDotsSize, bYSize
|
||||
END
|
||||
{
|
||||
LTEXT "&Editor:", IDC_EDIT_STATIC_EDITOR, m, m, xc, 8
|
||||
EDITTEXT IDC_EDIT_EDIT_EDITOR, m, 20, xc - m - bxsDots, 14, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "...", IDC_EDIT_BUTTON_SET, xs - m - bxsDots, 19, bxsDots, bys
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define IDD_EDIT 903
|
||||
#define IDD_EDIT 542
|
||||
#define IDC_EDIT_STATIC_EDITOR 1000
|
||||
#define IDC_EDIT_EDIT_EDITOR 1002
|
||||
#define IDC_EDIT_BUTTON_SET 1003
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
// ExtractCallback.h
|
||||
// ExtractCallback.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#include "../../Common/FilePathAutoRename.h"
|
||||
|
||||
#include "../GUI/ExtractRes.h"
|
||||
#include "../GUI/resource.h"
|
||||
|
||||
#include "ExtractCallback.h"
|
||||
#include "FormatUtils.h"
|
||||
#include "MessagesDialog.h"
|
||||
#include "OverwriteDialog.h"
|
||||
#ifndef _NO_CRYPTO
|
||||
#include "PasswordDialog.h"
|
||||
@@ -27,20 +21,12 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
CExtractCallbackImp::~CExtractCallbackImp()
|
||||
{
|
||||
if (ShowMessages && !Messages.IsEmpty())
|
||||
{
|
||||
CMessagesDialog messagesDialog;
|
||||
messagesDialog.Messages = &Messages;
|
||||
messagesDialog.Create(ParentWindow);
|
||||
}
|
||||
}
|
||||
CExtractCallbackImp::~CExtractCallbackImp() {}
|
||||
|
||||
void CExtractCallbackImp::Init()
|
||||
{
|
||||
Messages.Clear();
|
||||
NumArchiveErrors = 0;
|
||||
ThereAreMessageErrors = false;
|
||||
#ifndef _SFX
|
||||
NumFolders = NumFiles = 0;
|
||||
NeedAddFile = false;
|
||||
@@ -49,7 +35,8 @@ void CExtractCallbackImp::Init()
|
||||
|
||||
void CExtractCallbackImp::AddErrorMessage(LPCWSTR message)
|
||||
{
|
||||
Messages.Add(message);
|
||||
ThereAreMessageErrors = true;
|
||||
ProgressDialog->Sync.AddErrorMessage(message);
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64
|
||||
@@ -59,40 +46,40 @@ STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64
|
||||
)
|
||||
{
|
||||
#ifndef _SFX
|
||||
ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles);
|
||||
ProgressDialog->Sync.SetNumFilesTotal(numFiles);
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total)
|
||||
{
|
||||
ProgressDialog.ProgressSynch.SetProgress(total, 0);
|
||||
ProgressDialog->Sync.SetProgress(total, 0);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value)
|
||||
{
|
||||
RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
|
||||
RINOK(ProgressDialog->Sync.ProcessStopAndPause());
|
||||
if (value != NULL)
|
||||
ProgressDialog.ProgressSynch.SetPos(*value);
|
||||
ProgressDialog->Sync.SetPos(*value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::Open_CheckBreak()
|
||||
{
|
||||
return ProgressDialog.ProgressSynch.ProcessStopAndPause();
|
||||
return ProgressDialog->Sync.ProcessStopAndPause();
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
|
||||
{
|
||||
// if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles);
|
||||
// if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesTotal(*numFiles);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
|
||||
{
|
||||
RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
|
||||
// if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles);
|
||||
RINOK(ProgressDialog->Sync.ProcessStopAndPause());
|
||||
// if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesCur(*numFiles);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -126,7 +113,7 @@ void CExtractCallbackImp::Open_ClearPasswordWasAskedFlag()
|
||||
#ifndef _SFX
|
||||
STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
|
||||
{
|
||||
ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize);
|
||||
ProgressDialog->Sync.SetRatioInfo(inSize, outSize);
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
@@ -134,14 +121,14 @@ STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt6
|
||||
/*
|
||||
STDMETHODIMP CExtractCallbackImp::SetTotalFiles(UInt64 total)
|
||||
{
|
||||
ProgressDialog.ProgressSynch.SetNumFilesTotal(total);
|
||||
ProgressDialog->Sync.SetNumFilesTotal(total);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value)
|
||||
{
|
||||
if (value != NULL)
|
||||
ProgressDialog.ProgressSynch.SetNumFilesCur(*value);
|
||||
ProgressDialog->Sync.SetNumFilesCur(*value);
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
@@ -153,30 +140,16 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite(
|
||||
{
|
||||
COverwriteDialog dialog;
|
||||
|
||||
dialog.OldFileInfo.Time = *existTime;
|
||||
dialog.OldFileInfo.SizeIsDefined = (existSize != NULL);
|
||||
if (dialog.OldFileInfo.SizeIsDefined)
|
||||
dialog.OldFileInfo.Size = *existSize;
|
||||
dialog.OldFileInfo.SetTime(existTime);
|
||||
dialog.OldFileInfo.SetSize(existSize);
|
||||
dialog.OldFileInfo.Name = existName;
|
||||
|
||||
if (newTime == 0)
|
||||
dialog.NewFileInfo.TimeIsDefined = false;
|
||||
else
|
||||
{
|
||||
dialog.NewFileInfo.TimeIsDefined = true;
|
||||
dialog.NewFileInfo.Time = *newTime;
|
||||
}
|
||||
|
||||
dialog.NewFileInfo.SizeIsDefined = (newSize != NULL);
|
||||
if (dialog.NewFileInfo.SizeIsDefined)
|
||||
dialog.NewFileInfo.Size = *newSize;
|
||||
dialog.NewFileInfo.SetTime(newTime);
|
||||
dialog.NewFileInfo.SetSize(newSize);
|
||||
dialog.NewFileInfo.Name = newName;
|
||||
|
||||
/*
|
||||
NOverwriteDialog::NResult::EEnum writeAnswer =
|
||||
NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
|
||||
*/
|
||||
INT_PTR writeAnswer = dialog.Create(ProgressDialog); // ParentWindow doesn't work with 7z
|
||||
ProgressDialog->WaitCreating();
|
||||
INT_PTR writeAnswer = dialog.Create(*ProgressDialog);
|
||||
|
||||
switch(writeAnswer)
|
||||
{
|
||||
@@ -243,7 +216,8 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool
|
||||
}
|
||||
if (_needWriteArchivePath)
|
||||
{
|
||||
AddErrorMessage(_currentArchivePath);
|
||||
if (!_currentArchivePath.IsEmpty())
|
||||
AddErrorMessage(_currentArchivePath);
|
||||
_needWriteArchivePath = false;
|
||||
}
|
||||
AddErrorMessage(
|
||||
@@ -259,7 +233,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool
|
||||
NumFolders++;
|
||||
else
|
||||
NumFiles++;
|
||||
ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles);
|
||||
ProgressDialog->Sync.SetNumFilesCur(NumFiles);
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
@@ -270,7 +244,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool
|
||||
HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name)
|
||||
{
|
||||
#ifndef _SFX
|
||||
ProgressDialog.ProgressSynch.SetTitleFileName(name);
|
||||
ProgressDialog->Sync.SetTitleFileName(name);
|
||||
#endif
|
||||
_currentArchivePath = name;
|
||||
return S_OK;
|
||||
@@ -280,7 +254,7 @@ HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path)
|
||||
{
|
||||
_currentFilePath = path;
|
||||
#ifndef _SFX
|
||||
ProgressDialog.ProgressSynch.SetCurrentFileName(path);
|
||||
ProgressDialog->Sync.SetCurrentFileName(path);
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
@@ -291,7 +265,7 @@ HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path)
|
||||
if (NeedAddFile)
|
||||
NumFiles++;
|
||||
NeedAddFile = true;
|
||||
ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles);
|
||||
ProgressDialog->Sync.SetNumFilesCur(NumFiles);
|
||||
#endif
|
||||
return SetCurrentFilePath2(path);
|
||||
}
|
||||
@@ -365,7 +339,8 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
CPasswordDialog dialog;
|
||||
if (dialog.Create(ProgressDialog) == IDCANCEL)
|
||||
ProgressDialog->WaitCreating();
|
||||
if (dialog.Create(*ProgressDialog) == IDCANCEL)
|
||||
return E_ABORT;
|
||||
Password = dialog.Password;
|
||||
PasswordIsDefined = true;
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
// ExtractCallback.h
|
||||
|
||||
#ifndef __EXTRACTCALLBACK_H
|
||||
#define __EXTRACTCALLBACK_H
|
||||
#ifndef __EXTRACT_CALLBACK_H
|
||||
#define __EXTRACT_CALLBACK_H
|
||||
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
#include "Common/MyString.h"
|
||||
#include "../Common/ArchiveOpenCallback.h"
|
||||
|
||||
#ifdef _SFX
|
||||
#include "ProgressDialog.h"
|
||||
#else
|
||||
#include "ProgressDialog2.h"
|
||||
#endif
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "LangUtils.h"
|
||||
#endif
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
#include "../Common/ArchiveOpenCallback.h"
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
#include "../../IPassword.h"
|
||||
#endif
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "IFolder.h"
|
||||
|
||||
#include "ProgressDialog2.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "LangUtils.h"
|
||||
#endif
|
||||
|
||||
class CExtractCallbackImp:
|
||||
public IExtractCallbackUI,
|
||||
public IOpenCallbackUI,
|
||||
@@ -99,32 +96,23 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
// bool _extractMode;
|
||||
UString _currentArchivePath;
|
||||
bool _needWriteArchivePath;
|
||||
|
||||
UString _currentFilePath;
|
||||
bool _isFolder;
|
||||
|
||||
// void CreateComplexDirectory(const UStringVector &aDirPathParts);
|
||||
|
||||
HRESULT SetCurrentFilePath2(const wchar_t *filePath);
|
||||
void AddErrorMessage(LPCWSTR message);
|
||||
public:
|
||||
CProgressDialog ProgressDialog;
|
||||
UStringVector Messages;
|
||||
bool ShowMessages;
|
||||
CProgressDialog *ProgressDialog;
|
||||
#ifndef _SFX
|
||||
UInt64 NumFolders;
|
||||
UInt64 NumFiles;
|
||||
bool NeedAddFile;
|
||||
#endif
|
||||
HWND ParentWindow;
|
||||
INT_PTR StartProgressDialog(const UString &title)
|
||||
{
|
||||
return ProgressDialog.Create(title, ParentWindow);
|
||||
}
|
||||
UInt32 NumArchiveErrors;
|
||||
bool ThereAreMessageErrors;
|
||||
NExtract::NOverwriteMode::EEnum OverwriteMode;
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
@@ -138,13 +126,13 @@ public:
|
||||
PasswordIsDefined(false),
|
||||
PasswordWasAsked(false),
|
||||
#endif
|
||||
OverwriteMode(NExtract::NOverwriteMode::kAskBefore),
|
||||
ParentWindow(0),
|
||||
ShowMessages(true)
|
||||
OverwriteMode(NExtract::NOverwriteMode::kAskBefore)
|
||||
{}
|
||||
|
||||
~CExtractCallbackImp();
|
||||
void Init();
|
||||
|
||||
bool IsOK() const { return NumArchiveErrors == 0 && !ThereAreMessageErrors; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/MemoryLock.h"
|
||||
#include "Windows/NtCheck.h"
|
||||
|
||||
#ifndef UNDER_CE
|
||||
#include "Windows/Security.h"
|
||||
#endif
|
||||
|
||||
#include "../GUI/ExtractRes.h"
|
||||
|
||||
@@ -29,13 +33,21 @@ using namespace NFind;
|
||||
|
||||
#define MENU_HEIGHT 26
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
#endif
|
||||
HINSTANCE g_hInstance;
|
||||
HWND g_HWND;
|
||||
bool g_OpenArchive = false;
|
||||
static UString g_MainPath;
|
||||
static bool g_Maximized = false;
|
||||
|
||||
#ifndef UNDER_CE
|
||||
DWORD g_ComCtl32Version;
|
||||
#endif
|
||||
|
||||
bool g_LVN_ITEMACTIVATE_Support = true;
|
||||
// LVN_ITEMACTIVATE replaces both NM_DBLCLK & NM_RETURN
|
||||
// Windows 2000
|
||||
// NT/98 + IE 3 (g_ComCtl32Version >= 4.70)
|
||||
|
||||
|
||||
const int kNumDefaultPanels = 1;
|
||||
|
||||
@@ -45,21 +57,6 @@ int kPanelSizeMin = 120;
|
||||
|
||||
// bool OnMenuCommand(HWND hWnd, int id);
|
||||
|
||||
static UString GetProgramPath()
|
||||
{
|
||||
UString s;
|
||||
NDLL::MyGetModuleFileName(g_hInstance, s);
|
||||
return s;
|
||||
}
|
||||
|
||||
UString GetProgramFolderPrefix()
|
||||
{
|
||||
UString path = GetProgramPath();
|
||||
int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
return path.Left(pos + 1);
|
||||
}
|
||||
|
||||
|
||||
class CSplitterPos
|
||||
{
|
||||
int _ratio; // 10000 is max
|
||||
@@ -123,22 +120,18 @@ static int g_StartCaptureSplitterPos;
|
||||
|
||||
CApp g_App;
|
||||
|
||||
void MoveSubWindows(HWND hWnd);
|
||||
void OnSize(HWND hWnd);
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
const wchar_t *kWindowClass = L"FM";
|
||||
|
||||
#ifndef _UNICODE
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#ifdef UNDER_CE
|
||||
#define WS_OVERLAPPEDWINDOW ( \
|
||||
WS_OVERLAPPED | \
|
||||
WS_CAPTION | \
|
||||
WS_SYSMENU | \
|
||||
WS_THICKFRAME | \
|
||||
WS_MINIMIZEBOX | \
|
||||
WS_MAXIMIZEBOX)
|
||||
#endif
|
||||
|
||||
// FUNCTION: InitInstance(HANDLE, int)
|
||||
@@ -173,14 +166,21 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FAM));
|
||||
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
|
||||
|
||||
// wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||
wc.hCursor = ::LoadCursor(0, IDC_SIZEWE);
|
||||
// wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
|
||||
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
|
||||
|
||||
wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
|
||||
wc.lpszMenuName =
|
||||
#ifdef UNDER_CE
|
||||
0
|
||||
#else
|
||||
MAKEINTRESOURCEW(IDM_MENU)
|
||||
#endif
|
||||
;
|
||||
|
||||
wc.lpszClassName = kWindowClass;
|
||||
|
||||
MyRegisterClass(&wc);
|
||||
@@ -225,29 +225,37 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
if (!wnd.Create(kWindowClass, title, style,
|
||||
x, y, xSize, ySize, NULL, NULL, hInstance, NULL))
|
||||
return FALSE;
|
||||
g_HWND = (HWND)wnd;
|
||||
|
||||
if (nCmdShow == SW_SHOWNORMAL ||
|
||||
nCmdShow == SW_SHOW
|
||||
#ifndef UNDER_CE
|
||||
|| nCmdShow == SW_SHOWDEFAULT
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (maximized)
|
||||
nCmdShow = SW_SHOWMAXIMIZED;
|
||||
else
|
||||
nCmdShow = SW_SHOWNORMAL;
|
||||
}
|
||||
|
||||
if (nCmdShow == SW_SHOWMAXIMIZED)
|
||||
g_Maximized = true;
|
||||
|
||||
#ifndef UNDER_CE
|
||||
WINDOWPLACEMENT placement;
|
||||
placement.length = sizeof(placement);
|
||||
if (wnd.GetPlacement(&placement))
|
||||
{
|
||||
if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
|
||||
nCmdShow == SW_SHOWDEFAULT)
|
||||
{
|
||||
if (maximized)
|
||||
placement.showCmd = SW_SHOWMAXIMIZED;
|
||||
else
|
||||
placement.showCmd = SW_SHOWNORMAL;
|
||||
}
|
||||
else
|
||||
placement.showCmd = nCmdShow;
|
||||
if (windowPosIsRead)
|
||||
placement.rcNormalPosition = rect;
|
||||
placement.showCmd = nCmdShow;
|
||||
wnd.SetPlacement(&placement);
|
||||
// window.Show(nCmdShow);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
wnd.Show(nCmdShow);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -277,22 +285,23 @@ static void GetCommands(const UString &aCommandLine, UString &aCommands)
|
||||
}
|
||||
*/
|
||||
|
||||
DWORD GetDllVersion(LPCTSTR lpszDllName)
|
||||
#ifndef UNDER_CE
|
||||
static DWORD GetDllVersion(LPCTSTR lpszDllName)
|
||||
{
|
||||
HINSTANCE hinstDll;
|
||||
DWORD dwVersion = 0;
|
||||
hinstDll = LoadLibrary(lpszDllName);
|
||||
if(hinstDll)
|
||||
if (hinstDll)
|
||||
{
|
||||
DLLGETVERSIONPROC pDllGetVersion;
|
||||
pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
|
||||
pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion");
|
||||
|
||||
/*Because some DLLs might not implement this function, you
|
||||
must test for it explicitly. Depending on the particular
|
||||
DLL, the lack of a DllGetVersion function can be a useful
|
||||
indicator of the version.
|
||||
*/
|
||||
if(pDllGetVersion)
|
||||
if (pDllGetVersion)
|
||||
{
|
||||
DLLVERSIONINFO dvi;
|
||||
HRESULT hr;
|
||||
@@ -302,7 +311,7 @@ DWORD GetDllVersion(LPCTSTR lpszDllName)
|
||||
|
||||
hr = (*pDllGetVersion)(&dvi);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
|
||||
}
|
||||
@@ -311,8 +320,7 @@ DWORD GetDllVersion(LPCTSTR lpszDllName)
|
||||
}
|
||||
return dwVersion;
|
||||
}
|
||||
|
||||
DWORD g_ComCtl32Version;
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifndef _WIN64
|
||||
@@ -354,6 +362,7 @@ bool IsLargePageSupported()
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef UNDER_CE
|
||||
static void SetMemoryLock()
|
||||
{
|
||||
if (!IsLargePageSupported())
|
||||
@@ -364,6 +373,7 @@ static void SetMemoryLock()
|
||||
if (ReadLockMemoryEnable())
|
||||
NSecurity::EnableLockMemoryPrivilege();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
static const int kNumSwitches = 1;
|
||||
@@ -378,34 +388,52 @@ enum Enum
|
||||
|
||||
static const CSwitchForm kSwitchForms[kNumSwitches] =
|
||||
{
|
||||
{ L"SOA", NSwitchType::kSimple, false },
|
||||
{ L"SOA", NSwitchType::kSimple, false },
|
||||
};
|
||||
*/
|
||||
|
||||
// int APIENTRY WinMain2(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */);
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int nCmdShow)
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
#define NT_CHECK_FAIL_ACTION MessageBoxW(0, L"Unsupported Windows version", L"7-zip", MB_ICONERROR); return 1;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
||||
#ifdef UNDER_CE
|
||||
LPWSTR
|
||||
#else
|
||||
LPSTR
|
||||
#endif
|
||||
/* lpCmdLine */, int nCmdShow)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
NT_CHECK
|
||||
SetLargePageSize();
|
||||
|
||||
#endif
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
#ifndef UNDER_CE
|
||||
g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
|
||||
g_LVN_ITEMACTIVATE_Support = (g_ComCtl32Version >= MAKELONG(71, 4));
|
||||
#endif
|
||||
|
||||
// OleInitialize is required for drag and drop.
|
||||
#ifndef UNDER_CE
|
||||
OleInitialize(NULL);
|
||||
#endif
|
||||
// Maybe needs CoInitializeEx also ?
|
||||
// NCOM::CComInitializer comInitializer;
|
||||
|
||||
UString programString, commandsString;
|
||||
UString commandsString;
|
||||
// MessageBoxW(0, GetCommandLineW(), L"", 0);
|
||||
|
||||
#ifdef UNDER_CE
|
||||
commandsString = GetCommandLineW();
|
||||
#else
|
||||
UString programString;
|
||||
SplitStringToTwoStrings(GetCommandLineW(), programString, commandsString);
|
||||
#endif
|
||||
|
||||
commandsString.Trim();
|
||||
UString paramString, tailString;
|
||||
@@ -427,7 +455,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /*
|
||||
{
|
||||
parser.ParseStrings(kSwitchForms, commandStrings);
|
||||
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
|
||||
if(nonSwitchStrings.Size() > 1)
|
||||
if (nonSwitchStrings.Size() > 1)
|
||||
{
|
||||
g_MainPath = nonSwitchStrings[1];
|
||||
// g_OpenArchive = parser[NKey::kOpenArachive].ThereIs;
|
||||
@@ -443,14 +471,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UNDER_CE
|
||||
SetMemoryLock();
|
||||
#endif
|
||||
|
||||
MSG msg;
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
return FALSE;
|
||||
|
||||
MyLoadMenu(g_HWND);
|
||||
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
{
|
||||
@@ -481,40 +509,39 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /*
|
||||
}
|
||||
|
||||
g_HWND = 0;
|
||||
#ifndef UNDER_CE
|
||||
OleUninitialize();
|
||||
#endif
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
static void SaveWindowInfo(HWND aWnd)
|
||||
{
|
||||
/*
|
||||
#ifdef UNDER_CE
|
||||
RECT rect;
|
||||
if (!::GetWindowRect(aWnd, &rect))
|
||||
return;
|
||||
*/
|
||||
SaveWindowSize(rect, g_Maximized);
|
||||
#else
|
||||
WINDOWPLACEMENT placement;
|
||||
placement.length = sizeof(placement);
|
||||
if (!::GetWindowPlacement(aWnd, &placement))
|
||||
return;
|
||||
SaveWindowSize(placement.rcNormalPosition,
|
||||
BOOLToBool(::IsZoomed(aWnd)));
|
||||
SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel,
|
||||
g_Splitter.GetPos());
|
||||
SaveWindowSize(placement.rcNormalPosition, BOOLToBool(::IsZoomed(aWnd)));
|
||||
#endif
|
||||
SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel, g_Splitter.GetPos());
|
||||
}
|
||||
|
||||
void ExecuteCommand(UINT commandID)
|
||||
static void ExecuteCommand(UINT commandID)
|
||||
{
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]);
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]);
|
||||
|
||||
switch (commandID)
|
||||
{
|
||||
case kAddCommand:
|
||||
g_App.AddToArchive();
|
||||
break;
|
||||
case kExtractCommand:
|
||||
g_App.ExtractArchives();
|
||||
break;
|
||||
case kTestCommand:
|
||||
g_App.TestArchives();
|
||||
break;
|
||||
case kAddCommand: g_App.AddToArchive(); break;
|
||||
case kExtractCommand: g_App.ExtractArchives(); break;
|
||||
case kTestCommand: g_App.TestArchives(); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,7 +581,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case WM_CREATE:
|
||||
{
|
||||
|
||||
g_HWND = hWnd;
|
||||
/*
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
@@ -679,7 +706,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos +
|
||||
(short)LOWORD(lParam) - g_StartCaptureMousePos);
|
||||
MoveSubWindows(hWnd);
|
||||
g_App.MoveSubWindows();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -693,8 +720,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
g_Splitter.SetPos(hWnd, g_SplitterPos );
|
||||
g_CanChangeSplitter = true;
|
||||
}
|
||||
|
||||
g_Maximized = (wParam == SIZE_MAXIMIZED) || (wParam == SIZE_MAXSHOW);
|
||||
|
||||
OnSize(hWnd);
|
||||
g_App.MoveSubWindows();
|
||||
/*
|
||||
int xSize = LOWORD(lParam);
|
||||
int ySize = HIWORD(lParam);
|
||||
@@ -729,7 +758,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
*/
|
||||
/*
|
||||
case kLangWasChangedMessage:
|
||||
MyLoadMenu(g_HWND);
|
||||
MyLoadMenu();
|
||||
return 0;
|
||||
*/
|
||||
|
||||
@@ -749,71 +778,71 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return 0 ;
|
||||
}
|
||||
*/
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||
else
|
||||
#endif
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
}
|
||||
|
||||
void OnSize(HWND hWnd)
|
||||
{
|
||||
/*
|
||||
if (g_App._rebar)
|
||||
{
|
||||
RECT rect;
|
||||
::GetClientRect(hWnd, &rect);
|
||||
int xSize = rect.right;
|
||||
int ySize = rect.bottom;
|
||||
// rect.bottom = 0;
|
||||
// g_App._rebar.SizeToRect(&rect);
|
||||
// g_App._rebar.Move(0, 0, xSize, ySize);
|
||||
}
|
||||
*/
|
||||
MoveSubWindows(hWnd);
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||
else
|
||||
#endif
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
}
|
||||
|
||||
int Window_GetRealHeight(NWindows::CWindow &w)
|
||||
static int Window_GetRealHeight(NWindows::CWindow &w)
|
||||
{
|
||||
RECT rect;
|
||||
WINDOWPLACEMENT placement;
|
||||
w.GetWindowRect(&rect);
|
||||
int res = rect.bottom - rect.top;
|
||||
#ifndef UNDER_CE
|
||||
WINDOWPLACEMENT placement;
|
||||
if (w.GetPlacement(&placement))
|
||||
res += placement.rcNormalPosition.top;
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
void MoveSubWindows(HWND hWnd)
|
||||
void CApp::MoveSubWindows()
|
||||
{
|
||||
HWND hWnd = _window;
|
||||
RECT rect;
|
||||
if (hWnd == 0)
|
||||
return;
|
||||
::GetClientRect(hWnd, &rect);
|
||||
int xSize = rect.right;
|
||||
if (xSize == 0)
|
||||
return;
|
||||
int headerSize = 0;
|
||||
if (g_App._rebar)
|
||||
headerSize = Window_GetRealHeight(g_App._rebar);
|
||||
#ifdef UNDER_CE
|
||||
_commandBar.AutoSize();
|
||||
{
|
||||
_commandBar.Show(true); // maybe we need it for
|
||||
headerSize += _commandBar.Height();
|
||||
}
|
||||
#endif
|
||||
if (_toolBar)
|
||||
{
|
||||
_toolBar.AutoSize();
|
||||
#ifdef UNDER_CE
|
||||
int h2 = Window_GetRealHeight(_toolBar);
|
||||
_toolBar.Move(0, headerSize, xSize, h2);
|
||||
#endif
|
||||
headerSize += Window_GetRealHeight(_toolBar);
|
||||
}
|
||||
int ySize = MyMax((int)(rect.bottom - headerSize), 0);
|
||||
|
||||
// It's for such case: Minimize / Close:
|
||||
if (xSize == 0 && ySize == 0)
|
||||
return;
|
||||
|
||||
if (g_App.NumPanels > 1)
|
||||
if (NumPanels > 1)
|
||||
{
|
||||
g_App.Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize);
|
||||
Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize);
|
||||
int xWidth1 = g_Splitter.GetPos() + kSplitterWidth;
|
||||
g_App.Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize);
|
||||
Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
int otherPanel = 1 - g_App.LastFocusedPanel;
|
||||
if (g_App.PanelsCreated[otherPanel])
|
||||
g_App.Panels[otherPanel].Move(0, headerSize, 0, ySize);
|
||||
int otherPanel = 1 - LastFocusedPanel;
|
||||
if (PanelsCreated[otherPanel])
|
||||
Panels[otherPanel].Move(0, headerSize, 0, ySize);
|
||||
*/
|
||||
g_App.Panels[g_App.LastFocusedPanel].Move(0, headerSize, xSize, ySize);
|
||||
Panels[LastFocusedPanel].Move(0, headerSize, xSize, ySize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,18 +404,6 @@ SOURCE=.\PanelSplitFile.cpp
|
||||
# Begin Group "Options"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "Settings"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SettingsPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SettingsPage.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\EditPage.cpp
|
||||
@@ -426,6 +414,14 @@ SOURCE=.\EditPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FoldersPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FoldersPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LangPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -434,6 +430,18 @@ SOURCE=.\LangPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MenuPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MenuPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OptionsDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PluginsPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -442,6 +450,14 @@ SOURCE=.\PluginsPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SettingsPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SettingsPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SystemPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -449,33 +465,6 @@ SOURCE=.\SystemPage.cpp
|
||||
SOURCE=.\SystemPage.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Password"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PasswordDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PasswordDialog.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Progress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ProgressDialog2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ProgressDialog2.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "About"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\AboutDialog.cpp
|
||||
@@ -484,19 +473,14 @@ SOURCE=.\AboutDialog.cpp
|
||||
|
||||
SOURCE=.\AboutDialog.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Split"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SplitDialog.cpp
|
||||
SOURCE=.\BrowseDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SplitDialog.h
|
||||
SOURCE=.\BrowseDialog.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ComboDialog.cpp
|
||||
@@ -515,6 +499,10 @@ SOURCE=CopyDialog.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DialogSize.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ListViewDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -537,6 +525,30 @@ SOURCE=OverwriteDialog.cpp
|
||||
|
||||
SOURCE=OverwriteDialog.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PasswordDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PasswordDialog.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ProgressDialog2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ProgressDialog2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SplitDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SplitDialog.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "FM Common"
|
||||
|
||||
@@ -855,6 +867,10 @@ SOURCE=..\..\..\Windows\FileIO.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileMapping.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileName.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -907,6 +923,10 @@ SOURCE=..\..\..\Windows\Net.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Process.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Process.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -1190,10 +1210,6 @@ SOURCE=..\Common\ExtractMode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\HandlerLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\IFileExtractCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -1333,6 +1349,26 @@ SOURCE=..\Agent\UpdateCallbackAgent.cpp
|
||||
SOURCE=..\Agent\UpdateCallbackAgent.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Explorer"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Explorer\ContextMenu.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Explorer\ContextMenu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Explorer\RegistryContextMenu.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Explorer\RegistryContextMenu.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
@@ -1436,10 +1472,6 @@ SOURCE=.\OpenCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OptionsDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PluginInterface.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
|
||||
#include "FSDrives.h"
|
||||
#include "FSFolder.h"
|
||||
|
||||
#ifndef UNDER_CE
|
||||
#include "NetFolder.h"
|
||||
#endif
|
||||
|
||||
#include "SysIconUtils.h"
|
||||
|
||||
namespace NWindows {
|
||||
@@ -61,8 +65,8 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
|
||||
{
|
||||
DWORD lastError = GetLastError();
|
||||
CFindFile findFile;
|
||||
CFileInfoW fileInfo;
|
||||
if (!findFile.FindFirst(_path + UString(L"*"), fileInfo))
|
||||
CFileInfoW fi;
|
||||
if (!findFile.FindFirst(_path + UString(L"*"), fi))
|
||||
return lastError;
|
||||
}
|
||||
return S_OK;
|
||||
@@ -73,13 +77,13 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles,
|
||||
RINOK(progress->SetCompleted(NULL));
|
||||
numFiles = numFolders = size = 0;
|
||||
CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*"));
|
||||
CFileInfoW fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
CFileInfoW fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
if (fileInfo.IsDir())
|
||||
if (fi.IsDir())
|
||||
{
|
||||
UInt64 subFolders, subFiles, subSize;
|
||||
RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fileInfo.Name, subFolders, subFiles, subSize, progress));
|
||||
RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fi.Name, subFolders, subFiles, subSize, progress));
|
||||
numFolders += subFolders;
|
||||
numFolders++;
|
||||
numFiles += subFiles;
|
||||
@@ -88,7 +92,7 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles,
|
||||
else
|
||||
{
|
||||
numFiles++;
|
||||
size += fileInfo.Size;
|
||||
size += fi.Size;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
@@ -98,21 +102,23 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
|
||||
{
|
||||
{
|
||||
CEnumeratorW enumerator(path + L"*");
|
||||
CDirItem fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
CDirItem fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
fileInfo.CompressedSizeIsDefined = false;
|
||||
#ifndef UNDER_CE
|
||||
fi.CompressedSizeIsDefined = false;
|
||||
/*
|
||||
if (!GetCompressedFileSize(_path + fileInfo.Name,
|
||||
fileInfo.CompressedSize))
|
||||
fileInfo.CompressedSize = fileInfo.Size;
|
||||
if (!GetCompressedFileSize(_path + fi.Name,
|
||||
fi.CompressedSize))
|
||||
fi.CompressedSize = fi.Size;
|
||||
*/
|
||||
if (fileInfo.IsDir())
|
||||
#endif
|
||||
if (fi.IsDir())
|
||||
{
|
||||
// fileInfo.Size = GetFolderSize(_path + fileInfo.Name);
|
||||
fileInfo.Size = 0;
|
||||
// fi.Size = GetFolderSize(_path + fi.Name);
|
||||
fi.Size = 0;
|
||||
}
|
||||
dirItem.Files.Add(fileInfo);
|
||||
dirItem.Files.Add(fi);
|
||||
}
|
||||
}
|
||||
if (!_flatMode)
|
||||
@@ -237,7 +243,8 @@ STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
|
||||
}
|
||||
*/
|
||||
|
||||
bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
|
||||
#ifndef UNDER_CE
|
||||
static bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
|
||||
{
|
||||
DWORD highPart;
|
||||
DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
|
||||
@@ -256,46 +263,49 @@ bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
|
||||
size = (UInt64(highPart) << 32) | lowPart;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
if (itemIndex >= (UInt32)_refs.Size())
|
||||
return E_INVALIDARG;
|
||||
CDirItem &fileInfo = *_refs[itemIndex];
|
||||
CDirItem &fi = *_refs[itemIndex];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidIsDir: prop = fileInfo.IsDir(); break;
|
||||
case kpidName: prop = fileInfo.Name; break;
|
||||
case kpidSize: if (!fileInfo.IsDir()) prop = fileInfo.Size; break;
|
||||
case kpidIsDir: prop = fi.IsDir(); break;
|
||||
case kpidName: prop = fi.Name; break;
|
||||
case kpidSize: if (!fi.IsDir()) prop = fi.Size; break;
|
||||
case kpidPackSize:
|
||||
if (!fileInfo.CompressedSizeIsDefined)
|
||||
#ifdef UNDER_CE
|
||||
prop = fi.Size;
|
||||
#else
|
||||
if (!fi.CompressedSizeIsDefined)
|
||||
{
|
||||
fileInfo.CompressedSizeIsDefined = true;
|
||||
if (fileInfo.IsDir () ||
|
||||
!MyGetCompressedFileSizeW(_path + GetRelPath(fileInfo), fileInfo.CompressedSize))
|
||||
fileInfo.CompressedSize = fileInfo.Size;
|
||||
fi.CompressedSizeIsDefined = true;
|
||||
if (fi.IsDir () ||
|
||||
!MyGetCompressedFileSizeW(_path + GetRelPath(fi), fi.CompressedSize))
|
||||
fi.CompressedSize = fi.Size;
|
||||
}
|
||||
prop = fileInfo.CompressedSize;
|
||||
prop = fi.CompressedSize;
|
||||
#endif
|
||||
break;
|
||||
case kpidAttrib: prop = (UInt32)fileInfo.Attrib; break;
|
||||
case kpidCTime: prop = fileInfo.CTime; break;
|
||||
case kpidATime: prop = fileInfo.ATime; break;
|
||||
case kpidMTime: prop = fileInfo.MTime; break;
|
||||
case kpidAttrib: prop = (UInt32)fi.Attrib; break;
|
||||
case kpidCTime: prop = fi.CTime; break;
|
||||
case kpidATime: prop = fi.ATime; break;
|
||||
case kpidMTime: prop = fi.MTime; break;
|
||||
case kpidComment:
|
||||
{
|
||||
LoadComments();
|
||||
UString comment;
|
||||
if (_comments.GetValue(GetRelPath(fileInfo), comment))
|
||||
if (_comments.GetValue(GetRelPath(fi), comment))
|
||||
prop = comment;
|
||||
break;
|
||||
}
|
||||
case kpidPrefix:
|
||||
{
|
||||
if (_flatMode)
|
||||
{
|
||||
prop = GetPrefix(fileInfo);
|
||||
}
|
||||
prop = GetPrefix(fi);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -333,10 +343,10 @@ UString CFSFolder::GetRelPath(const CDirItem &item) const
|
||||
STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
const CDirItem &fileInfo = *_refs[index];
|
||||
if (!fileInfo.IsDir())
|
||||
const CDirItem &fi = *_refs[index];
|
||||
if (!fi.IsDir())
|
||||
return E_INVALIDARG;
|
||||
return BindToFolderSpec(GetRelPath(fileInfo), resultFolder);
|
||||
return BindToFolderSpec(GetRelPath(fi), resultFolder);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
@@ -362,15 +372,19 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
if (pos < 0)
|
||||
{
|
||||
parentPath.Empty();
|
||||
#ifdef UNDER_CE
|
||||
*resultFolder = 0;
|
||||
#else
|
||||
CFSDrives *drivesFolderSpec = new CFSDrives;
|
||||
CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
|
||||
drivesFolderSpec->Init();
|
||||
*resultFolder = drivesFolder.Detach();
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
UString parentPathReduced = parentPath.Left(pos);
|
||||
parentPath = parentPath.Left(pos + 1);
|
||||
#ifndef UNDER_CE
|
||||
pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
if (pos == 1)
|
||||
{
|
||||
@@ -382,6 +396,7 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
*resultFolder = netFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
CFSFolder *parentFolderSpec = new CFSFolder;
|
||||
CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
|
||||
RINOK(parentFolderSpec->Init(parentPath, 0));
|
||||
@@ -457,11 +472,11 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
|
||||
int index = indices[i];
|
||||
if (index >= _refs.Size())
|
||||
return E_INVALIDARG;
|
||||
const CDirItem &fileInfo = *_refs[index];
|
||||
if (fileInfo.IsDir())
|
||||
const CDirItem &fi = *_refs[index];
|
||||
if (fi.IsDir())
|
||||
{
|
||||
UInt64 subFolders, subFiles, subSize;
|
||||
RINOK(GetFolderSize(_path + GetRelPath(fileInfo), subFolders, subFiles, subSize, progress));
|
||||
RINOK(GetFolderSize(_path + GetRelPath(fi), subFolders, subFiles, subSize, progress));
|
||||
numFolders += subFolders;
|
||||
numFolders++;
|
||||
numFiles += subFiles;
|
||||
@@ -470,7 +485,7 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
|
||||
else
|
||||
{
|
||||
numFiles++;
|
||||
size += fileInfo.Size;
|
||||
size += fi.Size;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
@@ -478,8 +493,8 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
|
||||
{
|
||||
const CDirItem &fileInfo = *_refs[index];
|
||||
if (fileInfo.IsDir())
|
||||
const CDirItem &fi = *_refs[index];
|
||||
if (fi.IsDir())
|
||||
{
|
||||
/*
|
||||
CMyComPtr<IFolderFolder> subFolder;
|
||||
@@ -499,9 +514,9 @@ HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
|
||||
}
|
||||
*/
|
||||
UInt64 numFolders, numFiles;
|
||||
return GetFolderSize(_path + GetRelPath(fileInfo), numFolders, numFiles, size, progress);
|
||||
return GetFolderSize(_path + GetRelPath(fi), numFolders, numFiles, size, progress);
|
||||
}
|
||||
size = fileInfo.Size;
|
||||
size = fi.Size;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -560,9 +575,9 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress
|
||||
|
||||
STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */)
|
||||
{
|
||||
const CDirItem &fileInfo = *_refs[index];
|
||||
const UString fullPrefix = _path + GetPrefix(fileInfo);
|
||||
if (!NDirectory::MyMoveFile(fullPrefix + fileInfo.Name, fullPrefix + newName))
|
||||
const CDirItem &fi = *_refs[index];
|
||||
const UString fullPrefix = _path + GetPrefix(fi);
|
||||
if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + newName))
|
||||
return GetLastError();
|
||||
return S_OK;
|
||||
}
|
||||
@@ -572,10 +587,10 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress
|
||||
RINOK(progress->SetTotal(numItems));
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
const CDirItem &fileInfo = *_refs[indices[i]];
|
||||
const UString fullPath = _path + GetRelPath(fileInfo);
|
||||
const CDirItem &fi = *_refs[indices[i]];
|
||||
const UString fullPath = _path + GetRelPath(fi);
|
||||
bool result;
|
||||
if (fileInfo.IsDir())
|
||||
if (fi.IsDir())
|
||||
result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
|
||||
else
|
||||
result = NDirectory::DeleteFileAlways(fullPath);
|
||||
@@ -592,14 +607,14 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
|
||||
{
|
||||
if (index >= (UInt32)_refs.Size())
|
||||
return E_INVALIDARG;
|
||||
CDirItem &fileInfo = *_refs[index];
|
||||
if (fileInfo.Parent->Parent != 0)
|
||||
CDirItem &fi = *_refs[index];
|
||||
if (fi.Parent->Parent != 0)
|
||||
return E_NOTIMPL;
|
||||
switch(propID)
|
||||
{
|
||||
case kpidComment:
|
||||
{
|
||||
UString filename = fileInfo.Name;
|
||||
UString filename = fi.Name;
|
||||
filename.Trim();
|
||||
if (value->vt == VT_EMPTY)
|
||||
_comments.DeletePair(filename);
|
||||
@@ -630,10 +645,10 @@ STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
|
||||
{
|
||||
if (index >= (UInt32)_refs.Size())
|
||||
return E_INVALIDARG;
|
||||
const CDirItem &fileInfo = *_refs[index];
|
||||
const CDirItem &fi = *_refs[index];
|
||||
*iconIndex = 0;
|
||||
int iconIndexTemp;
|
||||
if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attrib, iconIndexTemp) != 0)
|
||||
if (GetRealIconIndex(_path + GetRelPath(fi), fi.Attrib, iconIndexTemp) != 0)
|
||||
{
|
||||
*iconIndex = iconIndexTemp;
|
||||
return S_OK;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#ifndef __FSFOLDER_H
|
||||
#define __FSFOLDER_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "Windows/FileFind.h"
|
||||
@@ -17,8 +16,10 @@ class CFSFolder;
|
||||
|
||||
struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
bool CompressedSizeIsDefined;
|
||||
UInt64 CompressedSize;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct CDirItem;
|
||||
@@ -98,6 +99,9 @@ private:
|
||||
void AddRefs(CDirItem &dirItem);
|
||||
public:
|
||||
HRESULT Init(const UString &path, IFolderFolder *parentFolder);
|
||||
#ifdef UNDER_CE
|
||||
HRESULT InitToRoot() { return Init(L"\\", NULL); }
|
||||
#endif
|
||||
|
||||
CFSFolder() : _flatMode(false) {}
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "../../Common/FilePathAutoRename.h"
|
||||
|
||||
@@ -41,6 +42,29 @@ struct CProgressInfo
|
||||
IProgress *Progress;
|
||||
};
|
||||
|
||||
#ifndef PROGRESS_CONTINUE
|
||||
|
||||
#define PROGRESS_CONTINUE 0
|
||||
#define PROGRESS_CANCEL 1
|
||||
|
||||
#define COPY_FILE_FAIL_IF_EXISTS 0x00000001
|
||||
|
||||
typedef
|
||||
DWORD
|
||||
(WINAPI* LPPROGRESS_ROUTINE)(
|
||||
LARGE_INTEGER TotalFileSize,
|
||||
LARGE_INTEGER TotalBytesTransferred,
|
||||
LARGE_INTEGER StreamSize,
|
||||
LARGE_INTEGER StreamBytesTransferred,
|
||||
DWORD dwStreamNumber,
|
||||
DWORD dwCallbackReason,
|
||||
HANDLE hSourceFile,
|
||||
HANDLE hDestinationFile,
|
||||
LPVOID lpData
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
static DWORD CALLBACK CopyProgressRoutine(
|
||||
LARGE_INTEGER /* TotalFileSize */, // file size
|
||||
LARGE_INTEGER TotalBytesTransferred, // bytes transferred
|
||||
@@ -94,11 +118,17 @@ static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
|
||||
if (g_IsNT)
|
||||
#endif
|
||||
{
|
||||
const wchar_t *k_DllName =
|
||||
#ifdef UNDER_CE
|
||||
L"coredll.dll"
|
||||
#else
|
||||
L"kernel32.dll"
|
||||
#endif
|
||||
;
|
||||
CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
|
||||
::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"),
|
||||
"CopyFileExW");
|
||||
My_GetProcAddress(::GetModuleHandleW(k_DllName), "CopyFileExW");
|
||||
if (copyFunctionW == 0)
|
||||
return false;
|
||||
return BOOLToBool(::CopyFileW(existingFile, newFile, TRUE));
|
||||
if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
|
||||
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
|
||||
return true;
|
||||
@@ -141,6 +171,7 @@ typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
|
||||
|
||||
static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
// if (IsItWindows2000orHigher())
|
||||
// {
|
||||
CProgressInfo progressInfo;
|
||||
@@ -148,7 +179,7 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
|
||||
progressInfo.StartPos = completedSize;
|
||||
|
||||
MoveFileWithProgressPointer moveFunction = (MoveFileWithProgressPointer)
|
||||
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
|
||||
My_GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
|
||||
"MoveFileWithProgressW");
|
||||
if (moveFunction != 0)
|
||||
{
|
||||
@@ -172,6 +203,7 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
|
||||
}
|
||||
// }
|
||||
// else
|
||||
#endif
|
||||
return NDirectory::MyMoveFile(existingFile, newFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,12 @@ struct CThreadArchiveOpen
|
||||
|
||||
void Process()
|
||||
{
|
||||
OpenCallbackSpec->ProgressDialog.WaitCreating();
|
||||
Result = FolderManager->OpenFolderFile(InStream, Path, &Folder, OpenCallback);
|
||||
OpenCallbackSpec->ProgressDialog.MyClose();
|
||||
try
|
||||
{
|
||||
CProgressCloser closer(OpenCallbackSpec->ProgressDialog);
|
||||
Result = FolderManager->OpenFolderFile(InStream, Path, &Folder, OpenCallback);
|
||||
}
|
||||
catch(...) { Result = E_FAIL; }
|
||||
}
|
||||
|
||||
static THREAD_FUNC_DECL MyThreadFunction(void *param)
|
||||
@@ -42,14 +45,15 @@ struct CThreadArchiveOpen
|
||||
}
|
||||
};
|
||||
|
||||
static int FindPlugin(const CObjectVector<CPluginInfo> &plugins,
|
||||
const UString &pluginName)
|
||||
/*
|
||||
static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &pluginName)
|
||||
{
|
||||
for (int i = 0; i < plugins.Size(); i++)
|
||||
if (plugins[i].Name.CompareNoCase(pluginName) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT OpenFileFolderPlugin(
|
||||
IInStream *inStream,
|
||||
@@ -77,6 +81,7 @@ HRESULT OpenFileFolderPlugin(
|
||||
|
||||
NFile::NName::SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
|
||||
|
||||
/*
|
||||
if (!extension.IsEmpty())
|
||||
{
|
||||
CExtInfo extInfo;
|
||||
@@ -94,6 +99,7 @@ HRESULT OpenFileFolderPlugin(
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for (int i = 0; i < plugins.Size(); i++)
|
||||
{
|
||||
@@ -127,11 +133,13 @@ HRESULT OpenFileFolderPlugin(
|
||||
t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow;
|
||||
t.OpenCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
|
||||
t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
|
||||
t.OpenCallbackSpec->ProgressDialog.WaitMode = true;
|
||||
|
||||
NWindows::CThread thread;
|
||||
if (thread.Create(CThreadArchiveOpen::MyThreadFunction, &t) != S_OK)
|
||||
throw 271824;
|
||||
t.OpenCallbackSpec->StartProgressDialog(progressTitle);
|
||||
{
|
||||
NWindows::CThread thread;
|
||||
RINOK(thread.Create(CThreadArchiveOpen::MyThreadFunction, &t));
|
||||
t.OpenCallbackSpec->StartProgressDialog(progressTitle, thread);
|
||||
}
|
||||
|
||||
if (t.Result == E_ABORT)
|
||||
return t.Result;
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "IFolder.h"
|
||||
#include "FilePlugins.h"
|
||||
#include "StringUtils.h"
|
||||
#include "PluginLoader.h"
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
#include "FilePlugins.h"
|
||||
#include "PluginLoader.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
using namespace NRegistryAssociations;
|
||||
|
||||
int CExtDatabase::FindExtInfoBig(const UString &ext)
|
||||
@@ -31,9 +30,12 @@ int CExtDatabase::FindPlugin(const UString &plugin)
|
||||
|
||||
void CExtDatabase::Read()
|
||||
{
|
||||
/*
|
||||
CObjectVector<CExtInfo> extItems;
|
||||
ReadInternalAssociations(extItems);
|
||||
*/
|
||||
ReadFileFolderPluginInfoList(Plugins);
|
||||
/*
|
||||
for (int i = 0; i < extItems.Size(); i++)
|
||||
{
|
||||
const CExtInfo &extInfo = extItems[i];
|
||||
@@ -48,6 +50,7 @@ void CExtDatabase::Read()
|
||||
}
|
||||
ExtBigItems.Add(extInfoBig);
|
||||
}
|
||||
*/
|
||||
for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++)
|
||||
{
|
||||
const CPluginInfo &pluginInfo = Plugins[pluginIndex];
|
||||
@@ -69,6 +72,10 @@ void CExtDatabase::Read()
|
||||
for (int i = 0; i < exts.Size(); i++)
|
||||
{
|
||||
const UString &ext = exts[i];
|
||||
#ifdef UNDER_CE
|
||||
if (ext == L"cab")
|
||||
continue;
|
||||
#endif
|
||||
int index = FindExtInfoBig(ext);
|
||||
if (index < 0)
|
||||
{
|
||||
@@ -91,6 +98,7 @@ void CExtDatabase::Read()
|
||||
|
||||
void CExtDatabase::Save()
|
||||
{
|
||||
/*
|
||||
CObjectVector<CExtInfo> extItems;
|
||||
for (int i = 0; i < ExtBigItems.Size(); i++)
|
||||
{
|
||||
@@ -107,6 +115,5 @@ void CExtDatabase::Save()
|
||||
extItems.Add(extInfo);
|
||||
}
|
||||
WriteInternalAssociations(extItems);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,13 +5,7 @@
|
||||
#include "FoldersPageRes.h"
|
||||
#include "FoldersPage.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/Shell.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "../FileManager/BrowseDialog.h"
|
||||
#include "../FileManager/HelpUtils.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
|
||||
@@ -38,7 +32,7 @@ static const int kNumWorkModeButtons = sizeof(kWorkModeButtons) / sizeof(kWorkMo
|
||||
bool CFoldersPage::OnInit()
|
||||
{
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
ReadWorkDirInfo(m_WorkDirInfo);
|
||||
m_WorkDirInfo.Load();
|
||||
|
||||
CheckButton(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly);
|
||||
|
||||
@@ -138,14 +132,14 @@ void CFoldersPage::OnFoldersWorkButtonPath()
|
||||
m_WorkPath.GetText(currentPath);
|
||||
UString title = LangString(IDS_FOLDERS_SET_WORK_PATH_TITLE, 0x01000281);
|
||||
UString resultPath;
|
||||
if (NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
|
||||
if (MyBrowseForFolder(HWND(*this), title, currentPath, resultPath))
|
||||
m_WorkPath.SetText(resultPath);
|
||||
}
|
||||
|
||||
LONG CFoldersPage::OnApply()
|
||||
{
|
||||
GetWorkDir(m_WorkDirInfo);
|
||||
SaveWorkDirInfo(m_WorkDirInfo);
|
||||
m_WorkDirInfo.Save();
|
||||
return PSNRET_NOERROR;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// FoldersPage.h
|
||||
|
||||
#ifndef __FOLDERSPAGE_H
|
||||
#define __FOLDERSPAGE_H
|
||||
#ifndef __FOLDERS_PAGE_H
|
||||
#define __FOLDERS_PAGE_H
|
||||
|
||||
#include "Windows/Control/PropertyPage.h"
|
||||
|
||||
@@ -19,7 +19,6 @@ class CFoldersPage : public NWindows::NControl::CPropertyPage
|
||||
int GetWorkMode() const;
|
||||
void GetWorkDir(NWorkDir::CInfo &workDirInfo);
|
||||
// bool WasChanged();
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
virtual bool OnCommand(int code, int itemID, LPARAM lParam);
|
||||
virtual void OnNotifyHelp();
|
||||
23
CPP/7zip/UI/FileManager/FoldersPage.rc
Executable file
23
CPP/7zip/UI/FileManager/FoldersPage.rc
Executable file
@@ -0,0 +1,23 @@
|
||||
#include "FoldersPageRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xc 196
|
||||
#define yc 100
|
||||
|
||||
IDD_FOLDERS MY_PAGE
|
||||
#include "FoldersPage2.rc"
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
#undef xc
|
||||
#define xc SMALL_PAGE_SIZE_X
|
||||
|
||||
IDD_FOLDERS_2 MY_PAGE
|
||||
#include "FoldersPage2.rc"
|
||||
|
||||
#endif
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_FOLDERS_SET_WORK_PATH_TITLE "Specify a location for temporary archive files."
|
||||
END
|
||||
16
CPP/7zip/UI/FileManager/FoldersPage2.rc
Executable file
16
CPP/7zip/UI/FileManager/FoldersPage2.rc
Executable file
@@ -0,0 +1,16 @@
|
||||
CAPTION "Folders"
|
||||
BEGIN
|
||||
// GROUPBOX "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, m, m, xc, 98
|
||||
|
||||
LTEXT "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, m, m, xc, 8
|
||||
CONTROL "&System temp folder", IDC_FOLDERS_WORK_RADIO_SYSTEM, "Button", BS_AUTORADIOBUTTON | WS_GROUP,
|
||||
m, 20, xc, 10
|
||||
CONTROL "&Current", IDC_FOLDERS_WORK_RADIO_CURRENT, "Button", BS_AUTORADIOBUTTON,
|
||||
m, 34, xc, 10
|
||||
CONTROL "Specified:", IDC_FOLDERS_WORK_RADIO_SPECIFIED, "Button", BS_AUTORADIOBUTTON,
|
||||
m, 48, xc, 10
|
||||
EDITTEXT IDC_FOLDERS_WORK_EDIT_PATH, m + m, 62, xc - m - m - bxsDots, 14, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "...", IDC_FOLDERS_WORK_BUTTON_PATH, xs - m - bxsDots, 61, bxsDots, bys
|
||||
CONTROL "Use for removable drives only", IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, MY_CHECKBOX,
|
||||
m, 86, xc, 10
|
||||
END
|
||||
@@ -1,6 +1,7 @@
|
||||
#define IDD_FOLDERS 900
|
||||
#define IDD_FOLDERS 571
|
||||
#define IDD_FOLDERS_2 671
|
||||
|
||||
#define IDS_FOLDERS_SET_WORK_PATH_TITLE 103
|
||||
#define IDS_FOLDERS_SET_WORK_PATH_TITLE 877
|
||||
|
||||
#define IDC_FOLDERS_STATIC_WORKING_FOLDER 1001
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
static LPCWSTR kHelpFileName = L"7-zip.chm::/";
|
||||
|
||||
#ifdef UNDER_CE
|
||||
void ShowHelpWindow(HWND, LPCWSTR)
|
||||
{
|
||||
}
|
||||
#else
|
||||
void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
|
||||
{
|
||||
UString path;
|
||||
@@ -19,5 +24,4 @@ void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
|
||||
path += topicFile;
|
||||
HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// LangPage.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "LangPageRes.h"
|
||||
#include "LangPage.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#include "RegistryUtils.h"
|
||||
#include "HelpUtils.h"
|
||||
#include "LangPage.h"
|
||||
#include "LangPageRes.h"
|
||||
#include "LangUtils.h"
|
||||
#include "RegistryUtils.h"
|
||||
|
||||
static CIDLangPair kIDLangPairs[] =
|
||||
{
|
||||
@@ -19,17 +19,19 @@ static CIDLangPair kIDLangPairs[] =
|
||||
|
||||
static LPCWSTR kLangTopic = L"fm/options.htm#language";
|
||||
|
||||
static UString NativeLangString(const UString &s)
|
||||
{
|
||||
return L" (" + s + L')';
|
||||
}
|
||||
|
||||
bool CLangPage::OnInit()
|
||||
{
|
||||
_langWasChanged = false;
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
|
||||
_langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG));
|
||||
|
||||
UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH);
|
||||
s += L" (";
|
||||
s += NWindows::MyLoadStringW(IDS_LANG_NATIVE);
|
||||
s += L")";
|
||||
UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH) +
|
||||
NativeLangString(NWindows::MyLoadStringW(IDS_LANG_NATIVE));
|
||||
int index = (int)_langCombo.AddString(s);
|
||||
_langCombo.SetItemData(index, _paths.Size());
|
||||
_paths.Add(L"-");
|
||||
@@ -40,21 +42,12 @@ bool CLangPage::OnInit()
|
||||
for (int i = 0; i < langs.Size(); i++)
|
||||
{
|
||||
const CLangEx &lang = langs[i];
|
||||
UString name;
|
||||
UString englishName, nationalName;
|
||||
if (lang.Lang.GetMessage(0x00000000, englishName))
|
||||
name = englishName;
|
||||
else
|
||||
UString name, nationalName;
|
||||
if (!lang.Lang.GetMessage(0, name))
|
||||
name = lang.ShortName;
|
||||
if (lang.Lang.GetMessage(0x00000001, nationalName))
|
||||
{
|
||||
if (!nationalName.IsEmpty())
|
||||
{
|
||||
name += L" (";
|
||||
name += nationalName;
|
||||
name += L")";
|
||||
}
|
||||
}
|
||||
if (lang.Lang.GetMessage(1, nationalName) && !nationalName.IsEmpty())
|
||||
name += NativeLangString(nationalName);
|
||||
|
||||
index = (int)_langCombo.AddString(name);
|
||||
_langCombo.SetItemData(index, _paths.Size());
|
||||
_paths.Add(lang.ShortName);
|
||||
@@ -70,13 +63,13 @@ LONG CLangPage::OnApply()
|
||||
int pathIndex = (int)_langCombo.GetItemData(selectedIndex);
|
||||
SaveRegLang(_paths[pathIndex]);
|
||||
ReloadLang();
|
||||
_langWasChanged = true;
|
||||
LangWasChanged = true;
|
||||
return PSNRET_NOERROR;
|
||||
}
|
||||
|
||||
void CLangPage::OnNotifyHelp()
|
||||
{
|
||||
ShowHelpWindow(NULL, kLangTopic); // change it
|
||||
ShowHelpWindow(NULL, kLangTopic);
|
||||
}
|
||||
|
||||
bool CLangPage::OnCommand(int code, int itemID, LPARAM param)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// LangPage.h
|
||||
|
||||
#ifndef __LANGPAGE_H
|
||||
#define __LANGPAGE_H
|
||||
#ifndef __LANG_PAGE_H
|
||||
#define __LANG_PAGE_H
|
||||
|
||||
#include "Windows/Control/PropertyPage.h"
|
||||
#include "Windows/Control/ComboBox.h"
|
||||
@@ -11,7 +11,8 @@ class CLangPage: public NWindows::NControl::CPropertyPage
|
||||
NWindows::NControl::CComboBox _langCombo;
|
||||
UStringVector _paths;
|
||||
public:
|
||||
bool _langWasChanged;
|
||||
bool LangWasChanged;
|
||||
CLangPage() { LangWasChanged = false; }
|
||||
virtual bool OnInit();
|
||||
virtual void OnNotifyHelp();
|
||||
virtual bool OnCommand(int code, int itemID, LPARAM param);
|
||||
|
||||
@@ -1,18 +1,34 @@
|
||||
#include "LangPageRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 196
|
||||
#define ySize2 140
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
#define xc 148
|
||||
#define yc 100
|
||||
|
||||
IDD_LANG DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE
|
||||
IDD_LANG MY_PAGE
|
||||
CAPTION "Language"
|
||||
MY_FONT
|
||||
BEGIN
|
||||
LTEXT "Language:", IDC_LANG_STATIC_LANG, marg, marg, xSize2, 8
|
||||
COMBOBOX IDC_LANG_COMBO_LANG, marg, 20, 146, ySize2 - 12, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
END
|
||||
{
|
||||
LTEXT "Language:", IDC_LANG_STATIC_LANG, m, m, xc, 8
|
||||
COMBOBOX IDC_LANG_COMBO_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED
|
||||
}
|
||||
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
#undef m
|
||||
#undef xc
|
||||
|
||||
#define m 4
|
||||
#define xc (SMALL_PAGE_SIZE_X + 8)
|
||||
|
||||
IDD_LANG_2 MY_PAGE
|
||||
CAPTION "Language"
|
||||
{
|
||||
LTEXT "Language:", IDC_LANG_STATIC_LANG, m, m, xc, 8
|
||||
COMBOBOX IDC_LANG_COMBO_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#define IDD_LANG 900
|
||||
#define IDD_LANG 544
|
||||
#define IDD_LANG_2 644
|
||||
|
||||
#define IDS_LANG_ENGLISH 995
|
||||
#define IDS_LANG_NATIVE 996
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// ListViewDialog.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ListViewDialog.h"
|
||||
#include "RegistryUtils.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "LangUtils.h"
|
||||
@@ -18,13 +20,17 @@ bool CListViewDialog::OnInit()
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
#endif
|
||||
_listView.Attach(GetItem(IDC_LISTVIEW_LIST));
|
||||
|
||||
if (ReadSingleClick())
|
||||
_listView.SetExtendedListViewStyle(LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT);
|
||||
|
||||
SetText(Title);
|
||||
|
||||
LVCOLUMN columnInfo;
|
||||
columnInfo.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
|
||||
columnInfo.fmt = LVCFMT_LEFT;
|
||||
columnInfo.iSubItem = 0;
|
||||
columnInfo.cx = 1000;
|
||||
columnInfo.cx = 200;
|
||||
|
||||
_listView.InsertColumn(0, &columnInfo);
|
||||
|
||||
@@ -32,20 +38,67 @@ bool CListViewDialog::OnInit()
|
||||
_listView.InsertItem(i, Strings[i]);
|
||||
|
||||
if (Strings.Size() > 0)
|
||||
_listView.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
|
||||
_listView.SetItemState_FocusedSelected(0);
|
||||
|
||||
_listView.SetColumnWidthAuto(0);
|
||||
StringsWereChanged = false;
|
||||
|
||||
NormalizeSize();
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
bool CListViewDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
|
||||
{
|
||||
int mx, my;
|
||||
GetMargins(8, mx, my);
|
||||
int bx1, bx2, by;
|
||||
GetItemSizes(IDCANCEL, bx1, by);
|
||||
GetItemSizes(IDOK, bx2, by);
|
||||
int y = ySize - my - by;
|
||||
int x = xSize - mx - bx1;
|
||||
|
||||
/*
|
||||
RECT rect;
|
||||
GetClientRect(&rect);
|
||||
rect.top = y - my;
|
||||
InvalidateRect(&rect);
|
||||
*/
|
||||
InvalidateRect(NULL);
|
||||
|
||||
MoveItem(IDCANCEL, x, y, bx1, by);
|
||||
MoveItem(IDOK, x - mx - bx2, y, bx2, by);
|
||||
/*
|
||||
if (wParam == SIZE_MAXSHOW || wParam == SIZE_MAXIMIZED || wParam == SIZE_MAXHIDE)
|
||||
mx = 0;
|
||||
*/
|
||||
_listView.Move(mx, my, xSize - mx * 2, y - my * 2);
|
||||
return false;
|
||||
}
|
||||
|
||||
extern bool g_LVN_ITEMACTIVATE_Support;
|
||||
|
||||
bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
|
||||
{
|
||||
if (header->hwndFrom != _listView)
|
||||
return false;
|
||||
switch(header->code)
|
||||
{
|
||||
case LVN_ITEMACTIVATE:
|
||||
if (g_LVN_ITEMACTIVATE_Support)
|
||||
{
|
||||
OnOK();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case NM_DBLCLK:
|
||||
OnOK();
|
||||
return true;
|
||||
case NM_RETURN: // probabably it's unused
|
||||
if (!g_LVN_ITEMACTIVATE_Support)
|
||||
{
|
||||
OnOK();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case LVN_KEYDOWN:
|
||||
{
|
||||
LPNMLVKEYDOWN keyDownInfo = LPNMLVKEYDOWN(header);
|
||||
@@ -55,9 +108,6 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
|
||||
{
|
||||
if (!DeleteIsAllowed)
|
||||
return false;
|
||||
int focusedIndex = _listView.GetFocusedItem();
|
||||
if (focusedIndex < 0)
|
||||
focusedIndex = 0;
|
||||
for (;;)
|
||||
{
|
||||
int index = _listView.GetNextSelectedItem(-1);
|
||||
@@ -67,10 +117,10 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
|
||||
_listView.DeleteItem(index);
|
||||
Strings.Delete(index);
|
||||
}
|
||||
if (focusedIndex >= _listView.GetItemCount())
|
||||
focusedIndex = _listView.GetItemCount() - 1;
|
||||
int focusedIndex = _listView.GetFocusedItem();
|
||||
if (focusedIndex >= 0)
|
||||
_listView.SetItemState(focusedIndex, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
|
||||
_listView.SetItemState_FocusedSelected(focusedIndex);
|
||||
_listView.SetColumnWidthAuto(0);
|
||||
return true;
|
||||
}
|
||||
case 'A':
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// ListViewDialog.h
|
||||
|
||||
#ifndef __LISTVIEWDIALOG_H
|
||||
#define __LISTVIEWDIALOG_H
|
||||
#ifndef __LISTVIEW_DIALOG_H
|
||||
#define __LISTVIEW_DIALOG_H
|
||||
|
||||
#include "Windows/Control/Dialog.h"
|
||||
#include "Windows/Control/ListView.h"
|
||||
|
||||
#include "ListViewDialogRes.h"
|
||||
|
||||
class CListViewDialog: public NWindows::NControl::CModalDialog
|
||||
@@ -12,19 +13,18 @@ class CListViewDialog: public NWindows::NControl::CModalDialog
|
||||
NWindows::NControl::CListView _listView;
|
||||
virtual void OnOK();
|
||||
virtual bool OnInit();
|
||||
virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
|
||||
virtual bool OnNotify(UINT controlID, LPNMHDR header);
|
||||
|
||||
public:
|
||||
UString Title;
|
||||
bool DeleteIsAllowed;
|
||||
UStringVector Strings;
|
||||
bool StringsWereChanged;
|
||||
UStringVector Strings;
|
||||
int FocusedItemIndex;
|
||||
|
||||
INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_LISTVIEW, wndParent); }
|
||||
|
||||
CListViewDialog(): DeleteIsAllowed(false) {}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
#include "ListViewDialogRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 342
|
||||
#define ySize2 220
|
||||
#define xc 320
|
||||
#define yc 240
|
||||
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
|
||||
#define bYPos (ySize - marg - bYSize)
|
||||
#define b1XPos (xSize - marg - bXSize)
|
||||
#define b2XPos (b1XPos - 10 - bXSize)
|
||||
|
||||
|
||||
IDD_DIALOG_LISTVIEW DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
|
||||
IDD_DIALOG_LISTVIEW MY_RESIZE_DIALOG
|
||||
CAPTION "ListView"
|
||||
MY_FONT
|
||||
BEGIN
|
||||
{
|
||||
CONTROL "List1", IDC_LISTVIEW_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS |
|
||||
LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,
|
||||
marg, marg, xSize2, ySize2 - bYSize - 10
|
||||
DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize
|
||||
PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize
|
||||
END
|
||||
|
||||
|
||||
m, m, xc, yc - bys - m
|
||||
OK_CANCEL
|
||||
}
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
#define IDD_DIALOG_LISTVIEW 201
|
||||
|
||||
#define IDC_LISTVIEW_LIST 1000
|
||||
#define IDD_DIALOG_LISTVIEW 508
|
||||
#define IDC_LISTVIEW_LIST 1000
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
// SystemPage.cpp
|
||||
// MenuPage.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "resource.h"
|
||||
#include "SystemPageRes.h"
|
||||
#include "SystemPage.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/Control/ListView.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "../FileManager/HelpUtils.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
#include "../FileManager/FormatUtils.h"
|
||||
#include "../Explorer/ContextMenuFlags.h"
|
||||
#include "../Explorer/RegistryContextMenu.h"
|
||||
#include "../Explorer/resource.h"
|
||||
|
||||
#include "RegistryContextMenu.h"
|
||||
#include "ContextMenuFlags.h"
|
||||
#include "HelpUtils.h"
|
||||
#include "LangUtils.h"
|
||||
#include "MenuPage.h"
|
||||
#include "MenuPageRes.h"
|
||||
#include "FormatUtils.h"
|
||||
|
||||
using namespace NContextMenuFlags;
|
||||
|
||||
@@ -47,40 +42,41 @@ static CContextMenuItem kMenuItems[] =
|
||||
{ IDS_CONTEXT_TEST, 0x02000109, kTest},
|
||||
|
||||
{ IDS_CONTEXT_COMPRESS, 0x02000107, kCompress },
|
||||
{ IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressTo7z },
|
||||
{ IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressToZip }
|
||||
|
||||
#ifndef UNDER_CE
|
||||
,
|
||||
{ IDS_CONTEXT_COMPRESS_EMAIL, 0x02000111, kCompressEmail },
|
||||
{ IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressTo7z },
|
||||
{ IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressTo7zEmail},
|
||||
{ IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressToZip },
|
||||
{ IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressToZipEmail}
|
||||
{ IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressTo7zEmail },
|
||||
{ IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressToZipEmail }
|
||||
#endif
|
||||
};
|
||||
|
||||
const int kNumMenuItems = sizeof(kMenuItems) / sizeof(kMenuItems[0]);
|
||||
|
||||
bool CSystemPage::OnInit()
|
||||
bool CMenuPage::OnInit()
|
||||
{
|
||||
_initMode = true;
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
|
||||
CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
|
||||
NZipRootRegistry::CheckContextMenuHandler());
|
||||
#ifdef UNDER_CE
|
||||
EnableItem(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, false);
|
||||
#else
|
||||
CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, NZipRootRegistry::CheckContextMenuHandler());
|
||||
#endif
|
||||
|
||||
CheckButton(IDC_SYSTEM_CASCADED_MENU, ReadCascadedMenu());
|
||||
CContextMenuInfo ci;
|
||||
ci.Load();
|
||||
|
||||
UInt32 contextMenuFlags;
|
||||
if (!ReadContextMenuStatus(contextMenuFlags))
|
||||
contextMenuFlags = NContextMenuFlags::GetDefaultFlags();
|
||||
CheckButton(IDC_SYSTEM_CASCADED_MENU, ci.Cascaded);
|
||||
|
||||
m_ListView.Attach(GetItem(IDC_SYSTEM_OPTIONS_LIST));
|
||||
|
||||
/*
|
||||
CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
|
||||
NRegistryAssociations::CheckContextMenuHandler());
|
||||
*/
|
||||
_listView.Attach(GetItem(IDC_SYSTEM_OPTIONS_LIST));
|
||||
|
||||
UInt32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT;
|
||||
m_ListView.SetExtendedListViewStyle(newFlags, newFlags);
|
||||
_listView.SetExtendedListViewStyle(newFlags, newFlags);
|
||||
|
||||
m_ListView.InsertColumn(0, L"", 270);
|
||||
_listView.InsertColumn(0, L"", 100);
|
||||
|
||||
for (int i = 0; i < kNumMenuItems; i++)
|
||||
{
|
||||
@@ -115,19 +111,25 @@ bool CSystemPage::OnInit()
|
||||
}
|
||||
}
|
||||
|
||||
int itemIndex = m_ListView.InsertItem(i, s);
|
||||
m_ListView.SetCheckState(itemIndex, ((contextMenuFlags & menuItem.Flag) != 0));
|
||||
int itemIndex = _listView.InsertItem(i, s);
|
||||
_listView.SetCheckState(itemIndex, ((ci.Flags & menuItem.Flag) != 0));
|
||||
}
|
||||
|
||||
_listView.SetColumnWidthAuto(0);
|
||||
_initMode = false;
|
||||
return CPropertyPage::OnInit();
|
||||
}
|
||||
|
||||
#ifndef UNDER_CE
|
||||
STDAPI DllRegisterServer(void);
|
||||
STDAPI DllUnregisterServer(void);
|
||||
HWND g_MenuPageHWND = 0;
|
||||
#endif
|
||||
|
||||
LONG CSystemPage::OnApply()
|
||||
LONG CMenuPage::OnApply()
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
g_MenuPageHWND = *this;
|
||||
if (IsButtonCheckedBool(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU))
|
||||
{
|
||||
DllRegisterServer();
|
||||
@@ -138,23 +140,25 @@ LONG CSystemPage::OnApply()
|
||||
DllUnregisterServer();
|
||||
NZipRootRegistry::DeleteContextMenuHandler();
|
||||
}
|
||||
SaveCascadedMenu(IsButtonCheckedBool(IDC_SYSTEM_CASCADED_MENU));
|
||||
#endif
|
||||
|
||||
UInt32 flags = 0;
|
||||
CContextMenuInfo ci;
|
||||
ci.Cascaded = IsButtonCheckedBool(IDC_SYSTEM_CASCADED_MENU);
|
||||
ci.Flags = 0;
|
||||
for (int i = 0; i < kNumMenuItems; i++)
|
||||
if (m_ListView.GetCheckState(i))
|
||||
flags |= kMenuItems[i].Flag;
|
||||
SaveContextMenuStatus(flags);
|
||||
if (_listView.GetCheckState(i))
|
||||
ci.Flags |= kMenuItems[i].Flag;
|
||||
ci.Save();
|
||||
|
||||
return PSNRET_NOERROR;
|
||||
}
|
||||
|
||||
void CSystemPage::OnNotifyHelp()
|
||||
void CMenuPage::OnNotifyHelp()
|
||||
{
|
||||
ShowHelpWindow(NULL, kSystemTopic);
|
||||
}
|
||||
|
||||
bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
bool CMenuPage::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
{
|
||||
switch(buttonID)
|
||||
{
|
||||
@@ -167,9 +171,9 @@ bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
|
||||
}
|
||||
|
||||
bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
|
||||
bool CMenuPage::OnNotify(UINT controlID, LPNMHDR lParam)
|
||||
{
|
||||
if (lParam->hwndFrom == HWND(m_ListView))
|
||||
if (lParam->hwndFrom == HWND(_listView))
|
||||
{
|
||||
switch(lParam->code)
|
||||
{
|
||||
@@ -181,7 +185,7 @@ bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
|
||||
}
|
||||
|
||||
|
||||
bool CSystemPage::OnItemChanged(const NMLISTVIEW *info)
|
||||
bool CMenuPage::OnItemChanged(const NMLISTVIEW *info)
|
||||
{
|
||||
if (_initMode)
|
||||
return true;
|
||||
@@ -192,7 +196,5 @@ bool CSystemPage::OnItemChanged(const NMLISTVIEW *info)
|
||||
if (oldState != newState)
|
||||
Changed();
|
||||
}
|
||||
// PostMessage(kRefreshpluginsListMessage, 0);
|
||||
// RefreshPluginsList();
|
||||
return true;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user