mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-09 10:07:10 -06:00
4.24 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
ac2b563958
commit
47f4915611
@@ -3,8 +3,6 @@
|
||||
#ifndef __AGENT_AGENT_H
|
||||
#define __AGENT_AGENT_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
@@ -260,7 +258,7 @@ public:
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
CObjectVector<UString> m_PropNames;
|
||||
std::vector<NWindows::NCOM::CPropVariant> m_PropValues;
|
||||
CObjectVector<NWindows::NCOM::CPropVariant> m_PropValues;
|
||||
#endif
|
||||
|
||||
IInArchive *GetArchive() { return _archiveLink.GetArchive(); }
|
||||
|
||||
@@ -81,7 +81,7 @@ STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix,
|
||||
_folderPrefix = folderPrefix;
|
||||
_names.Clear();
|
||||
_names.Reserve(numNames);
|
||||
for (int i = 0; i < numNames; i++)
|
||||
for (UINT32 i = 0; i < numNames; i++)
|
||||
_names.Add(names[i]);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -249,12 +249,23 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
for(i = 0; i < m_PropNames.Size(); i++)
|
||||
names.Add((const wchar_t *)m_PropNames[i]);
|
||||
|
||||
RINOK(setProperties->SetProperties(&names.Front(),
|
||||
&m_PropValues.front(), names.Size()));
|
||||
NWindows::NCOM::CPropVariant *propValues = new NWindows::NCOM::CPropVariant[m_PropValues.Size()];
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < m_PropValues.Size(); i++)
|
||||
propValues[i] = m_PropValues[i];
|
||||
RINOK(setProperties->SetProperties(&names.Front(), propValues, names.Size()));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete []propValues;
|
||||
throw;
|
||||
}
|
||||
delete []propValues;
|
||||
}
|
||||
}
|
||||
m_PropNames.Clear();
|
||||
m_PropValues.clear();
|
||||
m_PropValues.Clear();
|
||||
|
||||
if (sfxModule != NULL)
|
||||
{
|
||||
@@ -265,8 +276,7 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
RINOK(CopyBlock(sfxStream, outStream));
|
||||
}
|
||||
|
||||
return outArchive->UpdateItems(outStream, updatePairs2.Size(),
|
||||
updateCallback);
|
||||
return outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback);
|
||||
}
|
||||
|
||||
|
||||
@@ -340,9 +350,9 @@ STDMETHODIMP CAgent::DeleteItems(
|
||||
_archiveFolderItem->GetRealIndices(indices, numItems, realIndices);
|
||||
CObjectVector<CUpdatePair2> updatePairs;
|
||||
int curIndex = 0;
|
||||
UINT32 numItemsInArchive;
|
||||
UInt32 numItemsInArchive;
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
for (int i = 0; i < numItemsInArchive; i++)
|
||||
for (UInt32 i = 0; i < numItemsInArchive; i++)
|
||||
{
|
||||
if (curIndex < realIndices.Size())
|
||||
if (realIndices[curIndex] == i)
|
||||
@@ -379,7 +389,7 @@ HRESULT CAgent::CreateFolder(
|
||||
CObjectVector<CUpdatePair2> updatePairs;
|
||||
UINT32 numItemsInArchive;
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
for (int i = 0; i < numItemsInArchive; i++)
|
||||
for (UInt32 i = 0; i < numItemsInArchive; i++)
|
||||
{
|
||||
CUpdatePair2 updatePair;
|
||||
updatePair.NewData = updatePair.NewProperties = false;
|
||||
@@ -450,7 +460,7 @@ HRESULT CAgent::RenameItem(
|
||||
int curIndex = 0;
|
||||
UINT32 numItemsInArchive;
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
for (int i = 0; i < numItemsInArchive; i++)
|
||||
for (UInt32 i = 0; i < numItemsInArchive; i++)
|
||||
{
|
||||
if (curIndex < realIndices.Size())
|
||||
if (realIndices[curIndex] == i)
|
||||
@@ -495,11 +505,11 @@ STDMETHODIMP CAgent::SetProperties(const wchar_t **names,
|
||||
const PROPVARIANT *values, INT32 numProperties)
|
||||
{
|
||||
m_PropNames.Clear();
|
||||
m_PropValues.clear();
|
||||
m_PropValues.Clear();
|
||||
for (int i = 0; i < numProperties; i++)
|
||||
{
|
||||
m_PropNames.Add(names[i]);
|
||||
m_PropValues.push_back(values[i]);
|
||||
m_PropValues.Add(values[i]);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ STDMETHODIMP CArchiveFolderManager::OpenFolderFile(const wchar_t *filePath,
|
||||
progressWrapper.QueryInterface(IID_IArchiveOpenCallback, &openArchiveCallback);
|
||||
}
|
||||
CAgent *agent = new CAgent();
|
||||
CComPtr<IInFolderArchive> archive = agent;
|
||||
CMyComPtr<IInFolderArchive> archive = agent;
|
||||
RINOK(agent->Open(filePath, NULL, openArchiveCallback));
|
||||
return agent->BindToRootFolder(resultFolder);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
|
||||
recursed = false;
|
||||
break;
|
||||
}
|
||||
wildcardCensor.AddItem(name, include, recursed);
|
||||
wildcardCensor.AddItem(include, name, recursed);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -374,6 +374,72 @@ static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// This code converts all short file names to long file names.
|
||||
|
||||
static void ConvertToLongName(const UString &prefix, UString &name)
|
||||
{
|
||||
if (name.IsEmpty() || DoesNameContainWildCard(name))
|
||||
return;
|
||||
NFind::CFileInfoW fileInfo;
|
||||
if (NFind::FindFile(prefix + name, fileInfo))
|
||||
name = fileInfo.Name;
|
||||
}
|
||||
|
||||
static void ConvertToLongNames(const UString &prefix, CObjectVector<NWildcard::CItem> &items)
|
||||
{
|
||||
for (int i = 0; i < items.Size(); i++)
|
||||
{
|
||||
NWildcard::CItem &item = items[i];
|
||||
if (item.Recursive || item.PathParts.Size() != 1)
|
||||
continue;
|
||||
ConvertToLongName(prefix, item.PathParts.Front());
|
||||
}
|
||||
}
|
||||
|
||||
static void ConvertToLongNames(const UString &prefix, NWildcard::CCensorNode &node)
|
||||
{
|
||||
ConvertToLongNames(prefix, node.IncludeItems);
|
||||
ConvertToLongNames(prefix, node.ExcludeItems);
|
||||
int i;
|
||||
for (i = 0; i < node.SubNodes.Size(); i++)
|
||||
ConvertToLongName(prefix, node.SubNodes[i].Name);
|
||||
// mix folders with same name
|
||||
for (i = 0; i < node.SubNodes.Size(); i++)
|
||||
{
|
||||
NWildcard::CCensorNode &nextNode1 = node.SubNodes[i];
|
||||
for (int j = i + 1; j < node.SubNodes.Size();)
|
||||
{
|
||||
const NWildcard::CCensorNode &nextNode2 = node.SubNodes[j];
|
||||
if (nextNode1.Name.CollateNoCase(nextNode2.Name) == 0)
|
||||
{
|
||||
nextNode1.IncludeItems += nextNode2.IncludeItems;
|
||||
nextNode1.ExcludeItems += nextNode2.ExcludeItems;
|
||||
node.SubNodes.Delete(j);
|
||||
}
|
||||
else
|
||||
j++;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < node.SubNodes.Size(); i++)
|
||||
{
|
||||
NWildcard::CCensorNode &nextNode = node.SubNodes[i];
|
||||
ConvertToLongNames(prefix + nextNode.Name + wchar_t(NFile::NName::kDirDelimiter), nextNode);
|
||||
}
|
||||
}
|
||||
|
||||
static void ConvertToLongNames(NWildcard::CCensor &censor)
|
||||
{
|
||||
for (int i = 0; i < censor.Pairs.Size(); i++)
|
||||
{
|
||||
NWildcard::CPair &pair = censor.Pairs[i];
|
||||
ConvertToLongNames(pair.Prefix, pair.Head);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static NUpdateArchive::NPairAction::EEnum GetUpdatePairActionType(int i)
|
||||
{
|
||||
switch(i)
|
||||
@@ -718,6 +784,10 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
if (thereIsArchiveName)
|
||||
AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);
|
||||
|
||||
#ifdef _WIN32
|
||||
ConvertToLongNames(archiveWildcardCensor);
|
||||
#endif
|
||||
|
||||
CObjectVector<CDirItem> dirItems;
|
||||
UString errorPath;
|
||||
if (EnumerateItems(archiveWildcardCensor, dirItems, NULL, errorPath) != S_OK)
|
||||
@@ -826,6 +896,10 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
throw kTerminalOutError;
|
||||
if(updateOptions.StdInMode)
|
||||
updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();
|
||||
|
||||
#ifdef _WIN32
|
||||
ConvertToLongNames(options.WildcardCensor);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
throw kUserErrorMessage;
|
||||
|
||||
@@ -12,12 +12,10 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NName;
|
||||
|
||||
// using namespace NUpdateArchive;
|
||||
|
||||
void AddDirFileInfo(
|
||||
const UString &prefix,
|
||||
const UString &fullPathName,
|
||||
NFind::CFileInfoW &fileInfo,
|
||||
const UString &prefix, // prefix for logical path
|
||||
const UString &fullPathName, // path on disk: can be relative to some basePrefix
|
||||
const NFind::CFileInfoW &fileInfo,
|
||||
CObjectVector<CDirItem> &dirItems)
|
||||
{
|
||||
CDirItem item;
|
||||
@@ -32,9 +30,9 @@ void AddDirFileInfo(
|
||||
}
|
||||
|
||||
static HRESULT EnumerateDirectory(
|
||||
const UString &baseFolderPrefix,
|
||||
const UString &directory,
|
||||
const UString &prefix,
|
||||
const UString &baseFolderPrefix, // base (disk) prefix for scanning
|
||||
const UString &directory, // additional disk prefix starting from baseFolderPrefix
|
||||
const UString &prefix, // logical prefix
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
UString &errorPath)
|
||||
{
|
||||
@@ -51,8 +49,7 @@ static HRESULT EnumerateDirectory(
|
||||
}
|
||||
if (!found)
|
||||
break;
|
||||
AddDirFileInfo(prefix, directory + fileInfo.Name, fileInfo,
|
||||
dirItems);
|
||||
AddDirFileInfo(prefix, directory + fileInfo.Name, fileInfo, dirItems);
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(EnumerateDirectory(baseFolderPrefix, directory + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
@@ -63,8 +60,8 @@ static HRESULT EnumerateDirectory(
|
||||
}
|
||||
|
||||
HRESULT EnumerateDirItems(
|
||||
const UString &baseFolderPrefix,
|
||||
const UStringVector &fileNames,
|
||||
const UString &baseFolderPrefix, // base (disk) prefix for scanning
|
||||
const UStringVector &fileNames, // names relative to baseFolderPrefix
|
||||
const UString &archiveNamePrefix,
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
UString &errorPath)
|
||||
@@ -74,7 +71,11 @@ HRESULT EnumerateDirItems(
|
||||
const UString &fileName = fileNames[i];
|
||||
NFind::CFileInfoW fileInfo;
|
||||
if (!NFind::FindFile(baseFolderPrefix + fileName, fileInfo))
|
||||
throw 1081736;
|
||||
{
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = baseFolderPrefix + fileName;
|
||||
return error;
|
||||
}
|
||||
AddDirFileInfo(archiveNamePrefix, fileName, fileInfo, dirItems);
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
@@ -88,9 +89,9 @@ HRESULT EnumerateDirItems(
|
||||
|
||||
static HRESULT EnumerateDirItems(
|
||||
const NWildcard::CCensorNode &curNode,
|
||||
const UString &diskPrefix,
|
||||
const UString &archivePrefix,
|
||||
const UString &addArchivePrefix,
|
||||
const UString &diskPrefix, // full disk path prefix
|
||||
const UString &archivePrefix, // prefix from root
|
||||
const UStringVector &addArchivePrefix, // prefix from curNode
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
bool enterToSubFolders,
|
||||
IEnumDirItemCallback *callback,
|
||||
@@ -101,6 +102,107 @@ static HRESULT EnumerateDirItems(
|
||||
enterToSubFolders = true;
|
||||
if (callback)
|
||||
RINOK(callback->CheckBreak());
|
||||
|
||||
// try direct_names case at first
|
||||
if (addArchivePrefix.IsEmpty() && !enterToSubFolders)
|
||||
{
|
||||
// check that all names are direct
|
||||
int i;
|
||||
for (i = 0; i < curNode.IncludeItems.Size(); i++)
|
||||
{
|
||||
const NWildcard::CItem &item = curNode.IncludeItems[i];
|
||||
if (item.Recursive || item.PathParts.Size() != 1)
|
||||
break;
|
||||
const UString &name = item.PathParts.Front();
|
||||
if (name.IsEmpty() || DoesNameContainWildCard(name))
|
||||
break;
|
||||
}
|
||||
if (i == curNode.IncludeItems.Size())
|
||||
{
|
||||
// all names are direct (no wildcards)
|
||||
// so we don't need file_system's dir enumerator
|
||||
CRecordVector<bool> needEnterVector;
|
||||
for (i = 0; i < curNode.IncludeItems.Size(); i++)
|
||||
{
|
||||
const NWildcard::CItem &item = curNode.IncludeItems[i];
|
||||
const UString &name = item.PathParts.Front();
|
||||
const UString fullPath = diskPrefix + name;
|
||||
NFind::CFileInfoW fileInfo;
|
||||
if (!NFind::FindFile(fullPath, fileInfo))
|
||||
{
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = fullPath;
|
||||
return error;
|
||||
}
|
||||
bool isDir = fileInfo.IsDirectory();
|
||||
if (isDir && !item.ForDir || !isDir && !item.ForFile)
|
||||
{
|
||||
errorPath = fullPath;
|
||||
return E_FAIL;
|
||||
}
|
||||
const UString realName = fileInfo.Name;
|
||||
const UString realDiskPath = diskPrefix + realName;
|
||||
{
|
||||
UStringVector pathParts;
|
||||
pathParts.Add(fileInfo.Name);
|
||||
if (curNode.CheckPathToRoot(false, pathParts, !isDir))
|
||||
continue;
|
||||
}
|
||||
AddDirFileInfo(archivePrefix, realDiskPath, fileInfo, dirItems);
|
||||
if (!isDir)
|
||||
continue;
|
||||
|
||||
UStringVector addArchivePrefixNew;
|
||||
const NWildcard::CCensorNode *nextNode = 0;
|
||||
int index = curNode.FindSubNode(name);
|
||||
if (index >= 0)
|
||||
{
|
||||
for (int t = needEnterVector.Size(); t <= index; t++)
|
||||
needEnterVector.Add(true);
|
||||
needEnterVector[index] = false;
|
||||
nextNode = &curNode.SubNodes[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
nextNode = &curNode;
|
||||
addArchivePrefixNew.Add(name); // don't change it to realName. It's for shortnames support
|
||||
}
|
||||
RINOK(EnumerateDirItems(*nextNode,
|
||||
realDiskPath + wchar_t(kDirDelimiter),
|
||||
archivePrefix + realName + wchar_t(kDirDelimiter),
|
||||
addArchivePrefixNew, dirItems, true, callback, errorPath));
|
||||
}
|
||||
for (i = 0; i < curNode.SubNodes.Size(); i++)
|
||||
{
|
||||
if (i < needEnterVector.Size())
|
||||
if (!needEnterVector[i])
|
||||
continue;
|
||||
const NWildcard::CCensorNode &nextNode = curNode.SubNodes[i];
|
||||
const UString fullPath = diskPrefix + nextNode.Name;
|
||||
NFind::CFileInfoW fileInfo;
|
||||
if (!NFind::FindFile(fullPath, fileInfo))
|
||||
{
|
||||
if (!nextNode.AreThereIncludeItems())
|
||||
continue;
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = fullPath;
|
||||
return error;
|
||||
}
|
||||
if (!fileInfo.IsDirectory())
|
||||
{
|
||||
errorPath = fullPath;
|
||||
return E_FAIL;
|
||||
}
|
||||
RINOK(EnumerateDirItems(nextNode,
|
||||
diskPrefix + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
archivePrefix + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
UStringVector(), dirItems, false, callback, errorPath));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NFind::CEnumeratorW enumerator(diskPrefix + wchar_t(kAnyStringWildcard));
|
||||
while (true)
|
||||
{
|
||||
@@ -117,13 +219,17 @@ static HRESULT EnumerateDirItems(
|
||||
|
||||
if (callback)
|
||||
RINOK(callback->CheckBreak());
|
||||
UString name = fileInfo.Name;
|
||||
const UString &name = fileInfo.Name;
|
||||
bool enterToSubFolders2 = enterToSubFolders;
|
||||
if (curNode.CheckPathToRoot(addArchivePrefix + name, !fileInfo.IsDirectory()))
|
||||
UStringVector addArchivePrefixNew = addArchivePrefix;
|
||||
addArchivePrefixNew.Add(name);
|
||||
if (curNode.CheckPathToRoot(false, UStringVector(addArchivePrefixNew), !fileInfo.IsDirectory()))
|
||||
continue;
|
||||
if (curNode.CheckPathToRoot(true, addArchivePrefixNew, !fileInfo.IsDirectory()))
|
||||
{
|
||||
AddDirFileInfo(archivePrefix, diskPrefix + fileInfo.Name, fileInfo, dirItems);
|
||||
AddDirFileInfo(archivePrefix, diskPrefix + name, fileInfo, dirItems);
|
||||
if (fileInfo.IsDirectory())
|
||||
enterToSubFolders2 = true;;
|
||||
enterToSubFolders2 = true;
|
||||
}
|
||||
if (!fileInfo.IsDirectory())
|
||||
continue;
|
||||
@@ -138,20 +244,16 @@ static HRESULT EnumerateDirItems(
|
||||
if (!enterToSubFolders2 && nextNode == 0)
|
||||
continue;
|
||||
|
||||
UString archivePrefixNew = archivePrefix;
|
||||
UString addArchivePrefixNew = addArchivePrefix;
|
||||
addArchivePrefixNew = addArchivePrefix;
|
||||
if (nextNode == 0)
|
||||
{
|
||||
nextNode = &curNode;
|
||||
addArchivePrefixNew += name;
|
||||
addArchivePrefixNew += wchar_t(kDirDelimiter);
|
||||
addArchivePrefixNew.Add(name);
|
||||
}
|
||||
archivePrefixNew += name;
|
||||
archivePrefixNew += wchar_t(kDirDelimiter);
|
||||
RINOK(EnumerateDirItems(*nextNode,
|
||||
diskPrefix + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
archivePrefixNew, addArchivePrefixNew,
|
||||
dirItems, enterToSubFolders2, callback, errorPath));
|
||||
diskPrefix + name + wchar_t(kDirDelimiter),
|
||||
archivePrefix + name + wchar_t(kDirDelimiter),
|
||||
addArchivePrefixNew, dirItems, enterToSubFolders2, callback, errorPath));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -167,7 +269,7 @@ HRESULT EnumerateItems(
|
||||
if (callback)
|
||||
RINOK(callback->CheckBreak());
|
||||
const NWildcard::CPair &pair = censor.Pairs[i];
|
||||
RINOK(EnumerateDirItems(pair.Head, pair.Prefix, L"", L"", dirItems, false, callback, errorPath));
|
||||
RINOK(EnumerateDirItems(pair.Head, pair.Prefix, L"", UStringVector(), dirItems, false, callback, errorPath));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
void AddDirFileInfo(
|
||||
const UString &prefix,
|
||||
const UString &fullPathName,
|
||||
NWindows::NFile::NFind::CFileInfoW &fileInfo,
|
||||
const NWindows::NFile::NFind::CFileInfoW &fileInfo,
|
||||
CObjectVector<CDirItem> &dirItems);
|
||||
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ static const char *kCopyrightString = "\n7-Zip"
|
||||
" [NT]"
|
||||
#endif
|
||||
|
||||
" 4.23 Copyright (c) 1999-2005 Igor Pavlov 2005-06-29\n";
|
||||
" 4.24 beta Copyright (c) 1999-2005 Igor Pavlov 2005-07-06\n";
|
||||
|
||||
static const char *kHelpString =
|
||||
"\nUsage: 7z"
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
#include "../../../Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -66,8 +66,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,23,0,0
|
||||
PRODUCTVERSION 4,23,0,0
|
||||
FILEVERSION 4,24,0,0
|
||||
PRODUCTVERSION 4,24,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -85,14 +85,14 @@ BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "Igor Pavlov\0"
|
||||
VALUE "FileDescription", "7-Zip Console version\0"
|
||||
VALUE "FileVersion", "4, 23, 0, 0\0"
|
||||
VALUE "FileVersion", "4, 24, 0, 0\0"
|
||||
VALUE "InternalName", "7z\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2005 Igor Pavlov\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "7z.exe\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "7-Zip\0"
|
||||
VALUE "ProductVersion", "4, 23, 0, 0\0"
|
||||
VALUE "ProductVersion", "4, 24, 0, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -47,6 +47,11 @@ static LPCTSTR kFileClassIDString = TEXT("SevenZip");
|
||||
///////////////////////////////
|
||||
// IShellExtInit
|
||||
|
||||
extern LONG g_DllRefCount;
|
||||
|
||||
CZipContextMenu::CZipContextMenu() { InterlockedIncrement(&g_DllRefCount); }
|
||||
CZipContextMenu::~CZipContextMenu() { InterlockedDecrement(&g_DllRefCount); }
|
||||
|
||||
HRESULT CZipContextMenu::GetFileNames(LPDATAOBJECT dataObject,
|
||||
CSysStringVector &fileNames)
|
||||
{
|
||||
@@ -71,6 +76,22 @@ HRESULT CZipContextMenu::GetFileNames(LPDATAOBJECT dataObject,
|
||||
STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder,
|
||||
LPDATAOBJECT dataObject, HKEY hkeyProgID)
|
||||
{
|
||||
// OutputDebugString(TEXT("::Initialize\r\n"));
|
||||
_dropMode = false;
|
||||
_dropPath.Empty();
|
||||
if (pidlFolder != 0)
|
||||
{
|
||||
CSysString path;
|
||||
if (NShell::GetPathFromIDList(pidlFolder, path))
|
||||
{
|
||||
_dropPath = GetUnicodeString(path);
|
||||
// OutputDebugString(path);
|
||||
// OutputDebugString(TEXT("\r\n"));
|
||||
NFile::NName::NormalizeDirPathPrefix(_dropPath);
|
||||
_dropMode = !_dropPath.IsEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
m_IsFolder = false;
|
||||
if (pidlFolder == 0)
|
||||
@@ -91,6 +112,7 @@ STDMETHODIMP CZipContextMenu::InitContextMenu(const wchar_t *folder,
|
||||
_fileNames.Clear();
|
||||
for (UINT32 i = 0; i < numFiles; i++)
|
||||
_fileNames.Add(names[i]);
|
||||
_dropMode = false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -288,7 +310,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
(flags & CMF_EXPLORE) == 0)
|
||||
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, currentCommandID);
|
||||
|
||||
_commandMap.clear();
|
||||
_commandMap.Clear();
|
||||
|
||||
CMenu popupMenu;
|
||||
CMenuDestroyer menuDestroyer;
|
||||
@@ -305,7 +327,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
commandMapItem.CommandInternalID = kCommandNULL;
|
||||
commandMapItem.Verb = kMainVerb;
|
||||
commandMapItem.HelpString = LangLoadStringW(IDS_CONTEXT_CAPTION_HELP, 0x02000102);
|
||||
_commandMap.push_back(commandMapItem);
|
||||
_commandMap.Add(commandMapItem);
|
||||
|
||||
menuItem.wID = currentCommandID++;
|
||||
subIndex = 0;
|
||||
@@ -338,7 +360,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
CCommandMapItem commandMapItem;
|
||||
FillCommand(kOpen, mainString, commandMapItem);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
|
||||
_commandMap.push_back(commandMapItem);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,11 +389,13 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
{
|
||||
CCommandMapItem commandMapItem;
|
||||
FillCommand(kExtract, mainString, commandMapItem);
|
||||
commandMapItem.Folder = folderPrefix +
|
||||
GetSubFolderNameForExtract(fileInfo.Name) +
|
||||
UString(L'\\');
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = folderPrefix;
|
||||
commandMapItem.Folder += GetSubFolderNameForExtract(fileInfo.Name) + UString(L'\\');
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
|
||||
_commandMap.push_back(commandMapItem);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
// Extract Here
|
||||
@@ -380,8 +404,11 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
CCommandMapItem commandMapItem;
|
||||
FillCommand(kExtractHere, mainString, commandMapItem);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
|
||||
commandMapItem.Folder = folderPrefix;
|
||||
_commandMap.push_back(commandMapItem);
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = folderPrefix;
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
// Extract To
|
||||
@@ -396,10 +423,15 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
else
|
||||
folder = L'*';
|
||||
folder += L'\\';
|
||||
commandMapItem.Folder = folderPrefix + folder;
|
||||
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = folderPrefix;
|
||||
commandMapItem.Folder += folder;
|
||||
s = MyFormatNew(s, GetReducedString(folder));
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(s));
|
||||
_commandMap.push_back(commandMapItem);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
// Test
|
||||
if ((contextMenuFlags & NContextMenuFlags::kTest) != 0)
|
||||
@@ -407,7 +439,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
CCommandMapItem commandMapItem;
|
||||
FillCommand(kTest, mainString, commandMapItem);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
|
||||
_commandMap.push_back(commandMapItem);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
}
|
||||
UString archiveName = CreateArchiveName(fileName, _fileNames.Size() > 1, false);
|
||||
@@ -419,11 +451,14 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompress) != 0)
|
||||
{
|
||||
CCommandMapItem commandMapItem;
|
||||
commandMapItem.Folder = archivePathPrefix;
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = archivePathPrefix;
|
||||
commandMapItem.Archive = archiveName;
|
||||
FillCommand(kCompress, mainString, commandMapItem);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
|
||||
_commandMap.push_back(commandMapItem);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
|
||||
@@ -433,26 +468,29 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
CCommandMapItem commandMapItem;
|
||||
UString s;
|
||||
FillCommand2(kCompressTo, s, commandMapItem);
|
||||
commandMapItem.Folder = archivePathPrefix;
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = archivePathPrefix;
|
||||
commandMapItem.Archive = archiveName7z;
|
||||
UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\"");
|
||||
s = MyFormatNew(s, t);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(s));
|
||||
_commandMap.push_back(commandMapItem);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
// CompressEmail
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompressEmail) != 0)
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompressEmail) != 0 && !_dropMode)
|
||||
{
|
||||
CCommandMapItem commandMapItem;
|
||||
commandMapItem.Archive = archiveName;
|
||||
FillCommand(kCompressEmail, mainString, commandMapItem);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(mainString));
|
||||
_commandMap.push_back(commandMapItem);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
// CompressToEmail
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompressToEmail) != 0)
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompressToEmail) != 0 && !_dropMode)
|
||||
{
|
||||
CCommandMapItem commandMapItem;
|
||||
UString s;
|
||||
@@ -461,7 +499,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\"");
|
||||
s = MyFormatNew(s, t);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, GetSystemString(s));
|
||||
_commandMap.push_back(commandMapItem);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,7 +529,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
|
||||
UINT CZipContextMenu::FindVerb(const UString &verb)
|
||||
{
|
||||
for(int i = 0; i < _commandMap.size(); i++)
|
||||
for(int i = 0; i < _commandMap.Size(); i++)
|
||||
if(_commandMap[i].Verb.Compare(verb) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
@@ -622,7 +660,7 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
|
||||
#endif
|
||||
*/
|
||||
|
||||
if(commandOffset < 0 || commandOffset >= _commandMap.size())
|
||||
if(commandOffset < 0 || commandOffset >= _commandMap.Size())
|
||||
return E_FAIL;
|
||||
|
||||
const CCommandMapItem commandMapItem = _commandMap[commandOffset];
|
||||
@@ -697,12 +735,12 @@ STDMETHODIMP CZipContextMenu::GetCommandString(UINT commandOffset, UINT uType,
|
||||
{
|
||||
case GCS_VALIDATEA:
|
||||
case GCS_VALIDATEW:
|
||||
if(commandOffset < 0 || commandOffset >= (UINT)_commandMap.size())
|
||||
if(commandOffset < 0 || commandOffset >= (UINT)_commandMap.Size())
|
||||
return S_FALSE;
|
||||
else
|
||||
return S_OK;
|
||||
}
|
||||
if(commandOffset < 0 || commandOffset >= (UINT)_commandMap.size())
|
||||
if(commandOffset < 0 || commandOffset >= (UINT)_commandMap.Size())
|
||||
return E_FAIL;
|
||||
if(uType == GCS_HELPTEXTA || uType == GCS_HELPTEXTW)
|
||||
{
|
||||
|
||||
@@ -7,20 +7,17 @@
|
||||
DEFINE_GUID(CLSID_CZipContextMenu,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "Common/String.h"
|
||||
|
||||
#include "../../FileManager/PluginInterface.h"
|
||||
|
||||
#include "../../FileManager/MyCom2.h"
|
||||
|
||||
|
||||
class CZipContextMenu:
|
||||
public IContextMenu,
|
||||
public IShellExtInit,
|
||||
public IInitContextMenu,
|
||||
public CComObjectRoot,
|
||||
public CComCoClass<CZipContextMenu, &CLSID_CZipContextMenu>
|
||||
public CMyUnknownImp
|
||||
{
|
||||
|
||||
public:
|
||||
@@ -48,18 +45,7 @@ public:
|
||||
UString Archive;
|
||||
};
|
||||
|
||||
BEGIN_COM_MAP(CZipContextMenu)
|
||||
COM_INTERFACE_ENTRY(IContextMenu)
|
||||
COM_INTERFACE_ENTRY(IShellExtInit)
|
||||
COM_INTERFACE_ENTRY(IInitContextMenu)
|
||||
END_COM_MAP()
|
||||
|
||||
DECLARE_NOT_AGGREGATABLE(CZipContextMenu)
|
||||
|
||||
DECLARE_REGISTRY(CZipContextMenu,
|
||||
// _T("SevenZip.ContextMenu.1"), _T("SevenZip.ContextMenu"),
|
||||
TEXT("SevenZip.1"), TEXT("SevenZip"),
|
||||
UINT(0), THREADFLAGS_APARTMENT)
|
||||
MY_UNKNOWN_IMP3_MT(IContextMenu, IShellExtInit, IInitContextMenu)
|
||||
|
||||
///////////////////////////////
|
||||
// IShellExtInit
|
||||
@@ -81,7 +67,9 @@ DECLARE_REGISTRY(CZipContextMenu,
|
||||
STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UINT32 numFiles);
|
||||
private:
|
||||
UStringVector _fileNames;
|
||||
std::vector<CCommandMapItem> _commandMap;
|
||||
bool _dropMode;
|
||||
UString _dropPath;
|
||||
CObjectVector<CCommandMapItem> _commandMap;
|
||||
HRESULT GetFileNames(LPDATAOBJECT dataObject, CSysStringVector &fileNames);
|
||||
UINT FindVerb(const UString &verb);
|
||||
|
||||
@@ -89,6 +77,9 @@ private:
|
||||
CCommandMapItem &commandMapItem);
|
||||
void FillCommand2(ECommandInternalID id, UString &mainString,
|
||||
CCommandMapItem &commandMapItem);
|
||||
public:
|
||||
CZipContextMenu();
|
||||
~CZipContextMenu();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,43 +1,90 @@
|
||||
// DLLExports.cpp
|
||||
//
|
||||
// Notes:
|
||||
// Win2000:
|
||||
// If I register at HKCR\Folder\ShellEx then DLL is locked.
|
||||
// otherwise it unloads after exlorer closing.
|
||||
// but if I call menu for desktop items it's locked all the time
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
// #include <locale.h>
|
||||
|
||||
#include <initguid.h>
|
||||
#include <ShlGuid.h>
|
||||
#include <windows.h>
|
||||
#include <ShlGuid.h>
|
||||
#include <OleCtl.h>
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../Agent/Agent.h"
|
||||
#include "../../FileManager/LangUtils.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
#include "ContextMenu.h"
|
||||
#include "../../IPassword.h"
|
||||
#include "../../FileManager/LangUtils.h"
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
#include "ContextMenu.h"
|
||||
#include "OptionsDialog.h"
|
||||
|
||||
CComModule _Module;
|
||||
|
||||
BEGIN_OBJECT_MAP(ObjectMap)
|
||||
// OBJECT_ENTRY(CLSID_CAgentArchiveHandler, CAgent)
|
||||
OBJECT_ENTRY(CLSID_CZipContextMenu, CZipContextMenu)
|
||||
// OBJECT_ENTRY(CLSID_CSevenZipOptions, CSevenZipOptions)
|
||||
END_OBJECT_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// DLL Entry Point
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
LONG g_DllRefCount = 0; // Reference count of this DLL.
|
||||
|
||||
static LPCTSTR kShellExtName = TEXT("7-Zip Shell Extension");
|
||||
static LPCTSTR kClsidMask = TEXT("CLSID\\%s");
|
||||
static LPCTSTR kClsidInprocMask = TEXT("CLSID\\%s\\InprocServer32");
|
||||
static LPCTSTR kApprovedKeyPath = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
|
||||
// #define ODS(sz) OutputDebugString(L#sz)
|
||||
|
||||
class CShellExtClassFactory:
|
||||
public IClassFactory,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
CShellExtClassFactory() { InterlockedIncrement(&g_DllRefCount); }
|
||||
~CShellExtClassFactory() { InterlockedDecrement(&g_DllRefCount); }
|
||||
|
||||
|
||||
MY_UNKNOWN_IMP1_MT(IClassFactory)
|
||||
|
||||
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, void**);
|
||||
STDMETHODIMP LockServer(BOOL);
|
||||
};
|
||||
|
||||
STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
|
||||
REFIID riid, void **ppvObj)
|
||||
{
|
||||
// ODS("CShellExtClassFactory::CreateInstance()\r\n");
|
||||
*ppvObj = NULL;
|
||||
if (pUnkOuter)
|
||||
return CLASS_E_NOAGGREGATION;
|
||||
|
||||
CZipContextMenu *shellExt;
|
||||
try
|
||||
{
|
||||
shellExt = new CZipContextMenu();
|
||||
}
|
||||
catch(...) { return E_OUTOFMEMORY; }
|
||||
if (shellExt == NULL)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
HRESULT res = shellExt->QueryInterface(riid, ppvObj);
|
||||
if (res != S_OK)
|
||||
delete shellExt;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CShellExtClassFactory::LockServer(BOOL fLock)
|
||||
{
|
||||
return S_OK; // Check it
|
||||
}
|
||||
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO aVersionInfo;
|
||||
aVersionInfo.dwOSVersionInfoSize = sizeof(aVersionInfo);
|
||||
if (!::GetVersionEx(&aVersionInfo))
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (aVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -47,15 +94,16 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
// ODS("In DLLMain, DLL_PROCESS_ATTACH\r\n");
|
||||
#ifdef UNICODE
|
||||
if (!IsItWindowsNT())
|
||||
return FALSE;
|
||||
#endif
|
||||
_Module.Init(ObjectMap, hInstance);
|
||||
//DisableThreadLibraryCalls(hInstance);
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH)
|
||||
_Module.Term();
|
||||
{
|
||||
// ODS("In DLLMain, DLL_PROCESS_DETACH\r\n");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -64,28 +112,138 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
|
||||
|
||||
STDAPI DllCanUnloadNow(void)
|
||||
{
|
||||
return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
|
||||
// ODS("In DLLCanUnloadNow\r\n");
|
||||
return (g_DllRefCount == 0 ? S_OK : S_FALSE);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Returns a class factory to create an object of the requested type
|
||||
|
||||
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
|
||||
{
|
||||
return _Module.GetClassObject(rclsid, riid, ppv);
|
||||
// ODS("In DllGetClassObject\r\n");
|
||||
*ppv = NULL;
|
||||
if (IsEqualIID(rclsid, CLSID_CZipContextMenu))
|
||||
{
|
||||
CShellExtClassFactory *cf;
|
||||
try
|
||||
{
|
||||
cf = new CShellExtClassFactory;
|
||||
}
|
||||
catch(...) { return E_OUTOFMEMORY; }
|
||||
if (cf == 0)
|
||||
return E_OUTOFMEMORY;
|
||||
HRESULT res = cf->QueryInterface(riid, ppv);
|
||||
if (res != S_OK)
|
||||
delete cf;
|
||||
return res;
|
||||
}
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
// return _Module.GetClassObject(rclsid, riid, ppv);
|
||||
}
|
||||
|
||||
static BOOL GetStringFromIID(CLSID clsid, LPTSTR s, int size)
|
||||
{
|
||||
LPWSTR pwsz;
|
||||
if (StringFromIID(clsid, &pwsz) != S_OK)
|
||||
return FALSE;
|
||||
if(!pwsz)
|
||||
return FALSE;
|
||||
#ifdef UNICODE
|
||||
lstrcpyn(s, pwsz, size);
|
||||
#else
|
||||
WideCharToMultiByte(CP_ACP, 0, pwsz, -1, s, size, NULL, NULL);
|
||||
#endif
|
||||
CoTaskMemFree(pwsz);
|
||||
s[size - 1] = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HKEY hRootKey;
|
||||
LPCTSTR SubKey;
|
||||
LPCTSTR ValueName;
|
||||
LPCTSTR Data;
|
||||
} CRegItem;
|
||||
|
||||
static BOOL RegisterServer(CLSID clsid, LPCTSTR title)
|
||||
{
|
||||
TCHAR clsidString[MAX_PATH];
|
||||
if (!GetStringFromIID(clsid, clsidString, MAX_PATH))
|
||||
return FALSE;
|
||||
|
||||
TCHAR modulePath[MAX_PATH + 1];
|
||||
if (GetModuleFileName(g_hInstance, modulePath, MAX_PATH) == 0)
|
||||
return FALSE;
|
||||
|
||||
CRegItem clsidEntries[] =
|
||||
{
|
||||
HKEY_CLASSES_ROOT, kClsidMask, NULL, title,
|
||||
HKEY_CLASSES_ROOT, kClsidInprocMask, NULL, modulePath,
|
||||
HKEY_CLASSES_ROOT, kClsidInprocMask, TEXT("ThreadingModel"), TEXT("Apartment"),
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
HKEY hKey;
|
||||
DWORD dwDisp;
|
||||
//register the CLSID entries
|
||||
for(int i = 0; clsidEntries[i].hRootKey; i++)
|
||||
{
|
||||
TCHAR subKey[MAX_PATH];
|
||||
wsprintf(subKey, clsidEntries[i].SubKey, clsidString);
|
||||
if (RegCreateKeyEx(clsidEntries[i].hRootKey, subKey, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != NOERROR)
|
||||
return FALSE;
|
||||
const TCHAR *data = clsidEntries[i].Data;
|
||||
RegSetValueEx(hKey, clsidEntries[i].ValueName, 0, REG_SZ,
|
||||
(LPBYTE)data, (lstrlen(data) + 1) * sizeof(TCHAR));
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
if(IsItWindowsNT())
|
||||
{
|
||||
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, kApprovedKeyPath, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) == NOERROR)
|
||||
{
|
||||
RegSetValueEx(hKey, clsidString, 0, REG_SZ,
|
||||
(LPBYTE)title,(lstrlen(title) + 1) * sizeof(TCHAR));
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI DllRegisterServer(void)
|
||||
{
|
||||
return _Module.RegisterServer(FALSE);
|
||||
return RegisterServer(CLSID_CZipContextMenu, kShellExtName) ? S_OK: SELFREG_E_CLASS;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// DllUnregisterServer - Removes entries from the system registry
|
||||
static BOOL UnregisterServer(CLSID clsid)
|
||||
{
|
||||
TCHAR clsidString[MAX_PATH];
|
||||
if (!GetStringFromIID(clsid, clsidString, MAX_PATH))
|
||||
return FALSE;
|
||||
|
||||
TCHAR subKey[MAX_PATH];
|
||||
wsprintf(subKey, kClsidInprocMask, clsidString);
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, subKey);
|
||||
|
||||
wsprintf (subKey, kClsidMask, clsidString);
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, subKey);
|
||||
|
||||
if(IsItWindowsNT())
|
||||
{
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, kApprovedKeyPath, 0, KEY_SET_VALUE, &hKey) == NOERROR)
|
||||
{
|
||||
RegDeleteValue(hKey, clsidString);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI DllUnregisterServer(void)
|
||||
{
|
||||
return _Module.UnregisterServer();
|
||||
return UnregisterServer(CLSID_CZipContextMenu) ? S_OK: SELFREG_E_CLASS;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
|
||||
@@ -18,16 +18,9 @@
|
||||
#include <mbstring.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#define _ATL_APARTMENT_THREADED
|
||||
|
||||
#define _ATL_NO_UUIDOF
|
||||
|
||||
#include <atlbase.h>
|
||||
|
||||
extern CComModule _Module;
|
||||
|
||||
#include <atlcom.h>
|
||||
#include <shlguid.h>
|
||||
#include <regstr.h>
|
||||
|
||||
#include "Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -68,8 +68,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,23,0,0
|
||||
PRODUCTVERSION 4,23,0,0
|
||||
FILEVERSION 4,24,0,0
|
||||
PRODUCTVERSION 4,24,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -87,14 +87,14 @@ BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "Igor Pavlov\0"
|
||||
VALUE "FileDescription", "7-Zip Shell Extension\0"
|
||||
VALUE "FileVersion", "4, 23, 0, 0\0"
|
||||
VALUE "FileVersion", "4, 24, 0, 0\0"
|
||||
VALUE "InternalName", "7-zip\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2005 Igor Pavlov\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "7-zip.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "7-Zip\0"
|
||||
VALUE "ProductVersion", "4, 23, 0, 0\0"
|
||||
VALUE "ProductVersion", "4, 24, 0, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -134,6 +134,14 @@ SOURCE=..\..\..\Common\IntToString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -66,8 +66,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,23,0,0
|
||||
PRODUCTVERSION 4,23,0,0
|
||||
FILEVERSION 4,24,0,0
|
||||
PRODUCTVERSION 4,24,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -85,14 +85,14 @@ BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "Igor Pavlov\0"
|
||||
VALUE "FileDescription", "7-Zip FAR Plugin\0"
|
||||
VALUE "FileVersion", "4, 23, 0, 0\0"
|
||||
VALUE "FileVersion", "4, 24, 0, 0\0"
|
||||
VALUE "InternalName", "7-ZipFar\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2005 Igor Pavlov\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "7-ZipFar.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "7-Zip\0"
|
||||
VALUE "ProductVersion", "4, 23, 0, 0\0"
|
||||
VALUE "ProductVersion", "4, 24, 0, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -406,18 +406,6 @@ static HANDLE MyOpenFilePlugin(const char *name)
|
||||
|
||||
// ::OutputDebugString("after OpenArchive\n");
|
||||
|
||||
/*
|
||||
std::auto_ptr<CProxyHandler> aProxyHandler(new CProxyHandler());
|
||||
|
||||
if(aProxyHandler->Init(archiveHandler,
|
||||
fileInfo,
|
||||
GetDefaultName(fullName, archiverInfoResult.Extension),
|
||||
openArchiveCallbackSpec) != S_OK)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
// ::OutputDebugString("after Init\n");
|
||||
*/
|
||||
|
||||
CPlugin *plugin = new CPlugin(
|
||||
fullName,
|
||||
// defaultName,
|
||||
|
||||
@@ -42,7 +42,6 @@ public:
|
||||
// UString m_DefaultName;
|
||||
NWindows::NFile::NFind::CFileInfoW m_FileInfo;
|
||||
|
||||
// std::auto_ptr<CProxyHandler> m_ProxyHandler;
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
CMyComPtr<IFolderFolder> _folder;
|
||||
|
||||
@@ -71,15 +70,6 @@ public:
|
||||
int DeleteFiles(PluginPanelItem *aPanelItems, int itemsNumber, int opMode);
|
||||
|
||||
|
||||
/*
|
||||
void AddRealIndexOfFile(const CArchiveFolderItem &aFolder, int anIndexInVector,
|
||||
std::vector<int> &aRealIndexes);
|
||||
void AddRealIndexes(const CArchiveFolderItem &anItem,
|
||||
std::vector<int> &aRealIndexes);
|
||||
void GetRealIndexes(PluginPanelItem *aPanelItems, int itemsNumber,
|
||||
std::vector<int> &aRealIndexes);
|
||||
*/
|
||||
|
||||
HRESULT ExtractFiles(
|
||||
bool decompressAllItems,
|
||||
const UINT32 *indices,
|
||||
|
||||
@@ -4,12 +4,6 @@
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
/*
|
||||
using namespace NWindows;
|
||||
using namespace std;
|
||||
using namespace NFar;
|
||||
*/
|
||||
|
||||
/*
|
||||
void CPlugin::AddRealIndexOfFile(const CArchiveFolderItem &aFolder,
|
||||
int anIndexInVector, vector<int> &aRealIndexes)
|
||||
|
||||
@@ -44,14 +44,11 @@ static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
|
||||
{
|
||||
UStringVector realNames;
|
||||
realNames.Add(UString(L"x"));
|
||||
std::vector<NCOM::CPropVariant> values;
|
||||
values.push_back(NCOM::CPropVariant((UINT32)method));
|
||||
|
||||
NCOM::CPropVariant value = (UInt32)method;
|
||||
CRecordVector<const wchar_t *> names;
|
||||
for(int i = 0; i < realNames.Size(); i++)
|
||||
names.Add(realNames[i]);
|
||||
RINOK(setProperties->SetProperties(&names.Front(),
|
||||
&values.front(), names.Size()));
|
||||
RINOK(setProperties->SetProperties(&names.Front(), &value, names.Size()));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -595,7 +592,6 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 1 << 16);
|
||||
|
||||
|
||||
// std::auto_ptr<CProxyHandler> proxyHandler;
|
||||
NFind::CFileInfoW fileInfo;
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
|
||||
@@ -4,5 +4,9 @@
|
||||
#define __STDAFX_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -360,6 +360,14 @@ void CCompressDialog::CheckSFXControlsEnable()
|
||||
EnableItem(IDC_COMPRESS_SFX, enable);
|
||||
}
|
||||
|
||||
void CCompressDialog::CheckVolumeEnable()
|
||||
{
|
||||
bool isSFX = IsSFX();
|
||||
m_Volume.Enable(!isSFX);
|
||||
if (isSFX)
|
||||
m_Volume.SetText(TEXT(""));
|
||||
}
|
||||
|
||||
void CCompressDialog::CheckControlsEnable()
|
||||
{
|
||||
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
|
||||
@@ -371,7 +379,8 @@ void CCompressDialog::CheckControlsEnable()
|
||||
EnableItem(IDC_COMPRESS_SOLID, fi.Solid);
|
||||
EnableItem(IDC_COMPRESS_MULTI_THREAD, multiThreadEnable);
|
||||
CheckSFXControlsEnable();
|
||||
|
||||
CheckVolumeEnable();
|
||||
|
||||
// EnableItem(IDC_STATIC_COMPRESS_VOLUME, enable);
|
||||
// EnableItem(IDC_COMPRESS_COMBO_VOLUME, enable);
|
||||
|
||||
@@ -379,6 +388,7 @@ void CCompressDialog::CheckControlsEnable()
|
||||
EnableItem(IDC_COMPRESS_PASSWORD, fi.Encrypt);
|
||||
EnableItem(IDC_COMPRESS_EDIT_PASSWORD, fi.Encrypt);
|
||||
EnableItem(IDC_COMPRESS_CHECK_SHOW_PASSWORD, fi.Encrypt);
|
||||
|
||||
}
|
||||
|
||||
bool CCompressDialog::IsSFX()
|
||||
@@ -419,9 +429,7 @@ void CCompressDialog::OnButtonSFX()
|
||||
SetArchiveName2(false); // it's for OnInit
|
||||
}
|
||||
|
||||
m_Volume.Enable(!isSFX);
|
||||
if (isSFX)
|
||||
m_Volume.SetText(TEXT(""));
|
||||
CheckVolumeEnable();
|
||||
}
|
||||
|
||||
void CCompressDialog::OnButtonSetArchive()
|
||||
|
||||
@@ -141,6 +141,7 @@ public:
|
||||
protected:
|
||||
|
||||
void CheckSFXControlsEnable();
|
||||
void CheckVolumeEnable();
|
||||
void CheckControlsEnable();
|
||||
|
||||
void OnButtonSetArchive();
|
||||
|
||||
@@ -8,4 +8,6 @@
|
||||
#include <shlobj.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -195,9 +195,9 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
|
||||
if (censor.Pairs.Size() > 0)
|
||||
{
|
||||
const NWildcard::CPair &pair = censor.Pairs[0];
|
||||
if (pair.Head.Items.Size() > 0)
|
||||
if (pair.Head.IncludeItems.Size() > 0)
|
||||
{
|
||||
const NWildcard::CItem &item = pair.Head.Items[0];
|
||||
const NWildcard::CItem &item = pair.Head.IncludeItems[0];
|
||||
if (item.ForFile)
|
||||
{
|
||||
UString name = pair.Prefix;
|
||||
@@ -209,7 +209,7 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
|
||||
}
|
||||
if (NFind::FindFile(name, fileInfo))
|
||||
{
|
||||
if (censor.Pairs.Size() == 1 && pair.Head.Items.Size() == 1)
|
||||
if (censor.Pairs.Size() == 1 && pair.Head.IncludeItems.Size() == 1)
|
||||
oneFile = !fileInfo.IsDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,23,0,0
|
||||
PRODUCTVERSION 4,23,0,0
|
||||
FILEVERSION 4,24,0,0
|
||||
PRODUCTVERSION 4,24,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -93,14 +93,14 @@ BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "Igor Pavlov\0"
|
||||
VALUE "FileDescription", "7-Zip GUI Module\0"
|
||||
VALUE "FileVersion", "4, 23, 0, 0\0"
|
||||
VALUE "FileVersion", "4, 24, 0, 0\0"
|
||||
VALUE "InternalName", "7zg\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2005 Igor Pavlov\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "7zg.exe\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "7-Zip\0"
|
||||
VALUE "ProductVersion", "4, 23, 0, 0\0"
|
||||
VALUE "ProductVersion", "4, 24, 0, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
|
||||
Reference in New Issue
Block a user