4.53 beta
@@ -57,7 +57,7 @@ STDMETHODIMP CAgentFolder::LoadItems()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetNumberOfItems(UINT32 *numItems)
|
||||
STDMETHODIMP CAgentFolder::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
if (_flatMode)
|
||||
*numItems = _items.Size();
|
||||
@@ -66,14 +66,6 @@ STDMETHODIMP CAgentFolder::GetNumberOfItems(UINT32 *numItems)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
STDMETHODIMP CAgentFolder::GetNumberOfSubFolders(UINT32 *aNumSubFolders)
|
||||
{
|
||||
*aNumSubFolders = _proxyFolderItem->Folders.Size();
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
UString CAgentFolder::GetName(UInt32 index) const
|
||||
{
|
||||
UInt32 realIndex;
|
||||
@@ -90,7 +82,7 @@ UString CAgentFolder::GetName(UInt32 index) const
|
||||
realIndex = index;
|
||||
}
|
||||
|
||||
if (realIndex < (UINT32)folder->Folders.Size())
|
||||
if (realIndex < (UInt32)folder->Folders.Size())
|
||||
return folder->Folders[realIndex].Name;
|
||||
return folder->Files[realIndex - folder->Folders.Size()].Name;
|
||||
}
|
||||
@@ -115,17 +107,17 @@ UString CAgentFolder::GetFullPathPrefixPlusPrefix(UInt32 index) const
|
||||
return _proxyFolderItem->GetFullPathPrefix() + GetPrefix(index);
|
||||
}
|
||||
|
||||
void CAgentFolder::GetPrefixIfAny(UInt32 index, NCOM::CPropVariant &propVariant) const
|
||||
void CAgentFolder::GetPrefixIfAny(UInt32 index, NCOM::CPropVariant &prop) const
|
||||
{
|
||||
if (!_flatMode)
|
||||
return;
|
||||
propVariant = GetPrefix(index);
|
||||
prop = GetPrefix(index);
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
NCOM::CPropVariant prop;
|
||||
const CProxyFolder *folder;
|
||||
UInt32 realIndex;
|
||||
if (_flatMode)
|
||||
@@ -140,20 +132,32 @@ STDMETHODIMP CAgentFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARI
|
||||
realIndex = itemIndex;
|
||||
}
|
||||
|
||||
if (realIndex < (UINT32)folder->Folders.Size())
|
||||
if (realIndex < (UInt32)folder->Folders.Size())
|
||||
{
|
||||
const CProxyFolder &item = folder->Folders[realIndex];
|
||||
if (!_flatMode && propID == kpidSize)
|
||||
prop = item.Size;
|
||||
else if (!_flatMode && propID == kpidPackedSize)
|
||||
prop = item.PackSize;
|
||||
else
|
||||
switch(propID)
|
||||
{
|
||||
case kpidIsFolder:
|
||||
propVariant = true;
|
||||
break;
|
||||
case kpidName:
|
||||
propVariant = item.Name;
|
||||
break;
|
||||
case kpidPrefix:
|
||||
GetPrefixIfAny(itemIndex, propVariant);
|
||||
case kpidIsFolder: prop = true; break;
|
||||
case kpidNumSubFolders: prop = item.NumSubFolders; break;
|
||||
case kpidNumSubFiles: prop = item.NumSubFiles; break;
|
||||
case kpidName: prop = item.Name; break;
|
||||
case kpidCRC:
|
||||
{
|
||||
if (item.IsLeaf)
|
||||
{
|
||||
RINOK(_agentSpec->GetArchive()->GetProperty(item.Index, propID, value));
|
||||
}
|
||||
if (item.CrcIsDefined && value->vt == VT_EMPTY)
|
||||
prop = item.Crc;
|
||||
break;
|
||||
}
|
||||
case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
|
||||
|
||||
default:
|
||||
if (item.IsLeaf)
|
||||
return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
|
||||
@@ -165,20 +169,14 @@ STDMETHODIMP CAgentFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARI
|
||||
const CProxyFile &item = folder->Files[realIndex];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidIsFolder:
|
||||
propVariant = false;
|
||||
break;
|
||||
case kpidName:
|
||||
propVariant = item.Name;
|
||||
break;
|
||||
case kpidPrefix:
|
||||
GetPrefixIfAny(itemIndex, propVariant);
|
||||
break;
|
||||
default:
|
||||
case kpidIsFolder: prop = false; break;
|
||||
case kpidName: prop = item.Name; break;
|
||||
case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
|
||||
default:
|
||||
return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -198,7 +196,7 @@ HRESULT CAgentFolder::BindToFolder(CProxyFolder *folder, IFolderFolder **resultF
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
|
||||
STDMETHODIMP CAgentFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
@@ -215,7 +213,7 @@ STDMETHODIMP CAgentFolder::BindToFolder(UINT32 index, IFolderFolder **resultFold
|
||||
folder = _proxyFolderItem;
|
||||
realIndex = index;
|
||||
}
|
||||
if (realIndex >= (UINT32)folder->Folders.Size())
|
||||
if (realIndex >= (UInt32)folder->Folders.Size())
|
||||
return E_INVALIDARG;
|
||||
return BindToFolder(&folder->Folders[realIndex], resultFolder);
|
||||
COM_TRY_END
|
||||
@@ -240,15 +238,14 @@ STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetName(BSTR *name)
|
||||
STATPROPSTG kProperties[] =
|
||||
{
|
||||
CMyComBSTR temp = _proxyFolderItem->Name;
|
||||
*name = temp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
{ NULL, kpidNumSubFolders, VT_UI4},
|
||||
{ NULL, kpidNumSubFiles, VT_UI4},
|
||||
{ NULL, kpidPrefix, VT_BSTR}
|
||||
};
|
||||
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
static const UInt32 kNumProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
|
||||
struct CArchiveItemPropertyTemp
|
||||
{
|
||||
@@ -257,21 +254,21 @@ struct CArchiveItemPropertyTemp
|
||||
VARTYPE Type;
|
||||
};
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetNumberOfProperties(UINT32 *numProperties)
|
||||
STDMETHODIMP CAgentFolder::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
RINOK(_agentSpec->GetArchive()->GetNumberOfProperties(numProperties));
|
||||
if (_flatMode)
|
||||
(*numProperties)++;
|
||||
*numProperties += kNumProperties;
|
||||
if (!_flatMode)
|
||||
(*numProperties)--;
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetPropertyInfo(UINT32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
UINT32 numProperties;
|
||||
UInt32 numProperties;
|
||||
_agentSpec->GetArchive()->GetNumberOfProperties(&numProperties);
|
||||
if (index < numProperties)
|
||||
{
|
||||
@@ -281,55 +278,73 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UINT32 index,
|
||||
}
|
||||
else
|
||||
{
|
||||
*name = NULL;
|
||||
*propID = kpidPrefix;
|
||||
*varType = VT_BSTR;
|
||||
const STATPROPSTG &srcItem = kProperties[index - numProperties];
|
||||
*propID = srcItem.propid;
|
||||
*varType = srcItem.vt;
|
||||
*name = 0;
|
||||
}
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetTypeID(BSTR *name)
|
||||
STATPROPSTG kFolderProps[] =
|
||||
{
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidPackedSize, VT_UI8},
|
||||
{ NULL, kpidNumSubFolders, VT_UI4},
|
||||
{ NULL, kpidNumSubFiles, VT_UI4},
|
||||
{ NULL, kpidCRC, VT_UI4}
|
||||
};
|
||||
|
||||
static const UInt32 kNumFolderProps = sizeof(kFolderProps) / sizeof(kFolderProps[0]);
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
UString temp = UString(L"7-Zip.") + _agentSpec->ArchiveType;
|
||||
CMyComBSTR bstrTemp = temp;
|
||||
*name = bstrTemp.Detach();
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
switch(propID)
|
||||
{
|
||||
case kpidSize: prop = _proxyFolderItem->Size; break;
|
||||
case kpidPackedSize: prop = _proxyFolderItem->PackSize; break;
|
||||
case kpidNumSubFolders: prop = _proxyFolderItem->NumSubFolders; break;
|
||||
case kpidNumSubFiles: prop = _proxyFolderItem->NumSubFiles; break;
|
||||
case kpidName: prop = _proxyFolderItem->Name; break;
|
||||
case kpidPath: prop = _proxyFolderItem->GetFullPathPrefix(); break;
|
||||
case kpidType: prop = UString(L"7-Zip.") + _agentSpec->ArchiveType; break;
|
||||
case kpidCRC: if (_proxyFolderItem->CrcIsDefined) prop = _proxyFolderItem->Crc; break;
|
||||
}
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetPath(BSTR *path)
|
||||
STDMETHODIMP CAgentFolder::GetNumberOfFolderProperties(UInt32 *numProperties)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
UStringVector pathParts;
|
||||
pathParts.Clear();
|
||||
CMyComPtr<IFolderFolder> currentFolder = this;
|
||||
for (;;)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
currentFolder->BindToParentFolder(&newFolder);
|
||||
if (newFolder == NULL)
|
||||
break;
|
||||
CMyComBSTR aName;
|
||||
currentFolder->GetName(&aName);
|
||||
pathParts.Insert(0, (const wchar_t *)aName);
|
||||
currentFolder = newFolder;
|
||||
}
|
||||
|
||||
UString prefix;
|
||||
for(int i = 0; i < pathParts.Size(); i++)
|
||||
{
|
||||
prefix += pathParts[i];
|
||||
prefix += L'\\';
|
||||
}
|
||||
|
||||
CMyComBSTR tempPath = prefix;
|
||||
*path = tempPath.Detach();
|
||||
*numProperties = kNumFolderProps;
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetFolderPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
// if (index < kNumFolderProps)
|
||||
{
|
||||
const STATPROPSTG &srcItem = kFolderProps[index];
|
||||
*propID = srcItem.propid;
|
||||
*varType = srcItem.vt;
|
||||
*name = 0;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetFolderArchiveProperties(IFolderArchiveProperties **object)
|
||||
{
|
||||
CMyComPtr<IFolderArchiveProperties> temp = _agentSpec;
|
||||
*object = temp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
|
||||
STDMETHODIMP CAgentFolder::SetFlatMode(Int32 flatMode)
|
||||
{
|
||||
_flatMode = IntToBool(flatMode);
|
||||
@@ -338,7 +353,7 @@ STDMETHODIMP CAgentFolder::SetFlatMode(Int32 flatMode)
|
||||
|
||||
#endif
|
||||
|
||||
void CAgentFolder::GetRealIndices(const UINT32 *indices, UINT32 numItems, CUIntVector &realIndices) const
|
||||
void CAgentFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const
|
||||
{
|
||||
if (!_flatMode)
|
||||
{
|
||||
@@ -346,20 +361,20 @@ void CAgentFolder::GetRealIndices(const UINT32 *indices, UINT32 numItems, CUIntV
|
||||
return;
|
||||
}
|
||||
realIndices.Clear();
|
||||
for(UINT32 i = 0; i < numItems; i++)
|
||||
for(UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
const CProxyItem &item = _items[indices[i]];
|
||||
const CProxyFolder *folder = item.Folder;
|
||||
UInt32 realIndex = item.Index;
|
||||
if (realIndex < (UINT32)folder->Folders.Size())
|
||||
if (realIndex < (UInt32)folder->Folders.Size())
|
||||
continue;
|
||||
realIndices.Add(folder->Files[realIndex - folder->Folders.Size()].Index);
|
||||
}
|
||||
HeapSort(&realIndices.Front(), realIndices.Size());
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::Extract(const UINT32 *indices,
|
||||
UINT32 numItems,
|
||||
STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
|
||||
UInt32 numItems,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
@@ -382,16 +397,17 @@ STDMETHODIMP CAgentFolder::Extract(const UINT32 *indices,
|
||||
pathMode = NExtract::NPathMode::kNoPathnames;
|
||||
*/
|
||||
|
||||
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
|
||||
|
||||
extractCallbackSpec->Init(_agentSpec->GetArchive(),
|
||||
extractCallback2,
|
||||
false,
|
||||
path,
|
||||
pathMode,
|
||||
overwriteMode,
|
||||
(path ? path : L""),
|
||||
pathParts,
|
||||
_agentSpec->DefaultName,
|
||||
_agentSpec->DefaultTime,
|
||||
_agentSpec->DefaultAttributes
|
||||
_agentSpec->DefaultAttributes,
|
||||
(UInt64)(Int64)-1
|
||||
// ,_agentSpec->_srcDirectoryPrefix
|
||||
);
|
||||
CUIntVector realIndices;
|
||||
@@ -522,30 +538,30 @@ STDMETHODIMP CAgent::Extract(
|
||||
COM_TRY_BEGIN
|
||||
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
|
||||
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
|
||||
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
|
||||
extractCallbackSpec->Init(GetArchive(),
|
||||
extractCallback2,
|
||||
false,
|
||||
path,
|
||||
pathMode,
|
||||
overwriteMode,
|
||||
UStringVector(),
|
||||
DefaultName,
|
||||
DefaultTime,
|
||||
DefaultAttributes
|
||||
DefaultAttributes,
|
||||
(UInt64)(Int64)-1
|
||||
// ,_srcDirectoryPrefix
|
||||
);
|
||||
return GetArchive()->Extract(0, (UInt32)(Int32)-1, testMode, extractCallback);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::GetNumberOfProperties(UINT32 *numProperties)
|
||||
STDMETHODIMP CAgent::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return GetArchive()->GetNumberOfProperties(numProperties);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::GetPropertyInfo(UINT32 index,
|
||||
STDMETHODIMP CAgent::GetPropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
@@ -563,14 +579,14 @@ STDMETHODIMP CAgent::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::GetNumberOfArchiveProperties(UINT32 *numProperties)
|
||||
STDMETHODIMP CAgent::GetNumberOfArchiveProperties(UInt32 *numProperties)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return GetArchive()->GetNumberOfArchiveProperties(numProperties);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::GetArchivePropertyInfo(UINT32 index,
|
||||
STDMETHODIMP CAgent::GetArchivePropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
@@ -13,19 +13,14 @@
|
||||
#include "AgentProxy.h"
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
#include "../../FileManager/IFolder.h"
|
||||
#include "../FileManager/IFolder.h"
|
||||
#include "../Common/LoadCodecs.h"
|
||||
#endif
|
||||
|
||||
class CAgentFolder;
|
||||
|
||||
// {23170F69-40C1-278A-0000-000100050001}
|
||||
DEFINE_GUID(IID_IArchiveFolderInternal,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x01);
|
||||
MIDL_INTERFACE("23170F69-40C1-278A-0000-000100050001")
|
||||
IArchiveFolderInternal: public IUnknown
|
||||
DECL_INTERFACE(IArchiveFolderInternal, 0x01, 0xC)
|
||||
{
|
||||
public:
|
||||
STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder) PURE;
|
||||
};
|
||||
|
||||
@@ -39,12 +34,11 @@ class CAgent;
|
||||
|
||||
class CAgentFolder:
|
||||
public IFolderFolder,
|
||||
public IFolderProperties,
|
||||
public IGetFolderArchiveProperties,
|
||||
public IArchiveFolder,
|
||||
public IArchiveFolderInternal,
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
public IEnumProperties,
|
||||
public IFolderGetTypeID,
|
||||
public IFolderGetPath,
|
||||
public IFolderOperations,
|
||||
public IFolderSetFlatMode,
|
||||
#endif
|
||||
@@ -54,31 +48,25 @@ public:
|
||||
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderFolder)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderProperties)
|
||||
MY_QUERYINTERFACE_ENTRY(IGetFolderArchiveProperties)
|
||||
MY_QUERYINTERFACE_ENTRY(IArchiveFolder)
|
||||
MY_QUERYINTERFACE_ENTRY(IArchiveFolderInternal)
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
MY_QUERYINTERFACE_ENTRY(IEnumProperties)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderGetTypeID)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderGetPath)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderOperations)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
|
||||
#endif
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
// IFolderFolder
|
||||
|
||||
void LoadFolder(CProxyFolder *folder);
|
||||
HRESULT BindToFolder(CProxyFolder *folder, IFolderFolder **resultFolder);
|
||||
void GetRealIndices(const UINT32 *indices, UINT32 numItems, CUIntVector &realIndices) const;
|
||||
|
||||
STDMETHOD(LoadItems)();
|
||||
STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
|
||||
STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetName)(BSTR *name);
|
||||
INTERFACE_FolderFolder(;)
|
||||
INTERFACE_FolderProperties(;)
|
||||
|
||||
STDMETHOD(GetFolderArchiveProperties)(IFolderArchiveProperties **object);
|
||||
|
||||
// IArchiveFolder
|
||||
STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems,
|
||||
@@ -91,25 +79,7 @@ public:
|
||||
STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder);
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UINT32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
STDMETHOD(GetTypeID)(BSTR *name);
|
||||
STDMETHOD(GetPath)(BSTR *path);
|
||||
|
||||
|
||||
// IFolderOperations
|
||||
STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress);
|
||||
STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress);
|
||||
STDMETHOD(Rename)(UINT32 index, const wchar_t *newName, IProgress *progress);
|
||||
STDMETHOD(Delete)(const UINT32 *indices, UINT32 numItems, IProgress *progress);
|
||||
STDMETHOD(CopyTo)(const UINT32 *indices, UINT32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback);
|
||||
STDMETHOD(MoveTo)(const UINT32 *indices, UINT32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback);
|
||||
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
|
||||
const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress);
|
||||
STDMETHOD(SetProperty)(UINT32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
|
||||
INTERFACE_FolderOperations(;)
|
||||
|
||||
STDMETHOD(SetFlatMode)(Int32 flatMode);
|
||||
#endif
|
||||
@@ -156,12 +126,9 @@ public:
|
||||
private:
|
||||
};
|
||||
|
||||
// {23170F69-40C1-278A-1000-000100030000}
|
||||
DEFINE_GUID(CLSID_CAgentArchiveHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00);
|
||||
|
||||
class CAgent:
|
||||
public IInFolderArchive,
|
||||
public IFolderArchiveProperties,
|
||||
#ifndef EXTRACT_ONLY
|
||||
public IOutFolderArchive,
|
||||
public ISetProperties,
|
||||
@@ -172,6 +139,7 @@ public:
|
||||
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInFolderArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderArchiveProperties)
|
||||
#ifndef EXTRACT_ONLY
|
||||
MY_QUERYINTERFACE_ENTRY(IOutFolderArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
@@ -179,45 +147,11 @@ public:
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
STDMETHOD(Open)(
|
||||
const wchar_t *filePath,
|
||||
BSTR *archiveType,
|
||||
IArchiveOpenCallback *openArchiveCallback);
|
||||
|
||||
STDMETHOD(ReOpen)(IArchiveOpenCallback *openArchiveCallback);
|
||||
STDMETHOD(Close)();
|
||||
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UINT32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
STDMETHOD(GetNumberOfArchiveProperties)(UINT32 *numProperties);
|
||||
STDMETHOD(GetArchivePropertyInfo)(UINT32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
STDMETHOD(BindToRootFolder)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(Extract)(
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
INT32 testMode,
|
||||
IFolderArchiveExtractCallback *extractCallback2);
|
||||
INTERFACE_IInFolderArchive(;)
|
||||
INTERFACE_IFolderArchiveProperties(;)
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
STDMETHOD(SetFolder)(IFolderFolder *folder);
|
||||
STDMETHOD(SetFiles)(const wchar_t *folderPrefix, const wchar_t **names, UINT32 numNames);
|
||||
STDMETHOD(DeleteItems)(const wchar_t *newArchiveName, const UINT32 *indices,
|
||||
UINT32 numItems, IFolderArchiveUpdateCallback *updateCallback);
|
||||
STDMETHOD(DoOperation)(
|
||||
CCodecs *codecs,
|
||||
int formatIndex,
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback);
|
||||
STDMETHOD(DoOperation2)(
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback);
|
||||
INTERFACE_IOutFolderArchive(;)
|
||||
|
||||
HRESULT CommonUpdate(
|
||||
const wchar_t *newArchiveName,
|
||||
@@ -252,9 +186,6 @@ public:
|
||||
CArchiveLink _archiveLink;
|
||||
// IInArchive *_archive2;
|
||||
|
||||
// CLSID _CLSID;
|
||||
// CMyComPtr<IArchiveFolder> m_RootFolder;
|
||||
|
||||
UString DefaultName;
|
||||
|
||||
FILETIME DefaultTime;
|
||||
@@ -286,12 +217,9 @@ class CArchiveFolderManager:
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(IFolderManager)
|
||||
// IFolderManager
|
||||
STDMETHOD(OpenFolderFile)(const wchar_t *filePath, IFolderFolder **resultFolder, IProgress *progress);
|
||||
STDMETHOD(GetExtensions)(BSTR *extensions);
|
||||
STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex);
|
||||
// STDMETHOD(GetTypes)(BSTR *types);
|
||||
// STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress);
|
||||
|
||||
INTERFACE_IFolderManager(;)
|
||||
|
||||
CArchiveFolderManager(): _codecs(0) {}
|
||||
private:
|
||||
void LoadFormats();
|
||||
|
||||
@@ -57,9 +57,11 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
|
||||
folderItem->BindToParentFolder(&newFolder);
|
||||
if (newFolder == NULL)
|
||||
break;
|
||||
CMyComBSTR name;
|
||||
folderItem->GetName(&name);
|
||||
pathParts.Insert(0, (const wchar_t *)name);
|
||||
|
||||
NCOM::CPropVariant prop;
|
||||
if (folderItem->GetFolderProperty(kpidName, &prop) == S_OK)
|
||||
if (prop.vt == VT_BSTR)
|
||||
pathParts.Insert(0, (const wchar_t *)prop.bstrVal);
|
||||
folderItem = newFolder;
|
||||
}
|
||||
|
||||
@@ -218,9 +220,17 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
|
||||
CObjectVector<CUpdatePair2> updatePairs2;
|
||||
UpdateProduce(updatePairs, actionSet, updatePairs2);
|
||||
|
||||
UInt32 numFiles = 0;
|
||||
for (i = 0; i < updatePairs2.Size(); i++)
|
||||
if (updatePairs2[i].NewData)
|
||||
numFiles++;
|
||||
|
||||
RINOK(updateCallback100->SetNumFiles(numFiles));
|
||||
|
||||
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.Callback = updateCallback100;
|
||||
updateCallbackAgent.SetCallback(updateCallback100);
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
@@ -362,7 +372,7 @@ STDMETHODIMP CAgent::DeleteItems(
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.Callback = updateCallback100;
|
||||
updateCallbackAgent.SetCallback(updateCallback100);
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
@@ -402,7 +412,7 @@ HRESULT CAgent::CreateFolder(
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.Callback = updateCallback100;
|
||||
updateCallbackAgent.SetCallback(updateCallback100);
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
@@ -464,7 +474,7 @@ HRESULT CAgent::RenameItem(
|
||||
if (numItems != 1)
|
||||
return E_INVALIDARG;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.Callback = updateCallback100;
|
||||
updateCallbackAgent.SetCallback(updateCallback100);
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
@@ -43,15 +44,14 @@ int CProxyFolder::FindDirSubItemIndex(const UString &name) const
|
||||
return FindDirSubItemIndex(name, insertPos);
|
||||
}
|
||||
|
||||
void CProxyFolder::AddFileSubItem(UINT32 index, const UString &name)
|
||||
void CProxyFolder::AddFileSubItem(UInt32 index, const UString &name)
|
||||
{
|
||||
Files.Add(CProxyFile());
|
||||
Files.Back().Name = name;
|
||||
Files.Back().Index = index;
|
||||
}
|
||||
|
||||
CProxyFolder* CProxyFolder::AddDirSubItem(UINT32 index, bool leaf,
|
||||
const UString &name)
|
||||
CProxyFolder* CProxyFolder::AddDirSubItem(UInt32 index, bool leaf, const UString &name)
|
||||
{
|
||||
int insertPos;
|
||||
int folderIndex = FindDirSubItemIndex(name, insertPos);
|
||||
@@ -80,6 +80,18 @@ void CProxyFolder::Clear()
|
||||
Files.Clear();
|
||||
}
|
||||
|
||||
void CProxyFolder::GetPathParts(UStringVector &pathParts) const
|
||||
{
|
||||
pathParts.Clear();
|
||||
UString result;
|
||||
const CProxyFolder *current = this;
|
||||
while (current->Parent != NULL)
|
||||
{
|
||||
pathParts.Insert(0, (const wchar_t *)current->Name);
|
||||
current = current->Parent;
|
||||
}
|
||||
}
|
||||
|
||||
UString CProxyFolder::GetFullPathPrefix() const
|
||||
{
|
||||
UString result;
|
||||
@@ -92,9 +104,9 @@ UString CProxyFolder::GetFullPathPrefix() const
|
||||
return result;
|
||||
}
|
||||
|
||||
UString CProxyFolder::GetItemName(UINT32 index) const
|
||||
UString CProxyFolder::GetItemName(UInt32 index) const
|
||||
{
|
||||
if (index < (UINT32)Folders.Size())
|
||||
if (index < (UInt32)Folders.Size())
|
||||
return Folders[index].Name;
|
||||
return Files[index - Folders.Size()].Name;
|
||||
}
|
||||
@@ -110,11 +122,10 @@ void CProxyFolder::AddRealIndices(CUIntVector &realIndices) const
|
||||
realIndices.Add(Files[i].Index);
|
||||
}
|
||||
|
||||
void CProxyFolder::GetRealIndices(const UINT32 *indices,
|
||||
UINT32 numItems, CUIntVector &realIndices) const
|
||||
void CProxyFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const
|
||||
{
|
||||
realIndices.Clear();
|
||||
for(UINT32 i = 0; i < numItems; i++)
|
||||
for(UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
int index = indices[i];
|
||||
int numDirItems = Folders.Size();
|
||||
@@ -138,7 +149,7 @@ HRESULT CProxyArchive::Reload(IInArchive *archive, IProgress *progress)
|
||||
HRESULT CProxyArchive::Load(IInArchive *archive,
|
||||
const UString &defaultName,
|
||||
// const FILETIME &defaultTime,
|
||||
// UINT32 defaultAttributes,
|
||||
// UInt32 defaultAttributes,
|
||||
IProgress *progress)
|
||||
{
|
||||
DefaultName = defaultName;
|
||||
@@ -147,17 +158,65 @@ HRESULT CProxyArchive::Load(IInArchive *archive,
|
||||
return Reload(archive, progress);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CProxyArchive::ReadObjects(IInArchive *archiveHandler, IProgress *progress)
|
||||
static UInt64 GetSize(IInArchive *archive, UInt32 index, PROPID propID)
|
||||
{
|
||||
UINT32 numItems;
|
||||
RINOK(archiveHandler->GetNumberOfItems(&numItems));
|
||||
NCOM::CPropVariant prop;
|
||||
if (archive->GetProperty(index, propID, &prop) == S_OK)
|
||||
if (prop.vt != VT_EMPTY)
|
||||
return ConvertPropVariantToUInt64(prop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CProxyFolder::CalculateSizes(IInArchive *archive)
|
||||
{
|
||||
Size = PackSize = 0;
|
||||
NumSubFolders = Folders.Size();
|
||||
NumSubFiles = Files.Size();
|
||||
CrcIsDefined = true;
|
||||
Crc = 0;
|
||||
int i;
|
||||
for (i = 0; i < Files.Size(); i++)
|
||||
{
|
||||
UInt32 index = Files[i].Index;
|
||||
Size += GetSize(archive, index, kpidSize);
|
||||
PackSize += GetSize(archive, index, kpidPackedSize);
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
if (archive->GetProperty(index, kpidCRC, &prop) == S_OK)
|
||||
{
|
||||
if (prop.vt == VT_UI4)
|
||||
Crc += prop.ulVal;
|
||||
else
|
||||
CrcIsDefined = false;
|
||||
}
|
||||
else
|
||||
CrcIsDefined = false;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < Folders.Size(); i++)
|
||||
{
|
||||
CProxyFolder &f = Folders[i];
|
||||
f.CalculateSizes(archive);
|
||||
Size += f.Size;
|
||||
PackSize += f.PackSize;
|
||||
NumSubFiles += f.NumSubFiles;
|
||||
NumSubFolders += f.NumSubFolders;
|
||||
Crc += f.Crc;
|
||||
if (!f.CrcIsDefined)
|
||||
CrcIsDefined = false;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CProxyArchive::ReadObjects(IInArchive *archive, IProgress *progress)
|
||||
{
|
||||
UInt32 numItems;
|
||||
RINOK(archive->GetNumberOfItems(&numItems));
|
||||
if (progress != NULL)
|
||||
{
|
||||
UINT64 totalItems = numItems;
|
||||
RINOK(progress->SetTotal(totalItems));
|
||||
}
|
||||
for(UINT32 i = 0; i < numItems; i++)
|
||||
for(UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
if (progress != NULL)
|
||||
{
|
||||
@@ -165,7 +224,7 @@ HRESULT CProxyArchive::ReadObjects(IInArchive *archiveHandler, IProgress *progre
|
||||
RINOK(progress->SetCompleted(¤tItemIndex));
|
||||
}
|
||||
NCOM::CPropVariant propVariantPath;
|
||||
RINOK(archiveHandler->GetProperty(i, kpidPath, &propVariantPath));
|
||||
RINOK(archive->GetProperty(i, kpidPath, &propVariantPath));
|
||||
CProxyFolder *currentItem = &RootFolder;
|
||||
UString fileName;
|
||||
if(propVariantPath.vt == VT_EMPTY)
|
||||
@@ -192,12 +251,13 @@ HRESULT CProxyArchive::ReadObjects(IInArchive *archiveHandler, IProgress *progre
|
||||
|
||||
NCOM::CPropVariant propVariantIsFolder;
|
||||
bool isFolder;
|
||||
RINOK(IsArchiveItemFolder(archiveHandler, i, isFolder));
|
||||
RINOK(IsArchiveItemFolder(archive, i, isFolder));
|
||||
if(isFolder)
|
||||
currentItem->AddDirSubItem(i, true, fileName);
|
||||
else
|
||||
currentItem->AddFileSubItem(i, fileName);
|
||||
}
|
||||
RootFolder.CalculateSizes(archive);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
class CProxyFile
|
||||
{
|
||||
public:
|
||||
UINT32 Index;
|
||||
UInt32 Index;
|
||||
UString Name;
|
||||
};
|
||||
|
||||
@@ -22,34 +22,41 @@ public:
|
||||
CObjectVector<CProxyFile> Files;
|
||||
bool IsLeaf;
|
||||
|
||||
bool CrcIsDefined;
|
||||
UInt64 Size;
|
||||
UInt64 PackSize;
|
||||
UInt32 Crc;
|
||||
UInt32 NumSubFolders;
|
||||
UInt32 NumSubFiles;
|
||||
|
||||
CProxyFolder(): Parent(NULL) {};
|
||||
int FindDirSubItemIndex(const UString &name, int &insertPos) const;
|
||||
int FindDirSubItemIndex(const UString &name) const;
|
||||
CProxyFolder* AddDirSubItem(UINT32 index,
|
||||
bool leaf, const UString &name);
|
||||
void AddFileSubItem(UINT32 index, const UString &name);
|
||||
CProxyFolder* AddDirSubItem(UInt32 index, bool leaf, const UString &name);
|
||||
void AddFileSubItem(UInt32 index, const UString &name);
|
||||
void Clear();
|
||||
|
||||
void GetPathParts(UStringVector &pathParts) const;
|
||||
UString GetFullPathPrefix() const;
|
||||
UString GetItemName(UINT32 index) const;
|
||||
UString GetItemName(UInt32 index) const;
|
||||
void AddRealIndices(CUIntVector &realIndices) const;
|
||||
void GetRealIndices(const UINT32 *indices, UINT32 numItems,
|
||||
CUIntVector &realIndices) const;
|
||||
void GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const;
|
||||
void CalculateSizes(IInArchive *archive);
|
||||
};
|
||||
|
||||
class CProxyArchive
|
||||
{
|
||||
HRESULT ReadObjects(IInArchive *inArchive, IProgress *progress);
|
||||
HRESULT ReadObjects(IInArchive *archive, IProgress *progress);
|
||||
public:
|
||||
UString DefaultName;
|
||||
// FILETIME DefaultTime;
|
||||
// UINT32 DefaultAttributes;
|
||||
// UInt32 DefaultAttributes;
|
||||
CProxyFolder RootFolder;
|
||||
HRESULT Reload(IInArchive *archive, IProgress *progress);
|
||||
HRESULT Load(IInArchive *archive,
|
||||
const UString &defaultName,
|
||||
// const FILETIME &defaultTime,
|
||||
// UINT32 defaultAttributes,
|
||||
// UInt32 defaultAttributes,
|
||||
IProgress *progress);
|
||||
};
|
||||
|
||||
|
||||
@@ -45,16 +45,17 @@ STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
|
||||
NExtract::NPathMode::kNoPathnames :
|
||||
NExtract::NPathMode::kCurrentPathnames;
|
||||
|
||||
extractCallbackSpec->InitForMulti(false, pathMode, NExtract::NOverwriteMode::kAskBefore);
|
||||
extractCallbackSpec->Init(_agentSpec->GetArchive(),
|
||||
extractCallback2,
|
||||
false,
|
||||
path,
|
||||
pathMode,
|
||||
NExtract::NOverwriteMode::kAskBefore,
|
||||
pathParts,
|
||||
_agentSpec->DefaultName,
|
||||
_agentSpec->DefaultTime,
|
||||
_agentSpec->DefaultAttributes
|
||||
_agentSpec->DefaultAttributes,
|
||||
(UInt64)(Int64)-1
|
||||
|
||||
// ,_agentSpec->_srcDirectoryPrefix
|
||||
);
|
||||
CUIntVector realIndices;
|
||||
|
||||
@@ -20,19 +20,7 @@ static LPCWSTR kTempArcivePrefix = L"7zA";
|
||||
|
||||
void CAgentFolder::GetPathParts(UStringVector &pathParts)
|
||||
{
|
||||
pathParts.Clear();
|
||||
CMyComPtr<IFolderFolder> folder = this;
|
||||
for (;;)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
folder->BindToParentFolder(&newFolder);
|
||||
if (newFolder == NULL)
|
||||
break;
|
||||
CMyComBSTR name;
|
||||
folder->GetName(&name);
|
||||
pathParts.Insert(0, (const wchar_t *)name);
|
||||
folder = newFolder;
|
||||
}
|
||||
_proxyFolderItem->GetPathParts(pathParts);
|
||||
}
|
||||
|
||||
HRESULT CAgentFolder::CommonUpdateOperation(
|
||||
|
||||
@@ -5,92 +5,70 @@
|
||||
|
||||
#include "../../Archive/IArchive.h"
|
||||
// #include "../Format/Common/ArchiveInterface.h"
|
||||
#include "../../FileManager/IFolder.h"
|
||||
#include "../../UI/FileManager/IFolder.h"
|
||||
#include "../Common/IFileExtractCallback.h"
|
||||
#include "../Common/ExtractMode.h"
|
||||
#include "../../UI/Common/LoadCodecs.h"
|
||||
|
||||
// {23170F69-40C1-278A-0000-000100050000}
|
||||
DEFINE_GUID(IID_IArchiveFolder,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00);
|
||||
MIDL_INTERFACE("23170F69-40C1-278A-0000-000100050000")
|
||||
IArchiveFolder: public IUnknown
|
||||
#include "../../IDecl.h"
|
||||
|
||||
#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) \
|
||||
STDMETHOD(Extract)(const UInt32 *indices, UInt32 numItems, \
|
||||
NExtract::NPathMode::EEnum pathMode, \
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode, \
|
||||
const wchar_t *path, Int32 testMode, \
|
||||
IFolderArchiveExtractCallback *extractCallback2) x; \
|
||||
|
||||
FOLDER_ARCHIVE_INTERFACE(IArchiveFolder, 0x05)
|
||||
{
|
||||
public:
|
||||
STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
INT32 testMode,
|
||||
IFolderArchiveExtractCallback *extractCallback2) PURE;
|
||||
INTERFACE_IArchiveFolder(PURE)
|
||||
};
|
||||
|
||||
// {23170F69-40C1-278A-0000-000100060000}
|
||||
DEFINE_GUID(IID_IInFolderArchive,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00);
|
||||
MIDL_INTERFACE("23170F69-40C1-278A-0000-000100060000")
|
||||
IInFolderArchive: public IUnknown
|
||||
#define INTERFACE_IInFolderArchive(x) \
|
||||
STDMETHOD(Open)(const wchar_t *filePath, BSTR *archiveType, IArchiveOpenCallback *openArchiveCallback) x; \
|
||||
STDMETHOD(ReOpen)(IArchiveOpenCallback *openArchiveCallback) x; \
|
||||
STDMETHOD(Close)() x; \
|
||||
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
|
||||
STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
|
||||
STDMETHOD(BindToRootFolder)(IFolderFolder **resultFolder) x; \
|
||||
STDMETHOD(Extract)(NExtract::NPathMode::EEnum pathMode, \
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode, const wchar_t *path, \
|
||||
Int32 testMode, IFolderArchiveExtractCallback *extractCallback2) x; \
|
||||
|
||||
FOLDER_ARCHIVE_INTERFACE(IInFolderArchive, 0x06)
|
||||
{
|
||||
public:
|
||||
STDMETHOD(Open)(
|
||||
const wchar_t *filePath,
|
||||
// CLSID *clsIDResult,
|
||||
BSTR *archiveType,
|
||||
IArchiveOpenCallback *openArchiveCallback) PURE;
|
||||
STDMETHOD(ReOpen)(
|
||||
// const wchar_t *filePath,
|
||||
IArchiveOpenCallback *openArchiveCallback) PURE;
|
||||
STDMETHOD(Close)() PURE;
|
||||
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) PURE;
|
||||
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties) PURE;
|
||||
STDMETHOD(GetPropertyInfo)(UINT32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
|
||||
STDMETHOD(GetNumberOfArchiveProperties)(UINT32 *numProperties) PURE;
|
||||
STDMETHOD(GetArchivePropertyInfo)(UINT32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
|
||||
STDMETHOD(BindToRootFolder)(IFolderFolder **resultFolder) PURE;
|
||||
STDMETHOD(Extract)(
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const wchar_t *path,
|
||||
INT32 testMode,
|
||||
IFolderArchiveExtractCallback *extractCallback2) PURE;
|
||||
INTERFACE_IInFolderArchive(PURE)
|
||||
};
|
||||
|
||||
// {23170F69-40C1-278A-0000-0001000B0000}
|
||||
DEFINE_GUID(IID_IFolderArchiveUpdateCallback,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x00);
|
||||
MIDL_INTERFACE("23170F69-40C1-278A-0000-0001000B0000")
|
||||
IFolderArchiveUpdateCallback: public IProgress
|
||||
#define INTERFACE_IFolderArchiveUpdateCallback(x) \
|
||||
STDMETHOD(CompressOperation)(const wchar_t *name) x; \
|
||||
STDMETHOD(DeleteOperation)(const wchar_t *name) x; \
|
||||
STDMETHOD(OperationResult)(Int32 operationResult) x; \
|
||||
STDMETHOD(UpdateErrorMessage)(const wchar_t *message) x; \
|
||||
STDMETHOD(SetNumFiles)(UInt64 numFiles) x; \
|
||||
|
||||
FOLDER_ARCHIVE_INTERFACE_SUB(IFolderArchiveUpdateCallback, IProgress, 0x0B)
|
||||
{
|
||||
public:
|
||||
STDMETHOD(CompressOperation)(const wchar_t *name) PURE;
|
||||
STDMETHOD(DeleteOperation)(const wchar_t *name) PURE;
|
||||
STDMETHOD(OperationResult)(INT32 operationResult) PURE;
|
||||
STDMETHOD(UpdateErrorMessage)(const wchar_t *message) PURE;
|
||||
INTERFACE_IFolderArchiveUpdateCallback(PURE)
|
||||
};
|
||||
|
||||
DEFINE_GUID(IID_IOutFolderArchive,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x02);
|
||||
MIDL_INTERFACE("23170F69-40C1-278A-0000-0001000A0002")
|
||||
IOutFolderArchive: public IUnknown
|
||||
#define INTERFACE_IOutFolderArchive(x) \
|
||||
STDMETHOD(SetFolder)(IFolderFolder *folder) x; \
|
||||
STDMETHOD(SetFiles)(const wchar_t *folderPrefix, const wchar_t **names, UInt32 numNames) x; \
|
||||
STDMETHOD(DeleteItems)(const wchar_t *newArchiveName, \
|
||||
const UInt32 *indices, UInt32 numItems, IFolderArchiveUpdateCallback *updateCallback) x; \
|
||||
STDMETHOD(DoOperation)(CCodecs *codecs, int index, \
|
||||
const wchar_t *newArchiveName, const Byte *stateActions, const wchar_t *sfxModule, \
|
||||
IFolderArchiveUpdateCallback *updateCallback) x; \
|
||||
STDMETHOD(DoOperation2)(const wchar_t *newArchiveName, const Byte *stateActions, \
|
||||
const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback) x; \
|
||||
|
||||
FOLDER_ARCHIVE_INTERFACE(IOutFolderArchive, 0x0A)
|
||||
{
|
||||
STDMETHOD(SetFolder)(IFolderFolder *folder) PURE;
|
||||
STDMETHOD(SetFiles)(const wchar_t *folderPrefix, const wchar_t **names, UINT32 numNames) PURE;
|
||||
STDMETHOD(DeleteItems)(const wchar_t *newArchiveName,
|
||||
const UINT32 *indices, UINT32 numItems, IFolderArchiveUpdateCallback *updateCallback) PURE;
|
||||
STDMETHOD(DoOperation)(
|
||||
CCodecs *codecs,
|
||||
int index,
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback) PURE;
|
||||
STDMETHOD(DoOperation2)(
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback) PURE;
|
||||
INTERFACE_IOutFolderArchive(PURE)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,11 +3,28 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Windows/Error.h"
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
#include "UpdateCallbackAgent.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
void CUpdateCallbackAgent::SetCallback(IFolderArchiveUpdateCallback *callback)
|
||||
{
|
||||
Callback = callback;
|
||||
_compressProgress.Release();
|
||||
if (Callback)
|
||||
Callback.QueryInterface(IID_ICompressProgressInfo, &_compressProgress);
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::SetNumFiles(UInt64 numFiles)
|
||||
{
|
||||
if (Callback)
|
||||
return Callback->SetNumFiles(numFiles);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CUpdateCallbackAgent::SetTotal(UINT64 size)
|
||||
{
|
||||
if (Callback)
|
||||
@@ -22,6 +39,13 @@ HRESULT CUpdateCallbackAgent::SetCompleted(const UINT64 *completeValue)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
|
||||
{
|
||||
if (_compressProgress)
|
||||
return _compressProgress->SetRatioInfo(inSize, outSize);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::CheckBreak()
|
||||
{
|
||||
return S_OK;
|
||||
@@ -57,14 +81,14 @@ HRESULT CUpdateCallbackAgent::GetStream(const wchar_t *name, bool /* isAnti */)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::SetOperationResult(INT32 operationResult)
|
||||
HRESULT CUpdateCallbackAgent::SetOperationResult(Int32 operationResult)
|
||||
{
|
||||
if (Callback)
|
||||
return Callback->OperationResult(operationResult);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::CryptoGetTextPassword2(INT32 *passwordIsDefined, BSTR *password)
|
||||
HRESULT CUpdateCallbackAgent::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
|
||||
{
|
||||
*passwordIsDefined = BoolToInt(false);
|
||||
if (!_cryptoGetTextPassword)
|
||||
|
||||
@@ -8,17 +8,12 @@
|
||||
|
||||
class CUpdateCallbackAgent: public IUpdateCallbackUI
|
||||
{
|
||||
virtual HRESULT SetTotal(UINT64 size);
|
||||
virtual HRESULT SetCompleted(const UINT64 *completeValue);
|
||||
virtual HRESULT CheckBreak();
|
||||
virtual HRESULT Finilize();
|
||||
virtual HRESULT GetStream(const wchar_t *name, bool isAnti);
|
||||
virtual HRESULT OpenFileError(const wchar_t *name, DWORD systemError);
|
||||
virtual HRESULT SetOperationResult(INT32 operationResult);
|
||||
virtual HRESULT CryptoGetTextPassword2(INT32 *passwordIsDefined, BSTR *password);
|
||||
INTERFACE_IUpdateCallbackUI(;)
|
||||
CMyComPtr<ICryptoGetTextPassword2> _cryptoGetTextPassword;
|
||||
public:
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> Callback;
|
||||
CMyComPtr<ICompressProgressInfo> _compressProgress;
|
||||
public:
|
||||
void SetCallback(IFolderArchiveUpdateCallback *callback);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -333,7 +333,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
|
||||
|
||||
_outFileStreamSpec = new COutFileStream;
|
||||
CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
|
||||
if (!_outFileStreamSpec->File.Open(fullProcessedPath, CREATE_ALWAYS))
|
||||
if (!_outFileStreamSpec->Open(fullProcessedPath, CREATE_ALWAYS))
|
||||
{
|
||||
PrintString((UString)L"can not open output file " + fullProcessedPath);
|
||||
return E_ABORT;
|
||||
@@ -396,7 +396,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
|
||||
}
|
||||
|
||||
if(_outFileStream != NULL && _processedFileInfo.UTCLastWriteTimeIsDefined)
|
||||
_outFileStreamSpec->File.SetLastWriteTime(&_processedFileInfo.UTCLastWriteTime);
|
||||
_outFileStreamSpec->SetLastWriteTime(&_processedFileInfo.UTCLastWriteTime);
|
||||
_outFileStream.Release();
|
||||
if (_extractMode && _processedFileInfo.AttributesAreDefined)
|
||||
NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attributes);
|
||||
|
||||
@@ -33,22 +33,32 @@ void CArchiveExtractCallback::Init(
|
||||
IFolderArchiveExtractCallback *extractCallback2,
|
||||
bool stdOutMode,
|
||||
const UString &directoryPath,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const UStringVector &removePathParts,
|
||||
const UString &itemDefaultName,
|
||||
const FILETIME &utcLastWriteTimeDefault,
|
||||
UInt32 attributesDefault)
|
||||
UInt32 attributesDefault,
|
||||
UInt64 packSize)
|
||||
{
|
||||
_stdOutMode = stdOutMode;
|
||||
_numErrors = 0;
|
||||
_ratioMode = false;
|
||||
_unpTotal = 1;
|
||||
_packTotal = packSize;
|
||||
|
||||
_extractCallback2 = extractCallback2;
|
||||
_compressProgress.Release();
|
||||
_extractCallback2.QueryInterface(IID_ICompressProgressInfo, &_compressProgress);
|
||||
if (!_localProgress)
|
||||
{
|
||||
LocalProgressSpec = new CLocalProgress();
|
||||
_localProgress = LocalProgressSpec;
|
||||
}
|
||||
LocalProgressSpec->Init(extractCallback2, true);
|
||||
|
||||
_itemDefaultName = itemDefaultName;
|
||||
_utcLastWriteTimeDefault = utcLastWriteTimeDefault;
|
||||
_attributesDefault = attributesDefault;
|
||||
_removePathParts = removePathParts;
|
||||
_pathMode = pathMode;
|
||||
_overwriteMode = overwriteMode;
|
||||
_archiveHandler = archiveHandler;
|
||||
_directoryPath = directoryPath;
|
||||
NFile::NName::NormalizeDirPathPrefix(_directoryPath);
|
||||
@@ -57,17 +67,60 @@ void CArchiveExtractCallback::Init(
|
||||
STDMETHODIMP CArchiveExtractCallback::SetTotal(UInt64 size)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return _extractCallback2->SetTotal(size);
|
||||
_unpTotal = size;
|
||||
if (!_multiArchives && _extractCallback2)
|
||||
return _extractCallback2->SetTotal(size);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
static void NormalizeVals(UInt64 &v1, UInt64 &v2)
|
||||
{
|
||||
const UInt64 kMax = (UInt64)1 << 31;
|
||||
while (v1 > kMax)
|
||||
{
|
||||
v1 >>= 1;
|
||||
v2 >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
static UInt64 MyMultDiv64(UInt64 unpCur, UInt64 unpTotal, UInt64 packTotal)
|
||||
{
|
||||
NormalizeVals(packTotal, unpTotal);
|
||||
NormalizeVals(unpCur, unpTotal);
|
||||
if (unpTotal == 0)
|
||||
unpTotal = 1;
|
||||
return unpCur * packTotal / unpTotal;
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 *completeValue)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
if (!_extractCallback2)
|
||||
return S_OK;
|
||||
|
||||
if (_multiArchives)
|
||||
{
|
||||
if (_ratioMode)
|
||||
return S_OK;
|
||||
if (completeValue != NULL)
|
||||
{
|
||||
UInt64 packCur = LocalProgressSpec->InSize + MyMultDiv64(*completeValue, _unpTotal, _packTotal);
|
||||
return _extractCallback2->SetCompleted(&packCur);
|
||||
}
|
||||
}
|
||||
return _extractCallback2->SetCompleted(completeValue);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
_ratioMode = true;
|
||||
return _localProgress->SetRatioInfo(inSize, outSize);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
void CArchiveExtractCallback::CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath)
|
||||
{
|
||||
fullPath = _directoryPath;
|
||||
@@ -116,10 +169,12 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
|
||||
_encrypted = false;
|
||||
_isSplit = false;
|
||||
_curSize = 0;
|
||||
|
||||
UString fullPath;
|
||||
|
||||
RINOK(GetArchiveItemPath(_archiveHandler, index, _itemDefaultName, fullPath));
|
||||
RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.IsDirectory));
|
||||
|
||||
_filePath = fullPath;
|
||||
|
||||
@@ -137,6 +192,19 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
|
||||
RINOK(IsArchiveItemProp(_archiveHandler, index, kpidEncrypted, _encrypted));
|
||||
|
||||
bool newFileSizeDefined;
|
||||
UInt64 newFileSize;
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
|
||||
newFileSizeDefined = (prop.vt != VT_EMPTY);
|
||||
if (newFileSizeDefined)
|
||||
{
|
||||
newFileSize = ConvertPropVariantToUInt64(prop);
|
||||
_curSize = newFileSize;
|
||||
}
|
||||
}
|
||||
|
||||
if(askExtractMode == NArchive::NExtract::NAskMode::kExtract)
|
||||
{
|
||||
if (_stdOutMode)
|
||||
@@ -163,8 +231,6 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
}
|
||||
}
|
||||
|
||||
RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.IsDirectory));
|
||||
|
||||
RINOK(GetTime(index, kpidCreationTime, _processedFileInfo.CreationTime,
|
||||
_processedFileInfo.IsCreationTimeDefined));
|
||||
RINOK(GetTime(index, kpidLastWriteTime, _processedFileInfo.LastWriteTime,
|
||||
@@ -172,16 +238,6 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
RINOK(GetTime(index, kpidLastAccessTime, _processedFileInfo.LastAccessTime,
|
||||
_processedFileInfo.IsLastAccessTimeDefined));
|
||||
|
||||
bool newFileSizeDefined;
|
||||
UInt64 newFileSize;
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
|
||||
newFileSizeDefined = (prop.vt != VT_EMPTY);
|
||||
if (newFileSizeDefined)
|
||||
newFileSize = ConvertPropVariantToUInt64(prop);
|
||||
}
|
||||
|
||||
bool isAnti = false;
|
||||
RINOK(IsArchiveItemProp(_archiveHandler, index, kpidIsAnti, isAnti));
|
||||
|
||||
@@ -324,8 +380,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
{
|
||||
_outFileStreamSpec = new COutFileStream;
|
||||
CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
|
||||
if (!_outFileStreamSpec->File.Open(fullProcessedPath,
|
||||
_isSplit ? OPEN_ALWAYS: CREATE_ALWAYS))
|
||||
if (!_outFileStreamSpec->Open(fullProcessedPath, _isSplit ? OPEN_ALWAYS: CREATE_ALWAYS))
|
||||
{
|
||||
// if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit)
|
||||
{
|
||||
@@ -360,7 +415,8 @@ STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
|
||||
case NArchive::NExtract::NAskMode::kExtract:
|
||||
_extractMode = true;
|
||||
};
|
||||
return _extractCallback2->PrepareOperation(_filePath, askExtractMode, _isSplit ? &_position: 0);
|
||||
return _extractCallback2->PrepareOperation(_filePath, _processedFileInfo.IsDirectory,
|
||||
askExtractMode, _isSplit ? &_position: 0);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -378,12 +434,21 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
|
||||
_outFileStream.Release();
|
||||
return E_FAIL;
|
||||
}
|
||||
if(_outFileStream != NULL)
|
||||
_outFileStreamSpec->File.SetTime(
|
||||
if (_outFileStream != NULL)
|
||||
{
|
||||
_outFileStreamSpec->SetTime(
|
||||
(WriteCreated && _processedFileInfo.IsCreationTimeDefined) ? &_processedFileInfo.CreationTime : NULL,
|
||||
(WriteAccessed && _processedFileInfo.IsLastAccessTimeDefined) ? &_processedFileInfo.LastAccessTime : NULL,
|
||||
(WriteModified && _processedFileInfo.IsLastWriteTimeDefined) ? &_processedFileInfo.LastWriteTime : &_utcLastWriteTimeDefault);
|
||||
_outFileStream.Release();
|
||||
_curSize = _outFileStreamSpec->ProcessedSize;
|
||||
_outFileStream.Release();
|
||||
}
|
||||
UnpackSize += _curSize;
|
||||
if (_processedFileInfo.IsDirectory)
|
||||
NumFolders++;
|
||||
else
|
||||
NumFiles++;
|
||||
|
||||
if (_extractMode && _processedFileInfo.AttributesAreDefined)
|
||||
NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attributes);
|
||||
RINOK(_extractCallback2->SetOperationResult(operationResult, _encrypted));
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../IPassword.h"
|
||||
|
||||
#include "ExtractMode.h"
|
||||
@@ -18,15 +19,17 @@ class CArchiveExtractCallback:
|
||||
public IArchiveExtractCallback,
|
||||
// public IArchiveVolumeExtractCallback,
|
||||
public ICryptoGetTextPassword,
|
||||
public ICompressProgressInfo,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
|
||||
MY_UNKNOWN_IMP2(ICryptoGetTextPassword, ICompressProgressInfo)
|
||||
// COM_INTERFACE_ENTRY(IArchiveVolumeExtractCallback)
|
||||
|
||||
// IProgress
|
||||
STDMETHOD(SetTotal)(UInt64 size);
|
||||
STDMETHOD(SetCompleted)(const UInt64 *completeValue);
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||
|
||||
// IExtractCallBack
|
||||
STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode);
|
||||
@@ -42,6 +45,7 @@ public:
|
||||
private:
|
||||
CMyComPtr<IInArchive> _archiveHandler;
|
||||
CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2;
|
||||
CMyComPtr<ICompressProgressInfo> _compressProgress;
|
||||
CMyComPtr<ICryptoGetTextPassword> _cryptoGetTextPassword;
|
||||
UString _directoryPath;
|
||||
NExtract::NPathMode::EEnum _pathMode;
|
||||
@@ -76,6 +80,7 @@ private:
|
||||
bool AttributesAreDefined;
|
||||
} _processedFileInfo;
|
||||
|
||||
UInt64 _curSize;
|
||||
COutFileStream *_outFileStreamSpec;
|
||||
CMyComPtr<ISequentialOutStream> _outFileStream;
|
||||
UStringVector _removePathParts;
|
||||
@@ -91,19 +96,39 @@ public:
|
||||
CArchiveExtractCallback():
|
||||
WriteModified(true),
|
||||
WriteCreated(false),
|
||||
WriteAccessed(false)
|
||||
WriteAccessed(false),
|
||||
_multiArchives(false)
|
||||
{}
|
||||
CLocalProgress *LocalProgressSpec;
|
||||
CMyComPtr<ICompressProgressInfo> _localProgress;
|
||||
bool _ratioMode;
|
||||
UInt64 _packTotal;
|
||||
UInt64 _unpTotal;
|
||||
|
||||
bool _multiArchives;
|
||||
UInt64 NumFolders;
|
||||
UInt64 NumFiles;
|
||||
UInt64 UnpackSize;
|
||||
|
||||
void InitForMulti(bool multiArchives,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode)
|
||||
{
|
||||
_multiArchives = multiArchives; NumFolders = NumFiles = UnpackSize = 0;
|
||||
_pathMode = pathMode;
|
||||
_overwriteMode = overwriteMode;
|
||||
}
|
||||
|
||||
void Init(
|
||||
IInArchive *archiveHandler,
|
||||
IFolderArchiveExtractCallback *extractCallback2,
|
||||
bool stdOutMode,
|
||||
const UString &directoryPath,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const UStringVector &removePathParts,
|
||||
const UString &itemDefaultName,
|
||||
const FILETIME &utcLastWriteTimeDefault,
|
||||
UInt32 attributesDefault);
|
||||
UInt32 attributesDefault,
|
||||
UInt64 packSize);
|
||||
|
||||
UInt64 _numErrors;
|
||||
};
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include "Windows/FileMapping.h"
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "../../FileManager/ProgramLocation.h"
|
||||
#include "../../FileManager/RegistryUtils.h"
|
||||
#include "../FileManager/ProgramLocation.h"
|
||||
#include "../FileManager/RegistryUtils.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
|
||||
@@ -14,10 +14,12 @@ using namespace NWindows;
|
||||
|
||||
HRESULT DecompressArchive(
|
||||
IInArchive *archive,
|
||||
UInt64 packSize,
|
||||
const UString &defaultName,
|
||||
const NWildcard::CCensorNode &wildcardCensor,
|
||||
const CExtractOptions &options,
|
||||
IExtractCallbackUI *callback,
|
||||
CArchiveExtractCallback *extractCallbackSpec,
|
||||
UString &errorMessage)
|
||||
{
|
||||
CRecordVector<UInt32> realIndices;
|
||||
@@ -40,9 +42,6 @@ HRESULT DecompressArchive(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
|
||||
CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
|
||||
|
||||
UStringVector removePathParts;
|
||||
|
||||
UString outDir = options.OutputDir;
|
||||
@@ -62,20 +61,18 @@ HRESULT DecompressArchive(
|
||||
callback,
|
||||
options.StdOutMode,
|
||||
outDir,
|
||||
options.PathMode,
|
||||
options.OverwriteMode,
|
||||
removePathParts,
|
||||
options.DefaultItemName,
|
||||
options.ArchiveFileInfo.LastWriteTime,
|
||||
options.ArchiveFileInfo.Attributes);
|
||||
options.ArchiveFileInfo.Attributes,
|
||||
packSize);
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
RINOK(SetProperties(archive, options.Properties));
|
||||
#endif
|
||||
|
||||
HRESULT result = archive->Extract(&realIndices.Front(),
|
||||
realIndices.Size(), options.TestMode? 1: 0,
|
||||
extractCallback);
|
||||
realIndices.Size(), options.TestMode? 1: 0, extractCallbackSpec);
|
||||
|
||||
return callback->ExtractResult(result);
|
||||
}
|
||||
@@ -87,10 +84,32 @@ HRESULT DecompressArchives(
|
||||
const CExtractOptions &optionsSpec,
|
||||
IOpenCallbackUI *openCallback,
|
||||
IExtractCallbackUI *extractCallback,
|
||||
UString &errorMessage)
|
||||
UString &errorMessage,
|
||||
CDecompressStat &stat)
|
||||
{
|
||||
stat.Clear();
|
||||
CExtractOptions options = optionsSpec;
|
||||
for (int i = 0; i < archivePaths.Size(); i++)
|
||||
int i;
|
||||
UInt64 totalPackSize = 0;
|
||||
for (i = 0; i < archivePaths.Size(); i++)
|
||||
{
|
||||
const UString &archivePath = archivePaths[i];
|
||||
NFile::NFind::CFileInfoW archiveFileInfo;
|
||||
if (!NFile::NFind::FindFile(archivePath, archiveFileInfo))
|
||||
throw "there is no such archive";
|
||||
if (archiveFileInfo.IsDirectory())
|
||||
throw "can't decompress folder";
|
||||
totalPackSize += archiveFileInfo.Size;
|
||||
}
|
||||
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
|
||||
CMyComPtr<IArchiveExtractCallback> ec(extractCallbackSpec);
|
||||
bool multi = (archivePaths.Size() > 1);
|
||||
extractCallbackSpec->InitForMulti(multi, options.PathMode, options.OverwriteMode);
|
||||
if (multi)
|
||||
{
|
||||
RINOK(extractCallback->SetTotal(totalPackSize));
|
||||
}
|
||||
for (i = 0; i < archivePaths.Size(); i++)
|
||||
{
|
||||
const UString &archivePath = archivePaths[i];
|
||||
NFile::NFind::CFileInfoW archiveFileInfo;
|
||||
@@ -140,10 +159,19 @@ HRESULT DecompressArchives(
|
||||
|
||||
options.DefaultItemName = archiveLink.GetDefaultItemName();
|
||||
RINOK(DecompressArchive(
|
||||
archiveLink.GetArchive(), archiveLink.GetDefaultItemName(),
|
||||
wildcardCensor, options, extractCallback, errorMessage));
|
||||
archiveLink.GetArchive(),
|
||||
archiveFileInfo.Size,
|
||||
archiveLink.GetDefaultItemName(),
|
||||
wildcardCensor, options, extractCallback, extractCallbackSpec, errorMessage));
|
||||
extractCallbackSpec->LocalProgressSpec->InSize += archiveFileInfo.Size;
|
||||
extractCallbackSpec->LocalProgressSpec->OutSize = extractCallbackSpec->UnpackSize;
|
||||
if (!errorMessage.IsEmpty())
|
||||
return E_FAIL;
|
||||
}
|
||||
stat.NumFolders = extractCallbackSpec->NumFolders;
|
||||
stat.NumFiles = extractCallbackSpec->NumFiles;
|
||||
stat.UnpackSize = extractCallbackSpec->UnpackSize;
|
||||
stat.NumArchives = archivePaths.Size();
|
||||
stat.PackSize = extractCallbackSpec->LocalProgressSpec->InSize;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,16 @@ public:
|
||||
*/
|
||||
};
|
||||
|
||||
struct CDecompressStat
|
||||
{
|
||||
UInt64 NumArchives;
|
||||
UInt64 UnpackSize;
|
||||
UInt64 PackSize;
|
||||
UInt64 NumFolders;
|
||||
UInt64 NumFiles;
|
||||
void Clear() { NumArchives = PackSize = UnpackSize = NumFolders = NumFiles = 0; }
|
||||
};
|
||||
|
||||
HRESULT DecompressArchives(
|
||||
CCodecs *codecs,
|
||||
UStringVector &archivePaths, UStringVector &archivePathsFull,
|
||||
@@ -61,6 +71,7 @@ HRESULT DecompressArchives(
|
||||
const CExtractOptions &options,
|
||||
IOpenCallbackUI *openCallback,
|
||||
IExtractCallbackUI *extractCallback,
|
||||
UString &errorMessage);
|
||||
UString &errorMessage,
|
||||
CDecompressStat &stat);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define __IFILEEXTRACTCALLBACK_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
#include "../../IDecl.h"
|
||||
|
||||
namespace NOverwriteAnswer
|
||||
{
|
||||
@@ -18,18 +19,14 @@ namespace NOverwriteAnswer
|
||||
};
|
||||
}
|
||||
|
||||
// {23170F69-40C1-278A-0000-000100070000}
|
||||
DEFINE_GUID(IID_IFolderArchiveExtractCallback,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00);
|
||||
MIDL_INTERFACE("23170F69-40C1-278A-0000-000100070000")
|
||||
IFolderArchiveExtractCallback: public IProgress
|
||||
DECL_INTERFACE_SUB(IFolderArchiveExtractCallback, IProgress, 0x01, 0x07)
|
||||
{
|
||||
public:
|
||||
STDMETHOD(AskOverwrite)(
|
||||
const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
|
||||
Int32 *answer) PURE;
|
||||
STDMETHOD(PrepareOperation)(const wchar_t *name, Int32 askExtractMode, const UInt64 *position) PURE;
|
||||
STDMETHOD(PrepareOperation)(const wchar_t *name, bool isFolder, Int32 askExtractMode, const UInt64 *position) PURE;
|
||||
STDMETHOD(MessageError)(const wchar_t *message) PURE;
|
||||
STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted) PURE;
|
||||
};
|
||||
|
||||
@@ -156,6 +156,33 @@ HRESULT OpenArchive(
|
||||
orderIndices2 += orderIndices;
|
||||
orderIndices = orderIndices2;
|
||||
}
|
||||
else if (extension == L"000" || extension == L"001")
|
||||
{
|
||||
CByteBuffer byteBuffer;
|
||||
const UInt32 kBufferSize = (1 << 10);
|
||||
byteBuffer.SetCapacity(kBufferSize);
|
||||
Byte *buffer = byteBuffer;
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
UInt32 processedSize;
|
||||
RINOK(ReadStream(inStream, buffer, kBufferSize, &processedSize));
|
||||
if (processedSize >= 16)
|
||||
{
|
||||
Byte kRarHeader[] = {0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00};
|
||||
if (TestSignature(buffer, kRarHeader, 7) && buffer[9] == 0x73 && (buffer[10] && 1) != 0)
|
||||
{
|
||||
for (int i = 0; i < orderIndices.Size(); i++)
|
||||
{
|
||||
int index = orderIndices[i];
|
||||
const CArcInfoEx &ai = codecs->Formats[index];
|
||||
if (ai.Name.CompareNoCase(L"rar") != 0)
|
||||
continue;
|
||||
orderIndices.Delete(i--);
|
||||
orderIndices.Insert(0, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT badResult = S_OK;
|
||||
|
||||
@@ -332,9 +332,17 @@ static HRESULT Compress(
|
||||
|
||||
CObjectVector<CUpdatePair2> updatePairs2;
|
||||
UpdateProduce(updatePairs, actionSet, updatePairs2);
|
||||
|
||||
UInt32 numFiles = 0;
|
||||
for (int i = 0; i < updatePairs2.Size(); i++)
|
||||
if (updatePairs2[i].NewData)
|
||||
numFiles++;
|
||||
|
||||
RINOK(callback->SetNumFiles(numFiles));
|
||||
|
||||
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
updateCallbackSpec->ShareForWrite = shareForWrite;
|
||||
updateCallbackSpec->StdInMode = stdInMode;
|
||||
|
||||
@@ -140,16 +140,18 @@ struct CUpdateErrorInfo: public CErrorInfo
|
||||
{
|
||||
};
|
||||
|
||||
#define INTERFACE_IUpdateCallbackUI2(x) \
|
||||
INTERFACE_IUpdateCallbackUI(x) \
|
||||
virtual HRESULT OpenResult(const wchar_t *name, HRESULT result) x; \
|
||||
virtual HRESULT StartScanning() x; \
|
||||
virtual HRESULT CanNotFindError(const wchar_t *name, DWORD systemError) x; \
|
||||
virtual HRESULT FinishScanning() x; \
|
||||
virtual HRESULT StartArchive(const wchar_t *name, bool updating) x; \
|
||||
virtual HRESULT FinishArchive() x; \
|
||||
|
||||
struct IUpdateCallbackUI2: public IUpdateCallbackUI
|
||||
{
|
||||
virtual HRESULT OpenResult(const wchar_t *name, HRESULT result) = 0;
|
||||
|
||||
virtual HRESULT StartScanning() = 0;
|
||||
virtual HRESULT CanNotFindError(const wchar_t *name, DWORD systemError) = 0;
|
||||
virtual HRESULT FinishScanning() = 0;
|
||||
|
||||
virtual HRESULT StartArchive(const wchar_t *name, bool updating) = 0;
|
||||
virtual HRESULT FinishArchive() = 0;
|
||||
INTERFACE_IUpdateCallbackUI2(=0)
|
||||
};
|
||||
|
||||
HRESULT UpdateArchive(
|
||||
|
||||
@@ -39,6 +39,14 @@ STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const UInt64 *completeValue)
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
return Callback->SetRatioInfo(inSize, outSize);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
STATPROPSTG kProperties[] =
|
||||
{
|
||||
|
||||
@@ -7,35 +7,46 @@
|
||||
#include "Common/MyString.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
#include "../Common/UpdatePair.h"
|
||||
#include "../Common/UpdateProduce.h"
|
||||
|
||||
#define INTERFACE_IUpdateCallbackUI(x) \
|
||||
virtual HRESULT SetTotal(UInt64 size) x; \
|
||||
virtual HRESULT SetCompleted(const UInt64 *completeValue) x; \
|
||||
virtual HRESULT SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) x; \
|
||||
virtual HRESULT CheckBreak() x; \
|
||||
virtual HRESULT Finilize() x; \
|
||||
virtual HRESULT SetNumFiles(UInt64 numFiles) x; \
|
||||
virtual HRESULT GetStream(const wchar_t *name, bool isAnti) x; \
|
||||
virtual HRESULT OpenFileError(const wchar_t *name, DWORD systemError) x; \
|
||||
virtual HRESULT SetOperationResult(Int32 operationResult) x; \
|
||||
virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \
|
||||
|
||||
// virtual HRESULT CloseProgress() { return S_OK; };
|
||||
|
||||
struct IUpdateCallbackUI
|
||||
{
|
||||
virtual HRESULT SetTotal(UInt64 size) = 0;
|
||||
virtual HRESULT SetCompleted(const UInt64 *completeValue) = 0;
|
||||
virtual HRESULT CheckBreak() = 0;
|
||||
virtual HRESULT Finilize() = 0;
|
||||
virtual HRESULT GetStream(const wchar_t *name, bool isAnti) = 0;
|
||||
virtual HRESULT OpenFileError(const wchar_t *name, DWORD systemError) = 0;
|
||||
virtual HRESULT SetOperationResult(Int32 operationResult) = 0;
|
||||
virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) = 0;
|
||||
virtual HRESULT CloseProgress() { return S_OK; };
|
||||
INTERFACE_IUpdateCallbackUI(=0)
|
||||
};
|
||||
|
||||
class CArchiveUpdateCallback:
|
||||
public IArchiveUpdateCallback2,
|
||||
public ICryptoGetTextPassword2,
|
||||
public ICompressProgressInfo,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP2(IArchiveUpdateCallback2,
|
||||
ICryptoGetTextPassword2)
|
||||
MY_UNKNOWN_IMP3(
|
||||
IArchiveUpdateCallback2,
|
||||
ICryptoGetTextPassword2,
|
||||
ICompressProgressInfo)
|
||||
|
||||
// IProgress
|
||||
STDMETHOD(SetTotal)(UInt64 size);
|
||||
STDMETHOD(SetCompleted)(const UInt64 *completeValue);
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||
|
||||
// IUpdateCallback
|
||||
STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator);
|
||||
|
||||
@@ -648,6 +648,14 @@ SOURCE=..\..\Common\FileStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\RegisterArc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -95,7 +95,7 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 askExtractMode, const UInt64 *position)
|
||||
STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, bool /* isFolder */, Int32 askExtractMode, const UInt64 *position)
|
||||
{
|
||||
switch (askExtractMode)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
|
||||
Int32 *answer);
|
||||
STDMETHOD (PrepareOperation)(const wchar_t *name, Int32 askExtractMode, const UInt64 *position);
|
||||
STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, Int32 askExtractMode, const UInt64 *position);
|
||||
|
||||
STDMETHOD(MessageError)(const wchar_t *message);
|
||||
STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted);
|
||||
|
||||
@@ -57,7 +57,17 @@ static CPropIdToName kPropIdToName[] =
|
||||
{ kpidGroup, L"Group" },
|
||||
{ kpidBlock, L"Block" },
|
||||
{ kpidComment, L"Comment" },
|
||||
{ kpidPosition, L"Position" }
|
||||
{ kpidPosition, L"Position" },
|
||||
{ kpidPrefix, L"Prefix" },
|
||||
{ kpidNumSubFolders, L"Folders" },
|
||||
{ kpidNumSubFiles, L"Files" },
|
||||
{ kpidUnpackVer, L"Version" },
|
||||
{ kpidVolume, L"Volume" },
|
||||
{ kpidIsVolume, L"Multivolume" },
|
||||
{ kpidOffset, L"Offset" },
|
||||
{ kpidLinks, L"Links" },
|
||||
{ kpidNumBlocks, L"Blocks" },
|
||||
{ kpidNumVolumes, L"Volumes" }
|
||||
};
|
||||
|
||||
static const char kEmptyAttributeChar = '.';
|
||||
@@ -184,6 +194,19 @@ void CFieldPrinter::Init(const CFieldInfoInit *standardFieldTable, int numItems)
|
||||
}
|
||||
}
|
||||
|
||||
static UString GetPropName(PROPID propID, BSTR name)
|
||||
{
|
||||
for (int i = 0; i < sizeof(kPropIdToName) / sizeof(kPropIdToName[0]); i++)
|
||||
{
|
||||
const CPropIdToName &propIdToName = kPropIdToName[i];
|
||||
if (propIdToName.PropID == propID)
|
||||
return propIdToName.Name;
|
||||
}
|
||||
if (name)
|
||||
return name;
|
||||
return L"?";
|
||||
}
|
||||
|
||||
HRESULT CFieldPrinter::Init(IInArchive *archive)
|
||||
{
|
||||
Clear();
|
||||
@@ -197,21 +220,7 @@ HRESULT CFieldPrinter::Init(IInArchive *archive)
|
||||
RINOK(archive->GetPropertyInfo(i, &name, &propID, &vt));
|
||||
CFieldInfo fieldInfo;
|
||||
fieldInfo.PropID = propID;
|
||||
if (name != NULL)
|
||||
fieldInfo.Name = name;
|
||||
else
|
||||
{
|
||||
fieldInfo.Name = L"Unknown";
|
||||
for (int i = 0; i < sizeof(kPropIdToName) / sizeof(kPropIdToName[0]); i++)
|
||||
{
|
||||
const CPropIdToName &propIdToName = kPropIdToName[i];
|
||||
if (propIdToName.PropID == propID)
|
||||
{
|
||||
fieldInfo.Name = propIdToName.Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fieldInfo.Name = GetPropName(propID, name);
|
||||
_fields.Add(fieldInfo);
|
||||
}
|
||||
return S_OK;
|
||||
@@ -463,14 +472,28 @@ HRESULT ListArchives(
|
||||
{
|
||||
g_StdOut << endl << kListing << archiveName << endl << endl;
|
||||
|
||||
NCOM::CPropVariant propVariant;
|
||||
RINOK(archive->GetArchiveProperty(kpidComment, &propVariant));
|
||||
if (propVariant.vt != VT_EMPTY)
|
||||
UInt32 numProps;
|
||||
if (archive->GetNumberOfArchiveProperties(&numProps) == S_OK)
|
||||
{
|
||||
UString s = ConvertPropertyToString(propVariant, kpidComment);
|
||||
if (!s.IsEmpty())
|
||||
g_StdOut << "Comment:\n" << s << "\n\n";
|
||||
for (UInt32 i = 0; i < numProps; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
if (archive->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK)
|
||||
continue;
|
||||
NCOM::CPropVariant prop;
|
||||
if (archive->GetArchiveProperty(propID, &prop) != S_OK)
|
||||
continue;
|
||||
UString s = ConvertPropertyToString(prop, propID);
|
||||
if (!s.IsEmpty())
|
||||
g_StdOut << GetPropName(propID, name) << " = " << s << endl;
|
||||
}
|
||||
}
|
||||
if (techMode)
|
||||
g_StdOut << "----------\n";
|
||||
if (numProps > 0)
|
||||
g_StdOut << endl;
|
||||
}
|
||||
|
||||
if (enableHeaders && !techMode)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Main.cpp
|
||||
/ Main.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
@@ -396,12 +396,13 @@ int Main2(
|
||||
eo.Properties = options.ExtractProperties;
|
||||
#endif
|
||||
UString errorMessage;
|
||||
CDecompressStat stat;
|
||||
HRESULT result = DecompressArchives(
|
||||
codecs,
|
||||
options.ArchivePathsSorted,
|
||||
options.ArchivePathsFullSorted,
|
||||
options.WildcardCensor.Pairs.Front().Head,
|
||||
eo, &openCallback, ecs, errorMessage);
|
||||
eo, &openCallback, ecs, errorMessage, stat);
|
||||
if (!errorMessage.IsEmpty())
|
||||
{
|
||||
stdStream << endl << "Error: " << errorMessage;
|
||||
@@ -409,15 +410,20 @@ int Main2(
|
||||
result = E_FAIL;
|
||||
}
|
||||
|
||||
stdStream << endl << endl << "Total:" << endl;
|
||||
if (ecs->NumArchives > 1)
|
||||
{
|
||||
stdStream << endl << endl << "Total:" << endl;
|
||||
stdStream << "Archives: " << ecs->NumArchives << endl;
|
||||
{
|
||||
stdStream << "Folders: " << stat.NumFolders << endl;
|
||||
stdStream << "Files: " << stat.NumFiles << endl;
|
||||
stdStream << "Size: " << stat.UnpackSize << endl;
|
||||
stdStream << "Compressed: " << stat.PackSize << endl;
|
||||
}
|
||||
if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
|
||||
{
|
||||
if (ecs->NumArchives > 1)
|
||||
{
|
||||
stdStream << endl;
|
||||
if (ecs->NumArchiveErrors != 0)
|
||||
stdStream << "Archive Errors: " << ecs->NumArchiveErrors << endl;
|
||||
if (ecs->NumFileErrors != 0)
|
||||
|
||||
@@ -112,6 +112,11 @@ HRESULT CUpdateCallbackConsole::Finilize()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetNumFiles(UInt64 /* numFiles */)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetTotal(UInt64 size)
|
||||
{
|
||||
MT_LOCK
|
||||
@@ -137,6 +142,15 @@ HRESULT CUpdateCallbackConsole::SetCompleted(const UInt64 *completeValue)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetRatioInfo(const UInt64 * /* inSize */, const UInt64 * /* outSize */)
|
||||
{
|
||||
/*
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
*/
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool isAnti)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
@@ -46,24 +46,7 @@ public:
|
||||
m_PercentPrinter.OutStream = outStream;
|
||||
}
|
||||
|
||||
HRESULT OpenResult(const wchar_t *name, HRESULT result);
|
||||
|
||||
HRESULT StartScanning();
|
||||
HRESULT CanNotFindError(const wchar_t *name, DWORD systemError);
|
||||
HRESULT FinishScanning();
|
||||
|
||||
HRESULT StartArchive(const wchar_t *name, bool updating);
|
||||
HRESULT FinishArchive();
|
||||
|
||||
HRESULT CheckBreak();
|
||||
HRESULT Finilize();
|
||||
HRESULT SetTotal(UInt64 size);
|
||||
HRESULT SetCompleted(const UInt64 *completeValue);
|
||||
|
||||
HRESULT GetStream(const wchar_t *name, bool isAnti);
|
||||
HRESULT OpenFileError(const wchar_t *name, DWORD systemError);
|
||||
HRESULT SetOperationResult(Int32 operationResult);
|
||||
HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password);
|
||||
INTERFACE_IUpdateCallbackUI2(;)
|
||||
|
||||
UStringVector FailedFiles;
|
||||
CRecordVector<HRESULT> FailedCodes;
|
||||
|
||||
@@ -51,6 +51,7 @@ WIN_OBJS = \
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\FilePathAutoRename.obj \
|
||||
$O\FileStreams.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
UI_COMMON_OBJS = \
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
#include "Windows/Menu.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#include "../../FileManager/FormatUtils.h"
|
||||
#include "../../FileManager/ProgramLocation.h"
|
||||
#include "../FileManager/FormatUtils.h"
|
||||
#include "../FileManager/ProgramLocation.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
#include "../Common/ArchiveName.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "../../FileManager/LangUtils.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
#endif
|
||||
|
||||
#include "resource.h"
|
||||
@@ -37,7 +37,7 @@
|
||||
// #include "CompressEngine.h"
|
||||
#include "MyMessages.h"
|
||||
|
||||
#include "../Resource/Extract/resource.h"
|
||||
#include "../GUI/ExtractRes.h"
|
||||
#include "../Common/CompressCall.h"
|
||||
|
||||
using namespace NWindows;
|
||||
@@ -311,7 +311,7 @@ static UString GetReducedString(const UString &s)
|
||||
|
||||
static const wchar_t *kExtractExludeExtensions[] =
|
||||
{
|
||||
L"txt", L"htm", L"html", L"xml", L"doc", L"xls",
|
||||
L"txt", L"htm", L"html", L"xml",
|
||||
L"bmp", L"gif", L"jpeg", L"jpg"
|
||||
};
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ DEFINE_GUID(CLSID_CZipContextMenu,
|
||||
|
||||
#include "Common/MyString.h"
|
||||
|
||||
#include "../../FileManager/PluginInterface.h"
|
||||
#include "../../FileManager/MyCom2.h"
|
||||
#include "../FileManager/PluginInterface.h"
|
||||
#include "../FileManager/MyCom2.h"
|
||||
|
||||
|
||||
class CZipContextMenu:
|
||||
|
||||
@@ -20,9 +20,8 @@
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/Registry.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../../FileManager/LangUtils.h"
|
||||
#include "../Agent/Agent.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
#include "../FileManager/IFolder.h"
|
||||
|
||||
#include "ContextMenu.h"
|
||||
#include "OptionsDialog.h"
|
||||
@@ -51,7 +50,6 @@ public:
|
||||
CShellExtClassFactory() { InterlockedIncrement(&g_DllRefCount); }
|
||||
~CShellExtClassFactory() { InterlockedDecrement(&g_DllRefCount); }
|
||||
|
||||
|
||||
MY_UNKNOWN_IMP1_MT(IClassFactory)
|
||||
|
||||
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, void**);
|
||||
@@ -258,16 +256,6 @@ STDAPI CreateObject(
|
||||
LoadLangOneTime();
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID == CLSID_CAgentArchiveHandler)
|
||||
{
|
||||
if (*interfaceID == IID_IFolderManager)
|
||||
{
|
||||
CMyComPtr<IFolderManager> manager = new CArchiveFolderManager;
|
||||
*outObject = manager.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
if (*classID == CLSID_CSevenZipOptions)
|
||||
{
|
||||
if (*interfaceID == IID_IPluginOptions)
|
||||
@@ -291,13 +279,6 @@ STDAPI GetPluginProperty(PROPID propID, PROPVARIANT *value)
|
||||
if ((value->bstrVal = ::SysAllocString(L"7-Zip")) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
case NPlugin::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CAgentArchiveHandler, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NPlugin::kOptionsClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
@@ -305,11 +286,6 @@ STDAPI GetPluginProperty(PROPID propID, PROPVARIANT *value)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
/*
|
||||
case NArchive::kType:
|
||||
propVariant = UINT32(0);
|
||||
break;
|
||||
*/
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
@@ -72,7 +72,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
@@ -99,7 +99,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "_MBCS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
@@ -128,7 +128,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
@@ -182,14 +182,6 @@ SOURCE=.\StdAfx.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveExtractCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveExtractCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveName.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -198,14 +190,6 @@ SOURCE=..\Common\ArchiveName.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveOpenCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveOpenCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CompressCall.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -214,106 +198,6 @@ SOURCE=..\Common\CompressCall.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DefaultName.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DefaultName.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\EnumDirItems.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\EnumDirItems.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ExtractingFilePath.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ExtractingFilePath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\HandlerLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\LoadCodecs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\LoadCodecs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OpenArchive.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OpenArchive.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\PropIDUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\PropIDUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\SortUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\SortUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateAction.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateAction.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdatePair.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdatePair.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateProduce.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateProduce.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\WorkDir.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\WorkDir.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ZipRegistry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -343,86 +227,30 @@ SOURCE=.\MyMessages.h
|
||||
# End Group
|
||||
# Begin Group "Dialogs"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "Options"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "SystemPage"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SystemPage\SystemPage.cpp
|
||||
SOURCE=.\FoldersPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SystemPage\SystemPage.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "FoldersPage"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FoldersPage\FoldersPage.cpp
|
||||
SOURCE=.\FoldersPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FoldersPage\FoldersPage.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Group "Agent"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\Agent.cpp
|
||||
SOURCE=.\FoldersPageRes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\Agent.h
|
||||
SOURCE=.\SystemPage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\AgentOut.cpp
|
||||
SOURCE=.\SystemPage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\AgentProxy.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\AgentProxy.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\ArchiveFolder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\ArchiveFolderOpen.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\ArchiveFolderOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\IFileExtractCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\IFolderArchive.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\UpdateCallbackAgent.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\UpdateCallbackAgent.h
|
||||
SOURCE=.\SystemPageRes.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "FileManager"
|
||||
@@ -430,87 +258,47 @@ SOURCE=..\Agent\UpdateCallbackAgent.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\FormatUtils.cpp
|
||||
SOURCE=..\FileManager\FormatUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\FormatUtils.h
|
||||
SOURCE=..\FileManager\FormatUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\HelpUtils.cpp
|
||||
SOURCE=..\FileManager\HelpUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\HelpUtils.h
|
||||
SOURCE=..\FileManager\HelpUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\IFolder.h
|
||||
SOURCE=..\FileManager\IFolder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\LangUtils.cpp
|
||||
SOURCE=..\FileManager\LangUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\LangUtils.h
|
||||
SOURCE=..\FileManager\LangUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\ProgramLocation.cpp
|
||||
SOURCE=..\FileManager\ProgramLocation.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\ProgramLocation.h
|
||||
SOURCE=..\FileManager\ProgramLocation.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\RegistryUtils.cpp
|
||||
SOURCE=..\FileManager\RegistryUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\FileManager\RegistryUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7-zip common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilePathAutoRename.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilePathAutoRename.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FileStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FileStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
SOURCE=..\FileManager\RegistryUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "C"
|
||||
@@ -518,24 +306,6 @@ SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sort.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sort.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
@@ -745,22 +515,6 @@ SOURCE=..\..\..\Windows\Menu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariantConversions.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariantConversions.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Registry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "resource.h"
|
||||
#include "FoldersPageRes.h"
|
||||
#include "FoldersPage.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
@@ -10,10 +10,10 @@
|
||||
#include "Windows/Shell.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#include "../../../FileManager/HelpUtils.h"
|
||||
#include "../../Common/ZipRegistry.h"
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "../../../FileManager/LangUtils.h"
|
||||
#include "../FileManager/HelpUtils.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "Windows/Control/PropertyPage.h"
|
||||
|
||||
#include "../../Common/ZipRegistry.h"
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
class CFoldersPage : public NWindows::NControl::CPropertyPage
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "resource.h"
|
||||
#include "../../../GuiCommon.rc"
|
||||
#include "FoldersPageRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 196
|
||||
#define ySize2 140
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "../../FileManager/LangUtils.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
#endif
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/Control/PropertyPage.h"
|
||||
|
||||
#include "../../FileManager/LangUtils.h"
|
||||
#include "FoldersPage/FoldersPage.h"
|
||||
#include "FoldersPage/resource.h"
|
||||
#include "SystemPage/SystemPage.h"
|
||||
#include "SystemPage/resource.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
#include "FoldersPage.h"
|
||||
#include "FoldersPageRes.h"
|
||||
#include "SystemPage.h"
|
||||
#include "SystemPageRes.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef __SEVENZIP_OPTIONSDIALOG_H
|
||||
#define __SEVENZIP_OPTIONSDIALOG_H
|
||||
|
||||
#include "../../FileManager/PluginInterface.h"
|
||||
#include "../FileManager/PluginInterface.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
// {23170F69-40C1-278D-1000-000100020000}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
// SystemPage.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "resource.h"
|
||||
#include "../resource.h"
|
||||
#include "SystemPageRes.h"
|
||||
#include "SystemPage.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/Control/ListView.h"
|
||||
|
||||
#include "SystemPage.h"
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "../../Common/ZipRegistry.h"
|
||||
#include "../RegistryContextMenu.h"
|
||||
#include "../ContextMenuFlags.h"
|
||||
#include "../FileManager/HelpUtils.h"
|
||||
#include "../FileManager/LangUtils.h"
|
||||
#include "../FileManager/FormatUtils.h"
|
||||
|
||||
#include "../../../FileManager/HelpUtils.h"
|
||||
#include "../../../FileManager/LangUtils.h"
|
||||
#include "../../../FileManager/FormatUtils.h"
|
||||
#include "RegistryContextMenu.h"
|
||||
#include "ContextMenuFlags.h"
|
||||
|
||||
using namespace NContextMenuFlags;
|
||||
|
||||
@@ -32,8 +33,8 @@ static LPCWSTR kSystemTopic = L"fm/plugins/7-zip/options.htm#system";
|
||||
struct CContextMenuItem
|
||||
{
|
||||
int ControlID;
|
||||
UINT32 LangID;
|
||||
UINT32 Flag;
|
||||
UInt32 LangID;
|
||||
UInt32 Flag;
|
||||
};
|
||||
|
||||
static CContextMenuItem kMenuItems[] =
|
||||
@@ -50,7 +51,7 @@ static CContextMenuItem kMenuItems[] =
|
||||
{ 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, kCompressToZipEmail}
|
||||
};
|
||||
|
||||
const int kNumMenuItems = sizeof(kMenuItems) / sizeof(kMenuItems[0]);
|
||||
@@ -65,7 +66,7 @@ bool CSystemPage::OnInit()
|
||||
|
||||
CheckButton(IDC_SYSTEM_CASCADED_MENU, ReadCascadedMenu());
|
||||
|
||||
UINT32 contextMenuFlags;
|
||||
UInt32 contextMenuFlags;
|
||||
if (!ReadContextMenuStatus(contextMenuFlags))
|
||||
contextMenuFlags = NContextMenuFlags::GetDefaultFlags();
|
||||
|
||||
@@ -76,7 +77,7 @@ bool CSystemPage::OnInit()
|
||||
NRegistryAssociations::CheckContextMenuHandler());
|
||||
*/
|
||||
|
||||
UINT32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT;
|
||||
UInt32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT;
|
||||
m_ListView.SetExtendedListViewStyle(newFlags, newFlags);
|
||||
|
||||
UString s; // = TEXT("Items"); // LangLoadString(IDS_PROPERTY_EXTENSION, 0x02000205);
|
||||
@@ -154,7 +155,7 @@ LONG CSystemPage::OnApply()
|
||||
}
|
||||
SaveCascadedMenu(IsButtonCheckedBool(IDC_SYSTEM_CASCADED_MENU));
|
||||
|
||||
UINT32 flags = 0;
|
||||
UInt32 flags = 0;
|
||||
for (int i = 0; i < kNumMenuItems; i++)
|
||||
if (m_ListView.GetCheckState(i))
|
||||
flags |= kMenuItems[i].Flag;
|
||||
@@ -181,7 +182,7 @@ bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
|
||||
}
|
||||
|
||||
bool CSystemPage::OnNotify(UINT aControlID, LPNMHDR lParam)
|
||||
bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
|
||||
{
|
||||
if (lParam->hwndFrom == HWND(m_ListView))
|
||||
{
|
||||
@@ -191,7 +192,7 @@ bool CSystemPage::OnNotify(UINT aControlID, LPNMHDR lParam)
|
||||
return OnItemChanged((const NMLISTVIEW *)lParam);
|
||||
}
|
||||
}
|
||||
return CPropertyPage::OnNotify(aControlID, lParam);
|
||||
return CPropertyPage::OnNotify(controlID, lParam);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "Windows/Control/PropertyPage.h"
|
||||
#include "Windows/Control/ListView.h"
|
||||
|
||||
#include "../../Common/LoadCodecs.h"
|
||||
#include "../Common/LoadCodecs.h"
|
||||
|
||||
class CSystemPage: public NWindows::NControl::CPropertyPage
|
||||
{
|
||||
@@ -16,10 +16,10 @@ class CSystemPage: public NWindows::NControl::CPropertyPage
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
virtual void OnNotifyHelp();
|
||||
virtual bool OnNotify(UINT aControlID, LPNMHDR lParam);
|
||||
virtual bool OnNotify(UINT controlID, LPNMHDR lParam);
|
||||
virtual bool OnItemChanged(const NMLISTVIEW *info);
|
||||
virtual LONG OnApply();
|
||||
virtual bool OnButtonClicked(int aButtonID, HWND aButtonHWND);
|
||||
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "resource.h"
|
||||
#include "../../../GuiCommon.rc"
|
||||
#include "SystemPageRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 196
|
||||
#define ySize2 164
|
||||
@@ -1,11 +1,9 @@
|
||||
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 ../../../ \
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -Ob2 \
|
||||
-DLANG \
|
||||
-DNEW_FOLDER_INTERFACE \
|
||||
-DWIN_LONG_PATH \
|
||||
-DEXTERNAL_CODECS \
|
||||
|
||||
EXPLORER_OBJS = \
|
||||
$O\DllExports.obj \
|
||||
@@ -13,6 +11,8 @@ EXPLORER_OBJS = \
|
||||
$O\MyMessages.obj \
|
||||
$O\OptionsDialog.obj \
|
||||
$O\RegistryContextMenu.obj \
|
||||
$O\SystemPage.obj \
|
||||
$O\FoldersPage.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\IntToString.obj \
|
||||
@@ -37,8 +37,6 @@ WIN_OBJS = \
|
||||
$O\FileIO.obj \
|
||||
$O\FileName.obj \
|
||||
$O\Menu.obj \
|
||||
$O\PropVariant.obj \
|
||||
$O\PropVariantConversions.obj \
|
||||
$O\Registry.obj \
|
||||
$O\ResourceString.obj \
|
||||
$O\Shell.obj \
|
||||
@@ -49,40 +47,11 @@ WIN_CTRL_OBJS = \
|
||||
$O\Dialog.obj \
|
||||
$O\PropertyPage.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\FilePathAutoRename.obj \
|
||||
$O\FileStreams.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
UI_COMMON_OBJS = \
|
||||
$O\ArchiveExtractCallback.obj \
|
||||
$O\ArchiveName.obj \
|
||||
$O\ArchiveOpenCallback.obj \
|
||||
$O\CompressCall.obj \
|
||||
$O\DefaultName.obj \
|
||||
$O\EnumDirItems.obj \
|
||||
$O\ExtractingFilePath.obj \
|
||||
$O\LoadCodecs.obj \
|
||||
$O\OpenArchive.obj \
|
||||
$O\PropIDUtils.obj \
|
||||
$O\SortUtils.obj \
|
||||
$O\UpdateAction.obj \
|
||||
$O\UpdateCallback.obj \
|
||||
$O\UpdatePair.obj \
|
||||
$O\UpdateProduce.obj \
|
||||
$O\WorkDir.obj \
|
||||
$O\ZipRegistry.obj \
|
||||
|
||||
AGENT_OBJS = \
|
||||
$O\Agent.obj \
|
||||
$O\AgentOut.obj \
|
||||
$O\AgentProxy.obj \
|
||||
$O\ArchiveFolder.obj \
|
||||
$O\ArchiveFolderOpen.obj \
|
||||
$O\ArchiveFolderOut.obj \
|
||||
$O\UpdateCallbackAgent.obj \
|
||||
|
||||
|
||||
FM_COMMON_OBJS = \
|
||||
$O\FormatUtils.obj \
|
||||
$O\HelpUtils.obj \
|
||||
@@ -91,8 +60,6 @@ FM_COMMON_OBJS = \
|
||||
$O\RegistryUtils.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\Sort.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
OBJS = \
|
||||
@@ -101,14 +68,9 @@ OBJS = \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(WIN_CTRL_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(UI_COMMON_OBJS) \
|
||||
$(AGENT_OBJS) \
|
||||
$(FM_COMMON_OBJS)\
|
||||
$(C_OBJS) \
|
||||
$O\SystemPage.obj \
|
||||
$O\FoldersPage.obj \
|
||||
$O\CopyCoder.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
@@ -121,19 +83,9 @@ $(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(UI_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AGENT_OBJS): ../Agent/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(FM_COMMON_OBJS): ../../FileManager/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\SystemPage.obj: SystemPage/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\FoldersPage.obj: FoldersPage/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(FM_COMMON_OBJS): ../FileManager/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(C_OBJS): ../../../../C/$(*B).c
|
||||
$(COMPL_O2)
|
||||
|
||||
@@ -33,6 +33,6 @@ BEGIN
|
||||
IDS_CONFIG_DIALOG_CAPTION "7-Zip Options"
|
||||
END
|
||||
|
||||
#include "FoldersPage/resource.rc"
|
||||
#include "SystemPage/resource.rc"
|
||||
#include "FoldersPage.rc"
|
||||
#include "SystemPage.rc"
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, INT32 /* askExtractMode */, const UINT64 * /* position */)
|
||||
STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, bool /* isFolder */, INT32 /* askExtractMode */, const UINT64 * /* position */)
|
||||
{
|
||||
m_CurrentFilePath = name;
|
||||
return S_OK;
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UINT64 *newSize,
|
||||
INT32 *result);
|
||||
STDMETHOD (PrepareOperation)(const wchar_t *name, INT32 askExtractMode, const UINT64 *position);
|
||||
STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, INT32 askExtractMode, const UINT64 *position);
|
||||
|
||||
STDMETHOD(MessageError)(const wchar_t *message);
|
||||
STDMETHOD(SetOperationResult)(INT32 resultEOperationResult, bool encrypted);
|
||||
|
||||
@@ -410,6 +410,14 @@ SOURCE=..\Common\OpenArchive.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\PropIDUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -456,11 +456,12 @@ struct PluginInfo
|
||||
char *CommandPrefix;
|
||||
};
|
||||
|
||||
const int kInfoPanelLineSize = 80;
|
||||
|
||||
struct InfoPanelLine
|
||||
{
|
||||
char Text[80];
|
||||
char Data[80];
|
||||
char Text[kInfoPanelLineSize];
|
||||
char Data[kInfoPanelLineSize];
|
||||
int Separator;
|
||||
};
|
||||
|
||||
|
||||
@@ -46,6 +46,15 @@ enum EEnum
|
||||
kBlock,
|
||||
kComment,
|
||||
kPosition,
|
||||
kNumSubFolders,
|
||||
kNumSubFiles,
|
||||
kUnpackVer,
|
||||
kVolume,
|
||||
kIsVolume,
|
||||
kOffset,
|
||||
kLinks,
|
||||
kNumBlocks,
|
||||
kNumVolumes,
|
||||
|
||||
kGetPasswordTitle,
|
||||
kEnterPasswordForFile,
|
||||
|
||||
@@ -50,7 +50,7 @@ CPlugin::~CPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
static void MyGetFileTime(IFolderFolder *anArchiveFolder, UINT32 itemIndex,
|
||||
static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex,
|
||||
PROPID propID, FILETIME &fileTime)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
@@ -69,7 +69,7 @@ static void MyGetFileTime(IFolderFolder *anArchiveFolder, UINT32 itemIndex,
|
||||
}
|
||||
}
|
||||
|
||||
void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UINT32 itemIndex)
|
||||
void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (_folder->GetProperty(itemIndex, kpidName, &propVariant) != S_OK)
|
||||
@@ -103,13 +103,13 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UINT32 itemIndex)
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidSize, &propVariant) != S_OK)
|
||||
throw 271932;
|
||||
UINT64 length;
|
||||
UInt64 length;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
length = 0;
|
||||
else
|
||||
length = ::ConvertPropVariantToUInt64(propVariant);
|
||||
panelItem.FindData.nFileSizeLow = UINT32(length);
|
||||
panelItem.FindData.nFileSizeHigh = UINT32(length >> 32);
|
||||
panelItem.FindData.nFileSizeLow = (UInt32)length;
|
||||
panelItem.FindData.nFileSizeHigh = (UInt32)(length >> 32);
|
||||
|
||||
MyGetFileTime(_folder, itemIndex, kpidCreationTime, panelItem.FindData.ftCreationTime);
|
||||
MyGetFileTime(_folder, itemIndex, kpidLastAccessTime, panelItem.FindData.ftLastAccessTime);
|
||||
@@ -125,8 +125,8 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UINT32 itemIndex)
|
||||
length = 0;
|
||||
else
|
||||
length = ::ConvertPropVariantToUInt64(propVariant);
|
||||
panelItem.PackSize = UINT32(length);
|
||||
panelItem.PackSizeHigh = UINT32(length >> 32);
|
||||
panelItem.PackSize = UInt32(length);
|
||||
panelItem.PackSizeHigh = UInt32(length >> 32);
|
||||
|
||||
panelItem.Flags = 0;
|
||||
panelItem.NumberOfLinks = 0;
|
||||
@@ -139,8 +139,6 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UINT32 itemIndex)
|
||||
panelItem.Reserved[0] = 0;
|
||||
panelItem.Reserved[1] = 0;
|
||||
panelItem.Reserved[2] = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int CPlugin::GetFindData(PluginPanelItem **panelItems,
|
||||
@@ -151,22 +149,22 @@ int CPlugin::GetFindData(PluginPanelItem **panelItems,
|
||||
{
|
||||
/*
|
||||
screenRestorer.Save();
|
||||
const char *aMsgItems[]=
|
||||
const char *msgItems[]=
|
||||
{
|
||||
g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kReadingList)
|
||||
};
|
||||
g_StartupInfo.ShowMessage(0, NULL, aMsgItems,
|
||||
sizeof(aMsgItems) / sizeof(aMsgItems[0]), 0);
|
||||
g_StartupInfo.ShowMessage(0, NULL, msgItems,
|
||||
sizeof(msgItems) / sizeof(msgItems[0]), 0);
|
||||
*/
|
||||
}
|
||||
|
||||
UINT32 numItems;
|
||||
UInt32 numItems;
|
||||
_folder->GetNumberOfItems(&numItems);
|
||||
*panelItems = new PluginPanelItem[numItems];
|
||||
try
|
||||
{
|
||||
for(UINT32 i = 0; i < numItems; i++)
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
PluginPanelItem &panelItem = (*panelItems)[i];
|
||||
ReadPluginPanelItem(panelItem, i);
|
||||
@@ -185,8 +183,8 @@ int CPlugin::GetFindData(PluginPanelItem **panelItems,
|
||||
void CPlugin::FreeFindData(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber)
|
||||
{
|
||||
for(int i = 0; i < itemsNumber; i++)
|
||||
if(panelItems[i].Description != NULL)
|
||||
for (int i = 0; i < itemsNumber; i++)
|
||||
if (panelItems[i].Description != NULL)
|
||||
delete []panelItems[i].Description;
|
||||
delete []panelItems;
|
||||
}
|
||||
@@ -196,7 +194,7 @@ void CPlugin::EnterToDirectory(const UString &aDirName)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(aDirName, &newFolder);
|
||||
if(newFolder == NULL)
|
||||
if (newFolder == NULL)
|
||||
if (aDirName.IsEmpty())
|
||||
return;
|
||||
else
|
||||
@@ -232,7 +230,7 @@ int CPlugin::SetDirectory(const char *aszDir, int /* opMode */)
|
||||
}
|
||||
UStringVector pathParts;
|
||||
SplitPathToParts(path, pathParts);
|
||||
for(int i = 0; i < pathParts.Size(); i++)
|
||||
for (int i = 0; i < pathParts.Size(); i++)
|
||||
EnterToDirectory(pathParts[i]);
|
||||
}
|
||||
GetCurrentDir();
|
||||
@@ -249,9 +247,10 @@ void CPlugin::GetPathParts(UStringVector &pathParts)
|
||||
folderItem->BindToParentFolder(&newFolder);
|
||||
if (newFolder == NULL)
|
||||
break;
|
||||
CMyComBSTR name;
|
||||
folderItem->GetName(&name);
|
||||
pathParts.Insert(0, (const wchar_t *)name);
|
||||
NCOM::CPropVariant prop;
|
||||
if (folderItem->GetFolderProperty(kpidName, &prop) == S_OK)
|
||||
if (prop.vt == VT_BSTR)
|
||||
pathParts.Insert(0, (const wchar_t *)prop.bstrVal);
|
||||
folderItem = newFolder;
|
||||
}
|
||||
}
|
||||
@@ -304,16 +303,24 @@ static CPROPIDToName kPROPIDToName[] =
|
||||
{ kpidGroup, NMessageID::kGroup },
|
||||
{ kpidBlock, NMessageID::kBlock },
|
||||
{ kpidComment, NMessageID::kComment },
|
||||
{ kpidPosition, NMessageID::kPosition }
|
||||
|
||||
{ kpidPosition, NMessageID::kPosition },
|
||||
{ kpidNumSubFolders, NMessageID::kNumSubFolders },
|
||||
{ kpidNumSubFiles, NMessageID::kNumSubFiles },
|
||||
{ kpidUnpackVer, NMessageID::kUnpackVer },
|
||||
{ kpidVolume, NMessageID::kVolume },
|
||||
{ kpidIsVolume, NMessageID::kIsVolume },
|
||||
{ kpidOffset, NMessageID::kOffset },
|
||||
{ kpidLinks, NMessageID::kLinks },
|
||||
{ kpidNumBlocks, NMessageID::kNumBlocks },
|
||||
{ kpidNumVolumes, NMessageID::kNumVolumes }
|
||||
};
|
||||
|
||||
static const int kNumPROPIDToName = sizeof(kPROPIDToName) / sizeof(kPROPIDToName[0]);
|
||||
|
||||
static int FindPropertyToName(PROPID propID)
|
||||
{
|
||||
for(int i = 0; i < kNumPROPIDToName; i++)
|
||||
if(kPROPIDToName[i].PropID == propID)
|
||||
for (int i = 0; i < kNumPROPIDToName; i++)
|
||||
if (kPROPIDToName[i].PropID == propID)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
@@ -353,8 +360,8 @@ static const int kNumPropertyIDInfos = sizeof(kPropertyIDInfos) /
|
||||
|
||||
static int FindPropertyInfo(PROPID propID)
|
||||
{
|
||||
for(int i = 0; i < kNumPropertyIDInfos; i++)
|
||||
if(kPropertyIDInfos[i].PropID == propID)
|
||||
for (int i = 0; i < kNumPropertyIDInfos; i++)
|
||||
if (kPropertyIDInfos[i].PropID == propID)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
@@ -376,7 +383,7 @@ void CPlugin::AddColumn(PROPID propID)
|
||||
int index = FindPropertyInfo(propID);
|
||||
if (index >= 0)
|
||||
{
|
||||
for(int i = 0; i < m_ProxyHandler->m_InternalProperties.Size(); i++)
|
||||
for (int i = 0; i < m_ProxyHandler->m_InternalProperties.Size(); i++)
|
||||
{
|
||||
const CArchiveItemProperty &aHandlerProperty = m_ProxyHandler->m_InternalProperties[i];
|
||||
if (aHandlerProperty.ID == propID)
|
||||
@@ -385,11 +392,11 @@ void CPlugin::AddColumn(PROPID propID)
|
||||
if (i == m_ProxyHandler->m_InternalProperties.Size())
|
||||
return;
|
||||
|
||||
const CPropertyIDInfo &aPropertyIDInfo = kPropertyIDInfos[index];
|
||||
SmartAddToString(PanelModeColumnTypes, aPropertyIDInfo.FarID);
|
||||
char aTmp[32];
|
||||
itoa(aPropertyIDInfo.Width, aTmp, 10);
|
||||
SmartAddToString(PanelModeColumnWidths, aTmp);
|
||||
const CPropertyIDInfo &propertyIDInfo = kPropertyIDInfos[index];
|
||||
SmartAddToString(PanelModeColumnTypes, propertyIDInfo.FarID);
|
||||
char tmp[32];
|
||||
itoa(propertyIDInfo.Width, tmp, 10);
|
||||
SmartAddToString(PanelModeColumnWidths, tmp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -425,7 +432,7 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
UString(L':') +
|
||||
name +
|
||||
UString(L' ');
|
||||
if(!m_CurrentDir.IsEmpty())
|
||||
if (!m_CurrentDir.IsEmpty())
|
||||
{
|
||||
// m_PannelTitle += '\\';
|
||||
m_PannelTitle += m_CurrentDir;
|
||||
@@ -434,44 +441,56 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
MyStringCopy(m_PannelTitleBuffer, (const char *)UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP));
|
||||
info->PanelTitle = m_PannelTitleBuffer;
|
||||
|
||||
memset(m_InfoLines,0,sizeof(m_InfoLines));
|
||||
MyStringCopy(m_InfoLines[0].Text,"");
|
||||
memset(m_InfoLines, 0, sizeof(m_InfoLines));
|
||||
MyStringCopy(m_InfoLines[0].Text, "");
|
||||
m_InfoLines[0].Separator = TRUE;
|
||||
|
||||
MyStringCopy(m_InfoLines[1].Text, g_StartupInfo.GetMsgString(NMessageID::kArchiveType));
|
||||
MyStringCopy(m_InfoLines[1].Data, (const char *)UnicodeStringToMultiByte(_archiveTypeName, CP_OEMCP));
|
||||
|
||||
int numItems = 2;
|
||||
UINT32 numProps;
|
||||
if (m_ArchiveHandler->GetNumberOfArchiveProperties(&numProps) == S_OK)
|
||||
|
||||
CMyComPtr<IFolderProperties> folderProperties;
|
||||
_folder.QueryInterface(IID_IFolderProperties, &folderProperties);
|
||||
if (folderProperties)
|
||||
{
|
||||
for (UINT32 i = 0; i < numProps && numItems < 30; i++)
|
||||
UInt32 numProps;
|
||||
if (folderProperties->GetNumberOfFolderProperties(&numProps) == S_OK)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
if (m_ArchiveHandler->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK)
|
||||
continue;
|
||||
|
||||
InfoPanelLine &item = m_InfoLines[numItems];
|
||||
int index = FindPropertyToName(propID);
|
||||
if (index < 0)
|
||||
for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++)
|
||||
{
|
||||
if (name != 0)
|
||||
MyStringCopy(item.Text, (const char *)UnicodeStringToMultiByte(
|
||||
(const wchar_t *)name, CP_OEMCP));
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
if (folderProperties->GetFolderPropertyInfo(i, &name, &propID, &vt) != S_OK)
|
||||
continue;
|
||||
|
||||
InfoPanelLine &item = m_InfoLines[numItems];
|
||||
int index = FindPropertyToName(propID);
|
||||
AString s;
|
||||
if (index < 0)
|
||||
{
|
||||
if (name != 0)
|
||||
s = (const char *)UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP);
|
||||
}
|
||||
else
|
||||
MyStringCopy(item.Text, "");
|
||||
s = g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID);
|
||||
|
||||
if (s.Length() > (kInfoPanelLineSize - 1))
|
||||
s = s.Left(kInfoPanelLineSize - 1);
|
||||
MyStringCopy(item.Text, (const char *)s);
|
||||
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (_folder->GetFolderProperty(propID, &propVariant) != S_OK)
|
||||
continue;
|
||||
s = ConvertPropertyToString2(propVariant, propID);
|
||||
s.Replace((char)0xA, ' ');
|
||||
s.Replace((char)0xD, ' ');
|
||||
if (s.Length() > (kInfoPanelLineSize - 1))
|
||||
s = s.Left(kInfoPanelLineSize - 1);
|
||||
MyStringCopy(item.Data, (const char *)s);
|
||||
numItems++;
|
||||
}
|
||||
else
|
||||
MyStringCopy(item.Text, g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID));
|
||||
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (m_ArchiveHandler->GetArchiveProperty(propID, &propVariant) != S_OK)
|
||||
continue;
|
||||
CSysString s = ConvertPropertyToString2(propVariant, propID);
|
||||
MyStringCopy(item.Data, (const char *)s);
|
||||
numItems++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,15 +558,15 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
int itemIndex = pluginPanelItem.UserData;
|
||||
|
||||
CObjectVector<CArchiveItemProperty> properties;
|
||||
UINT32 numProps;
|
||||
RINOK(m_ArchiveHandler->GetNumberOfProperties(&numProps));
|
||||
UInt32 numProps;
|
||||
RINOK(_folder->GetNumberOfProperties(&numProps));
|
||||
int i;
|
||||
for (i = 0; i < (int)numProps; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
RINOK(m_ArchiveHandler->GetPropertyInfo(i, &name, &propID, &vt));
|
||||
RINOK(_folder->GetPropertyInfo(i, &name, &propID, &vt));
|
||||
CArchiveItemProperty destProperty;
|
||||
destProperty.Type = vt;
|
||||
destProperty.ID = propID;
|
||||
@@ -556,29 +575,13 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
AString propName;
|
||||
{
|
||||
if (name != NULL)
|
||||
destProperty.Name = UnicodeStringToMultiByte(
|
||||
(const wchar_t *)name, CP_OEMCP);
|
||||
destProperty.Name = UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP);
|
||||
else
|
||||
destProperty.Name = "Error";
|
||||
destProperty.Name = "?";
|
||||
}
|
||||
properties.Add(destProperty);
|
||||
}
|
||||
|
||||
/*
|
||||
LPCITEMIDLIST aProperties;
|
||||
if (index < m_FolderItem->m_DirSubItems.Size())
|
||||
{
|
||||
const CArchiveFolderItem &anItem = m_FolderItem->m_DirSubItems[index];
|
||||
aProperties = anItem.m_Properties;
|
||||
}
|
||||
else
|
||||
{
|
||||
const CArchiveFolderFileItem &anItem =
|
||||
m_FolderItem->m_FileSubItems[index - m_FolderItem->m_DirSubItems.Size()];
|
||||
aProperties = anItem.m_Properties;
|
||||
}
|
||||
*/
|
||||
|
||||
int size = 2;
|
||||
CRecordVector<CInitDialogItem> initDialogItems;
|
||||
|
||||
@@ -586,7 +589,7 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
CInitDialogItem initDialogItem =
|
||||
{ DI_DOUBLEBOX, 3, 1, xSize - 4, size - 2, false, false, 0, false, NMessageID::kProperties, NULL, NULL };
|
||||
initDialogItems.Add(initDialogItem);
|
||||
AStringVector aValues;
|
||||
AStringVector values;
|
||||
|
||||
for (i = 0; i < properties.Size(); i++)
|
||||
{
|
||||
@@ -605,10 +608,9 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
initDialogItems.Add(initDialogItem);
|
||||
|
||||
NCOM::CPropVariant propVariant;
|
||||
RINOK(_folder->GetProperty(itemIndex,
|
||||
property.ID, &propVariant));
|
||||
CSysString aString = ConvertPropertyToString2(propVariant, property.ID);
|
||||
aValues.Add(aString);
|
||||
RINOK(_folder->GetProperty(itemIndex, property.ID, &propVariant));
|
||||
CSysString s = ConvertPropertyToString2(propVariant, property.ID);
|
||||
values.Add(s);
|
||||
|
||||
{
|
||||
CInitDialogItem initDialogItem =
|
||||
@@ -617,18 +619,18 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
}
|
||||
}
|
||||
|
||||
int numLines = aValues.Size();
|
||||
for(i = 0; i < numLines; i++)
|
||||
int numLines = values.Size();
|
||||
for (i = 0; i < numLines; i++)
|
||||
{
|
||||
CInitDialogItem &initDialogItem = initDialogItems[1 + i * 2 + 1];
|
||||
initDialogItem.DataString = aValues[i];
|
||||
initDialogItem.DataString = values[i];
|
||||
}
|
||||
|
||||
int numDialogItems = initDialogItems.Size();
|
||||
|
||||
CRecordVector<FarDialogItem> dialogItems;
|
||||
dialogItems.Reserve(numDialogItems);
|
||||
for(i = 0; i < numDialogItems; i++)
|
||||
for (i = 0; i < numDialogItems; i++)
|
||||
dialogItems.Add(FarDialogItem());
|
||||
g_StartupInfo.InitDialogItems(&initDialogItems.Front(),
|
||||
&dialogItems.Front(), numDialogItems);
|
||||
@@ -653,17 +655,17 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
}
|
||||
size = numLines + 6;
|
||||
xSize = maxLen + kSpace + maxLen2 + 5;
|
||||
FarDialogItem &aFirstDialogItem = dialogItems.Front();
|
||||
aFirstDialogItem.Y2 = size - 2;
|
||||
aFirstDialogItem.X2 = xSize - 4;
|
||||
FarDialogItem &firstDialogItem = dialogItems.Front();
|
||||
firstDialogItem.Y2 = size - 2;
|
||||
firstDialogItem.X2 = xSize - 4;
|
||||
|
||||
/* int askCode = */ g_StartupInfo.ShowDialog(xSize, size, NULL, &dialogItems.Front(), numDialogItems);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int CPlugin::ProcessKey(int aKey, unsigned int controlState)
|
||||
int CPlugin::ProcessKey(int key, unsigned int controlState)
|
||||
{
|
||||
if (controlState == PKF_CONTROL && aKey == 'A')
|
||||
if (controlState == PKF_CONTROL && key == 'A')
|
||||
{
|
||||
HRESULT result = ShowAttributesWindow();
|
||||
if (result == S_OK)
|
||||
@@ -672,7 +674,7 @@ int CPlugin::ProcessKey(int aKey, unsigned int controlState)
|
||||
return FALSE;
|
||||
throw "Error";
|
||||
}
|
||||
if ((controlState & PKF_ALT) != 0 && aKey == VK_F6)
|
||||
if ((controlState & PKF_ALT) != 0 && key == VK_F6)
|
||||
{
|
||||
UString folderPath;
|
||||
if (!NFile::NDirectory::GetOnlyDirPrefix(m_FileName, folderPath))
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "FarUtils.h"
|
||||
|
||||
const UInt32 kNumInfoLinesMax = 30; // Change it;
|
||||
|
||||
class CPlugin
|
||||
{
|
||||
NWindows::NCOM::CComInitializer m_ComInitializer;
|
||||
@@ -20,7 +22,7 @@ class CPlugin
|
||||
|
||||
UString m_PannelTitle;
|
||||
|
||||
InfoPanelLine m_InfoLines[30]; // Change it;
|
||||
InfoPanelLine m_InfoLines[kNumInfoLinesMax];
|
||||
|
||||
char m_FileNameBuffer[1024];
|
||||
char m_CurrentDirBuffer[1024];
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
using namespace NFar;
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 /* numFiles */)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetTotal(UINT64 aSize)
|
||||
{
|
||||
if (m_ProgressBox != 0)
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
STDMETHOD(DeleteOperation)(const wchar_t *aName);
|
||||
STDMETHOD(OperationResult)(INT32 aOperationResult);
|
||||
STDMETHOD(UpdateErrorMessage)(const wchar_t *message);
|
||||
STDMETHOD(SetNumFiles)(UInt64 numFiles);
|
||||
|
||||
private:
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
|
||||
@@ -43,6 +43,7 @@ WIN_OBJS = \
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\FilePathAutoRename.obj \
|
||||
$O\FileStreams.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
UI_COMMON_OBJS = \
|
||||
|
||||
1
CPP/7zip/UI/FileManager/7zFM.exe.manifest
Executable file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="7-Zip.7-Zip.7zFM" type="win32"/><description>7-Zip File manager.</description><dependency> <dependentAssembly><assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/></dependentAssembly></dependency></assembly>
|
||||
BIN
CPP/7zip/UI/FileManager/7zipLogo.ico
Executable file
|
After Width: | Height: | Size: 8.9 KiB |
60
CPP/7zip/UI/FileManager/AboutDialog.cpp
Executable file
@@ -0,0 +1,60 @@
|
||||
// AboutDialog.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "AboutDialogRes.h"
|
||||
#include "AboutDialog.h"
|
||||
#include "HelpUtils.h"
|
||||
#include "LangUtils.h"
|
||||
|
||||
static CIDLangPair kIDLangPairs[] =
|
||||
{
|
||||
{ IDC_ABOUT_STATIC_REGISTER_INFO, 0x01000103 },
|
||||
{ IDC_ABOUT_BUTTON_SUPPORT, 0x01000104 },
|
||||
{ IDC_ABOUT_BUTTON_REGISTER, 0x01000105 },
|
||||
{ IDOK, 0x02000702 }
|
||||
};
|
||||
|
||||
#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]));
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
default:
|
||||
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
18
CPP/7zip/UI/FileManager/AboutDialog.h
Executable file
@@ -0,0 +1,18 @@
|
||||
// AboutDialog.h
|
||||
|
||||
#ifndef __ABOUTDIALOG_H
|
||||
#define __ABOUTDIALOG_H
|
||||
|
||||
#include "AboutDialogRes.h"
|
||||
#include "Windows/Control/Dialog.h"
|
||||
|
||||
class CAboutDialog: public NWindows::NControl::CModalDialog
|
||||
{
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
virtual void OnHelp();
|
||||
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
|
||||
INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_ABOUT, wndParent); }
|
||||
};
|
||||
|
||||
#endif
|
||||
41
CPP/7zip/UI/FileManager/AboutDialog.rc
Executable file
@@ -0,0 +1,41 @@
|
||||
#include "AboutDialogRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
#include "../../MyVersion.h"
|
||||
|
||||
#define xSize2 224
|
||||
#define ySize2 158
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
|
||||
#define bXPos (xSize - marg - bXSize)
|
||||
#define bYPos (ySize - marg - bYSize)
|
||||
|
||||
#undef b2XSize
|
||||
#undef b2XPos
|
||||
#undef infoYPos
|
||||
#undef infoYSize
|
||||
|
||||
#define b2XSize 94
|
||||
#define b2XPos (xSize - marg - b2XSize)
|
||||
#define gSpace 2
|
||||
#define gSize (xSize2 - gSpace - b2XSize)
|
||||
|
||||
#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
|
||||
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
|
||||
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
|
||||
6
CPP/7zip/UI/FileManager/AboutDialogRes.h
Executable file
@@ -0,0 +1,6 @@
|
||||
#define IDD_ABOUT 100
|
||||
#define IDI_LOGO 138
|
||||
#define IDC_ABOUT_STATIC_REGISTER_INFO 1010
|
||||
#define IDC_ABOUT_BUTTON_HOMEPAGE 1020
|
||||
#define IDC_ABOUT_BUTTON_SUPPORT 1021
|
||||
#define IDC_ABOUT_BUTTON_REGISTER 1022
|
||||
BIN
CPP/7zip/UI/FileManager/Add.bmp
Executable file
|
After Width: | Height: | Size: 982 B |
BIN
CPP/7zip/UI/FileManager/Add2.bmp
Executable file
|
After Width: | Height: | Size: 406 B |
759
CPP/7zip/UI/FileManager/App.cpp
Executable file
@@ -0,0 +1,759 @@
|
||||
// App.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/COM.h"
|
||||
#include "Windows/Thread.h"
|
||||
#include "IFolder.h"
|
||||
|
||||
#include "App.h"
|
||||
|
||||
#include "CopyDialog.h"
|
||||
|
||||
#include "ExtractCallback.h"
|
||||
#include "ViewSettings.h"
|
||||
#include "RegistryUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
extern DWORD g_ComCtl32Version;
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
static LPCWSTR kTempDirPrefix = L"7zE";
|
||||
|
||||
void CPanelCallbackImp::OnTab()
|
||||
{
|
||||
if (g_App.NumPanels != 1)
|
||||
_app->Panels[1 - _index].SetFocusToList();
|
||||
}
|
||||
|
||||
void CPanelCallbackImp::SetFocusToPath(int index)
|
||||
{
|
||||
int newPanelIndex = index;
|
||||
if (g_App.NumPanels == 1)
|
||||
newPanelIndex = g_App.LastFocusedPanel;
|
||||
_app->Panels[newPanelIndex]._headerComboBox.SetFocus();
|
||||
}
|
||||
|
||||
|
||||
void CPanelCallbackImp::OnCopy(bool move, bool copyToSame)
|
||||
{ _app->OnCopy(move, copyToSame, _index); }
|
||||
|
||||
void CPanelCallbackImp::OnSetSameFolder()
|
||||
{ _app->OnSetSameFolder(_index); }
|
||||
|
||||
void CPanelCallbackImp::OnSetSubFolder()
|
||||
{ _app->OnSetSubFolder(_index); }
|
||||
|
||||
void CPanelCallbackImp::PanelWasFocused()
|
||||
{ _app->SetFocusedPanel(_index); }
|
||||
|
||||
void CPanelCallbackImp::DragBegin()
|
||||
{ _app->DragBegin(_index); }
|
||||
|
||||
void CPanelCallbackImp::DragEnd()
|
||||
{ _app->DragEnd(); }
|
||||
|
||||
void CApp::SetListSettings()
|
||||
{
|
||||
bool showDots = ReadShowDots();
|
||||
bool showRealFileIcons = ReadShowRealFileIcons();
|
||||
|
||||
DWORD extendedStyle = LVS_EX_HEADERDRAGDROP;
|
||||
if (ReadFullRow())
|
||||
extendedStyle |= LVS_EX_FULLROWSELECT;
|
||||
if (ReadShowGrid())
|
||||
extendedStyle |= LVS_EX_GRIDLINES;
|
||||
bool mySelectionMode = ReadAlternativeSelection();
|
||||
|
||||
/*
|
||||
if (ReadSingleClick())
|
||||
{
|
||||
extendedStyle |= LVS_EX_ONECLICKACTIVATE
|
||||
| LVS_EX_TRACKSELECT;
|
||||
if (ReadUnderline())
|
||||
extendedStyle |= LVS_EX_UNDERLINEHOT;
|
||||
}
|
||||
*/
|
||||
|
||||
for (int i = 0; i < kNumPanelsMax; i++)
|
||||
{
|
||||
CPanel &panel = Panels[i];
|
||||
panel._mySelectMode = mySelectionMode;
|
||||
panel._showDots = showDots;
|
||||
panel._showRealFileIcons = showRealFileIcons;
|
||||
panel._exStyle = extendedStyle;
|
||||
|
||||
DWORD style = (DWORD)panel._listView.GetStyle();
|
||||
if (mySelectionMode)
|
||||
style |= LVS_SINGLESEL;
|
||||
else
|
||||
style &= ~LVS_SINGLESEL;
|
||||
panel._listView.SetStyle(style);
|
||||
panel.SetExtendedStyle();
|
||||
}
|
||||
}
|
||||
|
||||
void CApp::SetShowSystemMenu()
|
||||
{
|
||||
ShowSystemMenu = ReadShowSystemMenu();
|
||||
}
|
||||
|
||||
void CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted)
|
||||
{
|
||||
if (PanelsCreated[panelIndex])
|
||||
return;
|
||||
m_PanelCallbackImp[panelIndex].Init(this, panelIndex);
|
||||
UString path;
|
||||
if (mainPath.IsEmpty())
|
||||
{
|
||||
if (!::ReadPanelPath(panelIndex, path))
|
||||
path.Empty();
|
||||
}
|
||||
else
|
||||
path = mainPath;
|
||||
int id = 1000 + 100 * panelIndex;
|
||||
Panels[panelIndex].Create(_window, _window,
|
||||
id, path, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted);
|
||||
PanelsCreated[panelIndex] = true;
|
||||
}
|
||||
|
||||
static void CreateToolbar(
|
||||
HWND parent,
|
||||
NWindows::NControl::CImageList &imageList,
|
||||
NWindows::NControl::CToolBar &toolBar,
|
||||
bool LargeButtons)
|
||||
{
|
||||
toolBar.Attach(::CreateWindowEx(0,
|
||||
TOOLBARCLASSNAME,
|
||||
NULL, 0
|
||||
| WS_VISIBLE
|
||||
| TBSTYLE_FLAT
|
||||
| TBSTYLE_TOOLTIPS
|
||||
| WS_CHILD
|
||||
| CCS_NOPARENTALIGN
|
||||
| CCS_NORESIZE
|
||||
| CCS_NODIVIDER
|
||||
// | TBSTYLE_AUTOSIZE
|
||||
// | CCS_ADJUSTABLE
|
||||
,0,0,0,0, parent, NULL, g_hInstance, NULL));
|
||||
|
||||
// TB_BUTTONSTRUCTSIZE message, which is required for
|
||||
// backward compatibility.
|
||||
toolBar.ButtonStructSize();
|
||||
|
||||
imageList.Create(
|
||||
LargeButtons ? 48: 24,
|
||||
LargeButtons ? 36: 24,
|
||||
ILC_MASK, 0, 0);
|
||||
toolBar.SetImageList(0, imageList);
|
||||
}
|
||||
|
||||
struct CButtonInfo
|
||||
{
|
||||
UINT commandID;
|
||||
UINT BitmapResID;
|
||||
UINT Bitmap2ResID;
|
||||
UINT StringResID;
|
||||
UINT32 LangID;
|
||||
UString GetText()const { return LangString(StringResID, LangID); };
|
||||
};
|
||||
|
||||
static CButtonInfo g_StandardButtons[] =
|
||||
{
|
||||
{ IDM_COPY_TO, IDB_COPY, IDB_COPY2, IDS_BUTTON_COPY, 0x03020420},
|
||||
{ IDM_MOVE_TO, IDB_MOVE, IDB_MOVE2, IDS_BUTTON_MOVE, 0x03020421},
|
||||
{ IDM_DELETE, IDB_DELETE, IDB_DELETE2, IDS_BUTTON_DELETE, 0x03020422} ,
|
||||
{ IDM_FILE_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO, 0x03020423}
|
||||
};
|
||||
|
||||
static CButtonInfo g_ArchiveButtons[] =
|
||||
{
|
||||
{ kAddCommand, IDB_ADD, IDB_ADD2, IDS_ADD, 0x03020400},
|
||||
{ kExtractCommand, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT, 0x03020401},
|
||||
{ kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402}
|
||||
};
|
||||
|
||||
bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, UString &s)
|
||||
{
|
||||
for (int i = 0; i < numButtons; i++)
|
||||
{
|
||||
const CButtonInfo &b = buttons[i];
|
||||
if (b.commandID == commandID)
|
||||
{
|
||||
s = b.GetText();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetButtonText(UINT32 commandID, UString &s)
|
||||
{
|
||||
if (SetButtonText(commandID, g_StandardButtons,
|
||||
sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s))
|
||||
return;
|
||||
SetButtonText(commandID, g_ArchiveButtons,
|
||||
sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s);
|
||||
}
|
||||
|
||||
static void AddButton(
|
||||
NControl::CImageList &imageList,
|
||||
NControl::CToolBar &toolBar,
|
||||
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.dwData = 0;
|
||||
|
||||
UString s = butInfo.GetText();
|
||||
but.iString = 0;
|
||||
if (showText)
|
||||
but.iString = (INT_PTR)(LPCWSTR)s;
|
||||
|
||||
but.iBitmap = imageList.GetImageCount();
|
||||
HBITMAP b = ::LoadBitmap(g_hInstance,
|
||||
large ?
|
||||
MAKEINTRESOURCE(butInfo.BitmapResID):
|
||||
MAKEINTRESOURCE(butInfo.Bitmap2ResID));
|
||||
if (b != 0)
|
||||
{
|
||||
imageList.AddMasked(b, RGB(255, 0, 255));
|
||||
::DeleteObject(b);
|
||||
}
|
||||
#ifdef _UNICODE
|
||||
toolBar.AddButton(1, &but);
|
||||
#else
|
||||
toolBar.AddButtonW(1, &but);
|
||||
#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;
|
||||
|
||||
while(_rebar.GetBandCount() > 0)
|
||||
_rebar.DeleteBand(0);
|
||||
|
||||
_archiveToolBar.Destroy();
|
||||
_archiveButtonsImageList.Destroy();
|
||||
|
||||
_standardButtonsImageList.Destroy();
|
||||
_standardToolBar.Destroy();
|
||||
|
||||
if (ShowArchiveToolbar)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void CApp::ReloadRebar(HWND hwnd)
|
||||
{
|
||||
_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);
|
||||
ReloadToolbars();
|
||||
}
|
||||
|
||||
void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted)
|
||||
{
|
||||
ReadToolbar();
|
||||
ReloadRebar(hwnd);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < kNumPanelsMax; i++)
|
||||
PanelsCreated[i] = false;
|
||||
|
||||
_window.Attach(hwnd);
|
||||
AppState.Read();
|
||||
SetListSettings();
|
||||
SetShowSystemMenu();
|
||||
if (LastFocusedPanel >= kNumPanelsMax)
|
||||
LastFocusedPanel = 0;
|
||||
|
||||
CListMode listMode;
|
||||
ReadListMode(listMode);
|
||||
for (i = 0; i < kNumPanelsMax; i++)
|
||||
{
|
||||
Panels[i]._ListViewMode = listMode.Panels[i];
|
||||
Panels[i]._xSize = xSizes[i];
|
||||
}
|
||||
for (i = 0; i < kNumPanelsMax; i++)
|
||||
if (NumPanels > 1 || i == LastFocusedPanel)
|
||||
{
|
||||
if (NumPanels == 1)
|
||||
Panels[i]._xSize = xSizes[0] + xSizes[1];
|
||||
bool archiveIsOpened2 = false;
|
||||
bool encrypted2 = false;
|
||||
bool mainPanel = (i == LastFocusedPanel);
|
||||
CreateOnePanel(i, mainPanel ? mainPath : L"", archiveIsOpened2, encrypted2);
|
||||
if (mainPanel)
|
||||
{
|
||||
archiveIsOpened = archiveIsOpened2;
|
||||
encrypted = encrypted2;
|
||||
}
|
||||
}
|
||||
SetFocusedPanel(LastFocusedPanel);
|
||||
Panels[LastFocusedPanel].SetFocusToList();
|
||||
}
|
||||
|
||||
extern void MoveSubWindows(HWND hWnd);
|
||||
|
||||
void CApp::SwitchOnOffOnePanel()
|
||||
{
|
||||
if (NumPanels == 1)
|
||||
{
|
||||
NumPanels++;
|
||||
bool archiveIsOpened, encrypted;
|
||||
CreateOnePanel(1 - LastFocusedPanel, UString(), archiveIsOpened, encrypted);
|
||||
Panels[1 - LastFocusedPanel].Enable(true);
|
||||
Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
NumPanels--;
|
||||
Panels[1 - LastFocusedPanel].Enable(false);
|
||||
Panels[1 - LastFocusedPanel].Show(SW_HIDE);
|
||||
}
|
||||
MoveSubWindows(_window);
|
||||
}
|
||||
|
||||
void CApp::Save()
|
||||
{
|
||||
AppState.Save();
|
||||
CListMode listMode;
|
||||
for (int i = 0; i < kNumPanelsMax; i++)
|
||||
{
|
||||
const CPanel &panel = Panels[i];
|
||||
UString path;
|
||||
if (panel._parentFolders.IsEmpty())
|
||||
path = panel._currentFolderPrefix;
|
||||
else
|
||||
path = GetFolderPath(panel._parentFolders[0].ParentFolder);
|
||||
SavePanelPath(i, path);
|
||||
listMode.Panels[i] = panel.GetListViewMode();
|
||||
}
|
||||
SaveListMode(listMode);
|
||||
}
|
||||
|
||||
void CApp::Release()
|
||||
{
|
||||
// It's for unloading COM dll's: don't change it.
|
||||
for (int i = 0; i < kNumPanelsMax; i++)
|
||||
Panels[i].Release();
|
||||
}
|
||||
|
||||
static bool IsThereFolderOfPath(const UString &path)
|
||||
{
|
||||
CFileInfoW fileInfo;
|
||||
if (!FindFile(path, fileInfo))
|
||||
return false;
|
||||
return fileInfo.IsDirectory();
|
||||
}
|
||||
|
||||
// reduces path to part that exists on disk
|
||||
static void ReducePathToRealFileSystemPath(UString &path)
|
||||
{
|
||||
while(!path.IsEmpty())
|
||||
{
|
||||
if (IsThereFolderOfPath(path))
|
||||
{
|
||||
NName::NormalizeDirPathPrefix(path);
|
||||
break;
|
||||
}
|
||||
int pos = path.ReverseFind('\\');
|
||||
if (pos < 0)
|
||||
path.Empty();
|
||||
else
|
||||
{
|
||||
path = path.Left(pos + 1);
|
||||
if (path.Length() == 3 && path[1] == L':')
|
||||
break;
|
||||
path = path.Left(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return true for dir\, if dir exist
|
||||
static bool CheckFolderPath(const UString &path)
|
||||
{
|
||||
UString pathReduced = path;
|
||||
ReducePathToRealFileSystemPath(pathReduced);
|
||||
return (pathReduced == path);
|
||||
}
|
||||
|
||||
static bool IsPathAbsolute(const UString &path)
|
||||
{
|
||||
if ((path.Length() >= 1 && path[0] == L'\\') ||
|
||||
(path.Length() >= 3 && path[1] == L':' && path[2] == L'\\'))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
{
|
||||
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
|
||||
CPanel &srcPanel = Panels[srcPanelIndex];
|
||||
CPanel &destPanel = Panels[destPanelIndex];
|
||||
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing1(destPanel);
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing2(srcPanel);
|
||||
|
||||
if (!srcPanel.DoesItSupportOperations())
|
||||
{
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
|
||||
CRecordVector<UInt32> indices;
|
||||
UString destPath;
|
||||
bool useDestPanel = false;
|
||||
|
||||
{
|
||||
if (copyToSame)
|
||||
{
|
||||
int focusedItem = srcPanel._listView.GetFocusedItem();
|
||||
if (focusedItem < 0)
|
||||
return;
|
||||
int realIndex = srcPanel.GetRealItemIndex(focusedItem);
|
||||
if (realIndex == kParentIndex)
|
||||
return;
|
||||
indices.Add(realIndex);
|
||||
destPath = srcPanel.GetItemName(realIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcPanel.GetOperatedItemIndices(indices);
|
||||
if (indices.Size() == 0)
|
||||
return;
|
||||
destPath = destPanel._currentFolderPrefix;
|
||||
if (NumPanels == 1)
|
||||
ReducePathToRealFileSystemPath(destPath);
|
||||
}
|
||||
|
||||
CCopyDialog copyDialog;
|
||||
UStringVector copyFolders;
|
||||
ReadCopyHistory(copyFolders);
|
||||
|
||||
copyDialog.Strings = copyFolders;
|
||||
copyDialog.Value = destPath;
|
||||
|
||||
copyDialog.Title = move ?
|
||||
LangString(IDS_MOVE, 0x03020202):
|
||||
LangString(IDS_COPY, 0x03020201);
|
||||
copyDialog.Static = move ?
|
||||
LangString(IDS_MOVE_TO, 0x03020204):
|
||||
LangString(IDS_COPY_TO, 0x03020203);
|
||||
|
||||
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
|
||||
return;
|
||||
|
||||
destPath = copyDialog.Value;
|
||||
|
||||
if (!IsPathAbsolute(destPath))
|
||||
{
|
||||
if (!srcPanel.IsFSFolder())
|
||||
{
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
destPath = srcPanel._currentFolderPrefix + destPath;
|
||||
}
|
||||
|
||||
if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) ||
|
||||
IsThereFolderOfPath(destPath))
|
||||
{
|
||||
NDirectory::CreateComplexDirectory(destPath);
|
||||
NName::NormalizeDirPathPrefix(destPath);
|
||||
if (!CheckFolderPath(destPath))
|
||||
{
|
||||
if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
|
||||
{
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
useDestPanel = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int pos = destPath.ReverseFind('\\');
|
||||
if (pos >= 0)
|
||||
{
|
||||
UString prefix = destPath.Left(pos + 1);
|
||||
NDirectory::CreateComplexDirectory(prefix);
|
||||
if (!CheckFolderPath(prefix))
|
||||
{
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AddUniqueStringToHeadOfList(copyFolders, destPath);
|
||||
while (copyFolders.Size() > 20)
|
||||
copyFolders.DeleteBack();
|
||||
SaveCopyHistory(copyFolders);
|
||||
}
|
||||
|
||||
bool useSrcPanel = (!useDestPanel || !srcPanel.IsFSFolder() || destPanel.IsFSFolder());
|
||||
bool useTemp = useSrcPanel && useDestPanel;
|
||||
NFile::NDirectory::CTempDirectoryW tempDirectory;
|
||||
UString tempDirPrefix;
|
||||
if (useTemp)
|
||||
{
|
||||
tempDirectory.Create(kTempDirPrefix);
|
||||
tempDirPrefix = tempDirectory.GetPath();
|
||||
NFile::NName::NormalizeDirPathPrefix(tempDirPrefix);
|
||||
}
|
||||
|
||||
CSelectedState srcSelState;
|
||||
CSelectedState destSelState;
|
||||
srcPanel.SaveSelectedState(srcSelState);
|
||||
destPanel.SaveSelectedState(destSelState);
|
||||
|
||||
HRESULT result;
|
||||
if (useSrcPanel)
|
||||
{
|
||||
UString folder = useTemp ? tempDirPrefix : destPath;
|
||||
result = srcPanel.CopyTo(indices, folder, move, true, 0);
|
||||
if (result != S_OK)
|
||||
{
|
||||
disableTimerProcessing1.Restore();
|
||||
disableTimerProcessing2.Restore();
|
||||
// For Password:
|
||||
srcPanel.SetFocusToList();
|
||||
if (result != E_ABORT)
|
||||
srcPanel.MessageBoxError(result, L"Error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (useDestPanel)
|
||||
{
|
||||
UStringVector filePaths;
|
||||
UString folderPrefix;
|
||||
if (useTemp)
|
||||
folderPrefix = tempDirPrefix;
|
||||
else
|
||||
folderPrefix = srcPanel._currentFolderPrefix;
|
||||
filePaths.Reserve(indices.Size());
|
||||
for(int i = 0; i < indices.Size(); i++)
|
||||
filePaths.Add(srcPanel.GetItemRelPath(indices[i]));
|
||||
|
||||
result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
disableTimerProcessing1.Restore();
|
||||
disableTimerProcessing2.Restore();
|
||||
// For Password:
|
||||
srcPanel.SetFocusToList();
|
||||
if (result != E_ABORT)
|
||||
srcPanel.MessageBoxError(result, L"Error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (copyToSame || move)
|
||||
{
|
||||
srcPanel.RefreshListCtrl(srcSelState);
|
||||
}
|
||||
if (!copyToSame)
|
||||
{
|
||||
destPanel.RefreshListCtrl(destSelState);
|
||||
srcPanel.KillSelection();
|
||||
}
|
||||
disableTimerProcessing1.Restore();
|
||||
disableTimerProcessing2.Restore();
|
||||
srcPanel.SetFocusToList();
|
||||
}
|
||||
|
||||
void CApp::OnSetSameFolder(int srcPanelIndex)
|
||||
{
|
||||
if (NumPanels <= 1)
|
||||
return;
|
||||
const CPanel &srcPanel = Panels[srcPanelIndex];
|
||||
CPanel &destPanel = Panels[1 - srcPanelIndex];
|
||||
destPanel.BindToPathAndRefresh(srcPanel._currentFolderPrefix);
|
||||
}
|
||||
|
||||
void CApp::OnSetSubFolder(int srcPanelIndex)
|
||||
{
|
||||
if (NumPanels <= 1)
|
||||
return;
|
||||
const CPanel &srcPanel = Panels[srcPanelIndex];
|
||||
CPanel &destPanel = Panels[1 - srcPanelIndex];
|
||||
|
||||
int focusedItem = srcPanel._listView.GetFocusedItem();
|
||||
if (focusedItem < 0)
|
||||
return;
|
||||
int realIndex = srcPanel.GetRealItemIndex(focusedItem);
|
||||
if (!srcPanel.IsItemFolder(realIndex))
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
UString string = srcPanel._currentFolderPrefix +
|
||||
srcPanel.GetItemName(realIndex) + L'\\';
|
||||
destPanel.BindToFolder(string);
|
||||
*/
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
if (realIndex == kParentIndex)
|
||||
{
|
||||
if (srcPanel._folder->BindToParentFolder(&newFolder) != S_OK)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (srcPanel._folder->BindToFolder(realIndex, &newFolder) != S_OK)
|
||||
return;
|
||||
}
|
||||
destPanel.CloseOpenFolders();
|
||||
destPanel._folder = newFolder;
|
||||
destPanel.RefreshListCtrl();
|
||||
}
|
||||
|
||||
/*
|
||||
int CApp::GetFocusedPanelIndex() const
|
||||
{
|
||||
return LastFocusedPanel;
|
||||
HWND hwnd = ::GetFocus();
|
||||
for (;;)
|
||||
{
|
||||
if (hwnd == 0)
|
||||
return 0;
|
||||
for (int i = 0; i < kNumPanelsMax; i++)
|
||||
{
|
||||
if (PanelsCreated[i] &&
|
||||
((HWND)Panels[i] == hwnd || Panels[i]._listView == hwnd))
|
||||
return i;
|
||||
}
|
||||
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)
|
||||
{
|
||||
LPNMTTDISPINFO info = (LPNMTTDISPINFO)pnmh;
|
||||
info->hinst = 0;
|
||||
g_ToolTipBuffer.Empty();
|
||||
SetButtonText((UINT32)info->hdr.idFrom, g_ToolTipBuffer);
|
||||
g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
|
||||
info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBufferSys;
|
||||
return;
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
if (pnmh->code == TTN_GETDISPINFOW)
|
||||
{
|
||||
LPNMTTDISPINFOW info = (LPNMTTDISPINFOW)pnmh;
|
||||
info->hinst = 0;
|
||||
g_ToolTipBuffer.Empty();
|
||||
SetButtonText((UINT32)info->hdr.idFrom, g_ToolTipBuffer);
|
||||
info->lpszText = (LPWSTR)(LPCWSTR)g_ToolTipBuffer;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
332
CPP/7zip/UI/FileManager/App.h
Executable file
@@ -0,0 +1,332 @@
|
||||
// App.h
|
||||
|
||||
#ifndef __APP_H
|
||||
#define __APP_H
|
||||
|
||||
#include "Panel.h"
|
||||
#include "AppState.h"
|
||||
#include "Windows/Control/ImageList.h"
|
||||
|
||||
class CApp;
|
||||
|
||||
extern CApp g_App;
|
||||
extern HWND g_HWND;
|
||||
|
||||
const int kNumPanelsMax = 2;
|
||||
|
||||
extern void MoveSubWindows(HWND hWnd);
|
||||
|
||||
enum
|
||||
{
|
||||
kAddCommand = kToolbarStartID,
|
||||
kExtractCommand,
|
||||
kTestCommand
|
||||
};
|
||||
|
||||
class CPanelCallbackImp: public CPanelCallback
|
||||
{
|
||||
CApp *_app;
|
||||
int _index;
|
||||
public:
|
||||
void Init(CApp *app, int index)
|
||||
{
|
||||
_app = app;
|
||||
_index = index;
|
||||
}
|
||||
virtual void OnTab();
|
||||
virtual void SetFocusToPath(int index);
|
||||
virtual void OnCopy(bool move, bool copyToSame);
|
||||
virtual void OnSetSameFolder();
|
||||
virtual void OnSetSubFolder();
|
||||
virtual void PanelWasFocused();
|
||||
virtual void DragBegin();
|
||||
virtual void DragEnd();
|
||||
};
|
||||
|
||||
class CApp;
|
||||
|
||||
class CDropTarget:
|
||||
public IDropTarget,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CMyComPtr<IDataObject> m_DataObject;
|
||||
UStringVector m_SourcePaths;
|
||||
int m_SelectionIndex;
|
||||
bool m_DropIsAllowed; // = true, if data contain fillist
|
||||
bool m_PanelDropIsAllowed; // = false, if current target_panel is source_panel.
|
||||
// check it only if m_DropIsAllowed == true
|
||||
int m_SubFolderIndex;
|
||||
UString m_SubFolderName;
|
||||
|
||||
CPanel *m_Panel;
|
||||
bool m_IsAppTarget; // true, if we want to drop to app window (not to panel).
|
||||
|
||||
bool m_SetPathIsOK;
|
||||
|
||||
bool IsItSameDrive() const;
|
||||
|
||||
void QueryGetData(IDataObject *dataObject);
|
||||
bool IsFsFolderPath() const;
|
||||
DWORD GetEffect(DWORD keyState, POINTL pt, DWORD allowedEffect);
|
||||
void RemoveSelection();
|
||||
void PositionCursor(POINTL ptl);
|
||||
UString GetTargetPath() const;
|
||||
bool SetPath(bool enablePath) const;
|
||||
bool SetPath();
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP1_MT(IDropTarget)
|
||||
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);
|
||||
|
||||
CDropTarget():
|
||||
TargetPanelIndex(-1),
|
||||
SrcPanelIndex(-1),
|
||||
m_IsAppTarget(false),
|
||||
m_Panel(0),
|
||||
App(0),
|
||||
m_PanelDropIsAllowed(false),
|
||||
m_DropIsAllowed(false),
|
||||
m_SelectionIndex(-1),
|
||||
m_SubFolderIndex(-1),
|
||||
m_SetPathIsOK(false) {}
|
||||
|
||||
CApp *App;
|
||||
int SrcPanelIndex; // index of D&D source_panel
|
||||
int TargetPanelIndex; // what panel to use as target_panel of Application
|
||||
};
|
||||
|
||||
class CApp
|
||||
{
|
||||
public:
|
||||
NWindows::CWindow _window;
|
||||
bool ShowSystemMenu;
|
||||
int NumPanels;
|
||||
int LastFocusedPanel;
|
||||
|
||||
bool ShowStandardToolbar;
|
||||
bool ShowArchiveToolbar;
|
||||
bool ShowButtonsLables;
|
||||
bool LargeButtons;
|
||||
|
||||
CAppState AppState;
|
||||
CPanelCallbackImp m_PanelCallbackImp[kNumPanelsMax];
|
||||
CPanel Panels[kNumPanelsMax];
|
||||
bool PanelsCreated[kNumPanelsMax];
|
||||
|
||||
NWindows::NControl::CImageList _archiveButtonsImageList;
|
||||
NWindows::NControl::CImageList _standardButtonsImageList;
|
||||
|
||||
NWindows::NControl::CReBar _rebar;
|
||||
NWindows::NControl::CToolBar _archiveToolBar;
|
||||
NWindows::NControl::CToolBar _standardToolBar;
|
||||
|
||||
CDropTarget *_dropTargetSpec;
|
||||
CMyComPtr<IDropTarget> _dropTarget;
|
||||
|
||||
void CreateDragTarget()
|
||||
{
|
||||
_dropTargetSpec = new CDropTarget();
|
||||
_dropTarget = _dropTargetSpec;
|
||||
_dropTargetSpec->App = (this);
|
||||
}
|
||||
|
||||
void SetFocusedPanel(int index)
|
||||
{
|
||||
LastFocusedPanel = index;
|
||||
_dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
|
||||
}
|
||||
|
||||
void DragBegin(int panelIndex)
|
||||
{
|
||||
_dropTargetSpec->TargetPanelIndex = (NumPanels > 1) ? 1 - panelIndex : panelIndex;
|
||||
_dropTargetSpec->SrcPanelIndex = panelIndex;
|
||||
}
|
||||
|
||||
void DragEnd()
|
||||
{
|
||||
_dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
|
||||
_dropTargetSpec->SrcPanelIndex = -1;
|
||||
}
|
||||
|
||||
|
||||
void OnCopy(bool move, bool copyToSame, int srcPanelIndex);
|
||||
void OnSetSameFolder(int srcPanelIndex);
|
||||
void OnSetSubFolder(int srcPanelIndex);
|
||||
|
||||
void CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted);
|
||||
void Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted);
|
||||
void Read();
|
||||
void Save();
|
||||
void Release();
|
||||
|
||||
|
||||
/*
|
||||
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()]; }
|
||||
|
||||
// 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 CalculateCrc();
|
||||
void Split();
|
||||
void Combine();
|
||||
void Properties()
|
||||
{ GetFocusedPanel().Properties(); }
|
||||
void Comment()
|
||||
{ GetFocusedPanel().ChangeComment(); }
|
||||
|
||||
void CreateFolder()
|
||||
{ GetFocusedPanel().CreateFolder(); }
|
||||
void CreateFile()
|
||||
{ GetFocusedPanel().CreateFile(); }
|
||||
|
||||
// Edit
|
||||
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 RefreshStatusBar()
|
||||
{ GetFocusedPanel().RefreshStatusBar(); }
|
||||
|
||||
void SetListViewMode(UINT32 index)
|
||||
{ GetFocusedPanel().SetListViewMode(index); }
|
||||
UINT32 GetListViewMode()
|
||||
{ return GetFocusedPanel().GetListViewMode(); }
|
||||
|
||||
void SortItemsWithPropID(PROPID propID)
|
||||
{ GetFocusedPanel().SortItemsWithPropID(propID); }
|
||||
|
||||
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++)
|
||||
{
|
||||
int index = i;
|
||||
if (NumPanels == 1)
|
||||
index = LastFocusedPanel;
|
||||
Panels[index].OnReload();
|
||||
}
|
||||
}
|
||||
void SetListSettings();
|
||||
void SetShowSystemMenu();
|
||||
void 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 ReloadRebar(HWND hwnd);
|
||||
void ReloadToolbars();
|
||||
void ReadToolbar()
|
||||
{
|
||||
UINT32 mask = ReadToolbarsMask();
|
||||
ShowButtonsLables = ((mask & 1) != 0);
|
||||
LargeButtons = ((mask & 2) != 0);
|
||||
ShowStandardToolbar = ((mask & 4) != 0);
|
||||
ShowArchiveToolbar = ((mask & 8) != 0);
|
||||
}
|
||||
void SaveToolbar()
|
||||
{
|
||||
UINT32 mask = 0;
|
||||
if (ShowButtonsLables) mask |= 1;
|
||||
if (LargeButtons) mask |= 2;
|
||||
if (ShowStandardToolbar) mask |= 4;
|
||||
if (ShowArchiveToolbar) mask |= 8;
|
||||
SaveToolbarsMask(mask);
|
||||
}
|
||||
void SwitchStandardToolbar()
|
||||
{
|
||||
ShowStandardToolbar = !ShowStandardToolbar;
|
||||
SaveToolbar();
|
||||
ReloadRebar(g_HWND);
|
||||
MoveSubWindows(_window);
|
||||
}
|
||||
void SwitchArchiveToolbar()
|
||||
{
|
||||
ShowArchiveToolbar = !ShowArchiveToolbar;
|
||||
SaveToolbar();
|
||||
ReloadRebar(g_HWND);
|
||||
MoveSubWindows(_window);
|
||||
}
|
||||
void SwitchButtonsLables()
|
||||
{
|
||||
ShowButtonsLables = !ShowButtonsLables;
|
||||
SaveToolbar();
|
||||
ReloadRebar(g_HWND);
|
||||
MoveSubWindows(_window);
|
||||
}
|
||||
void SwitchLargeButtons()
|
||||
{
|
||||
LargeButtons = !LargeButtons;
|
||||
SaveToolbar();
|
||||
ReloadRebar(g_HWND);
|
||||
MoveSubWindows(_window);
|
||||
}
|
||||
|
||||
|
||||
void AddToArchive()
|
||||
{ GetFocusedPanel().AddToArchive(); }
|
||||
void ExtractArchives()
|
||||
{ GetFocusedPanel().ExtractArchives(); }
|
||||
void TestArchives()
|
||||
{ GetFocusedPanel().TestArchives(); }
|
||||
|
||||
void OnNotify(int ctrlID, LPNMHDR pnmh);
|
||||
};
|
||||
|
||||
#endif
|
||||
114
CPP/7zip/UI/FileManager/AppState.h
Executable file
@@ -0,0 +1,114 @@
|
||||
// AppState.h
|
||||
|
||||
#ifndef __APPSTATE_H
|
||||
#define __APPSTATE_H
|
||||
|
||||
#include "Windows/Synchronization.h"
|
||||
|
||||
void inline AddUniqueStringToHead(UStringVector &list,
|
||||
const UString &string)
|
||||
{
|
||||
for(int i = 0; i < list.Size();)
|
||||
if (string.CompareNoCase(list[i]) == 0)
|
||||
list.Delete(i);
|
||||
else
|
||||
i++;
|
||||
list.Insert(0, string);
|
||||
}
|
||||
|
||||
class CFastFolders
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSection _criticalSection;
|
||||
public:
|
||||
UStringVector Strings;
|
||||
void SetString(int index, const UString &string)
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
while(Strings.Size() <= index)
|
||||
Strings.Add(UString());
|
||||
Strings[index] = string;
|
||||
}
|
||||
UString GetString(int index)
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
if (index >= Strings.Size())
|
||||
return UString();
|
||||
return Strings[index];
|
||||
}
|
||||
void Save()
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
SaveFastFolders(Strings);
|
||||
}
|
||||
void Read()
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
ReadFastFolders(Strings);
|
||||
}
|
||||
};
|
||||
|
||||
class CFolderHistory
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSection _criticalSection;
|
||||
UStringVector Strings;
|
||||
public:
|
||||
|
||||
void GetList(UStringVector &foldersHistory)
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
foldersHistory = Strings;
|
||||
}
|
||||
|
||||
void Normalize()
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
const int kMaxSize = 100;
|
||||
if (Strings.Size() > kMaxSize)
|
||||
Strings.Delete(kMaxSize, Strings.Size() - kMaxSize);
|
||||
}
|
||||
|
||||
void AddString(const UString &string)
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
AddUniqueStringToHead(Strings, string);
|
||||
Normalize();
|
||||
}
|
||||
|
||||
void RemoveAll()
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
Strings.Clear();
|
||||
}
|
||||
|
||||
void Save()
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
SaveFolderHistory(Strings);
|
||||
}
|
||||
|
||||
void Read()
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
ReadFolderHistory(Strings);
|
||||
Normalize();
|
||||
}
|
||||
};
|
||||
|
||||
struct CAppState
|
||||
{
|
||||
CFastFolders FastFolders;
|
||||
CFolderHistory FolderHistory;
|
||||
void Save()
|
||||
{
|
||||
FastFolders.Save();
|
||||
FolderHistory.Save();
|
||||
}
|
||||
void Read()
|
||||
{
|
||||
FastFolders.Read();
|
||||
FolderHistory.Read();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
17
CPP/7zip/UI/FileManager/ClassDefs.cpp
Executable file
@@ -0,0 +1,17 @@
|
||||
// ClassDefs.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <initguid.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);
|
||||
53
CPP/7zip/UI/FileManager/ComboDialog.cpp
Executable file
@@ -0,0 +1,53 @@
|
||||
// ComboDialog.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "ComboDialog.h"
|
||||
|
||||
#include "Windows/Control/Static.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "LangUtils.h"
|
||||
#endif
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
#ifdef LANG
|
||||
static CIDLangPair kIDLangPairs[] =
|
||||
{
|
||||
{ IDOK, 0x02000702 },
|
||||
{ IDCANCEL, 0x02000710 }
|
||||
};
|
||||
#endif
|
||||
|
||||
bool CComboDialog::OnInit()
|
||||
{
|
||||
#ifdef LANG
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
#endif
|
||||
_comboBox.Attach(GetItem(IDC_COMBO_COMBO));
|
||||
|
||||
/*
|
||||
// why it doesn't work ?
|
||||
DWORD style = _comboBox.GetStyle();
|
||||
if (Sorted)
|
||||
style |= CBS_SORT;
|
||||
else
|
||||
style &= ~CBS_SORT;
|
||||
_comboBox.SetStyle(style);
|
||||
*/
|
||||
SetText(Title);
|
||||
|
||||
NControl::CStatic staticContol;
|
||||
staticContol.Attach(GetItem(IDC_COMBO_STATIC));
|
||||
staticContol.SetText(Static);
|
||||
_comboBox.SetText(Value);
|
||||
for(int i = 0; i < Strings.Size(); i++)
|
||||
_comboBox.AddString(Strings[i]);
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
void CComboDialog::OnOK()
|
||||
{
|
||||
_comboBox.GetText(Value);
|
||||
CModalDialog::OnOK();
|
||||
}
|
||||
25
CPP/7zip/UI/FileManager/ComboDialog.h
Executable file
@@ -0,0 +1,25 @@
|
||||
// ComboDialog.h
|
||||
|
||||
#ifndef __COMBODIALOG_H
|
||||
#define __COMBODIALOG_H
|
||||
|
||||
#include "Windows/Control/Dialog.h"
|
||||
#include "Windows/Control/ComboBox.h"
|
||||
#include "ComboDialogRes.h"
|
||||
|
||||
class CComboDialog: public NWindows::NControl::CModalDialog
|
||||
{
|
||||
NWindows::NControl::CComboBox _comboBox;
|
||||
virtual void OnOK();
|
||||
virtual bool OnInit();
|
||||
public:
|
||||
// bool Sorted;
|
||||
UString Title;
|
||||
UString Static;
|
||||
UString Value;
|
||||
UStringVector Strings;
|
||||
// CComboDialog(): Sorted(false) {};
|
||||
INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COMBO, parentWindow); }
|
||||
};
|
||||
|
||||
#endif
|
||||
24
CPP/7zip/UI/FileManager/ComboDialog.rc
Executable file
@@ -0,0 +1,24 @@
|
||||
#include "ComboDialogRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 233
|
||||
#define ySize2 57
|
||||
|
||||
#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
|
||||
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
|
||||
4
CPP/7zip/UI/FileManager/ComboDialogRes.h
Executable file
@@ -0,0 +1,4 @@
|
||||
#define IDD_DIALOG_COMBO 200
|
||||
|
||||
#define IDC_COMBO_STATIC 1000
|
||||
#define IDC_COMBO_COMBO 1001
|
||||
BIN
CPP/7zip/UI/FileManager/Copy.bmp
Executable file
|
After Width: | Height: | Size: 982 B |
BIN
CPP/7zip/UI/FileManager/Copy2.bmp
Executable file
|
After Width: | Height: | Size: 406 B |
81
CPP/7zip/UI/FileManager/CopyDialog.cpp
Executable file
@@ -0,0 +1,81 @@
|
||||
// CopyDialog.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "CopyDialog.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Control/Static.h"
|
||||
#include "Windows/Shell.h"
|
||||
#include "Windows/FileName.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "LangUtils.h"
|
||||
#endif
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
#ifdef LANG
|
||||
static CIDLangPair kIDLangPairs[] =
|
||||
{
|
||||
{ IDOK, 0x02000702 },
|
||||
{ IDCANCEL, 0x02000710 }
|
||||
};
|
||||
#endif
|
||||
|
||||
bool CCopyDialog::OnInit()
|
||||
{
|
||||
#ifdef LANG
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
#endif
|
||||
_path.Attach(GetItem(IDC_COPY_COMBO));
|
||||
SetText(Title);
|
||||
|
||||
NControl::CStatic staticContol;
|
||||
staticContol.Attach(GetItem(IDC_COPY_STATIC));
|
||||
staticContol.SetText(Static);
|
||||
for(int i = 0; i < Strings.Size(); i++)
|
||||
_path.AddString(Strings[i]);
|
||||
_path.SetText(Value);
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
{
|
||||
switch(buttonID)
|
||||
{
|
||||
case IDC_COPY_SET_PATH:
|
||||
OnButtonSetPath();
|
||||
return true;
|
||||
}
|
||||
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
|
||||
}
|
||||
|
||||
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))
|
||||
return;
|
||||
NFile::NName::NormalizeDirPathPrefix(resultPath);
|
||||
_path.SetCurSel(-1);
|
||||
_path.SetText(resultPath);
|
||||
}
|
||||
|
||||
void CCopyDialog::OnOK()
|
||||
{
|
||||
_path.GetText(Value);
|
||||
CModalDialog::OnOK();
|
||||
}
|
||||
26
CPP/7zip/UI/FileManager/CopyDialog.h
Executable file
@@ -0,0 +1,26 @@
|
||||
// CopyDialog.h
|
||||
|
||||
#ifndef __COPYDIALOG_H
|
||||
#define __COPYDIALOG_H
|
||||
|
||||
#include "Windows/Control/Dialog.h"
|
||||
#include "Windows/Control/ComboBox.h"
|
||||
#include "CopyDialogRes.h"
|
||||
|
||||
class CCopyDialog: public NWindows::NControl::CModalDialog
|
||||
{
|
||||
NWindows::NControl::CComboBox _path;
|
||||
virtual void OnOK();
|
||||
virtual bool OnInit();
|
||||
void OnButtonSetPath();
|
||||
bool OnButtonClicked(int buttonID, HWND buttonHWND);
|
||||
public:
|
||||
UString Title;
|
||||
UString Static;
|
||||
UString Value;
|
||||
UStringVector Strings;
|
||||
|
||||
INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); }
|
||||
};
|
||||
|
||||
#endif
|
||||
28
CPP/7zip/UI/FileManager/CopyDialog.rc
Executable file
@@ -0,0 +1,28 @@
|
||||
#include "CopyDialogRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 346
|
||||
#define ySize2 57
|
||||
|
||||
#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
|
||||
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
|
||||
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
|
||||
7
CPP/7zip/UI/FileManager/CopyDialogRes.h
Executable file
@@ -0,0 +1,7 @@
|
||||
#define IDD_DIALOG_COPY 202
|
||||
|
||||
#define IDC_COPY_STATIC 1000
|
||||
#define IDC_COPY_COMBO 1001
|
||||
#define IDC_COPY_SET_PATH 1002
|
||||
|
||||
#define IDS_SET_FOLDER 210
|
||||
BIN
CPP/7zip/UI/FileManager/Delete.bmp
Executable file
|
After Width: | Height: | Size: 982 B |
BIN
CPP/7zip/UI/FileManager/Delete2.bmp
Executable file
|
After Width: | Height: | Size: 406 B |
91
CPP/7zip/UI/FileManager/EditPage.cpp
Executable file
@@ -0,0 +1,91 @@
|
||||
// EditPage.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "EditPageRes.h"
|
||||
#include "EditPage.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 "HelpUtils.h"
|
||||
#include "LangUtils.h"
|
||||
#include "ProgramLocation.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static CIDLangPair kIDLangPairs[] =
|
||||
{
|
||||
{ IDC_EDIT_STATIC_EDITOR, 0x03010201}
|
||||
};
|
||||
|
||||
static LPCWSTR kEditTopic = L"FM/options.htm#editor";
|
||||
|
||||
bool CEditPage::OnInit()
|
||||
{
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
|
||||
_editorEdit.Attach(GetItem(IDC_EDIT_EDIT_EDITOR));
|
||||
UString editorPath;
|
||||
ReadRegEditor(editorPath);
|
||||
_editorEdit.SetText(editorPath);
|
||||
return CPropertyPage::OnInit();
|
||||
}
|
||||
|
||||
LONG CEditPage::OnApply()
|
||||
{
|
||||
// int selectedIndex = _langCombo.GetCurSel();
|
||||
// int pathIndex = _langCombo.GetItemData(selectedIndex);
|
||||
// ReloadLang();
|
||||
UString editorPath;
|
||||
_editorEdit.GetText(editorPath);
|
||||
SaveRegEditor(editorPath);
|
||||
return PSNRET_NOERROR;
|
||||
}
|
||||
|
||||
void CEditPage::OnNotifyHelp()
|
||||
{
|
||||
ShowHelpWindow(NULL, kEditTopic); // change it
|
||||
}
|
||||
|
||||
bool CEditPage::OnButtonClicked(int aButtonID, HWND aButtonHWND)
|
||||
{
|
||||
switch(aButtonID)
|
||||
{
|
||||
case IDC_EDIT_BUTTON_SET:
|
||||
{
|
||||
OnSetEditorButton();
|
||||
// if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, aResultPath))
|
||||
// return;
|
||||
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();
|
||||
}
|
||||
|
||||
bool CEditPage::OnCommand(int code, int itemID, LPARAM param)
|
||||
{
|
||||
if (code == EN_CHANGE && itemID == IDC_EDIT_EDIT_EDITOR)
|
||||
{
|
||||
Changed();
|
||||
return true;
|
||||
}
|
||||
return CPropertyPage::OnCommand(code, itemID, param);
|
||||
}
|
||||
|
||||
|
||||
21
CPP/7zip/UI/FileManager/EditPage.h
Executable file
@@ -0,0 +1,21 @@
|
||||
// EditPage.h
|
||||
|
||||
#ifndef __EDITPAGE_H
|
||||
#define __EDITPAGE_H
|
||||
|
||||
#include "Windows/Control/PropertyPage.h"
|
||||
#include "Windows/Control/Edit.h"
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
#endif
|
||||
16
CPP/7zip/UI/FileManager/EditPage.rc
Executable file
@@ -0,0 +1,16 @@
|
||||
#include "EditPageRes.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 196
|
||||
#define ySize2 140
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
|
||||
IDD_EDIT DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE
|
||||
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
|
||||
4
CPP/7zip/UI/FileManager/EditPageRes.h
Executable file
@@ -0,0 +1,4 @@
|
||||
#define IDD_EDIT 903
|
||||
#define IDC_EDIT_STATIC_EDITOR 1000
|
||||
#define IDC_EDIT_EDIT_EDITOR 1002
|
||||
#define IDC_EDIT_BUTTON_SET 1003
|
||||
108
CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
Executable file
@@ -0,0 +1,108 @@
|
||||
// EnumFormatEtc.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "EnumFormatEtc.h"
|
||||
#include "MyCom2.h"
|
||||
|
||||
class CEnumFormatEtc :
|
||||
public IEnumFORMATETC,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1_MT(IEnumFORMATETC)
|
||||
|
||||
STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched);
|
||||
STDMETHOD(Skip)(ULONG celt);
|
||||
STDMETHOD(Reset)(void);
|
||||
STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc);
|
||||
|
||||
CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats);
|
||||
~CEnumFormatEtc();
|
||||
|
||||
private:
|
||||
LONG m_RefCount;
|
||||
ULONG m_NumFormats;
|
||||
FORMATETC *m_Formats;
|
||||
ULONG m_Index;
|
||||
};
|
||||
|
||||
static void DeepCopyFormatEtc(FORMATETC *dest, const FORMATETC *src)
|
||||
{
|
||||
*dest = *src;
|
||||
if(src->ptd)
|
||||
{
|
||||
dest->ptd = (DVTARGETDEVICE*)CoTaskMemAlloc(sizeof(DVTARGETDEVICE));
|
||||
*(dest->ptd) = *(src->ptd);
|
||||
}
|
||||
}
|
||||
|
||||
CEnumFormatEtc::CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats)
|
||||
{
|
||||
m_RefCount = 1;
|
||||
m_Index = 0;
|
||||
m_NumFormats = 0;
|
||||
m_Formats = new FORMATETC[numFormats];
|
||||
if(m_Formats)
|
||||
{
|
||||
m_NumFormats = numFormats;
|
||||
for(ULONG i = 0; i < numFormats; i++)
|
||||
DeepCopyFormatEtc(&m_Formats[i], &pFormatEtc[i]);
|
||||
}
|
||||
}
|
||||
|
||||
CEnumFormatEtc::~CEnumFormatEtc()
|
||||
{
|
||||
if(m_Formats)
|
||||
{
|
||||
for(ULONG i = 0; i < m_NumFormats; i++)
|
||||
if(m_Formats[i].ptd)
|
||||
CoTaskMemFree(m_Formats[i].ptd);
|
||||
delete[]m_Formats;
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pceltFetched)
|
||||
{
|
||||
ULONG copied = 0;
|
||||
if(celt == 0 || pFormatEtc == 0)
|
||||
return E_INVALIDARG;
|
||||
while(m_Index < m_NumFormats && copied < celt)
|
||||
{
|
||||
DeepCopyFormatEtc(&pFormatEtc[copied], &m_Formats[m_Index]);
|
||||
copied++;
|
||||
m_Index++;
|
||||
}
|
||||
if(pceltFetched != 0)
|
||||
*pceltFetched = copied;
|
||||
return (copied == celt) ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
STDMETHODIMP CEnumFormatEtc::Skip(ULONG celt)
|
||||
{
|
||||
m_Index += celt;
|
||||
return (m_Index <= m_NumFormats) ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
STDMETHODIMP CEnumFormatEtc::Reset(void)
|
||||
{
|
||||
m_Index = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc)
|
||||
{
|
||||
HRESULT hResult = CreateEnumFormatEtc(m_NumFormats, m_Formats, ppEnumFormatEtc);
|
||||
if(hResult == S_OK)
|
||||
((CEnumFormatEtc *)*ppEnumFormatEtc)->m_Index = m_Index;
|
||||
return hResult;
|
||||
}
|
||||
|
||||
// replacement for SHCreateStdEnumFmtEtc
|
||||
HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat)
|
||||
{
|
||||
if(numFormats == 0 || formats == 0 || enumFormat == 0)
|
||||
return E_INVALIDARG;
|
||||
*enumFormat = new CEnumFormatEtc(formats, numFormats);
|
||||
return (*enumFormat) ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
||||
10
CPP/7zip/UI/FileManager/EnumFormatEtc.h
Executable file
@@ -0,0 +1,10 @@
|
||||
// EnumFormatEtc.h
|
||||
|
||||
#ifndef __ENUMFORMATETC_H
|
||||
#define __ENUMFORMATETC_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat);
|
||||
|
||||
#endif
|
||||
BIN
CPP/7zip/UI/FileManager/Extract.bmp
Executable file
|
After Width: | Height: | Size: 982 B |
BIN
CPP/7zip/UI/FileManager/Extract2.bmp
Executable file
|
After Width: | Height: | Size: 406 B |
440
CPP/7zip/UI/FileManager/ExtractCallback.cpp
Executable file
@@ -0,0 +1,440 @@
|
||||
// ExtractCallback.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ExtractCallback.h"
|
||||
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Error.h"
|
||||
|
||||
#include "OverwriteDialog.h"
|
||||
#ifndef _NO_CRYPTO
|
||||
#include "PasswordDialog.h"
|
||||
#endif
|
||||
#include "MessagesDialog.h"
|
||||
#include "../GUI/ExtractRes.h"
|
||||
#include "../GUI/resource.h"
|
||||
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "FormatUtils.h"
|
||||
|
||||
#include "../../Common/FilePathAutoRename.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
CExtractCallbackImp::~CExtractCallbackImp()
|
||||
{
|
||||
if (ShowMessages && !Messages.IsEmpty())
|
||||
{
|
||||
CMessagesDialog messagesDialog;
|
||||
messagesDialog.Messages = &Messages;
|
||||
messagesDialog.Create(ParentWindow);
|
||||
}
|
||||
}
|
||||
|
||||
void CExtractCallbackImp::Init()
|
||||
{
|
||||
Messages.Clear();
|
||||
NumArchiveErrors = 0;
|
||||
#ifndef _SFX
|
||||
NumFolders = NumFiles = 0;
|
||||
NeedAddFile = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CExtractCallbackImp::AddErrorMessage(LPCWSTR message)
|
||||
{
|
||||
Messages.Add(message);
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64
|
||||
#ifndef _SFX
|
||||
numFiles
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifndef _SFX
|
||||
ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles);
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total)
|
||||
{
|
||||
ProgressDialog.ProgressSynch.SetProgress(total, 0);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if(ProgressDialog.ProgressSynch.GetStopped())
|
||||
return E_ABORT;
|
||||
if(!ProgressDialog.ProgressSynch.GetPaused())
|
||||
break;
|
||||
::Sleep(100);
|
||||
}
|
||||
if (value != NULL)
|
||||
ProgressDialog.ProgressSynch.SetPos(*value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifndef _SFX
|
||||
STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
|
||||
{
|
||||
ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize);
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
STDMETHODIMP CExtractCallbackImp::SetTotalFiles(UInt64 total)
|
||||
{
|
||||
ProgressDialog.ProgressSynch.SetNumFilesTotal(total);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value)
|
||||
{
|
||||
if (value != NULL)
|
||||
ProgressDialog.ProgressSynch.SetNumFilesCur(*value);
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::AskOverwrite(
|
||||
const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
|
||||
Int32 *answer)
|
||||
{
|
||||
COverwriteDialog dialog;
|
||||
|
||||
dialog.OldFileInfo.Time = *existTime;
|
||||
dialog.OldFileInfo.SizeIsDefined = (existSize != NULL);
|
||||
if (dialog.OldFileInfo.SizeIsDefined)
|
||||
dialog.OldFileInfo.Size = *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.Name = newName;
|
||||
|
||||
/*
|
||||
NOverwriteDialog::NResult::EEnum writeAnswer =
|
||||
NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
|
||||
*/
|
||||
INT_PTR writeAnswer = dialog.Create(NULL); // ParentWindow doesn't work with 7z
|
||||
|
||||
switch(writeAnswer)
|
||||
{
|
||||
case IDCANCEL:
|
||||
return E_ABORT;
|
||||
// askResult = NAskOverwriteAnswer::kCancel;
|
||||
// break;
|
||||
case IDNO:
|
||||
*answer = NOverwriteAnswer::kNo;
|
||||
break;
|
||||
case IDC_BUTTON_OVERWRITE_NO_TO_ALL:
|
||||
*answer = NOverwriteAnswer::kNoToAll;
|
||||
break;
|
||||
case IDC_BUTTON_OVERWRITE_YES_TO_ALL:
|
||||
*answer = NOverwriteAnswer::kYesToAll;
|
||||
break;
|
||||
case IDC_BUTTON_OVERWRITE_AUTO_RENAME:
|
||||
*answer = NOverwriteAnswer::kAutoRename;
|
||||
break;
|
||||
case IDYES:
|
||||
*answer = NOverwriteAnswer::kYes;
|
||||
break;
|
||||
default:
|
||||
throw 20413;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, bool isFolder, Int32 /* askExtractMode */, const UInt64 * /* position */)
|
||||
{
|
||||
_isFolder = isFolder;
|
||||
return SetCurrentFilePath2(name);
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
|
||||
{
|
||||
AddErrorMessage(message);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *message)
|
||||
{
|
||||
AddErrorMessage(message);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool encrypted)
|
||||
{
|
||||
switch(operationResult)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kOK:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
UINT messageID;
|
||||
UInt32 langID;
|
||||
switch(operationResult)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
|
||||
messageID = IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD;
|
||||
langID = 0x02000A91;
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kDataError:
|
||||
messageID = encrypted ?
|
||||
IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED:
|
||||
IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR;
|
||||
langID = encrypted ? 0x02000A94 : 0x02000A92;
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kCRCError:
|
||||
messageID = encrypted ?
|
||||
IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED:
|
||||
IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC;
|
||||
langID = encrypted ? 0x02000A95 : 0x02000A93;
|
||||
break;
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
if (_needWriteArchivePath)
|
||||
{
|
||||
AddErrorMessage(_currentArchivePath);
|
||||
_needWriteArchivePath = false;
|
||||
}
|
||||
AddErrorMessage(
|
||||
MyFormatNew(messageID,
|
||||
#ifdef LANG
|
||||
langID,
|
||||
#endif
|
||||
_currentFilePath));
|
||||
}
|
||||
}
|
||||
#ifndef _SFX
|
||||
if (_isFolder)
|
||||
NumFolders++;
|
||||
else
|
||||
NumFiles++;
|
||||
ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles);
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// IExtractCallbackUI
|
||||
|
||||
HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name)
|
||||
{
|
||||
#ifndef _SFX
|
||||
ProgressDialog.ProgressSynch.SetTitleFileName(name);
|
||||
#endif
|
||||
_currentArchivePath = name;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path)
|
||||
{
|
||||
_currentFilePath = path;
|
||||
#ifndef _SFX
|
||||
ProgressDialog.ProgressSynch.SetCurrentFileName(path);
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path)
|
||||
{
|
||||
#ifndef _SFX
|
||||
if (NeedAddFile)
|
||||
NumFiles++;
|
||||
NeedAddFile = true;
|
||||
ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles);
|
||||
#endif
|
||||
return SetCurrentFilePath2(path);
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, bool encrypted)
|
||||
{
|
||||
if (result != S_OK)
|
||||
{
|
||||
MessageError(MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE,
|
||||
#ifdef LANG
|
||||
(encrypted ? 0x0200060A : 0x02000609),
|
||||
#endif
|
||||
name));
|
||||
NumArchiveErrors++;
|
||||
}
|
||||
_currentArchivePath = name;
|
||||
_needWriteArchivePath = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::ThereAreNoFiles()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::ExtractResult(HRESULT result)
|
||||
{
|
||||
if (result == S_OK)
|
||||
return result;
|
||||
NumArchiveErrors++;
|
||||
if (result == E_ABORT || result == ERROR_DISK_FULL)
|
||||
return result;
|
||||
MessageError(_currentFilePath);
|
||||
MessageError(NError::MyFormatMessageW(result));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::SetPassword(const UString &password)
|
||||
{
|
||||
PasswordIsDefined = true;
|
||||
Password = password;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
|
||||
{
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
CPasswordDialog dialog;
|
||||
|
||||
if (dialog.Create(ParentWindow) == IDCANCEL)
|
||||
return E_ABORT;
|
||||
|
||||
Password = dialog.Password;
|
||||
PasswordIsDefined = true;
|
||||
}
|
||||
CMyComBSTR tempName(Password);
|
||||
*password = tempName.Detach();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
// IExtractCallBack3
|
||||
STDMETHODIMP CExtractCallbackImp::AskWrite(
|
||||
const wchar_t *srcPath, Int32 srcIsFolder,
|
||||
const FILETIME *srcTime, const UInt64 *srcSize,
|
||||
const wchar_t *destPath,
|
||||
BSTR *destPathResult,
|
||||
Int32 *writeAnswer)
|
||||
{
|
||||
UString destPathResultTemp = destPath;
|
||||
/*
|
||||
{
|
||||
CMyComBSTR destPathResultBSTR = destPath;
|
||||
*destPathResult = destPathResultBSTR.Detach();
|
||||
}
|
||||
*/
|
||||
*destPathResult = 0;
|
||||
*writeAnswer = BoolToInt(false);
|
||||
|
||||
UString destPathSpec = destPath;
|
||||
UString destPathSys = destPathSpec;
|
||||
bool srcIsFolderSpec = IntToBool(srcIsFolder);
|
||||
CFileInfoW destFileInfo;
|
||||
if (FindFile(destPathSys, destFileInfo))
|
||||
{
|
||||
if (srcIsFolderSpec)
|
||||
{
|
||||
if (!destFileInfo.IsDirectory())
|
||||
{
|
||||
UString message = UString(L"can not replace file \'")
|
||||
+ destPathSpec +
|
||||
UString(L"\' with folder with same name");
|
||||
RINOK(MessageError(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
*writeAnswer = BoolToInt(false);
|
||||
return S_OK;
|
||||
}
|
||||
if (destFileInfo.IsDirectory())
|
||||
{
|
||||
UString message = UString(L"can not replace folder \'")
|
||||
+ destPathSpec +
|
||||
UString(L"\' with file with same name");
|
||||
RINOK(MessageError(message));
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
switch(OverwriteMode)
|
||||
{
|
||||
case NExtract::NOverwriteMode::kSkipExisting:
|
||||
return S_OK;
|
||||
case NExtract::NOverwriteMode::kAskBefore:
|
||||
{
|
||||
Int32 overwiteResult;
|
||||
RINOK(AskOverwrite(
|
||||
destPathSpec,
|
||||
&destFileInfo.LastWriteTime, &destFileInfo.Size,
|
||||
srcPath,
|
||||
srcTime, srcSize,
|
||||
&overwiteResult));
|
||||
switch(overwiteResult)
|
||||
{
|
||||
case NOverwriteAnswer::kCancel:
|
||||
return E_ABORT;
|
||||
case NOverwriteAnswer::kNo:
|
||||
return S_OK;
|
||||
case NOverwriteAnswer::kNoToAll:
|
||||
OverwriteMode = NExtract::NOverwriteMode::kSkipExisting;
|
||||
return S_OK;
|
||||
case NOverwriteAnswer::kYesToAll:
|
||||
OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
|
||||
break;
|
||||
case NOverwriteAnswer::kYes:
|
||||
break;
|
||||
case NOverwriteAnswer::kAutoRename:
|
||||
OverwriteMode = NExtract::NOverwriteMode::kAutoRename;
|
||||
break;
|
||||
default:
|
||||
throw 20413;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OverwriteMode == NExtract::NOverwriteMode::kAutoRename)
|
||||
{
|
||||
if (!AutoRenamePath(destPathSys))
|
||||
{
|
||||
UString message = UString(L"can not create name of file ")
|
||||
+ destPathSys;
|
||||
RINOK(MessageError(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
destPathResultTemp = destPathSys;
|
||||
}
|
||||
else
|
||||
if (!NFile::NDirectory::DeleteFileAlways(destPathSys))
|
||||
{
|
||||
UString message = UString(L"can not delete output file ")
|
||||
+ destPathSys;
|
||||
RINOK(MessageError(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
CMyComBSTR destPathResultBSTR = destPathResultTemp;
|
||||
*destPathResult = destPathResultBSTR.Detach();
|
||||
*writeAnswer = BoolToInt(true);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
147
CPP/7zip/UI/FileManager/ExtractCallback.h
Executable file
@@ -0,0 +1,147 @@
|
||||
// ExtractCallback.h
|
||||
|
||||
#ifndef __EXTRACTCALLBACK_H
|
||||
#define __EXTRACTCALLBACK_H
|
||||
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
#include "Common/MyString.h"
|
||||
|
||||
#ifdef _SFX
|
||||
#include "ProgressDialog.h"
|
||||
#else
|
||||
#include "ProgressDialog2.h"
|
||||
#endif
|
||||
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "LangUtils.h"
|
||||
#endif
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
#include "../../IPassword.h"
|
||||
#endif
|
||||
#include "Common/MyCom.h"
|
||||
#include "IFolder.h"
|
||||
|
||||
class CExtractCallbackImp:
|
||||
public IExtractCallbackUI,
|
||||
public IFolderOperationsExtractCallback,
|
||||
// public IFolderArchiveExtractCallback, // mkultiple from IProgress
|
||||
#ifndef _SFX
|
||||
public ICompressProgressInfo,
|
||||
#endif
|
||||
#ifndef _NO_CRYPTO
|
||||
public ICryptoGetTextPassword,
|
||||
#endif
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN2(IFolderOperationsExtractCallback)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback)
|
||||
#ifndef _SFX
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressProgressInfo)
|
||||
#endif
|
||||
#ifndef _NO_CRYPTO
|
||||
MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword)
|
||||
#endif
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
// IProgress
|
||||
STDMETHOD(SetTotal)(UInt64 total);
|
||||
STDMETHOD(SetCompleted)(const UInt64 *value);
|
||||
|
||||
#ifndef _SFX
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||
#endif
|
||||
|
||||
// IFolderArchiveExtractCallback
|
||||
// STDMETHOD(SetTotalFiles)(UInt64 total);
|
||||
// STDMETHOD(SetCompletedFiles)(const UInt64 *value);
|
||||
STDMETHOD(AskOverwrite)(
|
||||
const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
|
||||
Int32 *answer);
|
||||
STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, Int32 askExtractMode, const UInt64 *position);
|
||||
|
||||
STDMETHOD(MessageError)(const wchar_t *message);
|
||||
STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted);
|
||||
|
||||
// IExtractCallbackUI
|
||||
|
||||
HRESULT BeforeOpen(const wchar_t *name);
|
||||
HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted);
|
||||
HRESULT ThereAreNoFiles();
|
||||
HRESULT ExtractResult(HRESULT result);
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
HRESULT SetPassword(const UString &password);
|
||||
#endif
|
||||
|
||||
// IFolderOperationsExtractCallback
|
||||
STDMETHOD(AskWrite)(
|
||||
const wchar_t *srcPath,
|
||||
Int32 srcIsFolder,
|
||||
const FILETIME *srcTime,
|
||||
const UInt64 *srcSize,
|
||||
const wchar_t *destPathRequest,
|
||||
BSTR *destPathResult,
|
||||
Int32 *writeAnswer);
|
||||
STDMETHOD(ShowMessage)(const wchar_t *message);
|
||||
STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath);
|
||||
STDMETHOD(SetNumFiles)(UInt64 numFiles);
|
||||
|
||||
// ICryptoGetTextPassword
|
||||
#ifndef _NO_CRYPTO
|
||||
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
|
||||
#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;
|
||||
#ifndef _SFX
|
||||
UInt64 NumFolders;
|
||||
UInt64 NumFiles;
|
||||
bool NeedAddFile;
|
||||
#endif
|
||||
HWND ParentWindow;
|
||||
INT_PTR StartProgressDialog(const UString &title)
|
||||
{
|
||||
return ProgressDialog.Create(title, ParentWindow);
|
||||
}
|
||||
UInt32 NumArchiveErrors;
|
||||
NExtract::NOverwriteMode::EEnum OverwriteMode;
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
#endif
|
||||
|
||||
CExtractCallbackImp():
|
||||
#ifndef _NO_CRYPTO
|
||||
PasswordIsDefined(false),
|
||||
#endif
|
||||
OverwriteMode(NExtract::NOverwriteMode::kAskBefore),
|
||||
ParentWindow(0),
|
||||
ShowMessages(true)
|
||||
{}
|
||||
|
||||
~CExtractCallbackImp();
|
||||
void Init();
|
||||
};
|
||||
|
||||
#endif
|
||||
803
CPP/7zip/UI/FileManager/FM.cpp
Executable file
@@ -0,0 +1,803 @@
|
||||
// FM.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "resource.h"
|
||||
#include "Panel.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Alloc.h"
|
||||
}
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/StringConvert.h"
|
||||
// #include "Common/CommandLineParser.h"
|
||||
|
||||
#include "Windows/Control/Toolbar.h"
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/COM.h"
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/Security.h"
|
||||
#include "Windows/MemoryLock.h"
|
||||
|
||||
#include "ViewSettings.h"
|
||||
#include "../GUI/ExtractRes.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include "MyLoadMenu.h"
|
||||
#include "LangUtils.h"
|
||||
#include "FormatUtils.h"
|
||||
#include "RegistryUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
// using namespace NCommandLineParser;
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
#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;
|
||||
|
||||
const int kNumDefaultPanels = 1;
|
||||
|
||||
const int kSplitterWidth = 4;
|
||||
int kSplitterRateMax = 1 << 16;
|
||||
|
||||
// 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(L'\\');
|
||||
return path.Left(pos + 1);
|
||||
}
|
||||
|
||||
|
||||
class CSplitterPos
|
||||
{
|
||||
int _ratio; // 10000 is max
|
||||
int _pos;
|
||||
int _fullWidth;
|
||||
void SetRatioFromPos(HWND hWnd)
|
||||
{ _ratio = (_pos + kSplitterWidth / 2) * kSplitterRateMax /
|
||||
MyMax(GetWidth(hWnd), 1); }
|
||||
public:
|
||||
int GetPos() const
|
||||
{ return _pos; }
|
||||
int GetWidth(HWND hWnd) const
|
||||
{
|
||||
RECT rect;
|
||||
::GetClientRect(hWnd, &rect);
|
||||
return rect.right;
|
||||
}
|
||||
void SetRatio(HWND hWnd, int aRatio)
|
||||
{
|
||||
_ratio = aRatio;
|
||||
SetPosFromRatio(hWnd);
|
||||
}
|
||||
void SetPosPure(HWND hWnd, int pos)
|
||||
{
|
||||
int posMax = GetWidth(hWnd) - kSplitterWidth;
|
||||
if (pos > posMax)
|
||||
pos = posMax;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
_pos = pos;
|
||||
}
|
||||
void SetPos(HWND hWnd, int pos)
|
||||
{
|
||||
_fullWidth = GetWidth(hWnd);
|
||||
SetPosPure(hWnd, pos);
|
||||
SetRatioFromPos(hWnd);
|
||||
}
|
||||
void SetPosFromRatio(HWND hWnd)
|
||||
{
|
||||
int fullWidth = GetWidth(hWnd);
|
||||
if (_fullWidth != fullWidth)
|
||||
{
|
||||
_fullWidth = fullWidth;
|
||||
SetPosPure(hWnd, GetWidth(hWnd) * _ratio / kSplitterRateMax - kSplitterWidth / 2);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bool g_CanChangeSplitter = false;
|
||||
UINT32 g_SplitterPos = 0;
|
||||
CSplitterPos g_Splitter;
|
||||
bool g_PanelsInfoDefined = false;
|
||||
|
||||
int g_StartCaptureMousePos;
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
// FUNCTION: InitInstance(HANDLE, int)
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
CWindow wnd;
|
||||
|
||||
g_hInstance = hInstance;
|
||||
|
||||
ReloadLangSmart();
|
||||
|
||||
// LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING);
|
||||
|
||||
// LoadString(hInstance, IDS_APP_TITLE, title, MAX_LOADSTRING);
|
||||
UString title = LangString(IDS_APP_TITLE, 0x03000000);
|
||||
|
||||
/*
|
||||
//If it is already running, then focus on the window
|
||||
hWnd = FindWindow(windowClass, title);
|
||||
if (hWnd)
|
||||
{
|
||||
SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
WNDCLASSW wc;
|
||||
|
||||
// wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = (WNDPROC) WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FAM));
|
||||
|
||||
// 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.lpszClassName = kWindowClass;
|
||||
|
||||
MyRegisterClass(&wc);
|
||||
|
||||
// RECT rect;
|
||||
// GetClientRect(hWnd, &rect);
|
||||
|
||||
DWORD style = WS_OVERLAPPEDWINDOW;
|
||||
// DWORD style = 0;
|
||||
|
||||
RECT rect;
|
||||
bool maximized = false;
|
||||
int x , y, xSize, ySize;
|
||||
x = y = xSize = ySize = CW_USEDEFAULT;
|
||||
bool windowPosIsRead = ReadWindowSize(rect, maximized);
|
||||
|
||||
if (windowPosIsRead)
|
||||
{
|
||||
// x = rect.left;
|
||||
// y = rect.top;
|
||||
xSize = rect.right - rect.left;
|
||||
ySize = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
UINT32 numPanels, currentPanel;
|
||||
g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos);
|
||||
if (g_PanelsInfoDefined)
|
||||
{
|
||||
if (numPanels < 1 || numPanels > 2)
|
||||
numPanels = kNumDefaultPanels;
|
||||
if (currentPanel >= 2)
|
||||
currentPanel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
numPanels = kNumDefaultPanels;
|
||||
currentPanel = 0;
|
||||
}
|
||||
g_App.NumPanels = numPanels;
|
||||
g_App.LastFocusedPanel = currentPanel;
|
||||
|
||||
if (!wnd.Create(kWindowClass, title, style,
|
||||
x, y, xSize, ySize, NULL, NULL, hInstance, NULL))
|
||||
return FALSE;
|
||||
g_HWND = (HWND)wnd;
|
||||
|
||||
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;
|
||||
wnd.SetPlacement(&placement);
|
||||
// window.Show(nCmdShow);
|
||||
}
|
||||
else
|
||||
wnd.Show(nCmdShow);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
static void GetCommands(const UString &aCommandLine, UString &aCommands)
|
||||
{
|
||||
UString aProgramName;
|
||||
aCommands.Empty();
|
||||
bool aQuoteMode = false;
|
||||
for (int i = 0; i < aCommandLine.Length(); i++)
|
||||
{
|
||||
wchar_t aChar = aCommandLine[i];
|
||||
if (aChar == L'\"')
|
||||
aQuoteMode = !aQuoteMode;
|
||||
else if (aChar == L' ' && !aQuoteMode)
|
||||
{
|
||||
if (!aQuoteMode)
|
||||
{
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
aProgramName += aChar;
|
||||
}
|
||||
aCommands = aCommandLine.Mid(i);
|
||||
}
|
||||
*/
|
||||
|
||||
DWORD GetDllVersion(LPCTSTR lpszDllName)
|
||||
{
|
||||
HINSTANCE hinstDll;
|
||||
DWORD dwVersion = 0;
|
||||
hinstDll = LoadLibrary(lpszDllName);
|
||||
if(hinstDll)
|
||||
{
|
||||
DLLGETVERSIONPROC pDllGetVersion;
|
||||
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)
|
||||
{
|
||||
DLLVERSIONINFO dvi;
|
||||
HRESULT hr;
|
||||
|
||||
ZeroMemory(&dvi, sizeof(dvi));
|
||||
dvi.cbSize = sizeof(dvi);
|
||||
|
||||
hr = (*pDllGetVersion)(&dvi);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
|
||||
}
|
||||
}
|
||||
FreeLibrary(hinstDll);
|
||||
}
|
||||
return dwVersion;
|
||||
}
|
||||
|
||||
DWORD g_ComCtl32Version;
|
||||
|
||||
/*
|
||||
#ifndef _WIN64
|
||||
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
|
||||
|
||||
static bool IsWow64()
|
||||
{
|
||||
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
|
||||
GetModuleHandle("kernel32"), "IsWow64Process");
|
||||
if (fnIsWow64Process == NULL)
|
||||
return false;
|
||||
BOOL isWow;
|
||||
if (!fnIsWow64Process(GetCurrentProcess(),&isWow))
|
||||
return false;
|
||||
return isWow != FALSE;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
bool IsLargePageSupported()
|
||||
{
|
||||
#ifdef _WIN64
|
||||
return true;
|
||||
#else
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 5)
|
||||
return false;
|
||||
if (versionInfo.dwMajorVersion > 5)
|
||||
return true;
|
||||
if (versionInfo.dwMinorVersion < 1)
|
||||
return false;
|
||||
if (versionInfo.dwMinorVersion > 1)
|
||||
return true;
|
||||
// return IsWow64();
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SetMemoryLock()
|
||||
{
|
||||
if (!IsLargePageSupported())
|
||||
return;
|
||||
// if (ReadLockMemoryAdd())
|
||||
NSecurity::AddLockMemoryPrivilege();
|
||||
|
||||
if (ReadLockMemoryEnable())
|
||||
NSecurity::EnableLockMemoryPrivilege();
|
||||
}
|
||||
|
||||
/*
|
||||
static const int kNumSwitches = 1;
|
||||
|
||||
namespace NKey {
|
||||
enum Enum
|
||||
{
|
||||
kOpenArachive = 0,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static const CSwitchForm kSwitchForms[kNumSwitches] =
|
||||
{
|
||||
{ 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
|
||||
|
||||
#ifdef _WIN32
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
|
||||
|
||||
// OleInitialize is required for drag and drop.
|
||||
OleInitialize(NULL);
|
||||
// Maybe needs CoInitializeEx also ?
|
||||
// NCOM::CComInitializer comInitializer;
|
||||
|
||||
UString programString, commandsString;
|
||||
// MessageBoxW(0, GetCommandLineW(), L"", 0);
|
||||
SplitStringToTwoStrings(GetCommandLineW(), programString, commandsString);
|
||||
|
||||
commandsString.Trim();
|
||||
UString paramString, tailString;
|
||||
SplitStringToTwoStrings(commandsString, paramString, tailString);
|
||||
paramString.Trim();
|
||||
|
||||
if (!paramString.IsEmpty())
|
||||
{
|
||||
g_MainPath = paramString;
|
||||
// return WinMain2(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||
|
||||
// MessageBoxW(0, paramString, L"", 0);
|
||||
}
|
||||
/*
|
||||
UStringVector commandStrings;
|
||||
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
|
||||
NCommandLineParser::CParser parser(kNumSwitches);
|
||||
try
|
||||
{
|
||||
parser.ParseStrings(kSwitchForms, commandStrings);
|
||||
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
|
||||
if(nonSwitchStrings.Size() > 1)
|
||||
{
|
||||
g_MainPath = nonSwitchStrings[1];
|
||||
// g_OpenArchive = parser[NKey::kOpenArachive].ThereIs;
|
||||
CFileInfoW fileInfo;
|
||||
if (FindFile(g_MainPath, fileInfo))
|
||||
{
|
||||
if (!fileInfo.IsDirectory())
|
||||
g_OpenArchive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...) { }
|
||||
*/
|
||||
|
||||
|
||||
SetMemoryLock();
|
||||
|
||||
MSG msg;
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
return FALSE;
|
||||
|
||||
MyLoadMenu(g_HWND);
|
||||
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
{
|
||||
HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
|
||||
while (GetMessageW(&msg, NULL, 0, 0))
|
||||
{
|
||||
if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
|
||||
{
|
||||
// if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
|
||||
// if (!IsDialogMessage(g_Hwnd, &msg))
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_HWND = 0;
|
||||
OleUninitialize();
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
static void SaveWindowInfo(HWND aWnd)
|
||||
{
|
||||
/*
|
||||
RECT rect;
|
||||
if (!::GetWindowRect(aWnd, &rect))
|
||||
return;
|
||||
*/
|
||||
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());
|
||||
}
|
||||
|
||||
void ExecuteCommand(UINT commandID)
|
||||
{
|
||||
switch (commandID)
|
||||
{
|
||||
case kAddCommand:
|
||||
g_App.AddToArchive();
|
||||
break;
|
||||
case kExtractCommand:
|
||||
g_App.ExtractArchives();
|
||||
break;
|
||||
case kTestCommand:
|
||||
g_App.TestArchives();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int wmId, wmEvent;
|
||||
switch (message)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
wmId = LOWORD(wParam);
|
||||
wmEvent = HIWORD(wParam);
|
||||
if ((HWND) lParam != NULL && wmEvent != 0)
|
||||
break;
|
||||
if (wmId >= kToolbarStartID)
|
||||
{
|
||||
ExecuteCommand(wmId);
|
||||
return 0;
|
||||
}
|
||||
if (OnMenuCommand(hWnd, wmId))
|
||||
return 0;
|
||||
break;
|
||||
case WM_INITMENUPOPUP:
|
||||
OnMenuActivating(hWnd, HMENU(wParam), LOWORD(lParam));
|
||||
break;
|
||||
|
||||
/*
|
||||
It doesn't help
|
||||
case WM_EXITMENULOOP:
|
||||
{
|
||||
OnMenuUnActivating(hWnd);
|
||||
break;
|
||||
}
|
||||
case WM_UNINITMENUPOPUP:
|
||||
OnMenuUnActivating(hWnd, HMENU(wParam), lParam);
|
||||
break;
|
||||
*/
|
||||
|
||||
case WM_CREATE:
|
||||
{
|
||||
|
||||
/*
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icex.dwICC = ICC_BAR_CLASSES;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
// Toolbar buttons used to create the first 4 buttons.
|
||||
TBBUTTON tbb [ ] =
|
||||
{
|
||||
// {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
|
||||
// {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
|
||||
// {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
|
||||
{VIEW_NEWFOLDER, ID_FILE_CREATEFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
|
||||
};
|
||||
|
||||
int baseID = 100;
|
||||
NWindows::NControl::CToolBar aToolBar;
|
||||
aToolBar.Attach(::CreateToolbarEx (hWnd,
|
||||
WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT
|
||||
baseID + 2, 11,
|
||||
(HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR,
|
||||
(LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
|
||||
0, 0, 100, 30, sizeof (TBBUTTON)));
|
||||
*/
|
||||
// HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
|
||||
// ::SetCursor(cursor);
|
||||
|
||||
if (g_PanelsInfoDefined)
|
||||
g_Splitter.SetPos(hWnd, g_SplitterPos);
|
||||
else
|
||||
{
|
||||
g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
|
||||
g_SplitterPos = g_Splitter.GetPos();
|
||||
}
|
||||
|
||||
RECT rect;
|
||||
::GetClientRect(hWnd, &rect);
|
||||
int xSize = rect.right;
|
||||
int xSizes[2];
|
||||
xSizes[0] = g_Splitter.GetPos();
|
||||
xSizes[1] = xSize - kSplitterWidth - xSizes[0];
|
||||
if (xSizes[1] < 0)
|
||||
xSizes[1] = 0;
|
||||
|
||||
g_App.CreateDragTarget();
|
||||
bool archiveIsOpened;
|
||||
bool encrypted;
|
||||
bool needOpenFile = false;
|
||||
if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
|
||||
{
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
if (NFile::NFind::FindFile(g_MainPath, fileInfo))
|
||||
if (!fileInfo.IsDirectory())
|
||||
needOpenFile = true;
|
||||
}
|
||||
g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted);
|
||||
|
||||
if (needOpenFile && !archiveIsOpened)
|
||||
{
|
||||
UString message;
|
||||
if (encrypted)
|
||||
message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath);
|
||||
else
|
||||
message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath);
|
||||
MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
// g_SplitterPos = 0;
|
||||
|
||||
// ::DragAcceptFiles(hWnd, TRUE);
|
||||
RegisterDragDrop(hWnd, g_App._dropTarget);
|
||||
|
||||
break;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
// ::DragAcceptFiles(hWnd, FALSE);
|
||||
RevokeDragDrop(hWnd);
|
||||
g_App._dropTarget.Release();
|
||||
|
||||
g_App.Save();
|
||||
g_App.Release();
|
||||
SaveWindowInfo(hWnd);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
case WM_MOVE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
*/
|
||||
case WM_LBUTTONDOWN:
|
||||
g_StartCaptureMousePos = LOWORD(lParam);
|
||||
g_StartCaptureSplitterPos = g_Splitter.GetPos();
|
||||
::SetCapture(hWnd);
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
::ReleaseCapture();
|
||||
break;
|
||||
}
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
if ((wParam & MK_LBUTTON) != 0 && ::GetCapture() == hWnd)
|
||||
{
|
||||
g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos +
|
||||
(short)LOWORD(lParam) - g_StartCaptureMousePos);
|
||||
MoveSubWindows(hWnd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
if (g_CanChangeSplitter)
|
||||
g_Splitter.SetPosFromRatio(hWnd);
|
||||
else
|
||||
{
|
||||
g_Splitter.SetPos(hWnd, g_SplitterPos );
|
||||
g_CanChangeSplitter = true;
|
||||
}
|
||||
|
||||
OnSize(hWnd);
|
||||
/*
|
||||
int xSize = LOWORD(lParam);
|
||||
int ySize = HIWORD(lParam);
|
||||
// int xSplitter = 2;
|
||||
int xWidth = g_SplitPos;
|
||||
// int xSplitPos = xWidth;
|
||||
g_Panel[0]._listView.MoveWindow(0, 0, xWidth, ySize);
|
||||
g_Panel[1]._listView.MoveWindow(xSize - xWidth, 0, xWidth, ySize);
|
||||
*/
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
case WM_SETFOCUS:
|
||||
// g_App.SetFocus(g_App.LastFocusedPanel);
|
||||
g_App.SetFocusToLastItem();
|
||||
break;
|
||||
/*
|
||||
case WM_ACTIVATE:
|
||||
{
|
||||
int fActive = LOWORD(wParam);
|
||||
switch (fActive)
|
||||
{
|
||||
case WA_INACTIVE:
|
||||
{
|
||||
// g_FocusIndex = g_App.LastFocusedPanel;
|
||||
// g_App.LastFocusedPanel = g_App.GetFocusedPanelIndex();
|
||||
// return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
case kLangWasChangedMessage:
|
||||
MyLoadMenu(g_HWND);
|
||||
return 0;
|
||||
*/
|
||||
|
||||
/*
|
||||
case WM_SETTINGCHANGE:
|
||||
break;
|
||||
*/
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
g_App.OnNotify((int)wParam, (LPNMHDR)lParam);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
case WM_DROPFILES:
|
||||
{
|
||||
g_App.GetFocusedPanel().CompressDropFiles((HDROP)wParam);
|
||||
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);
|
||||
}
|
||||
|
||||
void MoveSubWindows(HWND hWnd)
|
||||
{
|
||||
RECT rect;
|
||||
::GetClientRect(hWnd, &rect);
|
||||
int xSize = rect.right;
|
||||
int kHeaderSize = 0;
|
||||
int ySize = MyMax(int(rect.bottom - kHeaderSize), 0);
|
||||
if (g_App._rebar)
|
||||
{
|
||||
RECT barRect;
|
||||
g_App._rebar.GetWindowRect(&barRect);
|
||||
kHeaderSize = barRect.bottom - barRect.top;
|
||||
ySize = MyMax(int(rect.bottom - kHeaderSize), 0);
|
||||
}
|
||||
|
||||
// g_App._headerToolBar.Move(0, 2, xSize, kHeaderSize - 2);
|
||||
RECT rect2 = rect;
|
||||
rect2.bottom = 0;
|
||||
// g_App._headerReBar.SizeToRect(&rect2);
|
||||
if (g_App.NumPanels > 1)
|
||||
{
|
||||
g_App.Panels[0].Move(0, kHeaderSize, g_Splitter.GetPos(), ySize);
|
||||
int xWidth1 = g_Splitter.GetPos() + kSplitterWidth;
|
||||
g_App.Panels[1].Move(xWidth1, kHeaderSize, xSize - xWidth1, ySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
int otherPanel = 1 - g_App.LastFocusedPanel;
|
||||
if (g_App.PanelsCreated[otherPanel])
|
||||
g_App.Panels[otherPanel].Move(0, kHeaderSize, 0, ySize);
|
||||
*/
|
||||
g_App.Panels[g_App.LastFocusedPanel].Move(0, kHeaderSize, xSize, ySize);
|
||||
}
|
||||
}
|
||||
1486
CPP/7zip/UI/FileManager/FM.dsp
Executable file
29
CPP/7zip/UI/FileManager/FM.dsw
Executable file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "FM"=.\FM.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
CPP/7zip/UI/FileManager/FM.ico
Executable file
|
After Width: | Height: | Size: 4.7 KiB |
236
CPP/7zip/UI/FileManager/FSDrives.cpp
Executable file
@@ -0,0 +1,236 @@
|
||||
// FSDrives.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "FSDrives.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "../../PropID.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileSystem.h"
|
||||
|
||||
#include "SysIconUtils.h"
|
||||
#include "FSFolder.h"
|
||||
#include "PhysDriveFolder.h"
|
||||
#include "LangUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
static const STATPROPSTG kProperties[] =
|
||||
{
|
||||
{ NULL, kpidName, VT_BSTR},
|
||||
// { NULL, kpidIsFolder, VT_BOOL},
|
||||
{ L"Total Size", kpidTotalSize, VT_UI8},
|
||||
{ L"Free Space", kpidFreeSpace, VT_UI8},
|
||||
{ NULL, kpidType, VT_BSTR},
|
||||
{ L"Label", kpidVolumeName, VT_BSTR},
|
||||
{ L"File system", kpidFileSystem, VT_BSTR},
|
||||
{ L"Cluster Size", kpidClusterSize, VT_UI8}
|
||||
};
|
||||
|
||||
static const wchar_t *kDriveTypes[] =
|
||||
{
|
||||
L"Unknown",
|
||||
L"No Root Dir",
|
||||
L"Removable",
|
||||
L"Fixed",
|
||||
L"Remote",
|
||||
L"CD-ROM",
|
||||
L"RAM disk"
|
||||
};
|
||||
|
||||
STDMETHODIMP CFSDrives::LoadItems()
|
||||
{
|
||||
_drives.Clear();
|
||||
|
||||
UStringVector driveStrings;
|
||||
MyGetLogicalDriveStrings(driveStrings);
|
||||
for (int i = 0; i < driveStrings.Size(); i++)
|
||||
{
|
||||
CDriveInfo driveInfo;
|
||||
|
||||
const UString &driveName = driveStrings[i];
|
||||
|
||||
driveInfo.FullSystemName = driveName;
|
||||
|
||||
driveInfo.Name = driveInfo.FullSystemName.Left(
|
||||
driveInfo.FullSystemName.Length() - 1);
|
||||
driveInfo.ClusterSize = 0;
|
||||
driveInfo.DriveSize = 0;
|
||||
driveInfo.FreeSpace = 0;
|
||||
UINT driveType = NFile::NSystem::MyGetDriveType(driveName);
|
||||
if (driveType < sizeof(kDriveTypes) / sizeof(kDriveTypes[0]))
|
||||
{
|
||||
driveInfo.Type = kDriveTypes[driveType];
|
||||
}
|
||||
bool needRead = true;
|
||||
if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE)
|
||||
{
|
||||
/*
|
||||
DWORD dwSerialNumber;`
|
||||
if (!::GetVolumeInformation(driveInfo.FullSystemName,
|
||||
NULL, 0, &dwSerialNumber, NULL, NULL, NULL, 0))
|
||||
*/
|
||||
driveInfo.KnownSizes = false;
|
||||
{
|
||||
needRead = false;
|
||||
}
|
||||
}
|
||||
if (needRead)
|
||||
{
|
||||
UString volumeName, fileSystemName;
|
||||
DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
|
||||
NFile::NSystem::MyGetVolumeInformation(driveName,
|
||||
volumeName,
|
||||
&volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
|
||||
fileSystemName);
|
||||
driveInfo.VolumeName = volumeName;
|
||||
driveInfo.FileSystemName = fileSystemName;
|
||||
|
||||
NFile::NSystem::MyGetDiskFreeSpace(driveName,
|
||||
driveInfo.ClusterSize, driveInfo.DriveSize, driveInfo.FreeSpace);
|
||||
driveInfo.KnownSizes = true;
|
||||
}
|
||||
_drives.Add(driveInfo);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _drives.Size();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
if (itemIndex >= (UInt32)_drives.Size())
|
||||
return E_INVALIDARG;
|
||||
NCOM::CPropVariant propVariant;
|
||||
const CDriveInfo &driveInfo = _drives[itemIndex];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidIsFolder:
|
||||
propVariant = true;
|
||||
break;
|
||||
case kpidName:
|
||||
propVariant = driveInfo.Name;
|
||||
break;
|
||||
case kpidTotalSize:
|
||||
if (driveInfo.KnownSizes)
|
||||
propVariant = driveInfo.DriveSize;
|
||||
break;
|
||||
case kpidFreeSpace:
|
||||
if (driveInfo.KnownSizes)
|
||||
propVariant = driveInfo.FreeSpace;
|
||||
break;
|
||||
case kpidClusterSize:
|
||||
if (driveInfo.KnownSizes)
|
||||
propVariant = driveInfo.ClusterSize;
|
||||
break;
|
||||
case kpidType:
|
||||
propVariant = driveInfo.Type;
|
||||
break;
|
||||
case kpidVolumeName:
|
||||
propVariant = driveInfo.VolumeName;
|
||||
break;
|
||||
case kpidFileSystem:
|
||||
propVariant = driveInfo.FileSystemName;
|
||||
break;
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CFSDrives::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
|
||||
CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
|
||||
RINOK(fsFolderSpec->Init(name, 0));
|
||||
*resultFolder = subFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
if (index >= (UInt32)_drives.Size())
|
||||
return E_INVALIDARG;
|
||||
const CDriveInfo &driveInfo = _drives[index];
|
||||
if (_volumeMode)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
|
||||
CMyComPtr<IFolderFolder> subFolder = folderSpec;
|
||||
RINOK(folderSpec->Init(driveInfo.Name));
|
||||
*resultFolder = subFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
return BindToFolderSpec(driveInfo.FullSystemName, resultFolder);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
{
|
||||
return BindToFolderSpec(name, resultFolder);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetPropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
return E_INVALIDARG;
|
||||
const STATPROPSTG &prop = kProperties[index];
|
||||
*propID = prop.propid;
|
||||
*varType = prop.vt;
|
||||
*name = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
switch(propID)
|
||||
{
|
||||
case kpidType: prop = L"FSDrives"; break;
|
||||
case kpidPath: prop = LangString(IDS_COMPUTER, 0x03020300) + UString(L'\\'); break;
|
||||
}
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
|
||||
{
|
||||
*iconIndex = 0;
|
||||
const CDriveInfo &driveInfo = _drives[index];
|
||||
int iconIndexTemp;
|
||||
if (GetRealIconIndex(driveInfo.FullSystemName, 0, iconIndexTemp) != 0)
|
||||
{
|
||||
*iconIndex = iconIndexTemp;
|
||||
return S_OK;
|
||||
}
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
49
CPP/7zip/UI/FileManager/FSDrives.h
Executable file
@@ -0,0 +1,49 @@
|
||||
// FSDrives.h
|
||||
|
||||
#ifndef __FSDRIVES_H
|
||||
#define __FSDRIVES_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
#include "Common/Types.h"
|
||||
#include "Common/MyCom.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "IFolder.h"
|
||||
|
||||
struct CDriveInfo
|
||||
{
|
||||
UString Name;
|
||||
UString FullSystemName;
|
||||
bool KnownSizes;
|
||||
UInt64 DriveSize;
|
||||
UInt64 FreeSpace;
|
||||
UInt64 ClusterSize;
|
||||
UString Type;
|
||||
UString VolumeName;
|
||||
UString FileSystemName;
|
||||
};
|
||||
|
||||
class CFSDrives:
|
||||
public IFolderFolder,
|
||||
public IFolderGetSystemIconIndex,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(
|
||||
IFolderGetSystemIconIndex
|
||||
)
|
||||
|
||||
INTERFACE_FolderFolder(;)
|
||||
|
||||
STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
|
||||
|
||||
private:
|
||||
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
CObjectVector<CDriveInfo> _drives;
|
||||
bool _volumeMode;
|
||||
public:
|
||||
void Init() { _volumeMode = false;}
|
||||
};
|
||||
|
||||
#endif
|
||||
682
CPP/7zip/UI/FileManager/FSFolder.cpp
Executable file
@@ -0,0 +1,682 @@
|
||||
// FSFolder.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "FSFolder.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/StdInStream.h"
|
||||
#include "Common/StdOutStream.h"
|
||||
#include "Common/UTFConvert.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileIO.h"
|
||||
|
||||
#include "../../PropID.h"
|
||||
|
||||
#include "SysIconUtils.h"
|
||||
#include "FSDrives.h"
|
||||
#include "NetFolder.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NFile {
|
||||
|
||||
bool GetLongPath(LPCWSTR path, UString &longPath);
|
||||
|
||||
}}
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
namespace NFsFolder {
|
||||
|
||||
static STATPROPSTG kProperties[] =
|
||||
{
|
||||
{ NULL, kpidName, VT_BSTR},
|
||||
// { NULL, kpidIsFolder, VT_BOOL},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidLastWriteTime, VT_FILETIME},
|
||||
{ NULL, kpidCreationTime, VT_FILETIME},
|
||||
{ NULL, kpidLastAccessTime, VT_FILETIME},
|
||||
{ NULL, kpidAttributes, VT_UI4},
|
||||
{ NULL, kpidPackedSize, VT_UI8},
|
||||
{ NULL, kpidComment, VT_BSTR},
|
||||
{ NULL, kpidPrefix, VT_BSTR}
|
||||
};
|
||||
|
||||
HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
|
||||
{
|
||||
_parentFolder = parentFolder;
|
||||
_path = path;
|
||||
|
||||
_findChangeNotification.FindFirst(_path, false,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME |
|
||||
FILE_NOTIFY_CHANGE_DIR_NAME |
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_SIZE |
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE /*|
|
||||
FILE_NOTIFY_CHANGE_LAST_ACCESS |
|
||||
FILE_NOTIFY_CHANGE_CREATION |
|
||||
FILE_NOTIFY_CHANGE_SECURITY */);
|
||||
if (!_findChangeNotification.IsHandleAllocated())
|
||||
{
|
||||
DWORD lastError = GetLastError();
|
||||
CFindFile findFile;
|
||||
CFileInfoW fileInfo;
|
||||
if (!findFile.FindFirst(_path + UString(L"*"), fileInfo))
|
||||
return lastError;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
|
||||
{
|
||||
RINOK(progress->SetCompleted(NULL));
|
||||
numFiles = numFolders = size = 0;
|
||||
CEnumeratorW enumerator(path + UString(L"\\*"));
|
||||
CFileInfoW fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
{
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
UInt64 subFolders, subFiles, subSize;
|
||||
RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subFolders, subFiles, subSize, progress));
|
||||
numFolders += subFolders;
|
||||
numFolders++;
|
||||
numFiles += subFiles;
|
||||
size += subSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
numFiles++;
|
||||
size += fileInfo.Size;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
|
||||
{
|
||||
{
|
||||
CEnumeratorW enumerator(path + L"*");
|
||||
CDirItem fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
{
|
||||
fileInfo.CompressedSizeIsDefined = false;
|
||||
/*
|
||||
if (!GetCompressedFileSize(_path + fileInfo.Name,
|
||||
fileInfo.CompressedSize))
|
||||
fileInfo.CompressedSize = fileInfo.Size;
|
||||
*/
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
// fileInfo.Size = GetFolderSize(_path + fileInfo.Name);
|
||||
fileInfo.Size = 0;
|
||||
}
|
||||
dirItem.Files.Add(fileInfo);
|
||||
}
|
||||
}
|
||||
if (!_flatMode)
|
||||
return S_OK;
|
||||
|
||||
for (int i = 0; i < dirItem.Files.Size(); i++)
|
||||
{
|
||||
CDirItem &item = dirItem.Files[i];
|
||||
if (item.IsDirectory())
|
||||
LoadSubItems(item, path + item.Name + L'\\');
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CFSFolder::AddRefs(CDirItem &dirItem)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < dirItem.Files.Size(); i++)
|
||||
{
|
||||
CDirItem &item = dirItem.Files[i];
|
||||
item.Parent = &dirItem;
|
||||
_refs.Add(&item);
|
||||
}
|
||||
if (!_flatMode)
|
||||
return;
|
||||
for (i = 0; i < dirItem.Files.Size(); i++)
|
||||
{
|
||||
CDirItem &item = dirItem.Files[i];
|
||||
if (item.IsDirectory())
|
||||
AddRefs(item);
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::LoadItems()
|
||||
{
|
||||
// OutputDebugString(TEXT("Start\n"));
|
||||
INT32 dummy;
|
||||
WasChanged(&dummy);
|
||||
Clear();
|
||||
RINOK(LoadSubItems(_root, _path));
|
||||
AddRefs(_root);
|
||||
|
||||
// OutputDebugString(TEXT("Finish\n"));
|
||||
_commentsAreLoaded = false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const wchar_t *kDescriptionFileName = L"descript.ion";
|
||||
|
||||
bool CFSFolder::LoadComments()
|
||||
{
|
||||
if (_commentsAreLoaded)
|
||||
return true;
|
||||
_comments.Clear();
|
||||
_commentsAreLoaded = true;
|
||||
NIO::CInFile file;
|
||||
if (!file.Open(_path + kDescriptionFileName))
|
||||
return false;
|
||||
UInt64 length;
|
||||
if (!file.GetLength(length))
|
||||
return false;
|
||||
if (length >= (1 << 28))
|
||||
return false;
|
||||
AString s;
|
||||
char *p = s.GetBuffer((int)((size_t)length + 1));
|
||||
UInt32 processedSize;
|
||||
file.Read(p, (UInt32)length, processedSize);
|
||||
p[length] = 0;
|
||||
s.ReleaseBuffer();
|
||||
s.Replace("\r\n", "\n");
|
||||
if (processedSize != length)
|
||||
return false;
|
||||
file.Close();
|
||||
UString unicodeString;
|
||||
if (!ConvertUTF8ToUnicode(s, unicodeString))
|
||||
return false;
|
||||
return _comments.ReadFromString(unicodeString);
|
||||
}
|
||||
|
||||
static bool IsAscii(const UString &testString)
|
||||
{
|
||||
for (int i = 0; i < testString.Length(); i++)
|
||||
if (testString[i] >= 0x80)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFSFolder::SaveComments()
|
||||
{
|
||||
NIO::COutFile file;
|
||||
if (!file.Create(_path + kDescriptionFileName, true))
|
||||
return false;
|
||||
UString unicodeString;
|
||||
_comments.SaveToString(unicodeString);
|
||||
AString utfString;
|
||||
ConvertUnicodeToUTF8(unicodeString, utfString);
|
||||
UInt32 processedSize;
|
||||
if (!IsAscii(unicodeString))
|
||||
{
|
||||
Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A };
|
||||
file.Write(bom , sizeof(bom), processedSize);
|
||||
}
|
||||
utfString.Replace("\n", "\r\n");
|
||||
file.Write(utfString, utfString.Length(), processedSize);
|
||||
_commentsAreLoaded = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _refs.Size();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
|
||||
{
|
||||
UInt32 numSubFoldersLoc = 0;
|
||||
for (int i = 0; i < _files.Size(); i++)
|
||||
if (_files[i].IsDirectory())
|
||||
numSubFoldersLoc++;
|
||||
*numSubFolders = numSubFoldersLoc;
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
|
||||
{
|
||||
DWORD highPart;
|
||||
DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
|
||||
if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
|
||||
{
|
||||
#ifdef WIN_LONG_PATH
|
||||
{
|
||||
UString longPath;
|
||||
if (GetLongPath(fileName, longPath))
|
||||
lowPart = ::GetCompressedFileSizeW(longPath, &highPart);
|
||||
}
|
||||
#endif
|
||||
if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
|
||||
return false;
|
||||
}
|
||||
size = (UInt64(highPart) << 32) | lowPart;
|
||||
return true;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (itemIndex >= (UInt32)_refs.Size())
|
||||
return E_INVALIDARG;
|
||||
CDirItem &fileInfo = *_refs[itemIndex];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidIsFolder:
|
||||
propVariant = fileInfo.IsDirectory();
|
||||
break;
|
||||
case kpidName:
|
||||
propVariant = fileInfo.Name;
|
||||
break;
|
||||
case kpidSize:
|
||||
propVariant = fileInfo.Size;
|
||||
break;
|
||||
case kpidPackedSize:
|
||||
if (!fileInfo.CompressedSizeIsDefined)
|
||||
{
|
||||
fileInfo.CompressedSizeIsDefined = true;
|
||||
if (fileInfo.IsDirectory () ||
|
||||
!MyGetCompressedFileSizeW(_path + GetRelPath(fileInfo), fileInfo.CompressedSize))
|
||||
fileInfo.CompressedSize = fileInfo.Size;
|
||||
}
|
||||
propVariant = fileInfo.CompressedSize;
|
||||
break;
|
||||
case kpidAttributes:
|
||||
propVariant = (UInt32)fileInfo.Attributes;
|
||||
break;
|
||||
case kpidCreationTime:
|
||||
propVariant = fileInfo.CreationTime;
|
||||
break;
|
||||
case kpidLastAccessTime:
|
||||
propVariant = fileInfo.LastAccessTime;
|
||||
break;
|
||||
case kpidLastWriteTime:
|
||||
propVariant = fileInfo.LastWriteTime;
|
||||
break;
|
||||
case kpidComment:
|
||||
{
|
||||
LoadComments();
|
||||
UString comment;
|
||||
if (_comments.GetValue(GetRelPath(fileInfo), comment))
|
||||
propVariant = comment;
|
||||
break;
|
||||
}
|
||||
case kpidPrefix:
|
||||
{
|
||||
if (_flatMode)
|
||||
{
|
||||
propVariant = GetPrefix(fileInfo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
CFSFolder *folderSpec = new CFSFolder;
|
||||
CMyComPtr<IFolderFolder> subFolder = folderSpec;
|
||||
RINOK(folderSpec->Init(_path + name + UString(L'\\'), 0));
|
||||
*resultFolder = subFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
UString CFSFolder::GetPrefix(const CDirItem &item) const
|
||||
{
|
||||
UString path;
|
||||
CDirItem *cur = item.Parent;
|
||||
while (cur->Parent != 0)
|
||||
{
|
||||
path = cur->Name + UString('\\') + path;
|
||||
cur = cur->Parent;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
UString CFSFolder::GetRelPath(const CDirItem &item) const
|
||||
{
|
||||
return GetPrefix(item) + item.Name;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
const CDirItem &fileInfo = *_refs[index];
|
||||
if (!fileInfo.IsDirectory())
|
||||
return E_INVALIDARG;
|
||||
return BindToFolderSpec(GetRelPath(fileInfo), resultFolder);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
{
|
||||
return BindToFolderSpec(name, resultFolder);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
if (_parentFolder)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
|
||||
*resultFolder = parentFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
if (_path.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
int pos = _path.ReverseFind(L'\\');
|
||||
if (pos < 0 || pos != _path.Length() - 1)
|
||||
return E_FAIL;
|
||||
UString parentPath = _path.Left(pos);
|
||||
pos = parentPath.ReverseFind(L'\\');
|
||||
if (pos < 0)
|
||||
{
|
||||
parentPath.Empty();
|
||||
CFSDrives *drivesFolderSpec = new CFSDrives;
|
||||
CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
|
||||
drivesFolderSpec->Init();
|
||||
*resultFolder = drivesFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
UString parentPathReduced = parentPath.Left(pos);
|
||||
parentPath = parentPath.Left(pos + 1);
|
||||
pos = parentPathReduced.ReverseFind(L'\\');
|
||||
if (pos == 1)
|
||||
{
|
||||
if (parentPath[0] != L'\\')
|
||||
return E_FAIL;
|
||||
CNetFolder *netFolderSpec = new CNetFolder;
|
||||
CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
|
||||
netFolderSpec->Init(parentPath);
|
||||
*resultFolder = netFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
CFSFolder *parentFolderSpec = new CFSFolder;
|
||||
CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
|
||||
RINOK(parentFolderSpec->Init(parentPath, 0));
|
||||
*resultFolder = parentFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
if (!_flatMode)
|
||||
(*numProperties)--;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
return E_INVALIDARG;
|
||||
const STATPROPSTG &prop = kProperties[index];
|
||||
*propID = prop.propid;
|
||||
*varType = prop.vt;
|
||||
*name = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
switch(propID)
|
||||
{
|
||||
case kpidType: prop = L"FSFolder"; break;
|
||||
case kpidPath: prop = _path; break;
|
||||
}
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::WasChanged(INT32 *wasChanged)
|
||||
{
|
||||
bool wasChangedMain = false;
|
||||
for (;;)
|
||||
{
|
||||
if (!_findChangeNotification.IsHandleAllocated())
|
||||
{
|
||||
*wasChanged = BoolToInt(false);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
DWORD waitResult = ::WaitForSingleObject(_findChangeNotification, 0);
|
||||
bool wasChangedLoc = (waitResult == WAIT_OBJECT_0);
|
||||
if (wasChangedLoc)
|
||||
{
|
||||
_findChangeNotification.FindNext();
|
||||
wasChangedMain = true;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
*wasChanged = BoolToInt(wasChangedMain);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
|
||||
{
|
||||
CFSFolder *fsFolderSpec = new CFSFolder;
|
||||
CMyComPtr<IFolderFolder> folderNew = fsFolderSpec;
|
||||
fsFolderSpec->Init(_path, 0);
|
||||
*resultFolder = folderNew.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
|
||||
UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
|
||||
{
|
||||
numFiles = numFolders = size = 0;
|
||||
UInt32 i;
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
int index = indices[i];
|
||||
if (index >= _refs.Size())
|
||||
return E_INVALIDARG;
|
||||
const CDirItem &fileInfo = *_refs[index];
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
UInt64 subFolders, subFiles, subSize;
|
||||
RINOK(GetFolderSize(_path + GetRelPath(fileInfo), subFolders, subFiles, subSize, progress));
|
||||
numFolders += subFolders;
|
||||
numFolders++;
|
||||
numFiles += subFiles;
|
||||
size += subSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
numFiles++;
|
||||
size += fileInfo.Size;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
|
||||
{
|
||||
const CDirItem &fileInfo = *_refs[index];
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
/*
|
||||
CMyComPtr<IFolderFolder> subFolder;
|
||||
RINOK(BindToFolder(index, &subFolder));
|
||||
CMyComPtr<IFolderReload> aFolderReload;
|
||||
subFolder.QueryInterface(&aFolderReload);
|
||||
aFolderReload->Reload();
|
||||
UInt32 numItems;
|
||||
RINOK(subFolder->GetNumberOfItems(&numItems));
|
||||
CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize;
|
||||
subFolder.QueryInterface(&aGetItemFullSize);
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
UInt64 size;
|
||||
RINOK(aGetItemFullSize->GetItemFullSize(i, &size));
|
||||
*totalSize += size;
|
||||
}
|
||||
*/
|
||||
UInt64 numFolders, numFiles;
|
||||
return GetFolderSize(_path + GetRelPath(fileInfo), numFolders, numFiles, size, progress);
|
||||
}
|
||||
size = fileInfo.Size;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (index >= (UInt32)_refs.Size())
|
||||
return E_INVALIDARG;
|
||||
UInt64 size = 0;
|
||||
HRESULT result = GetItemFullSize(index, size, progress);
|
||||
propVariant = size;
|
||||
propVariant.Detach(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
|
||||
{
|
||||
UString newName = name;
|
||||
resultPath = _path + newName;
|
||||
if (newName.Length() < 1)
|
||||
return S_OK;
|
||||
if (newName[0] == L'\\')
|
||||
{
|
||||
resultPath = newName;
|
||||
return S_OK;
|
||||
}
|
||||
if (newName.Length() < 2)
|
||||
return S_OK;
|
||||
if (newName[1] == L':')
|
||||
resultPath = newName;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */)
|
||||
{
|
||||
UString processedName;
|
||||
RINOK(GetComplexName(name, processedName));
|
||||
if(NDirectory::MyCreateDirectory(processedName))
|
||||
return S_OK;
|
||||
if(::GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
return ::GetLastError();
|
||||
if (!NDirectory::CreateComplexDirectory(processedName))
|
||||
return ::GetLastError();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */)
|
||||
{
|
||||
UString processedName;
|
||||
RINOK(GetComplexName(name, processedName));
|
||||
NIO::COutFile outFile;
|
||||
if (!outFile.Create(processedName, false))
|
||||
return ::GetLastError();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
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))
|
||||
return GetLastError();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress)
|
||||
{
|
||||
RINOK(progress->SetTotal(numItems));
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
const CDirItem &fileInfo = *_refs[indices[i]];
|
||||
const UString fullPath = _path + GetRelPath(fileInfo);
|
||||
bool result;
|
||||
if (fileInfo.IsDirectory())
|
||||
result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
|
||||
else
|
||||
result = NDirectory::DeleteFileAlways(fullPath);
|
||||
if (!result)
|
||||
return GetLastError();
|
||||
UInt64 completed = i;
|
||||
RINOK(progress->SetCompleted(&completed));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
|
||||
const PROPVARIANT *value, IProgress * /* progress */)
|
||||
{
|
||||
if (index >= (UInt32)_refs.Size())
|
||||
return E_INVALIDARG;
|
||||
CDirItem &fileInfo = *_refs[index];
|
||||
if (fileInfo.Parent->Parent != 0)
|
||||
return E_NOTIMPL;
|
||||
switch(propID)
|
||||
{
|
||||
case kpidComment:
|
||||
{
|
||||
UString filename = fileInfo.Name;
|
||||
filename.Trim();
|
||||
if (value->vt == VT_EMPTY)
|
||||
_comments.DeletePair(filename);
|
||||
else if (value->vt == VT_BSTR)
|
||||
{
|
||||
CTextPair pair;
|
||||
pair.ID = filename;
|
||||
pair.ID.Trim();
|
||||
pair.Value = value->bstrVal;
|
||||
pair.Value.Trim();
|
||||
if (pair.Value.IsEmpty())
|
||||
_comments.DeletePair(filename);
|
||||
else
|
||||
_comments.AddPair(pair);
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
SaveComments();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
|
||||
{
|
||||
if (index >= (UInt32)_refs.Size())
|
||||
return E_INVALIDARG;
|
||||
const CDirItem &fileInfo = *_refs[index];
|
||||
*iconIndex = 0;
|
||||
int iconIndexTemp;
|
||||
if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attributes, iconIndexTemp) != 0)
|
||||
{
|
||||
*iconIndex = iconIndexTemp;
|
||||
return S_OK;
|
||||
}
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::SetFlatMode(Int32 flatMode)
|
||||
{
|
||||
_flatMode = IntToBool(flatMode);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
}
|
||||
118
CPP/7zip/UI/FileManager/FSFolder.h
Executable file
@@ -0,0 +1,118 @@
|
||||
// FSFolder.h
|
||||
|
||||
#ifndef __FSFOLDER_H
|
||||
#define __FSFOLDER_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
#include "Common/MyCom.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "IFolder.h"
|
||||
|
||||
#include "TextPairs.h"
|
||||
|
||||
namespace NFsFolder {
|
||||
|
||||
class CFSFolder;
|
||||
|
||||
struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
|
||||
{
|
||||
bool CompressedSizeIsDefined;
|
||||
UInt64 CompressedSize;
|
||||
};
|
||||
|
||||
struct CDirItem;
|
||||
|
||||
struct CDirItem: public CFileInfoEx
|
||||
{
|
||||
CDirItem *Parent;
|
||||
CObjectVector<CDirItem> Files;
|
||||
|
||||
CDirItem(): Parent(0) {}
|
||||
void Clear()
|
||||
{
|
||||
Files.Clear();
|
||||
Parent = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class CFSFolder:
|
||||
public IFolderFolder,
|
||||
public IFolderWasChanged,
|
||||
public IFolderOperations,
|
||||
// public IFolderOperationsDeleteToRecycleBin,
|
||||
public IFolderGetItemFullSize,
|
||||
public IFolderClone,
|
||||
public IFolderGetSystemIconIndex,
|
||||
public IFolderSetFlatMode,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
UInt64 GetSizeOfItem(int anIndex) const;
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
|
||||
// MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderOperations)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderClone)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
|
||||
INTERFACE_FolderFolder(;)
|
||||
INTERFACE_FolderOperations(;)
|
||||
|
||||
STDMETHOD(WasChanged)(INT32 *wasChanged);
|
||||
STDMETHOD(Clone)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
|
||||
|
||||
STDMETHOD(SetFlatMode)(Int32 flatMode);
|
||||
|
||||
STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
|
||||
|
||||
private:
|
||||
UString _path;
|
||||
CDirItem _root;
|
||||
CRecordVector<CDirItem *> _refs;
|
||||
|
||||
CMyComPtr<IFolderFolder> _parentFolder;
|
||||
|
||||
bool _commentsAreLoaded;
|
||||
CPairsStorage _comments;
|
||||
|
||||
bool _flatMode;
|
||||
|
||||
NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
|
||||
|
||||
HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
|
||||
UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
|
||||
HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
|
||||
HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
|
||||
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
|
||||
bool LoadComments();
|
||||
bool SaveComments();
|
||||
HRESULT LoadSubItems(CDirItem &dirItem, const UString &path);
|
||||
void AddRefs(CDirItem &dirItem);
|
||||
public:
|
||||
HRESULT Init(const UString &path, IFolderFolder *parentFolder);
|
||||
|
||||
CFSFolder() : _flatMode(false) {}
|
||||
|
||||
UString GetPrefix(const CDirItem &item) const;
|
||||
UString GetRelPath(const CDirItem &item) const;
|
||||
UString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
|
||||
|
||||
void Clear()
|
||||
{
|
||||
_root.Clear();
|
||||
_refs.Clear();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
475
CPP/7zip/UI/FileManager/FSFolderCopy.cpp
Executable file
@@ -0,0 +1,475 @@
|
||||
// FSFolderCopy.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <Winbase.h>
|
||||
|
||||
#include "FSFolder.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Error.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "../../Common/FilePathAutoRename.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
namespace NFsFolder {
|
||||
|
||||
/*
|
||||
static bool IsItWindows2000orHigher()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
|
||||
(versionInfo.dwMajorVersion >= 5);
|
||||
}
|
||||
*/
|
||||
|
||||
struct CProgressInfo
|
||||
{
|
||||
UInt64 StartPos;
|
||||
IProgress *Progress;
|
||||
};
|
||||
|
||||
static DWORD CALLBACK CopyProgressRoutine(
|
||||
LARGE_INTEGER /* TotalFileSize */, // file size
|
||||
LARGE_INTEGER TotalBytesTransferred, // bytes transferred
|
||||
LARGE_INTEGER /* StreamSize */, // bytes in stream
|
||||
LARGE_INTEGER /* StreamBytesTransferred */, // bytes transferred for stream
|
||||
DWORD /* dwStreamNumber */, // current stream
|
||||
DWORD /* dwCallbackReason */, // callback reason
|
||||
HANDLE /* hSourceFile */, // handle to source file
|
||||
HANDLE /* hDestinationFile */, // handle to destination file
|
||||
LPVOID lpData // from CopyFileEx
|
||||
)
|
||||
{
|
||||
CProgressInfo &progressInfo = *(CProgressInfo *)lpData;
|
||||
UInt64 completed = progressInfo.StartPos + TotalBytesTransferred.QuadPart;
|
||||
if (progressInfo.Progress->SetCompleted(&completed) != S_OK)
|
||||
return PROGRESS_CANCEL;
|
||||
return PROGRESS_CONTINUE;
|
||||
}
|
||||
|
||||
typedef BOOL (WINAPI * CopyFileExPointer)(
|
||||
IN LPCSTR lpExistingFileName,
|
||||
IN LPCSTR lpNewFileName,
|
||||
IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
|
||||
IN LPVOID lpData OPTIONAL,
|
||||
IN LPBOOL pbCancel OPTIONAL,
|
||||
IN DWORD dwCopyFlags
|
||||
);
|
||||
|
||||
typedef BOOL (WINAPI * CopyFileExPointerW)(
|
||||
IN LPCWSTR lpExistingFileName,
|
||||
IN LPCWSTR lpNewFileName,
|
||||
IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
|
||||
IN LPVOID lpData OPTIONAL,
|
||||
IN LPBOOL pbCancel OPTIONAL,
|
||||
IN DWORD dwCopyFlags
|
||||
);
|
||||
|
||||
#ifndef _UNICODE
|
||||
static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
static CSysString GetSysPath(LPCWSTR sysPath)
|
||||
{ return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
|
||||
#endif
|
||||
|
||||
static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
|
||||
{
|
||||
CProgressInfo progressInfo;
|
||||
progressInfo.Progress = progress;
|
||||
progressInfo.StartPos = completedSize;
|
||||
BOOL CancelFlag = FALSE;
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
#endif
|
||||
{
|
||||
CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
|
||||
::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"),
|
||||
"CopyFileExW");
|
||||
if (copyFunctionW == 0)
|
||||
return false;
|
||||
if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
|
||||
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
|
||||
return true;
|
||||
#ifdef WIN_LONG_PATH
|
||||
UString longPathExisting, longPathNew;
|
||||
if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew))
|
||||
return false;
|
||||
if (copyFunctionW(longPathExisting, longPathNew, CopyProgressRoutine,
|
||||
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
else
|
||||
{
|
||||
CopyFileExPointer copyFunction = (CopyFileExPointer)
|
||||
::GetProcAddress(::GetModuleHandleA("kernel32.dll"),
|
||||
"CopyFileExA");
|
||||
if (copyFunction != 0)
|
||||
{
|
||||
if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
|
||||
CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
|
||||
return true;
|
||||
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return false;
|
||||
}
|
||||
return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
|
||||
IN LPCWSTR lpExistingFileName,
|
||||
IN LPCWSTR lpNewFileName,
|
||||
IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
|
||||
IN LPVOID lpData OPTIONAL,
|
||||
IN DWORD dwFlags
|
||||
);
|
||||
|
||||
static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
|
||||
{
|
||||
// if (IsItWindows2000orHigher())
|
||||
// {
|
||||
CProgressInfo progressInfo;
|
||||
progressInfo.Progress = progress;
|
||||
progressInfo.StartPos = completedSize;
|
||||
|
||||
MoveFileWithProgressPointer moveFunction = (MoveFileWithProgressPointer)
|
||||
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
|
||||
"MoveFileWithProgressW");
|
||||
if (moveFunction != 0)
|
||||
{
|
||||
if (moveFunction(
|
||||
existingFile, newFile, CopyProgressRoutine,
|
||||
&progressInfo, MOVEFILE_COPY_ALLOWED))
|
||||
return true;
|
||||
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
#ifdef WIN_LONG_PATH
|
||||
UString longPathExisting, longPathNew;
|
||||
if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew))
|
||||
return false;
|
||||
if (moveFunction(longPathExisting, longPathNew, CopyProgressRoutine,
|
||||
&progressInfo, MOVEFILE_COPY_ALLOWED))
|
||||
return true;
|
||||
#endif
|
||||
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// }
|
||||
// else
|
||||
return NDirectory::MyMoveFile(existingFile, newFile);
|
||||
}
|
||||
|
||||
static HRESULT MyCopyFile(
|
||||
const UString &srcPath,
|
||||
const CFileInfoW &srcFileInfo,
|
||||
const UString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UInt64 &completedSize)
|
||||
{
|
||||
UString destPath = destPathSpec;
|
||||
if (destPath.CompareNoCase(srcPath) == 0)
|
||||
{
|
||||
UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
INT32 writeAskResult;
|
||||
CMyComBSTR destPathResult;
|
||||
RINOK(callback->AskWrite(
|
||||
srcPath,
|
||||
BoolToInt(false),
|
||||
&srcFileInfo.LastWriteTime, &srcFileInfo.Size,
|
||||
destPath,
|
||||
&destPathResult,
|
||||
&writeAskResult));
|
||||
if (IntToBool(writeAskResult))
|
||||
{
|
||||
UString destPathNew = UString(destPathResult);
|
||||
RINOK(callback->SetCurrentFilePath(srcPath));
|
||||
if (!MyCopyFile(srcPath, destPathNew, callback, completedSize))
|
||||
{
|
||||
UString message = NError::MyFormatMessageW(GetLastError()) +
|
||||
UString(L" \'") +
|
||||
UString(destPathNew) +
|
||||
UString(L"\'");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
completedSize += srcFileInfo.Size;
|
||||
return callback->SetCompleted(&completedSize);
|
||||
}
|
||||
|
||||
static HRESULT CopyFolder(
|
||||
const UString &srcPath,
|
||||
const UString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UInt64 &completedSize)
|
||||
{
|
||||
RINOK(callback->SetCompleted(&completedSize));
|
||||
|
||||
UString destPath = destPathSpec;
|
||||
int len = srcPath.Length();
|
||||
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
|
||||
{
|
||||
if (destPath.Length() == len || destPath[len] == L'\\')
|
||||
{
|
||||
UString message = UString(L"can not copy folder \'") +
|
||||
destPath + UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NDirectory::CreateComplexDirectory(destPath))
|
||||
{
|
||||
UString message = UString(L"can not create folder ") + destPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
CEnumeratorW enumerator(srcPath + UString(L"\\*"));
|
||||
CFileInfoEx fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
{
|
||||
const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name;
|
||||
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback)
|
||||
{
|
||||
if (numItems == 0)
|
||||
return S_OK;
|
||||
|
||||
UInt64 numFolders, numFiles, totalSize;
|
||||
GetItemsFullSize(indices, numItems, numFolders, numFiles, totalSize, callback);
|
||||
RINOK(callback->SetTotal(totalSize));
|
||||
RINOK(callback->SetNumFiles(numFiles));
|
||||
|
||||
UString destPath = path;
|
||||
if (destPath.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
bool directName = (destPath[destPath.Length() - 1] != L'\\');
|
||||
if (directName)
|
||||
{
|
||||
if (numItems > 1)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
/*
|
||||
// doesn't work in network
|
||||
else
|
||||
if (!NDirectory::CreateComplexDirectory(destPath)))
|
||||
{
|
||||
DWORD lastError = ::GetLastError();
|
||||
UString message = UString(L"can not create folder ") +
|
||||
destPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
*/
|
||||
|
||||
UInt64 completedSize = 0;
|
||||
RINOK(callback->SetCompleted(&completedSize));
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
const CDirItem &fileInfo = *_refs[indices[i]];
|
||||
UString destPath2 = destPath;
|
||||
if (!directName)
|
||||
destPath2 += fileInfo.Name;
|
||||
UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Move Operations
|
||||
|
||||
HRESULT MyMoveFile(
|
||||
const UString &srcPath,
|
||||
const CFileInfoW &srcFileInfo,
|
||||
const UString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UInt64 &completedSize)
|
||||
{
|
||||
UString destPath = destPathSpec;
|
||||
if (destPath.CompareNoCase(srcPath) == 0)
|
||||
{
|
||||
UString message = UString(L"can not move file \'")
|
||||
+ destPath +
|
||||
UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
INT32 writeAskResult;
|
||||
CMyComBSTR destPathResult;
|
||||
RINOK(callback->AskWrite(
|
||||
srcPath,
|
||||
BoolToInt(false),
|
||||
&srcFileInfo.LastWriteTime, &srcFileInfo.Size,
|
||||
destPath,
|
||||
&destPathResult,
|
||||
&writeAskResult));
|
||||
if (IntToBool(writeAskResult))
|
||||
{
|
||||
UString destPathNew = UString(destPathResult);
|
||||
RINOK(callback->SetCurrentFilePath(srcPath));
|
||||
if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
|
||||
{
|
||||
UString message = UString(L"can not move to file ") + destPathNew;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
}
|
||||
}
|
||||
completedSize += srcFileInfo.Size;
|
||||
RINOK(callback->SetCompleted(&completedSize));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT MyMoveFolder(
|
||||
const UString &srcPath,
|
||||
const UString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UInt64 &completedSize)
|
||||
{
|
||||
UString destPath = destPathSpec;
|
||||
int len = srcPath.Length();
|
||||
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
|
||||
{
|
||||
if (destPath.Length() == len || destPath[len] == L'\\')
|
||||
{
|
||||
UString message = UString(L"can not move folder \'") +
|
||||
destPath + UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
if (MyMoveFile(srcPath, destPath, callback, completedSize))
|
||||
return S_OK;
|
||||
|
||||
if (!NDirectory::CreateComplexDirectory(destPath))
|
||||
{
|
||||
UString message = UString(L"can not create folder ") + destPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
{
|
||||
CEnumeratorW enumerator(srcPath + UString(L"\\*"));
|
||||
CFileInfoEx fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
{
|
||||
const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name;
|
||||
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, callback, completedSize));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!NDirectory::MyRemoveDirectory(srcPath))
|
||||
{
|
||||
UString message = UString(L"can not remove folder") + srcPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::MoveTo(
|
||||
const UInt32 *indices,
|
||||
UInt32 numItems,
|
||||
const wchar_t *path,
|
||||
IFolderOperationsExtractCallback *callback)
|
||||
{
|
||||
if (numItems == 0)
|
||||
return S_OK;
|
||||
|
||||
UInt64 numFolders, numFiles, totalSize;
|
||||
GetItemsFullSize(indices, numItems, numFolders, numFiles, totalSize, callback);
|
||||
RINOK(callback->SetTotal(totalSize));
|
||||
RINOK(callback->SetNumFiles(numFiles));
|
||||
|
||||
UString destPath = path;
|
||||
if (destPath.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
bool directName = (destPath[destPath.Length() - 1] != L'\\');
|
||||
if (directName)
|
||||
{
|
||||
if (numItems > 1)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
else
|
||||
if (!NDirectory::CreateComplexDirectory(destPath))
|
||||
{
|
||||
UString message = UString(L"can not create folder ") +
|
||||
destPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
UInt64 completedSize = 0;
|
||||
RINOK(callback->SetCompleted(&completedSize));
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
const CDirItem &fileInfo = *_refs[indices[i]];
|
||||
UString destPath2 = destPath;
|
||||
if (!directName)
|
||||
destPath2 += fileInfo.Name;
|
||||
UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
|
||||
const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
}
|
||||