mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 15:14:59 -06:00
9.21
This commit is contained in:
committed by
Kornel Lesiński
parent
de4f8c22fe
commit
35596517f2
@@ -18,7 +18,7 @@ STDMETHODIMP CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CAgentFolder::LoadFolder(CProxyFolder *folder)
|
||||
void CAgentFolder::LoadFolder(const CProxyFolder *folder)
|
||||
{
|
||||
int i;
|
||||
CProxyItem item;
|
||||
@@ -56,22 +56,15 @@ STDMETHODIMP CAgentFolder::GetNumberOfItems(UInt32 *numItems)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#define SET_realIndex_AND_folder \
|
||||
UInt32 realIndex; const CProxyFolder *folder; \
|
||||
if (_flatMode) { const CProxyItem &item = _items[index]; folder = item.Folder; realIndex = item.Index; } \
|
||||
else { folder = _proxyFolderItem; realIndex = index; }
|
||||
|
||||
|
||||
UString CAgentFolder::GetName(UInt32 index) const
|
||||
{
|
||||
UInt32 realIndex;
|
||||
const CProxyFolder *folder;
|
||||
if (_flatMode)
|
||||
{
|
||||
const CProxyItem &item = _items[index];
|
||||
folder = item.Folder;
|
||||
realIndex = item.Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
folder = _proxyFolderItem;
|
||||
realIndex = index;
|
||||
}
|
||||
|
||||
SET_realIndex_AND_folder
|
||||
if (realIndex < (UInt32)folder->Folders.Size())
|
||||
return folder->Folders[realIndex].Name;
|
||||
return folder->Files[realIndex - folder->Folders.Size()].Name;
|
||||
@@ -97,32 +90,17 @@ UString CAgentFolder::GetFullPathPrefixPlusPrefix(UInt32 index) const
|
||||
return _proxyFolderItem->GetFullPathPrefix() + GetPrefix(index);
|
||||
}
|
||||
|
||||
void CAgentFolder::GetPrefixIfAny(UInt32 index, NCOM::CPropVariant &prop) const
|
||||
{
|
||||
if (!_flatMode)
|
||||
return;
|
||||
prop = GetPrefix(index);
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
STDMETHODIMP CAgentFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NCOM::CPropVariant prop;
|
||||
const CProxyFolder *folder;
|
||||
UInt32 realIndex;
|
||||
if (_flatMode)
|
||||
SET_realIndex_AND_folder
|
||||
if (propID == kpidPrefix)
|
||||
{
|
||||
const CProxyItem &item = _items[itemIndex];
|
||||
folder = item.Folder;
|
||||
realIndex = item.Index;
|
||||
if (_flatMode)
|
||||
prop = GetPrefix(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
folder = _proxyFolderItem;
|
||||
realIndex = itemIndex;
|
||||
}
|
||||
|
||||
if (realIndex < (UInt32)folder->Folders.Size())
|
||||
else if (realIndex < (UInt32)folder->Folders.Size())
|
||||
{
|
||||
const CProxyFolder &item = folder->Folders[realIndex];
|
||||
if (!_flatMode && propID == kpidSize)
|
||||
@@ -130,12 +108,12 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI
|
||||
else if (!_flatMode && propID == kpidPackSize)
|
||||
prop = item.PackSize;
|
||||
else
|
||||
switch(propID)
|
||||
switch (propID)
|
||||
{
|
||||
case kpidIsDir: prop = true; break;
|
||||
case kpidIsDir: prop = true; break;
|
||||
case kpidNumSubDirs: prop = item.NumSubFolders; break;
|
||||
case kpidNumSubFiles: prop = item.NumSubFiles; break;
|
||||
case kpidName: prop = item.Name; break;
|
||||
case kpidNumSubFiles: prop = item.NumSubFiles; break;
|
||||
case kpidName: prop = item.Name; break;
|
||||
case kpidCRC:
|
||||
{
|
||||
if (item.IsLeaf)
|
||||
@@ -146,8 +124,6 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI
|
||||
prop = item.Crc;
|
||||
break;
|
||||
}
|
||||
case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
|
||||
|
||||
default:
|
||||
if (item.IsLeaf)
|
||||
return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
|
||||
@@ -155,22 +131,21 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI
|
||||
}
|
||||
else
|
||||
{
|
||||
realIndex -= folder->Folders.Size();
|
||||
const CProxyFile &item = folder->Files[realIndex];
|
||||
switch(propID)
|
||||
const CProxyFile &item = folder->Files[realIndex - folder->Folders.Size()];
|
||||
switch (propID)
|
||||
{
|
||||
case kpidIsDir: prop = false; break;
|
||||
case kpidName: prop = item.Name; break;
|
||||
case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
|
||||
default:
|
||||
return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
|
||||
}
|
||||
}
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
HRESULT CAgentFolder::BindToFolder(CProxyFolder *folder, IFolderFolder **resultFolder)
|
||||
HRESULT CAgentFolder::BindToFolder(const CProxyFolder *folder, IFolderFolder **resultFolder)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> parentFolder;
|
||||
if (folder->Parent != _proxyFolderItem)
|
||||
@@ -189,20 +164,7 @@ HRESULT CAgentFolder::BindToFolder(CProxyFolder *folder, IFolderFolder **resultF
|
||||
STDMETHODIMP CAgentFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
CProxyFolder *folder;
|
||||
UInt32 realIndex;
|
||||
if (_flatMode)
|
||||
{
|
||||
const CProxyItem &item = _items[index];
|
||||
folder = item.Folder;
|
||||
realIndex = item.Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
folder = _proxyFolderItem;
|
||||
realIndex = index;
|
||||
}
|
||||
SET_realIndex_AND_folder
|
||||
if (realIndex >= (UInt32)folder->Folders.Size())
|
||||
return E_INVALIDARG;
|
||||
return BindToFolder(&folder->Folders[realIndex], resultFolder);
|
||||
@@ -235,19 +197,7 @@ STDMETHODIMP CAgentFolder::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
if (!getStream)
|
||||
return S_OK;
|
||||
|
||||
const CProxyFolder *folder;
|
||||
UInt32 realIndex;
|
||||
if (_flatMode)
|
||||
{
|
||||
const CProxyItem &item = _items[index];
|
||||
folder = item.Folder;
|
||||
realIndex = item.Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
folder = _proxyFolderItem;
|
||||
realIndex = index;
|
||||
}
|
||||
SET_realIndex_AND_folder
|
||||
|
||||
UInt32 indexInArchive;
|
||||
if (realIndex < (UInt32)folder->Folders.Size())
|
||||
@@ -262,7 +212,7 @@ STDMETHODIMP CAgentFolder::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
return getStream->GetStream(indexInArchive, stream);
|
||||
}
|
||||
|
||||
STATPROPSTG kProperties[] =
|
||||
static const STATPROPSTG kProperties[] =
|
||||
{
|
||||
{ NULL, kpidNumSubDirs, VT_UI4},
|
||||
{ NULL, kpidNumSubFiles, VT_UI4},
|
||||
@@ -325,7 +275,7 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STATPROPSTG kFolderProps[] =
|
||||
static const STATPROPSTG kFolderProps[] =
|
||||
{
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidPackSize, VT_UI8},
|
||||
@@ -340,7 +290,7 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
switch(propID)
|
||||
switch (propID)
|
||||
{
|
||||
case kpidSize: prop = _proxyFolderItem->Size; break;
|
||||
case kpidPackSize: prop = _proxyFolderItem->PackSize; break;
|
||||
@@ -399,7 +349,7 @@ void CAgentFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntV
|
||||
return;
|
||||
}
|
||||
realIndices.Clear();
|
||||
for(UInt32 i = 0; i < numItems; i++)
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
const CProxyItem &item = _items[indices[i]];
|
||||
const CProxyFolder *folder = item.Folder;
|
||||
@@ -423,13 +373,8 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
|
||||
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
|
||||
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
|
||||
UStringVector pathParts;
|
||||
CProxyFolder *currentProxyFolder = _proxyFolderItem;
|
||||
while (currentProxyFolder->Parent)
|
||||
{
|
||||
pathParts.Insert(0, currentProxyFolder->Name);
|
||||
currentProxyFolder = currentProxyFolder->Parent;
|
||||
}
|
||||
|
||||
_proxyFolderItem->GetPathParts(pathParts);
|
||||
|
||||
/*
|
||||
if (_flatMode)
|
||||
pathMode = NExtract::NPathMode::kNoPathnames;
|
||||
@@ -437,10 +382,13 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
|
||||
|
||||
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
|
||||
|
||||
FString pathU;
|
||||
if (path)
|
||||
pathU = us2fs(path);
|
||||
extractCallbackSpec->Init(NULL, &_agentSpec->GetArc(),
|
||||
extractCallback2,
|
||||
false, testMode ? true : false, false,
|
||||
(path ? path : L""),
|
||||
path ? pathU : FTEXT(""),
|
||||
pathParts,
|
||||
(UInt64)(Int64)-1);
|
||||
CUIntVector realIndices;
|
||||
@@ -474,10 +422,10 @@ STDMETHODIMP CAgent::Open(
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
_archiveFilePath = filePath;
|
||||
NFile::NFind::CFileInfoW fi;
|
||||
NFile::NFind::CFileInfo fi;
|
||||
if (!inStream)
|
||||
{
|
||||
if (!fi.Find(_archiveFilePath))
|
||||
if (!fi.Find(us2fs(_archiveFilePath)))
|
||||
return ::GetLastError();
|
||||
if (fi.IsDir())
|
||||
return E_FAIL;
|
||||
@@ -571,7 +519,7 @@ STDMETHODIMP CAgent::Extract(
|
||||
extractCallbackSpec->Init(NULL, &GetArc(),
|
||||
extractCallback2,
|
||||
false, testMode ? true : false, false,
|
||||
path,
|
||||
us2fs(path),
|
||||
UStringVector(),
|
||||
(UInt64)(Int64)-1);
|
||||
return GetArchive()->Extract(0, (UInt32)(Int32)-1, testMode, extractCallback);
|
||||
@@ -607,7 +555,7 @@ STDMETHODIMP CAgent::GetArcProp(UInt32 level, PROPID propID, PROPVARIANT *value)
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
CArc &arc = _archiveLink.Arcs[level];
|
||||
switch(propID)
|
||||
switch (propID)
|
||||
{
|
||||
case kpidType: prop = GetTypeOfArc(arc); break;
|
||||
case kpidPath: prop = arc.Path; break;
|
||||
|
||||
@@ -27,12 +27,21 @@ DECL_INTERFACE(IArchiveFolderInternal, 0x01, 0xC)
|
||||
|
||||
struct CProxyItem
|
||||
{
|
||||
CProxyFolder *Folder;
|
||||
const CProxyFolder *Folder;
|
||||
UInt32 Index;
|
||||
};
|
||||
|
||||
class CAgent;
|
||||
|
||||
enum AGENT_OP
|
||||
{
|
||||
AGENT_OP_Uni,
|
||||
AGENT_OP_Delete,
|
||||
AGENT_OP_CreateFolder,
|
||||
AGENT_OP_Rename,
|
||||
AGENT_OP_CopyFromFile
|
||||
};
|
||||
|
||||
class CAgentFolder:
|
||||
public IFolderFolder,
|
||||
public IFolderProperties,
|
||||
@@ -46,6 +55,7 @@ class CAgentFolder:
|
||||
#endif
|
||||
public CMyUnknownImp
|
||||
{
|
||||
void LoadFolder(const CProxyFolder *folder);
|
||||
public:
|
||||
|
||||
MY_QUERYINTERFACE_BEGIN2(IFolderFolder)
|
||||
@@ -61,8 +71,7 @@ public:
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
void LoadFolder(CProxyFolder *folder);
|
||||
HRESULT BindToFolder(CProxyFolder *folder, IFolderFolder **resultFolder);
|
||||
HRESULT BindToFolder(const CProxyFolder *folder, IFolderFolder **resultFolder);
|
||||
void GetRealIndices(const UINT32 *indices, UINT32 numItems, CUIntVector &realIndices) const;
|
||||
|
||||
INTERFACE_FolderFolder(;)
|
||||
@@ -90,8 +99,8 @@ public:
|
||||
|
||||
CAgentFolder(): _proxyFolderItem(NULL), _flatMode(0) {}
|
||||
|
||||
void Init(CProxyArchive *proxyHandler,
|
||||
CProxyFolder *proxyFolderItem,
|
||||
void Init(const CProxyArchive *proxyHandler,
|
||||
const CProxyFolder *proxyFolderItem,
|
||||
IFolderFolder *parentFolder,
|
||||
CAgent *agent)
|
||||
{
|
||||
@@ -104,9 +113,7 @@ public:
|
||||
|
||||
void GetPathParts(UStringVector &pathParts);
|
||||
HRESULT CommonUpdateOperation(
|
||||
bool deleteOperation,
|
||||
bool createFolderOperation,
|
||||
bool renameOperation,
|
||||
AGENT_OP operation,
|
||||
const wchar_t *newItemName,
|
||||
const NUpdateArchive::CActionSet *actionSet,
|
||||
const UINT32 *indices, UINT32 numItems,
|
||||
@@ -116,11 +123,10 @@ public:
|
||||
UString GetPrefix(UInt32 index) const;
|
||||
UString GetName(UInt32 index) const;
|
||||
UString GetFullPathPrefixPlusPrefix(UInt32 index) const;
|
||||
void GetPrefixIfAny(UInt32 index, NWindows::NCOM::CPropVariant &propVariant) const;
|
||||
|
||||
public:
|
||||
CProxyArchive *_proxyArchive;
|
||||
CProxyFolder *_proxyFolderItem;
|
||||
const CProxyArchive *_proxyArchive;
|
||||
const CProxyFolder *_proxyFolderItem;
|
||||
CMyComPtr<IFolderFolder> _parentFolder;
|
||||
CMyComPtr<IInFolderArchive> _agent;
|
||||
CAgent *_agentSpec;
|
||||
@@ -156,21 +162,19 @@ public:
|
||||
#ifndef EXTRACT_ONLY
|
||||
INTERFACE_IOutFolderArchive(;)
|
||||
|
||||
HRESULT CommonUpdate(
|
||||
const wchar_t *newArchiveName,
|
||||
int numUpdateItems,
|
||||
IArchiveUpdateCallback *updateCallback);
|
||||
HRESULT CommonUpdate(ISequentialOutStream *outArchiveStream,
|
||||
int numUpdateItems, IArchiveUpdateCallback *updateCallback);
|
||||
|
||||
HRESULT CreateFolder(
|
||||
const wchar_t *newArchiveName,
|
||||
const wchar_t *folderName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100);
|
||||
HRESULT CreateFolder(ISequentialOutStream *outArchiveStream,
|
||||
const wchar_t *folderName, IFolderArchiveUpdateCallback *updateCallback100);
|
||||
|
||||
HRESULT RenameItem(
|
||||
const wchar_t *newArchiveName,
|
||||
const UINT32 *indices, UINT32 numItems,
|
||||
const wchar_t *newItemName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100);
|
||||
HRESULT RenameItem(ISequentialOutStream *outArchiveStream,
|
||||
const UInt32 *indices, UInt32 numItems, const wchar_t *newItemName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100);
|
||||
|
||||
HRESULT UpdateOneFile(ISequentialOutStream *outArchiveStream,
|
||||
const UInt32 *indices, UInt32 numItems, const wchar_t *diskFilePath,
|
||||
IFolderArchiveUpdateCallback *updateCallback100);
|
||||
|
||||
// ISetProperties
|
||||
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
|
||||
@@ -190,8 +194,8 @@ public:
|
||||
|
||||
UString ArchiveType;
|
||||
|
||||
UStringVector _names;
|
||||
UString _folderPrefix;
|
||||
FStringVector _names;
|
||||
FString _folderPrefix;
|
||||
|
||||
UString _archiveNamePrefix;
|
||||
CAgentFolder *_agentFolder;
|
||||
@@ -203,8 +207,8 @@ public:
|
||||
CObjectVector<NWindows::NCOM::CPropVariant> m_PropValues;
|
||||
#endif
|
||||
|
||||
const CArc &GetArc() { return _archiveLink.Arcs.Back(); }
|
||||
IInArchive *GetArchive() { if ( _archiveLink.Arcs.IsEmpty()) return 0; return GetArc().Archive; }
|
||||
const CArc &GetArc() const { return _archiveLink.Arcs.Back(); }
|
||||
IInArchive *GetArchive() const { if ( _archiveLink.Arcs.IsEmpty()) return 0; return GetArc().Archive; }
|
||||
bool CanUpdate() const { return _archiveLink.Arcs.Size() <= 1; }
|
||||
|
||||
UString GetTypeOfArc(const CArc &arc) const { return _codecs->Formats[arc.FormatIndex].Name; }
|
||||
|
||||
@@ -2,23 +2,14 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Time.h"
|
||||
|
||||
#include "../../Compress/CopyCoder.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "../Common/EnumDirItems.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
#include "../Common/UpdateCallback.h"
|
||||
#include "../Common/UpdatePair.h"
|
||||
|
||||
#include "Agent.h"
|
||||
#include "UpdateCallbackAgent.h"
|
||||
|
||||
@@ -33,7 +24,7 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
|
||||
_agentFolder = NULL;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
CMyComPtr<IFolderFolder> archiveFolder = folder;
|
||||
CMyComPtr<IArchiveFolderInternal> archiveFolderInternal;
|
||||
@@ -41,40 +32,18 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
|
||||
RINOK(archiveFolderInternal->GetAgentFolder(&_agentFolder));
|
||||
}
|
||||
|
||||
UStringVector pathParts;
|
||||
pathParts.Clear();
|
||||
CMyComPtr<IFolderFolder> folderItem = folder;
|
||||
if (folderItem != NULL)
|
||||
for (;;)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
folderItem->BindToParentFolder(&newFolder);
|
||||
if (newFolder == NULL)
|
||||
break;
|
||||
|
||||
NCOM::CPropVariant prop;
|
||||
if (folderItem->GetFolderProperty(kpidName, &prop) == S_OK)
|
||||
if (prop.vt == VT_BSTR)
|
||||
pathParts.Insert(0, (const wchar_t *)prop.bstrVal);
|
||||
folderItem = newFolder;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pathParts.Size(); i++)
|
||||
{
|
||||
_archiveNamePrefix += pathParts[i];
|
||||
_archiveNamePrefix += WCHAR_PATH_SEPARATOR;
|
||||
}
|
||||
_archiveNamePrefix = _agentFolder->_proxyFolderItem->GetFullPathPrefix();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix,
|
||||
const wchar_t **names, UInt32 numNames)
|
||||
{
|
||||
_folderPrefix = folderPrefix;
|
||||
_folderPrefix = us2fs(folderPrefix);
|
||||
_names.Clear();
|
||||
_names.Reserve(numNames);
|
||||
for (UInt32 i = 0; i < numNames; i++)
|
||||
_names.Add(names[i]);
|
||||
_names.Add(us2fs(names[i]));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -89,12 +58,7 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
|
||||
const CProxyFile &fileItem = item.Files[i];
|
||||
CArcItem ai;
|
||||
RINOK(agent->GetArc().GetItemMTime(fileItem.Index, ai.MTime, ai.MTimeDefined));
|
||||
|
||||
CPropVariant property;
|
||||
agent->GetArchive()->GetProperty(fileItem.Index, kpidSize, &property);
|
||||
ai.SizeDefined = (property.vt != VT_EMPTY);
|
||||
if (ai.SizeDefined)
|
||||
ai.Size = ConvertPropVariantToUInt64(property);
|
||||
RINOK(agent->GetArc().GetItemSize(fileItem.Index, ai.Size, ai.SizeDefined));
|
||||
ai.IsDir = false;
|
||||
ai.Name = prefix + fileItem.Name;
|
||||
ai.Censored = true; // test it
|
||||
@@ -139,7 +103,7 @@ HRESULT CAgUpCallbackImp::ShowDeleteFile(int arcIndex)
|
||||
STDMETHODIMP CAgent::DoOperation(
|
||||
CCodecs *codecs,
|
||||
int formatIndex,
|
||||
const wchar_t *newArchiveName,
|
||||
ISequentialOutStream *outArchiveStream,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
@@ -154,9 +118,9 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
CDirItems dirItems;
|
||||
|
||||
{
|
||||
UString folderPrefix = _folderPrefix;
|
||||
FString folderPrefix = _folderPrefix;
|
||||
NFile::NName::NormalizeDirPathPrefix(folderPrefix);
|
||||
UStringVector errorPaths;
|
||||
FStringVector errorPaths;
|
||||
CRecordVector<DWORD> errorCodes;
|
||||
dirItems.EnumerateDirItems2(folderPrefix, _archiveNamePrefix, _names, errorPaths, errorCodes);
|
||||
if (errorCodes.Size() > 0)
|
||||
@@ -239,22 +203,6 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
updateCallbackSpec->Archive = GetArchive();
|
||||
updateCallbackSpec->Callback = &updateCallbackAgent;
|
||||
|
||||
COutFileStream *outStreamSpec = new COutFileStream;
|
||||
CMyComPtr<IOutStream> outStream(outStreamSpec);
|
||||
UString archiveName = newArchiveName;
|
||||
{
|
||||
UString resultPath;
|
||||
int pos;
|
||||
if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
|
||||
return E_FAIL;
|
||||
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
|
||||
}
|
||||
if (!outStreamSpec->Create(archiveName, true))
|
||||
{
|
||||
// ShowLastErrorMessage();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
CMyComPtr<ISetProperties> setProperties;
|
||||
if (outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties) == S_OK)
|
||||
{
|
||||
@@ -268,7 +216,7 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
for(i = 0; i < m_PropNames.Size(); i++)
|
||||
names.Add((const wchar_t *)m_PropNames[i]);
|
||||
|
||||
NWindows::NCOM::CPropVariant *propValues = new NWindows::NCOM::CPropVariant[m_PropValues.Size()];
|
||||
CPropVariant *propValues = new CPropVariant[m_PropValues.Size()];
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < m_PropValues.Size(); i++)
|
||||
@@ -290,88 +238,38 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
{
|
||||
CInFileStream *sfxStreamSpec = new CInFileStream;
|
||||
CMyComPtr<IInStream> sfxStream(sfxStreamSpec);
|
||||
if (!sfxStreamSpec->Open(sfxModule))
|
||||
if (!sfxStreamSpec->Open(us2fs(sfxModule)))
|
||||
return E_FAIL;
|
||||
// throw "Can't open sfx module";
|
||||
RINOK(NCompress::CopyStream(sfxStream, outStream, NULL));
|
||||
RINOK(NCompress::CopyStream(sfxStream, outArchiveStream, NULL));
|
||||
}
|
||||
|
||||
RINOK(outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback));
|
||||
return outStreamSpec->Close();
|
||||
return outArchive->UpdateItems(outArchiveStream, updatePairs2.Size(),updateCallback);
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::DoOperation2(
|
||||
const wchar_t *newArchiveName,
|
||||
const Byte *stateActions,
|
||||
const wchar_t *sfxModule,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
STDMETHODIMP CAgent::DoOperation2(ISequentialOutStream *outArchiveStream,
|
||||
const Byte *stateActions, const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
return DoOperation(_codecs, -1, newArchiveName,
|
||||
stateActions, sfxModule, updateCallback100);
|
||||
return DoOperation(_codecs, -1, outArchiveStream, stateActions, sfxModule, updateCallback100);
|
||||
}
|
||||
|
||||
HRESULT CAgent::CommonUpdate(
|
||||
const wchar_t *newArchiveName,
|
||||
int numUpdateItems,
|
||||
IArchiveUpdateCallback *updateCallback)
|
||||
HRESULT CAgent::CommonUpdate(ISequentialOutStream *outArchiveStream,
|
||||
int numUpdateItems, IArchiveUpdateCallback *updateCallback)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
CMyComPtr<IOutArchive> outArchive;
|
||||
RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive));
|
||||
|
||||
COutFileStream *outStreamSpec = new COutFileStream;
|
||||
CMyComPtr<IOutStream> outStream(outStreamSpec);
|
||||
|
||||
UString archiveName = newArchiveName;
|
||||
{
|
||||
UString resultPath;
|
||||
int pos;
|
||||
if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
|
||||
throw 141716;
|
||||
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
|
||||
}
|
||||
|
||||
/*
|
||||
bool isOK = false;
|
||||
for (int i = 0; i < (1 << 16); i++)
|
||||
{
|
||||
resultName = newArchiveName;
|
||||
if (i > 0)
|
||||
{
|
||||
wchar_t s[16];
|
||||
ConvertUInt32ToString(i, s);
|
||||
resultName += s;
|
||||
}
|
||||
if (outStreamSpec->Open(realPath))
|
||||
{
|
||||
isOK = true;
|
||||
break;
|
||||
}
|
||||
if (::GetLastError() != ERROR_FILE_EXISTS)
|
||||
return ::GetLastError();
|
||||
}
|
||||
if (!isOK)
|
||||
return ::GetLastError();
|
||||
*/
|
||||
if (!outStreamSpec->Create(archiveName, true))
|
||||
{
|
||||
// ShowLastErrorMessage();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
RINOK(outArchive->UpdateItems(outStream, numUpdateItems, updateCallback));
|
||||
return outStreamSpec->Close();
|
||||
return outArchive->UpdateItems(outArchiveStream, numUpdateItems, updateCallback);
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CAgent::DeleteItems(
|
||||
const wchar_t *newArchiveName,
|
||||
STDMETHODIMP CAgent::DeleteItems(ISequentialOutStream *outArchiveStream,
|
||||
const UInt32 *indices, UInt32 numItems,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
CRecordVector<CUpdatePair2> updatePairs;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.SetCallback(updateCallback100);
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
@@ -379,7 +277,6 @@ STDMETHODIMP CAgent::DeleteItems(
|
||||
|
||||
CUIntVector realIndices;
|
||||
_agentFolder->GetRealIndices(indices, numItems, realIndices);
|
||||
CRecordVector<CUpdatePair2> updatePairs;
|
||||
int curIndex = 0;
|
||||
UInt32 numItemsInArchive;
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
@@ -400,22 +297,21 @@ STDMETHODIMP CAgent::DeleteItems(
|
||||
updateCallbackSpec->UpdatePairs = &updatePairs;
|
||||
updateCallbackSpec->Archive = GetArchive();
|
||||
updateCallbackSpec->Callback = &updateCallbackAgent;
|
||||
return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
|
||||
return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
|
||||
}
|
||||
|
||||
HRESULT CAgent::CreateFolder(
|
||||
const wchar_t *newArchiveName,
|
||||
const wchar_t *folderName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
HRESULT CAgent::CreateFolder(ISequentialOutStream *outArchiveStream,
|
||||
const wchar_t *folderName, IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
CRecordVector<CUpdatePair2> updatePairs;
|
||||
CDirItems dirItems;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.SetCallback(updateCallback100);
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
CRecordVector<CUpdatePair2> updatePairs;
|
||||
UInt32 numItemsInArchive;
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
for (UInt32 i = 0; i < numItemsInArchive; i++)
|
||||
@@ -435,7 +331,6 @@ HRESULT CAgent::CreateFolder(
|
||||
|
||||
updatePairs.ReserveDown();
|
||||
|
||||
CDirItems dirItems;
|
||||
CDirItem di;
|
||||
|
||||
di.Attrib = FILE_ATTRIBUTE_DIRECTORY;
|
||||
@@ -452,20 +347,19 @@ HRESULT CAgent::CreateFolder(
|
||||
updateCallbackSpec->DirItems = &dirItems;
|
||||
updateCallbackSpec->UpdatePairs = &updatePairs;
|
||||
updateCallbackSpec->Archive = GetArchive();
|
||||
return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
|
||||
return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CAgent::RenameItem(
|
||||
const wchar_t *newArchiveName,
|
||||
const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *newItemName,
|
||||
HRESULT CAgent::RenameItem(ISequentialOutStream *outArchiveStream,
|
||||
const UInt32 *indices, UInt32 numItems, const wchar_t *newItemName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
if (numItems != 1)
|
||||
return E_INVALIDARG;
|
||||
CRecordVector<CUpdatePair2> updatePairs;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.SetCallback(updateCallback100);
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
@@ -478,7 +372,6 @@ HRESULT CAgent::RenameItem(
|
||||
UString oldItemPath = fullPrefix + _agentFolder->GetName(indices[0]);
|
||||
UString newItemPath = fullPrefix + newItemName;
|
||||
|
||||
CRecordVector<CUpdatePair2> updatePairs;
|
||||
UStringVector newNames;
|
||||
|
||||
int curIndex = 0;
|
||||
@@ -516,7 +409,64 @@ HRESULT CAgent::RenameItem(
|
||||
updateCallbackSpec->UpdatePairs = &updatePairs;
|
||||
updateCallbackSpec->NewNames = &newNames;
|
||||
updateCallbackSpec->Archive = GetArchive();
|
||||
return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
|
||||
return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
|
||||
}
|
||||
|
||||
HRESULT CAgent::UpdateOneFile(ISequentialOutStream *outArchiveStream,
|
||||
const UInt32 *indices, UInt32 numItems, const wchar_t *diskFilePath,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
CRecordVector<CUpdatePair2> updatePairs;
|
||||
CDirItems dirItems;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.SetCallback(updateCallback100);
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
UInt32 realIndex;
|
||||
{
|
||||
CUIntVector realIndices;
|
||||
_agentFolder->GetRealIndices(indices, numItems, realIndices);
|
||||
if (realIndices.Size() != 1)
|
||||
return E_FAIL;
|
||||
realIndex = realIndices[0];
|
||||
}
|
||||
|
||||
{
|
||||
FStringVector filePaths;
|
||||
filePaths.Add(us2fs(diskFilePath));
|
||||
FStringVector errorPaths;
|
||||
CRecordVector<DWORD> errorCodes;
|
||||
dirItems.EnumerateDirItems2(FString(), UString(), filePaths, errorPaths, errorCodes);
|
||||
if (dirItems.Items.Size() != 1)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
UInt32 numItemsInArchive;
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
for (UInt32 i = 0; i < numItemsInArchive; i++)
|
||||
{
|
||||
CUpdatePair2 up2;
|
||||
up2.ArcIndex = i;
|
||||
up2.IsAnti = false;
|
||||
up2.NewData = false;
|
||||
up2.NewProps = false;
|
||||
if (realIndex == i)
|
||||
{
|
||||
up2.DirIndex = 0;
|
||||
up2.NewData = true;
|
||||
up2.NewProps = true;
|
||||
}
|
||||
updatePairs.Add(up2);
|
||||
}
|
||||
updateCallbackSpec->DirItems = &dirItems;
|
||||
updateCallbackSpec->Callback = &updateCallbackAgent;
|
||||
updateCallbackSpec->UpdatePairs = &updatePairs;
|
||||
updateCallbackSpec->Archive = GetArchive();
|
||||
updateCallbackSpec->KeepOriginalItemNames = true;
|
||||
return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::SetProperties(const wchar_t **names,
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
#include "AgentProxy.h"
|
||||
|
||||
using namespace NWindows;
|
||||
@@ -79,11 +77,10 @@ void CProxyFolder::Clear()
|
||||
void CProxyFolder::GetPathParts(UStringVector &pathParts) const
|
||||
{
|
||||
pathParts.Clear();
|
||||
UString result;
|
||||
const CProxyFolder *current = this;
|
||||
while (current->Parent != NULL)
|
||||
{
|
||||
pathParts.Insert(0, (const wchar_t *)current->Name);
|
||||
pathParts.Insert(0, current->Name);
|
||||
current = current->Parent;
|
||||
}
|
||||
}
|
||||
@@ -100,13 +97,6 @@ UString CProxyFolder::GetFullPathPrefix() const
|
||||
return result;
|
||||
}
|
||||
|
||||
UString CProxyFolder::GetItemName(UInt32 index) const
|
||||
{
|
||||
if (index < (UInt32)Folders.Size())
|
||||
return Folders[index].Name;
|
||||
return Files[index - Folders.Size()].Name;
|
||||
}
|
||||
|
||||
void CProxyFolder::AddRealIndices(CUIntVector &realIndices) const
|
||||
{
|
||||
if (IsLeaf)
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef __AGENT_PROXY_H
|
||||
#define __AGENT_PROXY_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
struct CProxyFile
|
||||
@@ -13,8 +11,11 @@ struct CProxyFile
|
||||
UString Name;
|
||||
};
|
||||
|
||||
struct CProxyFolder: public CProxyFile
|
||||
class CProxyFolder: public CProxyFile
|
||||
{
|
||||
int FindDirSubItemIndex(const UString &name, int &insertPos) const;
|
||||
void AddRealIndices(CUIntVector &realIndices) const;
|
||||
public:
|
||||
CProxyFolder *Parent;
|
||||
CObjectVector<CProxyFolder> Folders;
|
||||
CObjectVector<CProxyFile> Files;
|
||||
@@ -28,7 +29,6 @@ struct CProxyFolder: public CProxyFile
|
||||
UInt32 NumSubFiles;
|
||||
|
||||
CProxyFolder(): Parent(NULL) {};
|
||||
int FindDirSubItemIndex(const UString &name, int &insertPos) const;
|
||||
int FindDirSubItemIndex(const UString &name) const;
|
||||
CProxyFolder* AddDirSubItem(UInt32 index, bool leaf, const UString &name);
|
||||
void AddFileSubItem(UInt32 index, const UString &name);
|
||||
@@ -36,8 +36,6 @@ struct CProxyFolder: public CProxyFile
|
||||
|
||||
void GetPathParts(UStringVector &pathParts) const;
|
||||
UString GetFullPathPrefix() const;
|
||||
UString GetItemName(UInt32 index) const;
|
||||
void AddRealIndices(CUIntVector &realIndices) const;
|
||||
void GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const;
|
||||
void CalculateSizes(IInArchive *archive);
|
||||
};
|
||||
|
||||
@@ -8,46 +8,20 @@
|
||||
|
||||
#include "Agent.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NCOM;
|
||||
|
||||
STDMETHODIMP CAgentFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
CArchiveExtractCallback *extractCallbackSpec = new
|
||||
CArchiveExtractCallback;
|
||||
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
|
||||
UStringVector pathParts;
|
||||
CProxyFolder *currentProxyFolder = _proxyFolderItem;
|
||||
while (currentProxyFolder->Parent)
|
||||
{
|
||||
pathParts.Insert(0, currentProxyFolder->Name);
|
||||
currentProxyFolder = currentProxyFolder->Parent;
|
||||
}
|
||||
|
||||
CMyComPtr<IFolderArchiveExtractCallback> extractCallback2;
|
||||
{
|
||||
CMyComPtr<IFolderOperationsExtractCallback> callbackWrap = callback;
|
||||
RINOK(callbackWrap.QueryInterface(
|
||||
IID_IFolderArchiveExtractCallback, &extractCallback2));
|
||||
RINOK(callbackWrap.QueryInterface(IID_IFolderArchiveExtractCallback, &extractCallback2));
|
||||
}
|
||||
|
||||
NExtract::NPathMode::EEnum pathMode = _flatMode ?
|
||||
NExtract::NPathMode::kNoPathnames :
|
||||
NExtract::NPathMode::kCurrentPathnames;
|
||||
|
||||
extractCallbackSpec->InitForMulti(false, pathMode, NExtract::NOverwriteMode::kAskBefore);
|
||||
extractCallbackSpec->Init(NULL, &_agentSpec->GetArc(),
|
||||
extractCallback2,
|
||||
false, false, false,
|
||||
path,
|
||||
pathParts,
|
||||
(UInt64)(Int64)-1);
|
||||
CUIntVector realIndices;
|
||||
GetRealIndices(indices, numItems, realIndices);
|
||||
return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
|
||||
realIndices.Size(), BoolToInt(false), extractCallback);
|
||||
return Extract(indices,numItems, pathMode, NExtract::NOverwriteMode::kAskBefore,
|
||||
path, BoolToInt(false), extractCallback2);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -56,4 +30,3 @@ STDMETHODIMP CAgentFolder::MoveTo(const UInt32 * /* indices */, UInt32 /* numIte
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,9 @@
|
||||
// Zip/ArchiveFolder.cpp
|
||||
// Agent/ArchiveFolderOpen.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Agent.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
static inline UINT GetCurrentFileCodePage()
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
return CP_ACP;
|
||||
#else
|
||||
return AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CArchiveFolderManager::LoadFormats()
|
||||
{
|
||||
if (!_codecs)
|
||||
@@ -39,7 +26,7 @@ STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream,
|
||||
IFolderFolder **resultFolder, IProgress *progress)
|
||||
{
|
||||
CMyComPtr<IArchiveOpenCallback> openArchiveCallback;
|
||||
if (progress != 0)
|
||||
if (progress)
|
||||
{
|
||||
CMyComPtr<IProgress> progressWrapper = progress;
|
||||
progressWrapper.QueryInterface(IID_IArchiveOpenCallback, &openArchiveCallback);
|
||||
@@ -104,16 +91,18 @@ STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPa
|
||||
if (lib.FindIconIndex(ext, ii))
|
||||
{
|
||||
*iconIndex = ii;
|
||||
return StringToBstr(GetUnicodeString(lib.Path, GetCurrentFileCodePage()), iconPath);
|
||||
return StringToBstr(fs2us(lib.Path), iconPath);
|
||||
}
|
||||
}
|
||||
int ii;
|
||||
if (_codecs->InternalIcons.FindIconIndex(ext, ii))
|
||||
{
|
||||
*iconIndex = ii;
|
||||
UString path;
|
||||
NWindows::NDLL::MyGetModuleFileName(g_hInstance, path);
|
||||
return StringToBstr(path, iconPath);
|
||||
FString path;
|
||||
if (NWindows::NDLL::MyGetModuleFileName(path))
|
||||
{
|
||||
*iconIndex = ii;
|
||||
return StringToBstr(fs2us(path), iconPath);
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
#include "../Common/WorkDir.h"
|
||||
|
||||
#include "Agent.h"
|
||||
@@ -14,32 +15,20 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDirectory;
|
||||
|
||||
static LPCWSTR kTempArcivePrefix = L"7zA";
|
||||
|
||||
void CAgentFolder::GetPathParts(UStringVector &pathParts)
|
||||
{
|
||||
_proxyFolderItem->GetPathParts(pathParts);
|
||||
}
|
||||
|
||||
HRESULT CAgentFolder::CommonUpdateOperation(
|
||||
bool deleteOperation,
|
||||
bool createFolderOperation,
|
||||
bool renameOperation,
|
||||
AGENT_OP operation,
|
||||
const wchar_t *newItemName,
|
||||
const NUpdateArchive::CActionSet *actionSet,
|
||||
const UINT32 *indices, UINT32 numItems,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
workDirInfo.Load();
|
||||
UString archiveFilePath = _agentSpec->_archiveFilePath;
|
||||
UString workDir = GetWorkDir(workDirInfo, archiveFilePath);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
CTempFileW tempFile;
|
||||
UString tempFileName;
|
||||
if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
|
||||
return E_FAIL;
|
||||
CWorkDirTempFile tempFile;
|
||||
RINOK(tempFile.CreateTempFile(us2fs(_agentSpec->_archiveFilePath)));
|
||||
|
||||
/*
|
||||
if (SetOutProperties(anOutArchive, aCompressionInfo.Method) != S_OK)
|
||||
@@ -53,44 +42,39 @@ HRESULT CAgentFolder::CommonUpdateOperation(
|
||||
GetPathParts(pathParts);
|
||||
|
||||
HRESULT result;
|
||||
if (deleteOperation)
|
||||
result = _agentSpec->DeleteItems(tempFileName,
|
||||
indices, numItems, updateCallback100);
|
||||
else if (createFolderOperation)
|
||||
switch (operation)
|
||||
{
|
||||
result = _agentSpec->CreateFolder(tempFileName,
|
||||
newItemName, updateCallback100);
|
||||
}
|
||||
else if (renameOperation)
|
||||
{
|
||||
result = _agentSpec->RenameItem(
|
||||
tempFileName,
|
||||
indices, numItems,
|
||||
newItemName,
|
||||
updateCallback100);
|
||||
}
|
||||
else
|
||||
{
|
||||
Byte actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (int i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = (Byte)actionSet->StateActions[i];
|
||||
result = _agentSpec->DoOperation2(tempFileName, actionSetByte, NULL, updateCallback100);
|
||||
case AGENT_OP_Delete:
|
||||
result = _agentSpec->DeleteItems(tempFile.OutStream, indices, numItems, updateCallback100);
|
||||
break;
|
||||
case AGENT_OP_CreateFolder:
|
||||
result = _agentSpec->CreateFolder(tempFile.OutStream, newItemName, updateCallback100);
|
||||
break;
|
||||
case AGENT_OP_Rename:
|
||||
result = _agentSpec->RenameItem(tempFile.OutStream, indices, numItems, newItemName, updateCallback100);
|
||||
break;
|
||||
case AGENT_OP_CopyFromFile:
|
||||
result = _agentSpec->UpdateOneFile(tempFile.OutStream, indices, numItems, newItemName, updateCallback100);
|
||||
break;
|
||||
case AGENT_OP_Uni:
|
||||
{
|
||||
Byte actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (int i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = (Byte)actionSet->StateActions[i];
|
||||
result = _agentSpec->DoOperation2(tempFile.OutStream, actionSetByte, NULL, updateCallback100);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (result != S_OK)
|
||||
return result;
|
||||
RINOK(result);
|
||||
|
||||
_agentSpec->Close();
|
||||
|
||||
// m_FolderItem = NULL;
|
||||
|
||||
if (NFind::DoesFileExist(archiveFilePath))
|
||||
if (!DeleteFileAlways(archiveFilePath))
|
||||
return GetLastError();
|
||||
|
||||
tempFile.DisableDeleting();
|
||||
if (!MyMoveFile(tempFileName, archiveFilePath))
|
||||
return GetLastError();
|
||||
RINOK(tempFile.MoveToOriginal(true));
|
||||
|
||||
{
|
||||
CMyComPtr<IArchiveOpenCallback> openCallback;
|
||||
@@ -134,7 +118,7 @@ STDMETHODIMP CAgentFolder::CopyFrom(
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
|
||||
if (progress != 0)
|
||||
if (progress)
|
||||
{
|
||||
RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&updateCallback100));
|
||||
}
|
||||
@@ -142,7 +126,7 @@ STDMETHODIMP CAgentFolder::CopyFrom(
|
||||
{
|
||||
RINOK(_agentSpec->SetFiles(fromFolderPath, itemsPaths, numItems));
|
||||
RINOK(_agentSpec->SetFolder(this));
|
||||
return CommonUpdateOperation(false, false, false, NULL,
|
||||
return CommonUpdateOperation(AGENT_OP_Uni, NULL,
|
||||
&NUpdateArchive::kAddActionSet, 0, 0, updateCallback100);
|
||||
}
|
||||
catch(const UString &s)
|
||||
@@ -153,18 +137,43 @@ STDMETHODIMP CAgentFolder::CopyFrom(
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::CopyFromFile(UInt32 destIndex, const wchar_t *itemPath, IProgress * progress)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
CUIntVector indices;
|
||||
indices.Add(destIndex);
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
|
||||
if (progress)
|
||||
{
|
||||
RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&updateCallback100));
|
||||
}
|
||||
try
|
||||
{
|
||||
RINOK(_agentSpec->SetFolder(this));
|
||||
return CommonUpdateOperation(AGENT_OP_CopyFromFile, itemPath,
|
||||
&NUpdateArchive::kAddActionSet,
|
||||
&indices.Front(), indices.Size(), updateCallback100);
|
||||
}
|
||||
catch(const UString &s)
|
||||
{
|
||||
RINOK(updateCallback100->UpdateErrorMessage(UString(L"Error: ") + s));
|
||||
return E_FAIL;
|
||||
}
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::Delete(const UINT32 *indices, UINT32 numItems, IProgress *progress)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
RINOK(_agentSpec->SetFolder(this));
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
|
||||
if (progress != 0)
|
||||
if (progress)
|
||||
{
|
||||
CMyComPtr<IProgress> progressWrapper = progress;
|
||||
RINOK(progressWrapper.QueryInterface(
|
||||
IID_IFolderArchiveUpdateCallback, &updateCallback100));
|
||||
}
|
||||
return CommonUpdateOperation(true, false, false, NULL,
|
||||
return CommonUpdateOperation(AGENT_OP_Delete, NULL,
|
||||
&NUpdateArchive::kDeleteActionSet, indices, numItems, updateCallback100);
|
||||
COM_TRY_END
|
||||
}
|
||||
@@ -176,12 +185,12 @@ STDMETHODIMP CAgentFolder::CreateFolder(const wchar_t *name, IProgress *progress
|
||||
return ERROR_ALREADY_EXISTS;
|
||||
RINOK(_agentSpec->SetFolder(this));
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
|
||||
if (progress != 0)
|
||||
if (progress)
|
||||
{
|
||||
CMyComPtr<IProgress> progressWrapper = progress;
|
||||
RINOK(progressWrapper.QueryInterface(IID_IFolderArchiveUpdateCallback, &updateCallback100));
|
||||
}
|
||||
return CommonUpdateOperation(false, true, false, name, NULL, NULL, 0, updateCallback100);
|
||||
return CommonUpdateOperation(AGENT_OP_CreateFolder, name, NULL, NULL, 0, updateCallback100);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -192,12 +201,12 @@ STDMETHODIMP CAgentFolder::Rename(UINT32 index, const wchar_t *newName, IProgres
|
||||
indices.Add(index);
|
||||
RINOK(_agentSpec->SetFolder(this));
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback100;
|
||||
if (progress != 0)
|
||||
if (progress)
|
||||
{
|
||||
CMyComPtr<IProgress> progressWrapper = progress;
|
||||
RINOK(progressWrapper.QueryInterface(IID_IFolderArchiveUpdateCallback, &updateCallback100));
|
||||
}
|
||||
return CommonUpdateOperation(false, false, true, newName, NULL, &indices.Front(),
|
||||
return CommonUpdateOperation(AGENT_OP_Rename, newName, NULL, &indices.Front(),
|
||||
indices.Size(), updateCallback100);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#ifndef __IFOLDER_ARCHIVE_H
|
||||
#define __IFOLDER_ARCHIVE_H
|
||||
|
||||
#include "../../IDecl.h"
|
||||
#include "../../Archive/IArchive.h"
|
||||
#include "../../UI/Common/LoadCodecs.h"
|
||||
#include "../../UI/FileManager/IFolder.h"
|
||||
@@ -57,13 +56,14 @@ FOLDER_ARCHIVE_INTERFACE_SUB(IFolderArchiveUpdateCallback, IProgress, 0x0B)
|
||||
#define INTERFACE_IOutFolderArchive(x) \
|
||||
STDMETHOD(SetFolder)(IFolderFolder *folder) x; \
|
||||
STDMETHOD(SetFiles)(const wchar_t *folderPrefix, const wchar_t **names, UInt32 numNames) x; \
|
||||
STDMETHOD(DeleteItems)(const wchar_t *newArchiveName, \
|
||||
STDMETHOD(DeleteItems)(ISequentialOutStream *outArchiveStream, \
|
||||
const UInt32 *indices, UInt32 numItems, IFolderArchiveUpdateCallback *updateCallback) x; \
|
||||
STDMETHOD(DoOperation)(CCodecs *codecs, int index, \
|
||||
const wchar_t *newArchiveName, const Byte *stateActions, const wchar_t *sfxModule, \
|
||||
ISequentialOutStream *outArchiveStream, const Byte *stateActions, const wchar_t *sfxModule, \
|
||||
IFolderArchiveUpdateCallback *updateCallback) x; \
|
||||
STDMETHOD(DoOperation2)( \
|
||||
ISequentialOutStream *outArchiveStream, const Byte *stateActions, const wchar_t *sfxModule, \
|
||||
IFolderArchiveUpdateCallback *updateCallback) x; \
|
||||
STDMETHOD(DoOperation2)(const wchar_t *newArchiveName, const Byte *stateActions, \
|
||||
const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback) x; \
|
||||
|
||||
FOLDER_ARCHIVE_INTERFACE(IOutFolderArchive, 0x0A)
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ HRESULT CUpdateCallbackAgent::OpenFileError(const wchar_t *name, DWORD systemErr
|
||||
UString(L"WARNING: ") +
|
||||
NError::MyFormatMessageW(systemError) +
|
||||
UString(L": ") +
|
||||
UString(name)));
|
||||
name));
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
#include "../../IPassword.h"
|
||||
#include "../../MyVersion.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
HINSTANCE g_hInstance = 0;
|
||||
#endif
|
||||
|
||||
// use another CLSIDs, if you want to support other formats (zip, rar, ...).
|
||||
// {23170F69-40C1-278A-1000-000110070000}
|
||||
DEFINE_GUID(CLSID_CFormat7z,
|
||||
@@ -30,9 +34,9 @@ using namespace NWindows;
|
||||
|
||||
#define kDllName "7z.dll"
|
||||
|
||||
static const char *kCopyrightString = MY_7ZIP_VERSION
|
||||
static const char *kCopyrightString = "\n" MY_7ZIP_VERSION
|
||||
" (" kDllName " client) "
|
||||
MY_COPYRIGHT " " MY_DATE;
|
||||
MY_COPYRIGHT " " MY_DATE "\n";
|
||||
|
||||
static const char *kHelpString =
|
||||
"Usage: Client7z.exe [a | l | x ] archive.7z [fileName ...]\n"
|
||||
@@ -48,28 +52,46 @@ typedef UINT32 (WINAPI * CreateObjectFunc)(
|
||||
void **outObject);
|
||||
|
||||
|
||||
void PrintString(const UString &s)
|
||||
static AString FStringToConsoleString(const FString &s)
|
||||
{
|
||||
return GetOemString(fs2us(s));
|
||||
}
|
||||
|
||||
static FString CmdStringToFString(const char *s)
|
||||
{
|
||||
return us2fs(GetUnicodeString(s));
|
||||
}
|
||||
|
||||
static void PrintString(const UString &s)
|
||||
{
|
||||
printf("%s", (LPCSTR)GetOemString(s));
|
||||
}
|
||||
|
||||
void PrintString(const AString &s)
|
||||
static void PrintString(const AString &s)
|
||||
{
|
||||
printf("%s", (LPCSTR)s);
|
||||
}
|
||||
|
||||
void PrintNewLine()
|
||||
static void PrintNewLine()
|
||||
{
|
||||
PrintString("\n");
|
||||
}
|
||||
|
||||
void PrintStringLn(const AString &s)
|
||||
static void PrintStringLn(const AString &s)
|
||||
{
|
||||
PrintString(s);
|
||||
PrintNewLine();
|
||||
}
|
||||
|
||||
void PrintError(const AString &s)
|
||||
static void PrintError(const char *message, const FString &name)
|
||||
{
|
||||
printf("Error: %s", (LPCSTR)message);
|
||||
PrintNewLine();
|
||||
PrintString(FStringToConsoleString(name));
|
||||
PrintNewLine();
|
||||
}
|
||||
|
||||
static void PrintError(const AString &s)
|
||||
{
|
||||
PrintNewLine();
|
||||
PrintString(s);
|
||||
@@ -148,8 +170,6 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Archive Extracting callback class
|
||||
|
||||
static const wchar_t *kCantDeleteOutputFile = L"ERROR: Can not delete output file ";
|
||||
|
||||
static const char *kTestingString = "Testing ";
|
||||
static const char *kExtractingString = "Extracting ";
|
||||
static const char *kSkippingString = "Skipping ";
|
||||
@@ -181,9 +201,9 @@ public:
|
||||
|
||||
private:
|
||||
CMyComPtr<IInArchive> _archiveHandler;
|
||||
UString _directoryPath; // Output directory
|
||||
FString _directoryPath; // Output directory
|
||||
UString _filePath; // name inside arcvhive
|
||||
UString _diskFilePath; // full path to file on disk
|
||||
FString _diskFilePath; // full path to file on disk
|
||||
bool _extractMode;
|
||||
struct CProcessedFileInfo
|
||||
{
|
||||
@@ -198,7 +218,7 @@ private:
|
||||
CMyComPtr<ISequentialOutStream> _outFileStream;
|
||||
|
||||
public:
|
||||
void Init(IInArchive *archiveHandler, const UString &directoryPath);
|
||||
void Init(IInArchive *archiveHandler, const FString &directoryPath);
|
||||
|
||||
UInt64 NumErrors;
|
||||
bool PasswordIsDefined;
|
||||
@@ -207,7 +227,7 @@ public:
|
||||
CArchiveExtractCallback() : PasswordIsDefined(false) {}
|
||||
};
|
||||
|
||||
void CArchiveExtractCallback::Init(IInArchive *archiveHandler, const UString &directoryPath)
|
||||
void CArchiveExtractCallback::Init(IInArchive *archiveHandler, const FString &directoryPath)
|
||||
{
|
||||
NumErrors = 0;
|
||||
_archiveHandler = archiveHandler;
|
||||
@@ -305,10 +325,10 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
|
||||
// Create folders for file
|
||||
int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
if (slashPos >= 0)
|
||||
NFile::NDirectory::CreateComplexDirectory(_directoryPath + _filePath.Left(slashPos));
|
||||
NFile::NDirectory::CreateComplexDirectory(_directoryPath + us2fs(_filePath.Left(slashPos)));
|
||||
}
|
||||
|
||||
UString fullProcessedPath = _directoryPath + _filePath;
|
||||
FString fullProcessedPath = _directoryPath + us2fs(_filePath);
|
||||
_diskFilePath = fullProcessedPath;
|
||||
|
||||
if (_processedFileInfo.isDir)
|
||||
@@ -317,12 +337,12 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
|
||||
}
|
||||
else
|
||||
{
|
||||
NFile::NFind::CFileInfoW fi;
|
||||
NFile::NFind::CFileInfo fi;
|
||||
if (fi.Find(fullProcessedPath))
|
||||
{
|
||||
if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
|
||||
{
|
||||
PrintString(UString(kCantDeleteOutputFile) + fullProcessedPath);
|
||||
PrintError("Can not delete output file", fullProcessedPath);
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
@@ -331,7 +351,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
|
||||
CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
|
||||
if (!_outFileStreamSpec->Open(fullProcessedPath, CREATE_ALWAYS))
|
||||
{
|
||||
PrintString((UString)L"can not open output file " + fullProcessedPath);
|
||||
PrintError("Can not open output file", fullProcessedPath);
|
||||
return E_ABORT;
|
||||
}
|
||||
_outFileStream = outStreamLoc;
|
||||
@@ -423,7 +443,7 @@ struct CDirItem
|
||||
FILETIME ATime;
|
||||
FILETIME MTime;
|
||||
UString Name;
|
||||
UString FullPath;
|
||||
FString FullPath;
|
||||
UInt32 Attrib;
|
||||
|
||||
bool isDir() const { return (Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 ; }
|
||||
@@ -458,7 +478,7 @@ public:
|
||||
UString VolName;
|
||||
UString VolExt;
|
||||
|
||||
UString DirPrefix;
|
||||
FString DirPrefix;
|
||||
const CObjectVector<CDirItem> *DirItems;
|
||||
|
||||
bool PasswordIsDefined;
|
||||
@@ -467,7 +487,7 @@ public:
|
||||
|
||||
bool m_NeedBeClosed;
|
||||
|
||||
UStringVector FailedFiles;
|
||||
FStringVector FailedFiles;
|
||||
CRecordVector<HRESULT> FailedCodes;
|
||||
|
||||
CArchiveUpdateCallback(): PasswordIsDefined(false), AskPassword(false), DirItems(0) {};
|
||||
@@ -514,7 +534,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
NCOM::CPropVariant prop;
|
||||
|
||||
if (propID == kpidIsAnti)
|
||||
{
|
||||
@@ -571,7 +591,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
|
||||
{
|
||||
CInFileStream *inStreamSpec = new CInFileStream;
|
||||
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
|
||||
UString path = DirPrefix + dirItem.FullPath;
|
||||
FString path = DirPrefix + dirItem.FullPath;
|
||||
if (!inStreamSpec->Open(path))
|
||||
{
|
||||
DWORD sysError = ::GetLastError();
|
||||
@@ -620,7 +640,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOu
|
||||
fileName += VolExt;
|
||||
COutFileStream *streamSpec = new COutFileStream;
|
||||
CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);
|
||||
if (!streamSpec->Create(fileName, false))
|
||||
if (!streamSpec->Create(us2fs(fileName), false))
|
||||
return ::GetLastError();
|
||||
*volumeStream = streamLoc.Detach();
|
||||
return S_OK;
|
||||
@@ -643,8 +663,6 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef
|
||||
return StringToBstr(Password, password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Main function
|
||||
|
||||
@@ -661,8 +679,8 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
PrintStringLn(kHelpString);
|
||||
return 1;
|
||||
}
|
||||
NWindows::NDLL::CLibrary lib;
|
||||
if (!lib.Load(TEXT(kDllName)))
|
||||
NDLL::CLibrary lib;
|
||||
if (!lib.Load(NDLL::GetModuleDirPrefix() + FTEXT(kDllName)))
|
||||
{
|
||||
PrintError("Can not load 7-zip library");
|
||||
return 1;
|
||||
@@ -682,10 +700,10 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
PrintError("incorrect command");
|
||||
return 1;
|
||||
}
|
||||
c = MyCharLower(command[0]);
|
||||
c = (char)MyCharUpper(command[0]);
|
||||
}
|
||||
UString archiveName = GetUnicodeString(args[2]);
|
||||
if (c == 'a')
|
||||
FString archiveName = CmdStringToFString(args[2]);
|
||||
if (c == 'A')
|
||||
{
|
||||
// create archive command
|
||||
if (numArgs < 4)
|
||||
@@ -698,12 +716,12 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
for (i = 3; i < numArgs; i++)
|
||||
{
|
||||
CDirItem di;
|
||||
UString name = GetUnicodeString(args[i]);
|
||||
FString name = CmdStringToFString(args[i]);
|
||||
|
||||
NFile::NFind::CFileInfoW fi;
|
||||
NFile::NFind::CFileInfo fi;
|
||||
if (!fi.Find(name))
|
||||
{
|
||||
PrintString(UString(L"Can't find file") + name);
|
||||
PrintError("Can't find file", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -712,7 +730,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
di.CTime = fi.CTime;
|
||||
di.ATime = fi.ATime;
|
||||
di.MTime = fi.MTime;
|
||||
di.Name = name;
|
||||
di.Name = fs2us(name);
|
||||
di.FullPath = name;
|
||||
dirItems.Add(di);
|
||||
}
|
||||
@@ -745,7 +763,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
L"x"
|
||||
};
|
||||
const int kNumProps = sizeof(names) / sizeof(names[0]);
|
||||
NWindows::NCOM::CPropVariant values[kNumProps] =
|
||||
NCOM::CPropVariant values[kNumProps] =
|
||||
{
|
||||
false, // solid mode OFF
|
||||
(UInt32)9 // compression level = 9 - ultra
|
||||
@@ -771,7 +789,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
for (i = 0; i < updateCallbackSpec->FailedFiles.Size(); i++)
|
||||
{
|
||||
PrintNewLine();
|
||||
PrintString((UString)L"Error for file: " + updateCallbackSpec->FailedFiles[i]);
|
||||
PrintError("Error for file", updateCallbackSpec->FailedFiles[i]);
|
||||
}
|
||||
if (updateCallbackSpec->FailedFiles.Size() != 0)
|
||||
return 1;
|
||||
@@ -785,9 +803,9 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
}
|
||||
|
||||
bool listCommand;
|
||||
if (c == 'l')
|
||||
if (c == 'L')
|
||||
listCommand = true;
|
||||
else if (c == 'x')
|
||||
else if (c == 'X')
|
||||
listCommand = false;
|
||||
else
|
||||
{
|
||||
@@ -807,7 +825,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
|
||||
if (!fileSpec->Open(archiveName))
|
||||
{
|
||||
PrintError("Can not open archive file");
|
||||
PrintError("Can not open archive file", archiveName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -820,7 +838,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
|
||||
if (archive->Open(file, 0, openCallback) != S_OK)
|
||||
{
|
||||
PrintError("Can not open archive");
|
||||
PrintError("Can not open file as archive", archiveName);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -834,7 +852,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
{
|
||||
{
|
||||
// Get uncompressed size of file
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
NCOM::CPropVariant prop;
|
||||
archive->GetProperty(i, kpidSize, &prop);
|
||||
UString s = ConvertPropVariantToString(prop);
|
||||
PrintString(s);
|
||||
@@ -842,12 +860,12 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
}
|
||||
{
|
||||
// Get name of file
|
||||
NWindows::NCOM::CPropVariant prop;
|
||||
NCOM::CPropVariant prop;
|
||||
archive->GetProperty(i, kpidPath, &prop);
|
||||
UString s = ConvertPropVariantToString(prop);
|
||||
PrintString(s);
|
||||
}
|
||||
PrintString("\n");
|
||||
PrintNewLine();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -855,7 +873,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
// Extract command
|
||||
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
|
||||
CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
|
||||
extractCallbackSpec->Init(archive, L""); // second parameter is output folder path
|
||||
extractCallbackSpec->Init(archive, FTEXT("")); // second parameter is output folder path
|
||||
extractCallbackSpec->PasswordIsDefined = false;
|
||||
// extractCallbackSpec->PasswordIsDefined = true;
|
||||
// extractCallbackSpec->Password = L"1";
|
||||
|
||||
@@ -283,9 +283,9 @@ static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
|
||||
LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
|
||||
{
|
||||
UStringVector names;
|
||||
if (!NFind::DoesFileExist(fileName))
|
||||
if (!NFind::DoesFileExist(us2fs(fileName)))
|
||||
throw kCannotFindListFile;
|
||||
if (!ReadNamesFromListFile(fileName, names, codePage))
|
||||
if (!ReadNamesFromListFile(us2fs(fileName), names, codePage))
|
||||
throw kIncorrectListFile;
|
||||
for (int i = 0; i < names.Size(); i++)
|
||||
AddNameToCensor(wildcardCensor, names[i], include, type);
|
||||
@@ -420,9 +420,9 @@ static void ConvertToLongName(const UString &prefix, UString &name)
|
||||
{
|
||||
if (name.IsEmpty() || DoesNameContainWildCard(name))
|
||||
return;
|
||||
NFind::CFileInfoW fi;
|
||||
if (fi.Find(prefix + name))
|
||||
name = fi.Name;
|
||||
NFind::CFileInfo fi;
|
||||
if (fi.Find(us2fs(prefix + name)))
|
||||
name = fs2us(fi.Name);
|
||||
}
|
||||
|
||||
static void ConvertToLongNames(const UString &prefix, CObjectVector<NWildcard::CItem> &items)
|
||||
@@ -463,7 +463,7 @@ static void ConvertToLongNames(const UString &prefix, NWildcard::CCensorNode &no
|
||||
for (i = 0; i < node.SubNodes.Size(); i++)
|
||||
{
|
||||
NWildcard::CCensorNode &nextNode = node.SubNodes[i];
|
||||
ConvertToLongNames(prefix + nextNode.Name + wchar_t(NFile::NName::kDirDelimiter), nextNode);
|
||||
ConvertToLongNames(prefix + nextNode.Name + WCHAR_PATH_SEPARATOR, nextNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,11 +647,11 @@ static void SetAddCommandOptions(
|
||||
if (postString.IsEmpty())
|
||||
NDirectory::MyGetTempPath(options.WorkingDir);
|
||||
else
|
||||
options.WorkingDir = postString;
|
||||
options.WorkingDir = us2fs(postString);
|
||||
}
|
||||
options.SfxMode = parser[NKey::kSfx].ThereIs;
|
||||
if (options.SfxMode)
|
||||
options.SfxModule = parser[NKey::kSfx].PostStrings[0];
|
||||
options.SfxModule = us2fs(parser[NKey::kSfx].PostStrings[0]);
|
||||
|
||||
if (parser[NKey::kVolume].ThereIs)
|
||||
{
|
||||
@@ -670,7 +670,6 @@ static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &pr
|
||||
{
|
||||
if (parser[NKey::kProperty].ThereIs)
|
||||
{
|
||||
// options.MethodMode.Properties.Clear();
|
||||
for (int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
|
||||
{
|
||||
CProperty property;
|
||||
@@ -774,7 +773,7 @@ void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor,
|
||||
{
|
||||
CDirItems dirItems;
|
||||
{
|
||||
UStringVector errorPaths;
|
||||
FStringVector errorPaths;
|
||||
CRecordVector<DWORD> errorCodes;
|
||||
HRESULT res = EnumerateItems(wildcardCensor, dirItems, NULL, errorPaths, errorCodes);
|
||||
if (res != S_OK || errorPaths.Size() > 0)
|
||||
@@ -796,9 +795,9 @@ void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor,
|
||||
int i;
|
||||
for (i = 0; i < paths.Size(); i++)
|
||||
{
|
||||
UString fullPath;
|
||||
NFile::NDirectory::MyGetFullPathName(paths[i], fullPath);
|
||||
fullPaths.Add(fullPath);
|
||||
FString fullPath;
|
||||
NFile::NDirectory::MyGetFullPathName(us2fs(paths[i]), fullPath);
|
||||
fullPaths.Add(fs2us(fullPath));
|
||||
}
|
||||
CIntVector indices;
|
||||
SortFileNames(fullPaths, indices);
|
||||
@@ -886,6 +885,8 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
if (parser[NKey::kArchiveType].ThereIs)
|
||||
options.ArcType = parser[NKey::kArchiveType].PostStrings[0];
|
||||
|
||||
SetMethodOptions(parser, options.Properties);
|
||||
|
||||
if (isExtractOrList)
|
||||
{
|
||||
if (!options.WildcardCensor.AllAreRelative())
|
||||
@@ -924,12 +925,11 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
|
||||
if (isExtractGroupCommand)
|
||||
{
|
||||
SetMethodOptions(parser, options.ExtractProperties);
|
||||
if (options.StdOutMode && options.IsStdOutTerminal && options.IsStdErrTerminal)
|
||||
throw kSameTerminalError;
|
||||
if (parser[NKey::kOutputDir].ThereIs)
|
||||
{
|
||||
options.OutputDir = parser[NKey::kOutputDir].PostStrings[0];
|
||||
options.OutputDir = us2fs(parser[NKey::kOutputDir].PostStrings[0]);
|
||||
NFile::NName::NormalizeDirPathPrefix(options.OutputDir);
|
||||
}
|
||||
|
||||
@@ -946,7 +946,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
|
||||
SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
|
||||
|
||||
SetMethodOptions(parser, updateOptions.MethodMode.Properties);
|
||||
updateOptions.MethodMode.Properties = options.Properties;
|
||||
|
||||
if (parser[NKey::kShareForWrite].ThereIs)
|
||||
updateOptions.OpenShareForWrite = true;
|
||||
@@ -988,50 +988,12 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
}
|
||||
else if (options.Command.CommandType == NCommandType::kBenchmark)
|
||||
{
|
||||
options.NumThreads = (UInt32)-1;
|
||||
options.DictionarySize = (UInt32)-1;
|
||||
options.NumIterations = 1;
|
||||
if (curCommandIndex < numNonSwitchStrings)
|
||||
{
|
||||
if (!ConvertStringToUInt32(nonSwitchStrings[curCommandIndex++], options.NumIterations))
|
||||
ThrowUserErrorException();
|
||||
}
|
||||
for (int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
|
||||
{
|
||||
UString postString = parser[NKey::kProperty].PostStrings[i];
|
||||
postString.MakeUpper();
|
||||
if (postString.Length() < 2)
|
||||
ThrowUserErrorException();
|
||||
if (postString[0] == 'D')
|
||||
{
|
||||
int pos = 1;
|
||||
if (postString[pos] == '=')
|
||||
pos++;
|
||||
UInt32 logSize;
|
||||
if (!ConvertStringToUInt32((const wchar_t *)postString + pos, logSize))
|
||||
ThrowUserErrorException();
|
||||
if (logSize > 31)
|
||||
ThrowUserErrorException();
|
||||
options.DictionarySize = 1 << logSize;
|
||||
}
|
||||
else if (postString[0] == 'M' && postString[1] == 'T' )
|
||||
{
|
||||
int pos = 2;
|
||||
if (postString[pos] == '=')
|
||||
pos++;
|
||||
if (postString[pos] != 0)
|
||||
if (!ConvertStringToUInt32((const wchar_t *)postString + pos, options.NumThreads))
|
||||
ThrowUserErrorException();
|
||||
}
|
||||
else if (postString[0] == 'M' && postString[1] == '=' )
|
||||
{
|
||||
int pos = 2;
|
||||
if (postString[pos] != 0)
|
||||
options.Method = postString.Mid(2);
|
||||
}
|
||||
else
|
||||
ThrowUserErrorException();
|
||||
}
|
||||
}
|
||||
else if (options.Command.CommandType == NCommandType::kInfo)
|
||||
{
|
||||
|
||||
@@ -75,11 +75,11 @@ struct CArchiveCommandLineOptions
|
||||
// Extract
|
||||
bool CalcCrc;
|
||||
bool AppendName;
|
||||
UString OutputDir;
|
||||
FString OutputDir;
|
||||
NExtract::NOverwriteMode::EEnum OverwriteMode;
|
||||
UStringVector ArchivePathsSorted;
|
||||
UStringVector ArchivePathsFullSorted;
|
||||
CObjectVector<CProperty> ExtractProperties;
|
||||
CObjectVector<CProperty> Properties;
|
||||
|
||||
CUpdateOptions UpdateOptions;
|
||||
UString ArcType;
|
||||
@@ -87,10 +87,6 @@ struct CArchiveCommandLineOptions
|
||||
|
||||
// Benchmark
|
||||
UInt32 NumIterations;
|
||||
UInt32 NumThreads;
|
||||
UInt32 DictionarySize;
|
||||
UString Method;
|
||||
|
||||
|
||||
CArchiveCommandLineOptions(): StdInMode(false), StdOutMode(false) {};
|
||||
};
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/ComTry.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Wildcard.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
@@ -18,16 +20,16 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static const wchar_t *kCantAutoRename = L"ERROR: Can not create file with auto name";
|
||||
static const wchar_t *kCantRenameFile = L"ERROR: Can not rename existing file ";
|
||||
static const wchar_t *kCantDeleteOutputFile = L"ERROR: Can not delete output file ";
|
||||
static const char *kCantAutoRename = "ERROR: Can not create file with auto name";
|
||||
static const char *kCantRenameFile = "ERROR: Can not rename existing file ";
|
||||
static const char *kCantDeleteOutputFile = "ERROR: Can not delete output file ";
|
||||
|
||||
void CArchiveExtractCallback::Init(
|
||||
const NWildcard::CCensorNode *wildcardCensor,
|
||||
const CArc *arc,
|
||||
IFolderArchiveExtractCallback *extractCallback2,
|
||||
bool stdOutMode, bool testMode, bool crcMode,
|
||||
const UString &directoryPath,
|
||||
const FString &directoryPath,
|
||||
const UStringVector &removePathParts,
|
||||
UInt64 packSize)
|
||||
{
|
||||
@@ -107,14 +109,14 @@ STDMETHODIMP CArchiveExtractCallback::SetRatioInfo(const UInt64 *inSize, const U
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
void CArchiveExtractCallback::CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath)
|
||||
void CArchiveExtractCallback::CreateComplexDirectory(const UStringVector &dirPathParts, FString &fullPath)
|
||||
{
|
||||
fullPath = _directoryPath;
|
||||
for (int i = 0; i < dirPathParts.Size(); i++)
|
||||
{
|
||||
if (i > 0)
|
||||
fullPath += wchar_t(NFile::NName::kDirDelimiter);
|
||||
fullPath += dirPathParts[i];
|
||||
fullPath += FCHAR_PATH_SEPARATOR;
|
||||
fullPath += us2fs(dirPathParts[i]);
|
||||
NFile::NDirectory::MyCreateDirectory(fullPath);
|
||||
}
|
||||
}
|
||||
@@ -136,12 +138,12 @@ HRESULT CArchiveExtractCallback::GetTime(int index, PROPID propID, FILETIME &fil
|
||||
|
||||
HRESULT CArchiveExtractCallback::GetUnpackSize()
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(_arc->Archive->GetProperty(_index, kpidSize, &prop));
|
||||
_curSizeDefined = (prop.vt != VT_EMPTY);
|
||||
if (_curSizeDefined)
|
||||
_curSize = ConvertPropVariantToUInt64(prop);
|
||||
return S_OK;
|
||||
return _arc->GetItemSize(_index, _curSize, _curSizeDefined);
|
||||
}
|
||||
|
||||
HRESULT CArchiveExtractCallback::SendMessageError(const char *message, const FString &path)
|
||||
{
|
||||
return _extractCallback2->MessageError(GetUnicodeString(message) + fs2us(path));
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)
|
||||
@@ -256,7 +258,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
|
||||
if (!pathParts.IsEmpty())
|
||||
{
|
||||
UString fullPathNew;
|
||||
FString fullPathNew;
|
||||
CreateComplexDirectory(pathParts, fullPathNew);
|
||||
if (_fi.IsDir)
|
||||
NFile::NDirectory::SetDirTime(fullPathNew,
|
||||
@@ -267,7 +269,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
}
|
||||
|
||||
|
||||
UString fullProcessedPath = _directoryPath + processedPath;
|
||||
FString fullProcessedPath = _directoryPath + us2fs(processedPath);
|
||||
|
||||
if (_fi.IsDir)
|
||||
{
|
||||
@@ -279,7 +281,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
|
||||
if (!_isSplit)
|
||||
{
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
if (fileInfo.Find(fullProcessedPath))
|
||||
{
|
||||
switch(_overwriteMode)
|
||||
@@ -290,7 +292,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
{
|
||||
Int32 overwiteResult;
|
||||
RINOK(_extractCallback2->AskOverwrite(
|
||||
fullProcessedPath, &fileInfo.MTime, &fileInfo.Size, fullPath,
|
||||
fs2us(fullProcessedPath), &fileInfo.MTime, &fileInfo.Size, fullPath,
|
||||
_fi.MTimeDefined ? &_fi.MTime : NULL,
|
||||
_curSizeDefined ? &_curSize : NULL,
|
||||
&overwiteResult))
|
||||
@@ -321,32 +323,28 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
{
|
||||
if (!AutoRenamePath(fullProcessedPath))
|
||||
{
|
||||
UString message = UString(kCantAutoRename) + fullProcessedPath;
|
||||
RINOK(_extractCallback2->MessageError(message));
|
||||
RINOK(SendMessageError(kCantAutoRename, fullProcessedPath));
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else if (_overwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting)
|
||||
{
|
||||
UString existPath = fullProcessedPath;
|
||||
FString existPath = fullProcessedPath;
|
||||
if (!AutoRenamePath(existPath))
|
||||
{
|
||||
UString message = kCantAutoRename + fullProcessedPath;
|
||||
RINOK(_extractCallback2->MessageError(message));
|
||||
RINOK(SendMessageError(kCantAutoRename, fullProcessedPath));
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!NFile::NDirectory::MyMoveFile(fullProcessedPath, existPath))
|
||||
{
|
||||
UString message = UString(kCantRenameFile) + fullProcessedPath;
|
||||
RINOK(_extractCallback2->MessageError(message));
|
||||
RINOK(SendMessageError(kCantRenameFile, fullProcessedPath));
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
|
||||
{
|
||||
UString message = UString(kCantDeleteOutputFile) + fullProcessedPath;
|
||||
RINOK(_extractCallback2->MessageError(message));
|
||||
RINOK(SendMessageError(kCantDeleteOutputFile, fullProcessedPath));
|
||||
return S_OK;
|
||||
// return E_FAIL;
|
||||
}
|
||||
@@ -360,8 +358,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
{
|
||||
// if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit)
|
||||
{
|
||||
UString message = L"can not open output file " + fullProcessedPath;
|
||||
RINOK(_extractCallback2->MessageError(message));
|
||||
RINOK(SendMessageError("can not open output file ", fullProcessedPath));
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
@@ -485,4 +482,3 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
|
||||
return _cryptoGetTextPassword->CryptoGetTextPassword(password);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ class CArchiveExtractCallback:
|
||||
CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2;
|
||||
CMyComPtr<ICompressProgressInfo> _compressProgress;
|
||||
CMyComPtr<ICryptoGetTextPassword> _cryptoGetTextPassword;
|
||||
UString _directoryPath;
|
||||
FString _directoryPath;
|
||||
NExtract::NPathMode::EEnum _pathMode;
|
||||
NExtract::NOverwriteMode::EEnum _overwriteMode;
|
||||
|
||||
UString _diskFilePath;
|
||||
FString _diskFilePath;
|
||||
UString _filePath;
|
||||
UInt64 _position;
|
||||
bool _isSplit;
|
||||
@@ -83,10 +83,12 @@ class CArchiveExtractCallback:
|
||||
UInt64 _packTotal;
|
||||
UInt64 _unpTotal;
|
||||
|
||||
void CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath);
|
||||
void CreateComplexDirectory(const UStringVector &dirPathParts, FString &fullPath);
|
||||
HRESULT GetTime(int index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined);
|
||||
HRESULT GetUnpackSize();
|
||||
|
||||
HRESULT SendMessageError(const char *message, const FString &path);
|
||||
|
||||
public:
|
||||
|
||||
CLocalProgress *LocalProgressSpec;
|
||||
@@ -134,7 +136,7 @@ public:
|
||||
const CArc *arc,
|
||||
IFolderArchiveExtractCallback *extractCallback2,
|
||||
bool stdOutMode, bool testMode, bool crcMode,
|
||||
const UString &directoryPath,
|
||||
const FString &directoryPath,
|
||||
const UStringVector &removePathParts,
|
||||
UInt64 packSize);
|
||||
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static UString CreateArchiveName2(const UString &srcName, bool fromPrev, bool keepName)
|
||||
static FString CreateArchiveName2(const FString &srcName, bool fromPrev, bool keepName)
|
||||
{
|
||||
UString resultName = L"Archive";
|
||||
FString resultName = FTEXT("Archive");
|
||||
if (fromPrev)
|
||||
{
|
||||
UString dirPrefix;
|
||||
FString dirPrefix;
|
||||
if (NFile::NDirectory::GetOnlyDirPrefix(srcName, dirPrefix))
|
||||
{
|
||||
if (dirPrefix.Length() > 0)
|
||||
if (dirPrefix[dirPrefix.Length() - 1] == WCHAR_PATH_SEPARATOR)
|
||||
if (dirPrefix.Back() == FCHAR_PATH_SEPARATOR)
|
||||
{
|
||||
dirPrefix.Delete(dirPrefix.Length() - 1);
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
dirPrefix.DeleteBack();
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
if (fileInfo.Find(dirPrefix))
|
||||
resultName = fileInfo.Name;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ static UString CreateArchiveName2(const UString &srcName, bool fromPrev, bool ke
|
||||
}
|
||||
else
|
||||
{
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
if (!fileInfo.Find(srcName))
|
||||
// return resultName;
|
||||
return srcName;
|
||||
@@ -39,8 +39,8 @@ static UString CreateArchiveName2(const UString &srcName, bool fromPrev, bool ke
|
||||
int dotPos = resultName.ReverseFind('.');
|
||||
if (dotPos > 0)
|
||||
{
|
||||
UString archiveName2 = resultName.Left(dotPos);
|
||||
if (archiveName2.ReverseFind('.') < 0)
|
||||
FString archiveName2 = resultName.Left(dotPos);
|
||||
if (archiveName2.ReverseFind(FTEXT('.')) < 0)
|
||||
resultName = archiveName2;
|
||||
}
|
||||
}
|
||||
@@ -50,5 +50,5 @@ static UString CreateArchiveName2(const UString &srcName, bool fromPrev, bool ke
|
||||
|
||||
UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName)
|
||||
{
|
||||
return GetCorrectFsPath(CreateArchiveName2(srcName, fromPrev, keepName));
|
||||
return GetCorrectFsPath(fs2us(CreateArchiveName2(us2fs(srcName), fromPrev, keepName)));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
@@ -94,7 +93,7 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre
|
||||
RINOK(Callback->Open_CheckBreak());
|
||||
}
|
||||
*inStream = NULL;
|
||||
UString fullPath = _folderPrefix + name;
|
||||
FString fullPath = _folderPrefix + us2fs(name);
|
||||
if (!_fileInfo.Find(fullPath))
|
||||
return S_FALSE;
|
||||
if (_fileInfo.IsDir())
|
||||
@@ -130,4 +129,3 @@ STDMETHODIMP COpenCallbackImp::CryptoGetTextPassword(BSTR *password)
|
||||
COM_TRY_END
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
UString _folderPrefix;
|
||||
NWindows::NFile::NFind::CFileInfoW _fileInfo;
|
||||
FString _folderPrefix;
|
||||
NWindows::NFile::NFind::CFileInfo _fileInfo;
|
||||
bool _subArchiveMode;
|
||||
UString _subArchiveName;
|
||||
public:
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
UInt64 TotalSize;
|
||||
|
||||
COpenCallbackImp(): Callback(NULL) {}
|
||||
void Init(const UString &folderPrefix, const UString &fileName)
|
||||
void Init(const FString &folderPrefix, const FString &fileName)
|
||||
{
|
||||
_folderPrefix = folderPrefix;
|
||||
if (!_fileInfo.Find(_folderPrefix + fileName))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@
|
||||
#define __7ZIP_BENCH_H
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../UI/Common/Property.h"
|
||||
|
||||
struct CBenchInfo
|
||||
{
|
||||
@@ -14,7 +15,10 @@ struct CBenchInfo
|
||||
UInt64 UnpackSize;
|
||||
UInt64 PackSize;
|
||||
UInt32 NumIterations;
|
||||
|
||||
CBenchInfo(): NumIterations(0) {}
|
||||
UInt64 GetUsage() const;
|
||||
UInt64 GetRatingPerUsage(UInt64 rating) const;
|
||||
};
|
||||
|
||||
struct IBenchCallback
|
||||
@@ -23,20 +27,27 @@ struct IBenchCallback
|
||||
virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0;
|
||||
};
|
||||
|
||||
UInt64 GetUsage(const CBenchInfo &benchOnfo);
|
||||
UInt64 GetRatingPerUsage(const CBenchInfo &info, UInt64 rating);
|
||||
UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
|
||||
UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
|
||||
UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations);
|
||||
|
||||
HRESULT LzmaBench(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback);
|
||||
|
||||
const int kBenchMinDicLogSize = 18;
|
||||
|
||||
UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary);
|
||||
|
||||
bool CrcInternalTest();
|
||||
HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed);
|
||||
struct IBenchPrintCallback
|
||||
{
|
||||
virtual void Print(const char *s) = 0;
|
||||
virtual void NewLine() = 0;
|
||||
virtual HRESULT CheckBreak() = 0;
|
||||
};
|
||||
|
||||
HRESULT Bench(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IBenchPrintCallback *printCallback,
|
||||
IBenchCallback *benchCallback,
|
||||
const CObjectVector<CProperty> props,
|
||||
UInt32 numIterations,
|
||||
bool multiDict
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
#include "Common/Random.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileMapping.h"
|
||||
#include "Windows/Process.h"
|
||||
#include "Windows/Synchronization.h"
|
||||
|
||||
#include "../FileManager/ProgramLocation.h"
|
||||
#include "../FileManager/RegistryUtils.h"
|
||||
|
||||
#include "CompressCall.h"
|
||||
@@ -31,10 +32,13 @@ static LPCWSTR kArcIncludeSwitches = L" -an -ai";
|
||||
static LPCWSTR kStopSwitchParsing = L" --";
|
||||
static LPCWSTR kLargePagesDisable = L" -slp-";
|
||||
|
||||
extern HWND g_HWND;
|
||||
|
||||
UString GetQuotedString(const UString &s)
|
||||
{
|
||||
return UString(L'\"') + s + UString(L'\"');
|
||||
}
|
||||
|
||||
static void ErrorMessage(LPCWSTR message)
|
||||
{
|
||||
MessageBoxW(g_HWND, message, L"7-Zip", MB_ICONERROR | MB_OK);
|
||||
@@ -42,7 +46,7 @@ static void ErrorMessage(LPCWSTR message)
|
||||
|
||||
static void ErrorMessageHRESULT(HRESULT res, LPCWSTR s = NULL)
|
||||
{
|
||||
UString s2 = HResultToMessage(res);
|
||||
UString s2 = NError::MyFormatMessageW(res);
|
||||
if (s)
|
||||
{
|
||||
s2 += L'\n';
|
||||
@@ -80,9 +84,7 @@ static void AddLagePagesSwitch(UString ¶ms)
|
||||
|
||||
static UString Get7zGuiPath()
|
||||
{
|
||||
UString path;
|
||||
GetProgramFolderPath(path);
|
||||
return path + L"7zG.exe";
|
||||
return fs2us(NWindows::NDLL::GetModuleDirPrefix()) + L"7zG.exe";
|
||||
}
|
||||
|
||||
class CRandNameGenerator
|
||||
@@ -238,9 +240,9 @@ HRESULT TestArchives(const UStringVector &arcPaths)
|
||||
MY_TRY_FINISH
|
||||
}
|
||||
|
||||
HRESULT Benchmark()
|
||||
HRESULT Benchmark(bool totalMode)
|
||||
{
|
||||
MY_TRY_BEGIN
|
||||
return MyCreateProcess(Get7zGuiPath(), L'b', 0, false, NULL);
|
||||
return MyCreateProcess(Get7zGuiPath(), totalMode ? L"b -mm=*" : L"b", 0, false, NULL);
|
||||
MY_TRY_FINISH
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
|
||||
UString GetQuotedString(const UString &s);
|
||||
|
||||
extern HWND g_HWND;
|
||||
UString HResultToMessage(HRESULT errorCode);
|
||||
|
||||
HRESULT CompressFiles(
|
||||
const UString &arcPathPrefix,
|
||||
const UString &arcName,
|
||||
@@ -19,6 +16,6 @@ HRESULT CompressFiles(
|
||||
|
||||
HRESULT ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog);
|
||||
HRESULT TestArchives(const UStringVector &arcPaths);
|
||||
HRESULT Benchmark();
|
||||
HRESULT Benchmark(bool totalMode);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
#include "CompressCall.h"
|
||||
|
||||
extern HWND g_HWND;
|
||||
|
||||
#define MY_TRY_BEGIN try {
|
||||
#define MY_TRY_FINISH } \
|
||||
catch(CSystemException &e) { result = e.ErrorCode; } \
|
||||
@@ -110,7 +112,7 @@ static HRESULT ExtractGroupCommand(const UStringVector &arcPaths,
|
||||
CREATE_CODECS
|
||||
|
||||
CExtractOptions eo;
|
||||
eo.OutputDir = outFolder;
|
||||
eo.OutputDir = us2fs(outFolder);
|
||||
eo.TestMode = testMode;
|
||||
|
||||
CExtractCallbackImp *ecs = new CExtractCallbackImp;
|
||||
@@ -158,7 +160,7 @@ HRESULT TestArchives(const UStringVector &arcPaths)
|
||||
return ExtractGroupCommand(arcPaths, true, UString(), true);
|
||||
}
|
||||
|
||||
HRESULT Benchmark()
|
||||
HRESULT Benchmark(bool totalMode)
|
||||
{
|
||||
HRESULT result;
|
||||
MY_TRY_BEGIN
|
||||
@@ -168,11 +170,19 @@ HRESULT Benchmark()
|
||||
CObjectVector<CCodecInfoEx> externalCodecs;
|
||||
RINOK(LoadExternalCodecs(codecs, externalCodecs));
|
||||
#endif
|
||||
CObjectVector<CProperty> props;
|
||||
if (totalMode)
|
||||
{
|
||||
CProperty prop;
|
||||
prop.Name = L"m";
|
||||
prop.Value = L"*";
|
||||
props.Add(prop);
|
||||
}
|
||||
result = Benchmark(
|
||||
#ifdef EXTERNAL_CODECS
|
||||
codecs, &externalCodecs,
|
||||
#endif
|
||||
(UInt32)-1, (UInt32)-1, g_HWND);
|
||||
props, g_HWND);
|
||||
MY_TRY_FINISH
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@ public:
|
||||
int AddPrefix(int phyParent, int logParent, const UString &prefix);
|
||||
void DeleteLastPrefix();
|
||||
|
||||
void EnumerateDirectory(int phyParent, int logParent, const UString &phyPrefix,
|
||||
UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
|
||||
void EnumerateDirectory(int phyParent, int logParent, const FString &phyPrefix,
|
||||
FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
|
||||
|
||||
void EnumerateDirItems2(
|
||||
const UString &phyPrefix,
|
||||
const FString &phyPrefix,
|
||||
const UString &logPrefix,
|
||||
const UStringVector &filePaths,
|
||||
UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
|
||||
const FStringVector &filePaths,
|
||||
FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
|
||||
|
||||
void ReserveDown();
|
||||
};
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Windows/FileName.h"
|
||||
|
||||
#include "EnumDirItems.h"
|
||||
|
||||
using namespace NWindows;
|
||||
@@ -9,7 +11,7 @@ using namespace NFile;
|
||||
using namespace NName;
|
||||
|
||||
void AddDirFileInfo(int phyParent, int logParent,
|
||||
const NFind::CFileInfoW &fi, CObjectVector<CDirItem> &dirItems)
|
||||
const NFind::CFileInfo &fi, CObjectVector<CDirItem> &dirItems)
|
||||
{
|
||||
CDirItem di;
|
||||
di.Size = fi.Size;
|
||||
@@ -19,7 +21,7 @@ void AddDirFileInfo(int phyParent, int logParent,
|
||||
di.Attrib = fi.Attrib;
|
||||
di.PhyParent = phyParent;
|
||||
di.LogParent = logParent;
|
||||
di.Name = fi.Name;
|
||||
di.Name = fs2us(fi.Name);
|
||||
dirItems.Add(di);
|
||||
}
|
||||
|
||||
@@ -79,13 +81,13 @@ void CDirItems::DeleteLastPrefix()
|
||||
Prefixes.DeleteBack();
|
||||
}
|
||||
|
||||
void CDirItems::EnumerateDirectory(int phyParent, int logParent, const UString &phyPrefix,
|
||||
UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
|
||||
void CDirItems::EnumerateDirectory(int phyParent, int logParent, const FString &phyPrefix,
|
||||
FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
|
||||
{
|
||||
NFind::CEnumeratorW enumerator(phyPrefix + (wchar_t)kAnyStringWildcard);
|
||||
NFind::CEnumerator enumerator(phyPrefix + FCHAR_ANY_MASK);
|
||||
for (;;)
|
||||
{
|
||||
NFind::CFileInfoW fi;
|
||||
NFind::CFileInfo fi;
|
||||
bool found;
|
||||
if (!enumerator.Next(fi, found))
|
||||
{
|
||||
@@ -98,43 +100,43 @@ void CDirItems::EnumerateDirectory(int phyParent, int logParent, const UString &
|
||||
AddDirFileInfo(phyParent, logParent, fi, Items);
|
||||
if (fi.IsDir())
|
||||
{
|
||||
const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
|
||||
int parent = AddPrefix(phyParent, logParent, name2);
|
||||
const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR;
|
||||
int parent = AddPrefix(phyParent, logParent, fs2us(name2));
|
||||
EnumerateDirectory(parent, parent, phyPrefix + name2, errorPaths, errorCodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDirItems::EnumerateDirItems2(const UString &phyPrefix, const UString &logPrefix,
|
||||
const UStringVector &filePaths, UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
|
||||
void CDirItems::EnumerateDirItems2(const FString &phyPrefix, const UString &logPrefix,
|
||||
const FStringVector &filePaths, FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
|
||||
{
|
||||
int phyParent = phyPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, phyPrefix);
|
||||
int phyParent = phyPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, fs2us(phyPrefix));
|
||||
int logParent = logPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, logPrefix);
|
||||
|
||||
for (int i = 0; i < filePaths.Size(); i++)
|
||||
{
|
||||
const UString &filePath = filePaths[i];
|
||||
NFind::CFileInfoW fi;
|
||||
const UString phyPath = phyPrefix + filePath;
|
||||
const FString &filePath = filePaths[i];
|
||||
NFind::CFileInfo fi;
|
||||
const FString phyPath = phyPrefix + filePath;
|
||||
if (!fi.Find(phyPath))
|
||||
{
|
||||
errorCodes.Add(::GetLastError());
|
||||
errorPaths.Add(phyPath);
|
||||
continue;
|
||||
}
|
||||
int delimiter = filePath.ReverseFind((wchar_t)kDirDelimiter);
|
||||
UString phyPrefixCur;
|
||||
int delimiter = filePath.ReverseFind(FCHAR_PATH_SEPARATOR);
|
||||
FString phyPrefixCur;
|
||||
int phyParentCur = phyParent;
|
||||
if (delimiter >= 0)
|
||||
{
|
||||
phyPrefixCur = filePath.Left(delimiter + 1);
|
||||
phyParentCur = AddPrefix(phyParent, logParent, phyPrefixCur);
|
||||
phyParentCur = AddPrefix(phyParent, logParent, fs2us(phyPrefixCur));
|
||||
}
|
||||
AddDirFileInfo(phyParentCur, logParent, fi, Items);
|
||||
if (fi.IsDir())
|
||||
{
|
||||
const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
|
||||
int parent = AddPrefix(phyParentCur, logParent, name2);
|
||||
const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR;
|
||||
int parent = AddPrefix(phyParentCur, logParent, fs2us(name2));
|
||||
EnumerateDirectory(parent, parent, phyPrefix + phyPrefixCur + name2, errorPaths, errorCodes);
|
||||
}
|
||||
}
|
||||
@@ -142,27 +144,27 @@ void CDirItems::EnumerateDirItems2(const UString &phyPrefix, const UString &logP
|
||||
}
|
||||
|
||||
static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
|
||||
int phyParent, int logParent, const UString &phyPrefix,
|
||||
int phyParent, int logParent, const FString &phyPrefix,
|
||||
const UStringVector &addArchivePrefix,
|
||||
CDirItems &dirItems,
|
||||
bool enterToSubFolders,
|
||||
IEnumDirItemCallback *callback,
|
||||
UStringVector &errorPaths,
|
||||
FStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes);
|
||||
|
||||
static HRESULT EnumerateDirItems_Spec(const NWildcard::CCensorNode &curNode,
|
||||
int phyParent, int logParent, const UString &curFolderName,
|
||||
const UString &phyPrefix,
|
||||
int phyParent, int logParent, const FString &curFolderName,
|
||||
const FString &phyPrefix,
|
||||
const UStringVector &addArchivePrefix,
|
||||
CDirItems &dirItems,
|
||||
bool enterToSubFolders,
|
||||
IEnumDirItemCallback *callback,
|
||||
UStringVector &errorPaths,
|
||||
FStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes)
|
||||
|
||||
{
|
||||
const UString name2 = curFolderName + (wchar_t)kDirDelimiter;
|
||||
int parent = dirItems.AddPrefix(phyParent, logParent, name2);
|
||||
const FString name2 = curFolderName + FCHAR_PATH_SEPARATOR;
|
||||
int parent = dirItems.AddPrefix(phyParent, logParent, fs2us(name2));
|
||||
int numItems = dirItems.Items.Size();
|
||||
HRESULT res = EnumerateDirItems(curNode, parent, parent, phyPrefix + name2,
|
||||
addArchivePrefix, dirItems, enterToSubFolders, callback, errorPaths, errorCodes);
|
||||
@@ -173,19 +175,19 @@ static HRESULT EnumerateDirItems_Spec(const NWildcard::CCensorNode &curNode,
|
||||
|
||||
|
||||
static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
|
||||
int phyParent, int logParent, const UString &phyPrefix,
|
||||
int phyParent, int logParent, const FString &phyPrefix,
|
||||
const UStringVector &addArchivePrefix, // prefix from curNode
|
||||
CDirItems &dirItems,
|
||||
bool enterToSubFolders,
|
||||
IEnumDirItemCallback *callback,
|
||||
UStringVector &errorPaths,
|
||||
FStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes)
|
||||
{
|
||||
if (!enterToSubFolders)
|
||||
if (curNode.NeedCheckSubDirs())
|
||||
enterToSubFolders = true;
|
||||
if (callback)
|
||||
RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), phyPrefix));
|
||||
RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), fs2us(phyPrefix)));
|
||||
|
||||
// try direct_names case at first
|
||||
if (addArchivePrefix.IsEmpty() && !enterToSubFolders)
|
||||
@@ -210,8 +212,8 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
|
||||
{
|
||||
const NWildcard::CItem &item = curNode.IncludeItems[i];
|
||||
const UString &name = item.PathParts.Front();
|
||||
const UString fullPath = phyPrefix + name;
|
||||
NFind::CFileInfoW fi;
|
||||
const FString fullPath = phyPrefix + us2fs(name);
|
||||
NFind::CFileInfo fi;
|
||||
if (!fi.Find(fullPath))
|
||||
{
|
||||
errorCodes.Add(::GetLastError());
|
||||
@@ -227,7 +229,7 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
|
||||
}
|
||||
{
|
||||
UStringVector pathParts;
|
||||
pathParts.Add(fi.Name);
|
||||
pathParts.Add(fs2us(fi.Name));
|
||||
if (curNode.CheckPathToRoot(false, pathParts, !isDir))
|
||||
continue;
|
||||
}
|
||||
@@ -260,8 +262,8 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
|
||||
if (!needEnterVector[i])
|
||||
continue;
|
||||
const NWildcard::CCensorNode &nextNode = curNode.SubNodes[i];
|
||||
const UString fullPath = phyPrefix + nextNode.Name;
|
||||
NFind::CFileInfoW fi;
|
||||
const FString fullPath = phyPrefix + us2fs(nextNode.Name);
|
||||
NFind::CFileInfo fi;
|
||||
if (!fi.Find(fullPath))
|
||||
{
|
||||
if (!nextNode.AreThereIncludeItems())
|
||||
@@ -285,10 +287,10 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
|
||||
}
|
||||
|
||||
|
||||
NFind::CEnumeratorW enumerator(phyPrefix + wchar_t(kAnyStringWildcard));
|
||||
NFind::CEnumerator enumerator(phyPrefix + FCHAR_ANY_MASK);
|
||||
for (int ttt = 0; ; ttt++)
|
||||
{
|
||||
NFind::CFileInfoW fi;
|
||||
NFind::CFileInfo fi;
|
||||
bool found;
|
||||
if (!enumerator.Next(fi, found))
|
||||
{
|
||||
@@ -300,8 +302,8 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
|
||||
break;
|
||||
|
||||
if (callback && (ttt & 0xFF) == 0xFF)
|
||||
RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), phyPrefix));
|
||||
const UString &name = fi.Name;
|
||||
RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), fs2us(phyPrefix)));
|
||||
const UString &name = fs2us(fi.Name);
|
||||
bool enterToSubFolders2 = enterToSubFolders;
|
||||
UStringVector addArchivePrefixNew = addArchivePrefix;
|
||||
addArchivePrefixNew.Add(name);
|
||||
@@ -336,7 +338,7 @@ static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
|
||||
addArchivePrefixNew.Add(name);
|
||||
}
|
||||
|
||||
RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, name, phyPrefix,
|
||||
RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, fi.Name, phyPrefix,
|
||||
addArchivePrefixNew, dirItems, enterToSubFolders2, callback, errorPaths, errorCodes));
|
||||
}
|
||||
return S_OK;
|
||||
@@ -346,14 +348,14 @@ HRESULT EnumerateItems(
|
||||
const NWildcard::CCensor &censor,
|
||||
CDirItems &dirItems,
|
||||
IEnumDirItemCallback *callback,
|
||||
UStringVector &errorPaths,
|
||||
FStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes)
|
||||
{
|
||||
for (int i = 0; i < censor.Pairs.Size(); i++)
|
||||
{
|
||||
const NWildcard::CPair &pair = censor.Pairs[i];
|
||||
int phyParent = pair.Prefix.IsEmpty() ? -1 : dirItems.AddPrefix(-1, -1, pair.Prefix);
|
||||
RINOK(EnumerateDirItems(pair.Head, phyParent, -1, pair.Prefix, UStringVector(), dirItems, false,
|
||||
RINOK(EnumerateDirItems(pair.Head, phyParent, -1, us2fs(pair.Prefix), UStringVector(), dirItems, false,
|
||||
callback, errorPaths, errorCodes));
|
||||
}
|
||||
dirItems.ReserveDown();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "DirItem.h"
|
||||
|
||||
void AddDirFileInfo(int phyParent, int logParent,
|
||||
const NWindows::NFile::NFind::CFileInfoW &fi, CObjectVector<CDirItem> &dirItems);
|
||||
const NWindows::NFile::NFind::CFileInfo &fi, CObjectVector<CDirItem> &dirItems);
|
||||
|
||||
struct IEnumDirItemCallback
|
||||
{
|
||||
@@ -19,7 +19,7 @@ HRESULT EnumerateItems(
|
||||
const NWildcard::CCensor &censor,
|
||||
CDirItems &dirItems,
|
||||
IEnumDirItemCallback *callback,
|
||||
UStringVector &errorPaths,
|
||||
FStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -52,8 +52,8 @@ static HRESULT DecompressArchive(
|
||||
|
||||
UStringVector removePathParts;
|
||||
|
||||
UString outDir = options.OutputDir;
|
||||
outDir.Replace(L"*", GetCorrectFsPath(arc.DefaultName));
|
||||
FString outDir = options.OutputDir;
|
||||
outDir.Replace(FSTRING_ANY_MASK, us2fs(GetCorrectFsPath(arc.DefaultName)));
|
||||
#ifdef _WIN32
|
||||
// GetCorrectFullFsPath doesn't like "..".
|
||||
// outDir.TrimRight();
|
||||
@@ -66,7 +66,7 @@ static HRESULT DecompressArchive(
|
||||
HRESULT res = ::GetLastError();
|
||||
if (res == S_OK)
|
||||
res = E_FAIL;
|
||||
errorMessage = ((UString)L"Can not create output directory ") + outDir;
|
||||
errorMessage = ((UString)L"Can not create output directory ") + fs2us(outDir);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -118,11 +118,11 @@ HRESULT DecompressArchives(
|
||||
|
||||
for (i = 0; i < numArcs; i++)
|
||||
{
|
||||
NFile::NFind::CFileInfoW fi;
|
||||
NFile::NFind::CFileInfo fi;
|
||||
fi.Size = 0;
|
||||
if (!options.StdInMode)
|
||||
{
|
||||
const UString &arcPath = arcPaths[i];
|
||||
const FString &arcPath = us2fs(arcPaths[i]);
|
||||
if (!fi.Find(arcPath))
|
||||
throw "there is no such archive";
|
||||
if (fi.IsDir())
|
||||
@@ -142,7 +142,7 @@ HRESULT DecompressArchives(
|
||||
for (i = 0; i < numArcs; i++)
|
||||
{
|
||||
const UString &arcPath = arcPaths[i];
|
||||
NFile::NFind::CFileInfoW fi;
|
||||
NFile::NFind::CFileInfo fi;
|
||||
if (options.StdInMode)
|
||||
{
|
||||
fi.Size = 0;
|
||||
@@ -150,7 +150,7 @@ HRESULT DecompressArchives(
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fi.Find(arcPath) || fi.IsDir())
|
||||
if (!fi.Find(us2fs(arcPath)) || fi.IsDir())
|
||||
throw "there is no such archive";
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ struct CExtractOptions
|
||||
bool CalcCrc;
|
||||
NExtract::NPathMode::EEnum PathMode;
|
||||
NExtract::NOverwriteMode::EEnum OverwriteMode;
|
||||
UString OutputDir;
|
||||
FString OutputDir;
|
||||
|
||||
// bool ShowDialog;
|
||||
// bool PasswordEnabled;
|
||||
|
||||
@@ -20,8 +20,8 @@ static UString ReplaceIncorrectChars(const UString &s)
|
||||
res += c;
|
||||
}
|
||||
res.TrimRight();
|
||||
while (!res.IsEmpty() && res[res.Length() - 1] == '.')
|
||||
res.Delete(res.Length() - 1);
|
||||
while (!res.IsEmpty() && res.Back() == '.')
|
||||
res.DeleteBack();
|
||||
return res;
|
||||
#else
|
||||
return s;
|
||||
@@ -132,8 +132,8 @@ UString GetCorrectFullFsPath(const UString &path)
|
||||
{
|
||||
UString &s = parts[i];
|
||||
#ifdef _WIN32
|
||||
while (!s.IsEmpty() && s[s.Length() - 1] == '.')
|
||||
s.Delete(s.Length() - 1);
|
||||
while (!s.IsEmpty() && s.Back() == '.')
|
||||
s.DeleteBack();
|
||||
if (!IsSupportedName(s))
|
||||
s = (UString)L"_" + s;
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,7 @@ static const UINT kIconTypesResId = 100;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Registry.h"
|
||||
#endif
|
||||
|
||||
@@ -32,53 +33,52 @@ using namespace NFile;
|
||||
extern HINSTANCE g_hInstance;
|
||||
#endif
|
||||
|
||||
static CSysString GetLibraryFolderPrefix()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
TCHAR fullPath[MAX_PATH + 1];
|
||||
::GetModuleFileName(g_hInstance, fullPath, MAX_PATH);
|
||||
CSysString path = fullPath;
|
||||
int pos = path.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
|
||||
return path.Left(pos + 1);
|
||||
#else
|
||||
return CSysString(); // FIX IT
|
||||
#endif
|
||||
}
|
||||
|
||||
#define kCodecsFolderName TEXT("Codecs")
|
||||
#define kFormatsFolderName TEXT("Formats")
|
||||
static const TCHAR *kMainDll = TEXT("7z.dll");
|
||||
#define kCodecsFolderName FTEXT("Codecs")
|
||||
#define kFormatsFolderName FTEXT("Formats")
|
||||
static CFSTR kMainDll = FTEXT("7z.dll");
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
static LPCTSTR kRegistryPath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-zip");
|
||||
static LPCTSTR kProgramPathValue = TEXT("Path");
|
||||
static bool ReadPathFromRegistry(HKEY baseKey, CSysString &path)
|
||||
static LPCWSTR kProgramPathValue = L"Path";
|
||||
static LPCWSTR kProgramPath2Value = L"Path"
|
||||
#ifdef _WIN64
|
||||
L"64";
|
||||
#else
|
||||
L"32";
|
||||
#endif
|
||||
|
||||
static bool ReadPathFromRegistry(HKEY baseKey, LPCWSTR value, FString &path)
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if(key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
|
||||
if (key.QueryValue(kProgramPathValue, path) == ERROR_SUCCESS)
|
||||
if (key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
|
||||
{
|
||||
UString pathU;
|
||||
if (key.QueryValue(value, pathU) == ERROR_SUCCESS)
|
||||
{
|
||||
path = us2fs(pathU);
|
||||
NName::NormalizeDirPathPrefix(path);
|
||||
return true;
|
||||
return NFind::DoesFileExist(path + kMainDll);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
CSysString GetBaseFolderPrefixFromRegistry()
|
||||
static FString GetBaseFolderPrefixFromRegistry()
|
||||
{
|
||||
CSysString moduleFolderPrefix = GetLibraryFolderPrefix();
|
||||
FString moduleFolderPrefix = NDLL::GetModuleDirPrefix();
|
||||
#ifdef _WIN32
|
||||
if (!NFind::DoesFileExist(moduleFolderPrefix + kMainDll) &&
|
||||
!NFind::DoesDirExist(moduleFolderPrefix + kCodecsFolderName) &&
|
||||
!NFind::DoesDirExist(moduleFolderPrefix + kFormatsFolderName))
|
||||
{
|
||||
CSysString path;
|
||||
if (ReadPathFromRegistry(HKEY_CURRENT_USER, path))
|
||||
return path;
|
||||
if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
|
||||
return path;
|
||||
FString path;
|
||||
if (ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPath2Value, path)) return path;
|
||||
if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPath2Value, path)) return path;
|
||||
if (ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPathValue, path)) return path;
|
||||
if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPathValue, path)) return path;
|
||||
}
|
||||
#endif
|
||||
return moduleFolderPrefix;
|
||||
@@ -210,6 +210,14 @@ static void SplitString(const UString &srcString, UStringVector &destStrings)
|
||||
destStrings.Add(s);
|
||||
}
|
||||
|
||||
int CArcInfoEx::FindExtension(const UString &ext) const
|
||||
{
|
||||
for (int i = 0; i < Exts.Size(); i++)
|
||||
if (ext.CompareNoCase(Exts[i].Ext) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CArcInfoEx::AddExts(const wchar_t *ext, const wchar_t *addExt)
|
||||
{
|
||||
UStringVector exts, addExts;
|
||||
@@ -344,7 +352,7 @@ extern "C"
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT CCodecs::LoadDll(const CSysString &dllPath, bool needCheckDll)
|
||||
HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll)
|
||||
{
|
||||
if (needCheckDll)
|
||||
{
|
||||
@@ -393,9 +401,9 @@ HRESULT CCodecs::LoadDll(const CSysString &dllPath, bool needCheckDll)
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT CCodecs::LoadDllsFromFolder(const CSysString &folderPrefix)
|
||||
HRESULT CCodecs::LoadDllsFromFolder(const FString &folderPrefix)
|
||||
{
|
||||
NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*")));
|
||||
NFile::NFind::CEnumerator enumerator(folderPrefix + FCHAR_ANY_MASK);
|
||||
NFile::NFind::CFileInfo fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
@@ -443,10 +451,10 @@ HRESULT CCodecs::Load()
|
||||
Formats.Add(item);
|
||||
}
|
||||
#ifdef EXTERNAL_CODECS
|
||||
const CSysString baseFolder = GetBaseFolderPrefixFromRegistry();
|
||||
const FString baseFolder = GetBaseFolderPrefixFromRegistry();
|
||||
RINOK(LoadDll(baseFolder + kMainDll, false));
|
||||
RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName TEXT(STRING_PATH_SEPARATOR)));
|
||||
RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName TEXT(STRING_PATH_SEPARATOR)));
|
||||
RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName FSTRING_PATH_SEPARATOR));
|
||||
RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName FSTRING_PATH_SEPARATOR));
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
@@ -455,12 +463,11 @@ HRESULT CCodecs::Load()
|
||||
|
||||
int CCodecs::FindFormatForArchiveName(const UString &arcPath) const
|
||||
{
|
||||
int slashPos1 = arcPath.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
int slashPos2 = arcPath.ReverseFind(L'.');
|
||||
int slashPos = arcPath.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
int dotPos = arcPath.ReverseFind(L'.');
|
||||
if (dotPos < 0 || dotPos < slashPos1 || dotPos < slashPos2)
|
||||
if (dotPos < 0 || dotPos < slashPos)
|
||||
return -1;
|
||||
UString ext = arcPath.Mid(dotPos + 1);
|
||||
const UString ext = arcPath.Mid(dotPos + 1);
|
||||
for (int i = 0; i < Formats.Size(); i++)
|
||||
{
|
||||
const CArcInfoEx &arc = Formats[i];
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// LoadCodecs.h
|
||||
|
||||
#ifndef __LOADCODECS_H
|
||||
#define __LOADCODECS_H
|
||||
#ifndef __LOAD_CODECS_H
|
||||
#define __LOAD_CODECS_H
|
||||
|
||||
#include "../../../Common/Types.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../../Common/MyString.h"
|
||||
#include "../../../Common/Buffer.h"
|
||||
@@ -58,19 +57,16 @@ struct CArcInfoEx
|
||||
#endif
|
||||
#endif
|
||||
bool KeepName;
|
||||
|
||||
UString GetMainExt() const
|
||||
{
|
||||
if (Exts.IsEmpty())
|
||||
return UString();
|
||||
return Exts[0].Ext;
|
||||
}
|
||||
int FindExtension(const UString &ext) const
|
||||
{
|
||||
for (int i = 0; i < Exts.Size(); i++)
|
||||
if (ext.CompareNoCase(Exts[i].Ext) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
int FindExtension(const UString &ext) const;
|
||||
|
||||
/*
|
||||
UString GetAllExtensions() const
|
||||
{
|
||||
UString s;
|
||||
@@ -82,6 +78,7 @@ struct CArcInfoEx
|
||||
}
|
||||
return s;
|
||||
}
|
||||
*/
|
||||
|
||||
void AddExts(const wchar_t* ext, const wchar_t* addExt);
|
||||
|
||||
@@ -125,7 +122,7 @@ struct CCodecLib
|
||||
GetMethodPropertyFunc GetMethodProperty;
|
||||
CreateObjectFunc CreateObject;
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
CSysString Path;
|
||||
FString Path;
|
||||
void LoadIcons() { CCodecIcons::LoadIcons((HMODULE)Lib); }
|
||||
#endif
|
||||
CCodecLib(): GetMethodProperty(0) {}
|
||||
@@ -151,8 +148,8 @@ public:
|
||||
|
||||
HRESULT LoadCodecs();
|
||||
HRESULT LoadFormats();
|
||||
HRESULT LoadDll(const CSysString &path, bool needCheckDll);
|
||||
HRESULT LoadDllsFromFolder(const CSysString &folderPrefix);
|
||||
HRESULT LoadDll(const FString &path, bool needCheckDll);
|
||||
HRESULT LoadDllsFromFolder(const FString &folderPrefix);
|
||||
|
||||
HRESULT CreateArchiveHandler(const CArcInfoEx &ai, void **archive, bool outHandler) const
|
||||
{
|
||||
|
||||
@@ -63,6 +63,25 @@ HRESULT CArc::GetItemPath(UInt32 index, UString &result) const
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CArc::GetItemSize(UInt32 index, UInt64 &size, bool &defined) const
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
defined = false;
|
||||
size = 0;
|
||||
RINOK(Archive->GetProperty(index, kpidSize, &prop));
|
||||
switch (prop.vt)
|
||||
{
|
||||
case VT_UI1: size = prop.bVal; break;
|
||||
case VT_UI2: size = prop.uiVal; break;
|
||||
case VT_UI4: size = prop.ulVal; break;
|
||||
case VT_UI8: size = (UInt64)prop.uhVal.QuadPart; break;
|
||||
case VT_EMPTY: return S_OK;
|
||||
default: return E_FAIL;
|
||||
}
|
||||
defined = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CArc::GetItemMTime(UInt32 index, FILETIME &ft, bool &defined) const
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
@@ -339,7 +358,7 @@ HRESULT CArc::OpenStreamOrFile(
|
||||
{
|
||||
CInFileStream *fileStreamSpec = new CInFileStream;
|
||||
fileStream = fileStreamSpec;
|
||||
if (!fileStreamSpec->Open(Path))
|
||||
if (!fileStreamSpec->Open(us2fs(Path)))
|
||||
return GetLastError();
|
||||
stream = fileStream;
|
||||
}
|
||||
@@ -461,7 +480,7 @@ HRESULT CArchiveLink::Open(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void SetCallback(const UString &filePath,
|
||||
static void SetCallback(const FString &filePath,
|
||||
IOpenCallbackUI *callbackUI,
|
||||
IArchiveOpenCallback *reOpenCallback,
|
||||
CMyComPtr<IArchiveOpenCallback> &callback)
|
||||
@@ -471,12 +490,9 @@ static void SetCallback(const UString &filePath,
|
||||
openCallbackSpec->Callback = callbackUI;
|
||||
openCallbackSpec->ReOpenCallback = reOpenCallback;
|
||||
|
||||
UString fullName;
|
||||
int fileNamePartStartIndex;
|
||||
NFile::NDirectory::MyGetFullPathName(filePath, fullName, fileNamePartStartIndex);
|
||||
openCallbackSpec->Init(
|
||||
fullName.Left(fileNamePartStartIndex),
|
||||
fullName.Mid(fileNamePartStartIndex));
|
||||
FString dirPrefix, fileName;
|
||||
NFile::NDirectory::GetFullPathAndSplit(filePath, dirPrefix, fileName);
|
||||
openCallbackSpec->Init(dirPrefix, fileName);
|
||||
}
|
||||
|
||||
HRESULT CArchiveLink::Open2(CCodecs *codecs,
|
||||
@@ -491,14 +507,10 @@ HRESULT CArchiveLink::Open2(CCodecs *codecs,
|
||||
CMyComPtr<IArchiveOpenCallback> callback = openCallbackSpec;
|
||||
openCallbackSpec->Callback = callbackUI;
|
||||
|
||||
UString fullName, prefix, name;
|
||||
FString prefix, name;
|
||||
if (!stream && !stdInMode)
|
||||
{
|
||||
int fileNamePartStartIndex;
|
||||
if (!NFile::NDirectory::MyGetFullPathName(filePath, fullName, fileNamePartStartIndex))
|
||||
return GetLastError();
|
||||
prefix = fullName.Left(fileNamePartStartIndex);
|
||||
name = fullName.Mid(fileNamePartStartIndex);
|
||||
NFile::NDirectory::GetFullPathAndSplit(us2fs(filePath), prefix, name);
|
||||
openCallbackSpec->Init(prefix, name);
|
||||
}
|
||||
else
|
||||
@@ -507,9 +519,9 @@ HRESULT CArchiveLink::Open2(CCodecs *codecs,
|
||||
}
|
||||
|
||||
RINOK(Open(codecs, formatIndices, stdInMode, stream, filePath, callback));
|
||||
VolumePaths.Add(prefix + name);
|
||||
VolumePaths.Add(fs2us(prefix + name));
|
||||
for (int i = 0; i < openCallbackSpec->FileNames.Size(); i++)
|
||||
VolumePaths.Add(prefix + openCallbackSpec->FileNames[i]);
|
||||
VolumePaths.Add(fs2us(prefix) + openCallbackSpec->FileNames[i]);
|
||||
VolumesSize = openCallbackSpec->TotalSize;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -524,11 +536,11 @@ HRESULT CArchiveLink::ReOpen(CCodecs *codecs, const UString &filePath,
|
||||
return Open2(codecs, CIntVector(), false, NULL, filePath, 0);
|
||||
|
||||
CMyComPtr<IArchiveOpenCallback> openCallbackNew;
|
||||
SetCallback(filePath, NULL, callback, openCallbackNew);
|
||||
SetCallback(us2fs(filePath), NULL, callback, openCallbackNew);
|
||||
|
||||
CInFileStream *fileStreamSpec = new CInFileStream;
|
||||
CMyComPtr<IInStream> stream(fileStreamSpec);
|
||||
if (!fileStreamSpec->Open(filePath))
|
||||
if (!fileStreamSpec->Open(us2fs(filePath)))
|
||||
return GetLastError();
|
||||
HRESULT res = GetArchive()->Open(stream, &kMaxCheckStartPosition, callback);
|
||||
IsOpen = (res == S_OK);
|
||||
|
||||
@@ -29,6 +29,7 @@ struct CArc
|
||||
CArc(): MTimeDefined(false) {}
|
||||
|
||||
HRESULT GetItemPath(UInt32 index, UString &result) const;
|
||||
HRESULT GetItemSize(UInt32 index, UInt64 &size, bool &defined) const;
|
||||
HRESULT GetItemMTime(UInt32 index, FILETIME &ft, bool &defined) const;
|
||||
HRESULT IsItemAnti(UInt32 index, bool &result) const
|
||||
{ return GetArchiveItemBoolProp(Archive, index, kpidIsAnti, result); }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Property.h
|
||||
|
||||
#ifndef __PROPERTY_H
|
||||
#define __PROPERTY_H
|
||||
#ifndef __7Z_PROPERTY_H
|
||||
#define __7Z_PROPERTY_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
struct CProperty
|
||||
{
|
||||
|
||||
@@ -49,13 +49,13 @@ HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &propert
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
{
|
||||
wchar_t c = name[name.Length() - 1];
|
||||
wchar_t c = name.Back();
|
||||
if (c == L'-')
|
||||
propVariant = false;
|
||||
else if (c == L'+')
|
||||
propVariant = true;
|
||||
if (propVariant.vt != VT_EMPTY)
|
||||
name = name.Left(name.Length() - 1);
|
||||
name.DeleteBack();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -5,16 +5,15 @@
|
||||
#include "TempFiles.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileIO.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
|
||||
void CTempFiles::Clear()
|
||||
{
|
||||
while(!Paths.IsEmpty())
|
||||
while (!Paths.IsEmpty())
|
||||
{
|
||||
NDirectory::DeleteFileAlways((LPCWSTR)Paths.Back());
|
||||
NDirectory::DeleteFileAlways(Paths.Back());
|
||||
Paths.DeleteBack();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// TempFiles.h
|
||||
|
||||
#ifndef __TEMPFILES_H
|
||||
#define __TEMPFILES_H
|
||||
#ifndef __TEMP_FILES_H
|
||||
#define __TEMP_FILES_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
|
||||
@@ -9,7 +9,7 @@ class CTempFiles
|
||||
{
|
||||
void Clear();
|
||||
public:
|
||||
UStringVector Paths;
|
||||
FStringVector Paths;
|
||||
~CTempFiles() { Clear(); }
|
||||
};
|
||||
|
||||
|
||||
@@ -7,10 +7,7 @@
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Windows/DLL.h"
|
||||
#endif
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileName.h"
|
||||
@@ -40,7 +37,7 @@ using namespace NCOM;
|
||||
using namespace NFile;
|
||||
using namespace NName;
|
||||
|
||||
static const wchar_t *kTempFolderPrefix = L"7zE";
|
||||
static CFSTR kTempFolderPrefix = FTEXT("7zE");
|
||||
|
||||
using namespace NUpdateArchive;
|
||||
|
||||
@@ -57,7 +54,7 @@ class COutMultiVolStream:
|
||||
{
|
||||
COutFileStream *StreamSpec;
|
||||
CMyComPtr<IOutStream> Stream;
|
||||
UString Name;
|
||||
FString Name;
|
||||
UInt64 Pos;
|
||||
UInt64 RealSize;
|
||||
};
|
||||
@@ -65,7 +62,7 @@ class COutMultiVolStream:
|
||||
public:
|
||||
// CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
|
||||
CRecordVector<UInt64> Sizes;
|
||||
UString Prefix;
|
||||
FString Prefix;
|
||||
CTempFiles *TempFiles;
|
||||
|
||||
void Init()
|
||||
@@ -107,18 +104,18 @@ STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *pr
|
||||
{
|
||||
if (processedSize != NULL)
|
||||
*processedSize = 0;
|
||||
while(size > 0)
|
||||
while (size > 0)
|
||||
{
|
||||
if (_streamIndex >= Streams.Size())
|
||||
{
|
||||
CSubStreamInfo subStream;
|
||||
|
||||
wchar_t temp[16];
|
||||
FChar temp[16];
|
||||
ConvertUInt32ToString(_streamIndex + 1, temp);
|
||||
UString res = temp;
|
||||
FString res = temp;
|
||||
while (res.Length() < 3)
|
||||
res = UString(L'0') + res;
|
||||
UString name = Prefix + res;
|
||||
res = FString(FTEXT('0')) + res;
|
||||
FString name = Prefix + res;
|
||||
subStream.StreamSpec = new COutFileStream;
|
||||
subStream.Stream = subStream.StreamSpec;
|
||||
if (!subStream.StreamSpec->Create(name, false))
|
||||
@@ -311,7 +308,7 @@ static HRESULT Compress(
|
||||
bool stdOutMode,
|
||||
const CDirItems &dirItems,
|
||||
bool sfxMode,
|
||||
const UString &sfxModule,
|
||||
const FString &sfxModule,
|
||||
const CRecordVector<UInt64> &volumesSizes,
|
||||
CTempFiles &tempFiles,
|
||||
CUpdateErrorInfo &errorInfo,
|
||||
@@ -389,11 +386,10 @@ static HRESULT Compress(
|
||||
|
||||
if (!stdOutMode)
|
||||
{
|
||||
UString resultPath;
|
||||
int pos;
|
||||
if (!NFile::NDirectory::MyGetFullPathName(archivePath.GetFinalPath(), resultPath, pos))
|
||||
FString dirPrefix;
|
||||
if (!NFile::NDirectory::GetOnlyDirPrefix(us2fs(archivePath.GetFinalPath()), dirPrefix))
|
||||
throw 1417161;
|
||||
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
|
||||
NFile::NDirectory::CreateComplexDirectory(dirPrefix);
|
||||
}
|
||||
|
||||
COutFileStream *outStreamSpec = NULL;
|
||||
@@ -408,21 +404,21 @@ static HRESULT Compress(
|
||||
outStreamSpec = new COutFileStream;
|
||||
outStream = outStreamSpec;
|
||||
bool isOK = false;
|
||||
UString realPath;
|
||||
FString realPath;
|
||||
for (int i = 0; i < (1 << 16); i++)
|
||||
{
|
||||
if (archivePath.Temp)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
wchar_t s[16];
|
||||
FChar s[16];
|
||||
ConvertUInt32ToString(i, s);
|
||||
archivePath.TempPostfix = s;
|
||||
}
|
||||
realPath = archivePath.GetTempPath();
|
||||
}
|
||||
else
|
||||
realPath = archivePath.GetFinalPath();
|
||||
realPath = us2fs(archivePath.GetFinalPath());
|
||||
if (outStreamSpec->Create(realPath, false))
|
||||
{
|
||||
tempFiles.Paths.Add(realPath);
|
||||
@@ -450,7 +446,7 @@ static HRESULT Compress(
|
||||
volStreamSpec = new COutMultiVolStream;
|
||||
outStream = volStreamSpec;
|
||||
volStreamSpec->Sizes = volumesSizes;
|
||||
volStreamSpec->Prefix = archivePath.GetFinalPath() + UString(L".");
|
||||
volStreamSpec->Prefix = us2fs(archivePath.GetFinalPath() + L".");
|
||||
volStreamSpec->TempFiles = &tempFiles;
|
||||
volStreamSpec->Init();
|
||||
|
||||
@@ -484,7 +480,7 @@ static HRESULT Compress(
|
||||
{
|
||||
outStreamSpec = new COutFileStream;
|
||||
sfxOutStream = outStreamSpec;
|
||||
UString realPath = archivePath.GetFinalPath();
|
||||
FString realPath = us2fs(archivePath.GetFinalPath());
|
||||
if (!outStreamSpec->Create(realPath, false))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
@@ -527,14 +523,7 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
|
||||
RINOK(IsArchiveItemFolder(archive, i, ai.IsDir));
|
||||
ai.Censored = censor.CheckPath(ai.Name, !ai.IsDir);
|
||||
RINOK(arc.GetItemMTime(i, ai.MTime, ai.MTimeDefined));
|
||||
|
||||
{
|
||||
CPropVariant prop;
|
||||
RINOK(archive->GetProperty(i, kpidSize, &prop));
|
||||
ai.SizeDefined = (prop.vt != VT_EMPTY);
|
||||
if (ai.SizeDefined)
|
||||
ai.Size = ConvertPropVariantToUInt64(prop);
|
||||
}
|
||||
RINOK(arc.GetItemSize(i, ai.Size, ai.SizeDefined));
|
||||
|
||||
{
|
||||
CPropVariant prop;
|
||||
@@ -608,11 +597,11 @@ static HRESULT UpdateWithItemLists(
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
class CCurrentDirRestorer
|
||||
{
|
||||
UString _path;
|
||||
FString _path;
|
||||
public:
|
||||
CCurrentDirRestorer() { NFile::NDirectory::MyGetCurrentDirectory(_path); }
|
||||
~CCurrentDirRestorer() { RestoreDirectory();}
|
||||
bool RestoreDirectory() { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(_path)); }
|
||||
bool RestoreDirectory() const { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(_path)); }
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -661,17 +650,25 @@ HRESULT UpdateArchive(
|
||||
errorInfo.Message = L"SFX file is not specified";
|
||||
return E_FAIL;
|
||||
}
|
||||
UString name = options.SfxModule;
|
||||
#ifdef UNDER_CE
|
||||
if (!NFind::DoesFileExist(name))
|
||||
#else
|
||||
if (!NDirectory::MySearchPath(NULL, name, NULL, options.SfxModule))
|
||||
#endif
|
||||
bool found = false;
|
||||
if (options.SfxModule.Find(FCHAR_PATH_SEPARATOR) < 0)
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"7-Zip cannot find specified SFX module";
|
||||
errorInfo.FileName = name;
|
||||
return E_FAIL;
|
||||
const FString fullName = NDLL::GetModuleDirPrefix() + options.SfxModule;
|
||||
if (NFind::DoesFileExist(fullName))
|
||||
{
|
||||
options.SfxModule = fullName;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
if (!NFind::DoesFileExist(options.SfxModule))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"7-Zip cannot find specified SFX module";
|
||||
errorInfo.FileName = options.SfxModule;
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,8 +678,8 @@ HRESULT UpdateArchive(
|
||||
|
||||
if (!options.ArchivePath.OriginalPath.IsEmpty())
|
||||
{
|
||||
NFind::CFileInfoW fi;
|
||||
if (fi.Find(arcPath))
|
||||
NFind::CFileInfo fi;
|
||||
if (fi.Find(us2fs(arcPath)))
|
||||
{
|
||||
if (fi.IsDir())
|
||||
throw "there is no such archive";
|
||||
@@ -738,12 +735,12 @@ HRESULT UpdateArchive(
|
||||
CEnumDirItemUpdateCallback enumCallback;
|
||||
enumCallback.Callback = callback;
|
||||
RINOK(callback->StartScanning());
|
||||
UStringVector errorPaths;
|
||||
FStringVector errorPaths;
|
||||
CRecordVector<DWORD> errorCodes;
|
||||
HRESULT res = EnumerateItems(censor, dirItems, &enumCallback, errorPaths, errorCodes);
|
||||
for (int i = 0; i < errorPaths.Size(); i++)
|
||||
{
|
||||
RINOK(callback->CanNotFindError(errorPaths[i], errorCodes[i]));
|
||||
RINOK(callback->CanNotFindError(fs2us(errorPaths[i]), errorCodes[i]));
|
||||
}
|
||||
if (res != S_OK)
|
||||
{
|
||||
@@ -755,11 +752,11 @@ HRESULT UpdateArchive(
|
||||
}
|
||||
}
|
||||
|
||||
UString tempDirPrefix;
|
||||
FString tempDirPrefix;
|
||||
bool usesTempDir = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
NDirectory::CTempDirectoryW tempDirectory;
|
||||
NDirectory::CTempDir tempDirectory;
|
||||
if (options.EMailMode && options.EMailRemoveAfter)
|
||||
{
|
||||
tempDirectory.Create(kTempFolderPrefix);
|
||||
@@ -792,20 +789,20 @@ HRESULT UpdateArchive(
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < options.Commands.Size(); i++)
|
||||
for (int i = 0; i < options.Commands.Size(); i++)
|
||||
{
|
||||
CArchivePath &ap = options.Commands[i].ArchivePath;
|
||||
if (usesTempDir)
|
||||
{
|
||||
// Check it
|
||||
ap.Prefix = tempDirPrefix;
|
||||
ap.Prefix = fs2us(tempDirPrefix);
|
||||
// ap.Temp = true;
|
||||
// ap.TempPrefix = tempDirPrefix;
|
||||
}
|
||||
if (!options.StdOutMode &&
|
||||
(i > 0 || !createTempFile))
|
||||
{
|
||||
const UString &path = ap.GetFinalPath();
|
||||
const FString path = us2fs(ap.GetFinalPath());
|
||||
if (NFind::DoesFileOrDirExist(path))
|
||||
{
|
||||
errorInfo.SystemError = 0;
|
||||
@@ -839,21 +836,21 @@ HRESULT UpdateArchive(
|
||||
try
|
||||
{
|
||||
CArchivePath &ap = options.Commands[0].ArchivePath;
|
||||
const UString &tempPath = ap.GetTempPath();
|
||||
const FString &tempPath = ap.GetTempPath();
|
||||
if (thereIsInArchive)
|
||||
if (!NDirectory::DeleteFileAlways(arcPath))
|
||||
if (!NDirectory::DeleteFileAlways(us2fs(arcPath)))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"7-Zip cannot delete the file";
|
||||
errorInfo.FileName = arcPath;
|
||||
errorInfo.FileName = us2fs(arcPath);
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!NDirectory::MyMoveFile(tempPath, arcPath))
|
||||
if (!NDirectory::MyMoveFile(tempPath, us2fs(arcPath)))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"7-Zip cannot move the file";
|
||||
errorInfo.FileName = tempPath;
|
||||
errorInfo.FileName2 = arcPath;
|
||||
errorInfo.FileName2 = us2fs(arcPath);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
@@ -867,7 +864,7 @@ HRESULT UpdateArchive(
|
||||
if (options.EMailMode)
|
||||
{
|
||||
NDLL::CLibrary mapiLib;
|
||||
if (!mapiLib.Load(TEXT("Mapi32.dll")))
|
||||
if (!mapiLib.Load(FTEXT("Mapi32.dll")))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"7-Zip cannot load Mapi32.dll";
|
||||
@@ -880,13 +877,13 @@ HRESULT UpdateArchive(
|
||||
errorInfo.Message = L"7-Zip cannot find MAPISendDocuments function";
|
||||
return E_FAIL;
|
||||
}
|
||||
UStringVector fullPaths;
|
||||
FStringVector fullPaths;
|
||||
int i;
|
||||
for(i = 0; i < options.Commands.Size(); i++)
|
||||
for (i = 0; i < options.Commands.Size(); i++)
|
||||
{
|
||||
CArchivePath &ap = options.Commands[i].ArchivePath;
|
||||
UString arcPath;
|
||||
if (!NFile::NDirectory::MyGetFullPathName(ap.GetFinalPath(), arcPath))
|
||||
FString arcPath;
|
||||
if (!NFile::NDirectory::MyGetFullPathName(us2fs(ap.GetFinalPath()), arcPath))
|
||||
{
|
||||
errorInfo.SystemError = ::GetLastError();
|
||||
errorInfo.Message = L"GetFullPathName error";
|
||||
@@ -895,9 +892,9 @@ HRESULT UpdateArchive(
|
||||
fullPaths.Add(arcPath);
|
||||
}
|
||||
CCurrentDirRestorer curDirRestorer;
|
||||
for(i = 0; i < fullPaths.Size(); i++)
|
||||
for (i = 0; i < fullPaths.Size(); i++)
|
||||
{
|
||||
UString arcPath = fullPaths[i];
|
||||
UString arcPath = fs2us(fullPaths[i]);
|
||||
UString fileName = ExtractFileNameFromPath(arcPath);
|
||||
AString path = GetAnsiString(arcPath);
|
||||
AString name = GetAnsiString(fileName);
|
||||
|
||||
@@ -21,8 +21,8 @@ struct CArchivePath
|
||||
UString VolExtension; // archive type extension for volumes
|
||||
|
||||
bool Temp;
|
||||
UString TempPrefix; // path(folder) for temp location
|
||||
UString TempPostfix;
|
||||
FString TempPrefix; // path(folder) for temp location
|
||||
FString TempPostfix;
|
||||
|
||||
CArchivePath(): Temp(false) {};
|
||||
|
||||
@@ -63,12 +63,12 @@ struct CArchivePath
|
||||
}
|
||||
|
||||
|
||||
UString GetTempPath() const
|
||||
FString GetTempPath() const
|
||||
{
|
||||
UString path = TempPrefix + Name;
|
||||
FString path = TempPrefix + us2fs(Name);
|
||||
if (!BaseExtension.IsEmpty())
|
||||
path += UString(L'.') + BaseExtension;
|
||||
path += L".tmp";
|
||||
path += FString(FTEXT('.')) + us2fs(BaseExtension);
|
||||
path += FTEXT(".tmp");
|
||||
path += TempPostfix;
|
||||
return path;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ struct CUpdateOptions
|
||||
CArchivePath ArchivePath;
|
||||
|
||||
bool SfxMode;
|
||||
UString SfxModule;
|
||||
FString SfxModule;
|
||||
|
||||
bool OpenShareForWrite;
|
||||
|
||||
@@ -109,7 +109,7 @@ struct CUpdateOptions
|
||||
bool EMailRemoveAfter;
|
||||
UString EMailAddress;
|
||||
|
||||
UString WorkingDir;
|
||||
FString WorkingDir;
|
||||
|
||||
bool Init(const CCodecs *codecs, const CIntVector &formatIndices, const UString &arcPath);
|
||||
|
||||
@@ -137,8 +137,8 @@ struct CUpdateOptions
|
||||
struct CErrorInfo
|
||||
{
|
||||
DWORD SystemError;
|
||||
UString FileName;
|
||||
UString FileName2;
|
||||
FString FileName;
|
||||
FString FileName2;
|
||||
UString Message;
|
||||
// UStringVector ErrorPaths;
|
||||
// CRecordVector<DWORD> ErrorCodes;
|
||||
|
||||
@@ -22,7 +22,8 @@ CArchiveUpdateCallback::CArchiveUpdateCallback():
|
||||
DirItems(0),
|
||||
ArcItems(0),
|
||||
UpdatePairs(0),
|
||||
NewNames(0)
|
||||
NewNames(0),
|
||||
KeepOriginalItemNames(0)
|
||||
{}
|
||||
|
||||
|
||||
@@ -120,7 +121,22 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR
|
||||
const CDirItem &di = DirItems->Items[up.DirIndex];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath: prop = DirItems->GetLogPath(up.DirIndex); break;
|
||||
case kpidPath:
|
||||
{
|
||||
if (KeepOriginalItemNames)
|
||||
{
|
||||
if (up.ExistInArchive() && Archive)
|
||||
{
|
||||
UInt32 indexInArchive;
|
||||
if (ArcItems == 0)
|
||||
indexInArchive = up.ArcIndex;
|
||||
else
|
||||
indexInArchive = (*ArcItems)[up.ArcIndex].IndexInServer;
|
||||
return Archive->GetProperty(indexInArchive, propID, value);
|
||||
}
|
||||
}
|
||||
prop = DirItems->GetLogPath(up.DirIndex); break;
|
||||
}
|
||||
case kpidIsDir: prop = di.IsDir(); break;
|
||||
case kpidSize: prop = di.Size; break;
|
||||
case kpidAttrib: prop = di.Attrib; break;
|
||||
@@ -186,7 +202,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
|
||||
CInFileStream *inStreamSpec = new CInFileStream;
|
||||
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
|
||||
const UString path = DirItems->GetPhyPath(up.DirIndex);
|
||||
if (!inStreamSpec->OpenShared(path, ShareForWrite))
|
||||
if (!inStreamSpec->OpenShared(us2fs(path), ShareForWrite))
|
||||
{
|
||||
return Callback->OpenFileError(path, ::GetLastError());
|
||||
}
|
||||
@@ -216,12 +232,12 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size)
|
||||
STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
wchar_t temp[16];
|
||||
FChar temp[16];
|
||||
ConvertUInt32ToString(index + 1, temp);
|
||||
UString res = temp;
|
||||
FString res = temp;
|
||||
while (res.Length() < 2)
|
||||
res = UString(L'0') + res;
|
||||
UString fileName = VolName;
|
||||
res = FString(FTEXT('0')) + res;
|
||||
FString fileName = VolName;
|
||||
fileName += L'.';
|
||||
fileName += res;
|
||||
fileName += VolExt;
|
||||
|
||||
@@ -55,8 +55,8 @@ public:
|
||||
|
||||
public:
|
||||
CRecordVector<UInt64> VolumesSizes;
|
||||
UString VolName;
|
||||
UString VolExt;
|
||||
FString VolName;
|
||||
FString VolExt;
|
||||
|
||||
IUpdateCallbackUI *Callback;
|
||||
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
const CRecordVector<CUpdatePair2> *UpdatePairs;
|
||||
const UStringVector *NewNames;
|
||||
CMyComPtr<IInArchive> Archive;
|
||||
bool KeepOriginalItemNames;
|
||||
|
||||
CArchiveUpdateCallback();
|
||||
};
|
||||
|
||||
@@ -5,23 +5,23 @@
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Wildcard.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
|
||||
#include "WorkDir.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDirectory;
|
||||
|
||||
UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
|
||||
FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FString &fileName)
|
||||
{
|
||||
NWorkDir::NMode::EEnum mode = workDirInfo.Mode;
|
||||
#ifndef UNDER_CE
|
||||
if (workDirInfo.ForRemovableOnly)
|
||||
{
|
||||
mode = NWorkDir::NMode::kCurrent;
|
||||
UString prefix = path.Left(3);
|
||||
if (prefix[1] == L':' && prefix[2] == L'\\')
|
||||
FString prefix = path.Left(3);
|
||||
if (prefix[1] == FTEXT(':') && prefix[2] == FTEXT('\\'))
|
||||
{
|
||||
UINT driveType = GetDriveType(GetSystemString(prefix, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP));
|
||||
if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE)
|
||||
@@ -36,24 +36,56 @@ UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
switch(mode)
|
||||
int pos = path.ReverseFind(FCHAR_PATH_SEPARATOR) + 1;
|
||||
fileName = path.Mid(pos);
|
||||
switch (mode)
|
||||
{
|
||||
case NWorkDir::NMode::kCurrent:
|
||||
{
|
||||
return ExtractDirPrefixFromPath(path);
|
||||
return path.Left(pos);;
|
||||
}
|
||||
case NWorkDir::NMode::kSpecified:
|
||||
{
|
||||
UString tempDir = workDirInfo.Path;
|
||||
FString tempDir = workDirInfo.Path;
|
||||
NName::NormalizeDirPathPrefix(tempDir);
|
||||
return tempDir;
|
||||
}
|
||||
default:
|
||||
{
|
||||
UString tempDir;
|
||||
if (!NDirectory::MyGetTempPath(tempDir))
|
||||
FString tempDir;
|
||||
if (!MyGetTempPath(tempDir))
|
||||
throw 141717;
|
||||
return tempDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CWorkDirTempFile::CreateTempFile(const FString &originalPath)
|
||||
{
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
workDirInfo.Load();
|
||||
FString namePart;
|
||||
FString workDir = GetWorkDir(workDirInfo, originalPath, namePart);
|
||||
CreateComplexDirectory(workDir);
|
||||
CTempFile tempFile;
|
||||
_outStreamSpec = new COutFileStream;
|
||||
OutStream = _outStreamSpec;
|
||||
if (!_tempFile.Create(workDir + namePart, &_outStreamSpec->File))
|
||||
{
|
||||
DWORD error = GetLastError();
|
||||
return error ? error : E_FAIL;
|
||||
}
|
||||
_originalPath = originalPath;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CWorkDirTempFile::MoveToOriginal(bool deleteOriginal)
|
||||
{
|
||||
OutStream.Release();
|
||||
if (!_tempFile.MoveTo(_originalPath, deleteOriginal))
|
||||
{
|
||||
DWORD error = GetLastError();
|
||||
return error ? error : E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
// WorkDir.h
|
||||
|
||||
#ifndef __WORKDIR_H
|
||||
#define __WORKDIR_H
|
||||
#ifndef __WORK_DIR_H
|
||||
#define __WORK_DIR_H
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "ZipRegistry.h"
|
||||
|
||||
UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path);
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FString &fileName);
|
||||
|
||||
class CWorkDirTempFile
|
||||
{
|
||||
FString _originalPath;
|
||||
NWindows::NFile::NDirectory::CTempFile _tempFile;
|
||||
COutFileStream *_outStreamSpec;
|
||||
public:
|
||||
CMyComPtr<IOutStream> OutStream;
|
||||
|
||||
HRESULT CreateTempFile(const FString &originalPath);
|
||||
HRESULT MoveToOriginal(bool deleteOriginal);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Registry.h"
|
||||
@@ -53,6 +52,13 @@ void CInfo::Save() const
|
||||
key.SetValue_Strings(kPathHistory, Paths);
|
||||
}
|
||||
|
||||
void Save_ShowPassword(bool showPassword)
|
||||
{
|
||||
CS_LOCK
|
||||
CKey key;
|
||||
CreateMainKey(key, kKeyName);
|
||||
key.SetValue(kShowPassword, showPassword);
|
||||
}
|
||||
|
||||
void CInfo::Load()
|
||||
{
|
||||
@@ -75,6 +81,17 @@ void CInfo::Load()
|
||||
key.GetValue_IfOk(kShowPassword, ShowPassword);
|
||||
}
|
||||
|
||||
bool Read_ShowPassword()
|
||||
{
|
||||
CS_LOCK
|
||||
CKey key;
|
||||
bool showPassword = false;
|
||||
if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS)
|
||||
return showPassword;
|
||||
key.GetValue_IfOk(kShowPassword, showPassword);
|
||||
return showPassword;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace NCompression
|
||||
@@ -234,7 +251,7 @@ void CInfo::Save()const
|
||||
CKey key;
|
||||
CreateMainKey(key, kOptionsInfoKeyName);
|
||||
key.SetValue(kWorkDirType, (UInt32)Mode);
|
||||
key.SetValue(kWorkDirPath, Path);
|
||||
key.SetValue(kWorkDirPath, fs2us(Path));
|
||||
key.SetValue(kTempRemovableOnly, ForRemovableOnly);
|
||||
}
|
||||
|
||||
@@ -257,7 +274,10 @@ void CInfo::Load()
|
||||
case NMode::kSpecified:
|
||||
Mode = (NMode::EEnum)dirType;
|
||||
}
|
||||
if (key.QueryValue(kWorkDirPath, Path) != ERROR_SUCCESS)
|
||||
UString pathU;
|
||||
if (key.QueryValue(kWorkDirPath, pathU) == ERROR_SUCCESS)
|
||||
Path = us2fs(pathU);
|
||||
else
|
||||
{
|
||||
Path.Empty();
|
||||
if (Mode == NMode::kSpecified)
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace NExtract
|
||||
void Save() const;
|
||||
void Load();
|
||||
};
|
||||
void Save_ShowPassword(bool showPassword);
|
||||
bool Read_ShowPassword();
|
||||
}
|
||||
|
||||
namespace NCompression
|
||||
@@ -76,7 +78,7 @@ namespace NWorkDir
|
||||
struct CInfo
|
||||
{
|
||||
NMode::EEnum Mode;
|
||||
UString Path;
|
||||
FString Path;
|
||||
bool ForRemovableOnly;
|
||||
|
||||
void SetForRemovableOnlyDefault() { ForRemovableOnly = true; }
|
||||
|
||||
@@ -2,296 +2,41 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
#if !defined(_7ZIP_ST) || defined(_WIN32)
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
#include "../Common/Bench.h"
|
||||
|
||||
#include "BenchCon.h"
|
||||
#include "ConsoleClose.h"
|
||||
|
||||
struct CTotalBenchRes
|
||||
struct CPrintBenchCallback: public IBenchPrintCallback
|
||||
{
|
||||
UInt64 NumIterations;
|
||||
UInt64 Rating;
|
||||
UInt64 Usage;
|
||||
UInt64 RPU;
|
||||
void Init() { NumIterations = 0; Rating = 0; Usage = 0; RPU = 0; }
|
||||
void Normalize()
|
||||
{
|
||||
if (NumIterations == 0)
|
||||
return;
|
||||
Rating /= NumIterations;
|
||||
Usage /= NumIterations;
|
||||
RPU /= NumIterations;
|
||||
NumIterations = 1;
|
||||
}
|
||||
void SetMid(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
|
||||
{
|
||||
Rating = (r1.Rating + r2.Rating) / 2;
|
||||
Usage = (r1.Usage + r2.Usage) / 2;
|
||||
RPU = (r1.RPU + r2.RPU) / 2;
|
||||
NumIterations = (r1.NumIterations + r2.NumIterations) / 2;
|
||||
}
|
||||
FILE *_file;
|
||||
|
||||
void Print(const char *s);
|
||||
void NewLine();
|
||||
HRESULT CheckBreak();
|
||||
};
|
||||
|
||||
struct CBenchCallback: public IBenchCallback
|
||||
void CPrintBenchCallback::Print(const char *s)
|
||||
{
|
||||
CTotalBenchRes EncodeRes;
|
||||
CTotalBenchRes DecodeRes;
|
||||
FILE *f;
|
||||
void Init() { EncodeRes.Init(); DecodeRes.Init(); }
|
||||
void Normalize() { EncodeRes.Normalize(); DecodeRes.Normalize(); }
|
||||
UInt32 dictionarySize;
|
||||
HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
|
||||
HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
|
||||
};
|
||||
|
||||
static void NormalizeVals(UInt64 &v1, UInt64 &v2)
|
||||
{
|
||||
while (v1 > 1000000)
|
||||
{
|
||||
v1 >>= 1;
|
||||
v2 >>= 1;
|
||||
}
|
||||
fputs(s, _file);
|
||||
}
|
||||
|
||||
static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
|
||||
void CPrintBenchCallback::NewLine()
|
||||
{
|
||||
UInt64 elTime = elapsedTime;
|
||||
NormalizeVals(freq, elTime);
|
||||
if (elTime == 0)
|
||||
elTime = 1;
|
||||
return value * freq / elTime;
|
||||
Print("\n");
|
||||
}
|
||||
|
||||
static void PrintNumber(FILE *f, UInt64 value, int size)
|
||||
HRESULT CPrintBenchCallback::CheckBreak()
|
||||
{
|
||||
char s[32];
|
||||
ConvertUInt64ToString(value, s);
|
||||
fprintf(f, " ");
|
||||
for (int len = (int)strlen(s); len < size; len++)
|
||||
fprintf(f, " ");
|
||||
fputs(s, f);
|
||||
return NConsoleClose::TestBreakSignal() ? E_ABORT: S_OK;
|
||||
}
|
||||
|
||||
static void PrintRating(FILE *f, UInt64 rating)
|
||||
HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const CObjectVector<CProperty> props, UInt32 numIterations, FILE *f)
|
||||
{
|
||||
PrintNumber(f, rating / 1000000, 6);
|
||||
}
|
||||
|
||||
static void PrintResults(FILE *f, UInt64 usage, UInt64 rpu, UInt64 rating)
|
||||
{
|
||||
PrintNumber(f, (usage + 5000) / 10000, 5);
|
||||
PrintRating(f, rpu);
|
||||
PrintRating(f, rating);
|
||||
}
|
||||
|
||||
|
||||
static void PrintResults(FILE *f, const CBenchInfo &info, UInt64 rating, CTotalBenchRes &res)
|
||||
{
|
||||
UInt64 speed = MyMultDiv64(info.UnpackSize, info.GlobalTime, info.GlobalFreq);
|
||||
PrintNumber(f, speed / 1024, 7);
|
||||
UInt64 usage = GetUsage(info);
|
||||
UInt64 rpu = GetRatingPerUsage(info, rating);
|
||||
PrintResults(f, usage, rpu, rating);
|
||||
res.NumIterations++;
|
||||
res.RPU += rpu;
|
||||
res.Rating += rating;
|
||||
res.Usage += usage;
|
||||
}
|
||||
|
||||
static void PrintTotals(FILE *f, const CTotalBenchRes &res)
|
||||
{
|
||||
fprintf(f, " ");
|
||||
PrintResults(f, res.Usage, res.RPU, res.Rating);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
|
||||
{
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
if (final)
|
||||
{
|
||||
UInt64 rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, info.UnpackSize);
|
||||
PrintResults(f, info, rating, EncodeRes);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const char *kSep = " | ";
|
||||
|
||||
|
||||
HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
|
||||
{
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
if (final)
|
||||
{
|
||||
UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
|
||||
fputs(kSep, f);
|
||||
CBenchInfo info2 = info;
|
||||
info2.UnpackSize *= info2.NumIterations;
|
||||
info2.PackSize *= info2.NumIterations;
|
||||
info2.NumIterations = 1;
|
||||
PrintResults(f, info2, rating, DecodeRes);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void PrintRequirements(FILE *f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
|
||||
{
|
||||
fprintf(f, "\nRAM %s ", sizeString);
|
||||
PrintNumber(f, (size >> 20), 5);
|
||||
fprintf(f, " MB, # %s %3d", threadsString, (unsigned int)numThreads);
|
||||
}
|
||||
|
||||
HRESULT LzmaBenchCon(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
|
||||
{
|
||||
if (!CrcInternalTest())
|
||||
return S_FALSE;
|
||||
#ifndef _7ZIP_ST
|
||||
UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
|
||||
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
|
||||
PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
|
||||
if (numThreads == (UInt32)-1)
|
||||
numThreads = numCPUs;
|
||||
if (numThreads > 1)
|
||||
numThreads &= ~1;
|
||||
if (dictionary == (UInt32)-1)
|
||||
{
|
||||
int dicSizeLog;
|
||||
for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
|
||||
if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
|
||||
break;
|
||||
dictionary = (1 << dicSizeLog);
|
||||
}
|
||||
#else
|
||||
if (dictionary == (UInt32)-1)
|
||||
dictionary = (1 << 22);
|
||||
numThreads = 1;
|
||||
#endif
|
||||
|
||||
PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dictionary), "Benchmark threads: ", numThreads);
|
||||
|
||||
CBenchCallback callback;
|
||||
callback.Init();
|
||||
callback.f = f;
|
||||
|
||||
fprintf(f, "\n\nDict Compressing | Decompressing\n ");
|
||||
int j;
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
fprintf(f, " Speed Usage R/U Rating");
|
||||
if (j == 0)
|
||||
fputs(kSep, f);
|
||||
}
|
||||
fprintf(f, "\n ");
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
fprintf(f, " KB/s %% MIPS MIPS");
|
||||
if (j == 0)
|
||||
fputs(kSep, f);
|
||||
}
|
||||
fprintf(f, "\n\n");
|
||||
for (UInt32 i = 0; i < numIterations; i++)
|
||||
{
|
||||
const int kStartDicLog = 22;
|
||||
int pow = (dictionary < ((UInt32)1 << kStartDicLog)) ? kBenchMinDicLogSize : kStartDicLog;
|
||||
while (((UInt32)1 << pow) > dictionary)
|
||||
pow--;
|
||||
for (; ((UInt32)1 << pow) <= dictionary; pow++)
|
||||
{
|
||||
fprintf(f, "%2d:", pow);
|
||||
callback.dictionarySize = (UInt32)1 << pow;
|
||||
HRESULT res = LzmaBench(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
numThreads, callback.dictionarySize, &callback);
|
||||
fprintf(f, "\n");
|
||||
RINOK(res);
|
||||
}
|
||||
}
|
||||
callback.Normalize();
|
||||
fprintf(f, "----------------------------------------------------------------\nAvr:");
|
||||
PrintTotals(f, callback.EncodeRes);
|
||||
fprintf(f, " ");
|
||||
PrintTotals(f, callback.DecodeRes);
|
||||
fprintf(f, "\nTot:");
|
||||
CTotalBenchRes midRes;
|
||||
midRes.SetMid(callback.EncodeRes, callback.DecodeRes);
|
||||
PrintTotals(f, midRes);
|
||||
fprintf(f, "\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
struct CTempValues
|
||||
{
|
||||
UInt64 *Values;
|
||||
CTempValues(UInt32 num) { Values = new UInt64[num]; }
|
||||
~CTempValues() { delete []Values; }
|
||||
};
|
||||
|
||||
HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
|
||||
{
|
||||
if (!CrcInternalTest())
|
||||
return S_FALSE;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
UInt64 ramSize = NWindows::NSystem::GetRamSize();
|
||||
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
|
||||
PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
|
||||
if (numThreads == (UInt32)-1)
|
||||
numThreads = numCPUs;
|
||||
#else
|
||||
numThreads = 1;
|
||||
#endif
|
||||
if (dictionary == (UInt32)-1)
|
||||
dictionary = (1 << 24);
|
||||
|
||||
CTempValues speedTotals(numThreads);
|
||||
fprintf(f, "\n\nSize");
|
||||
for (UInt32 ti = 0; ti < numThreads; ti++)
|
||||
{
|
||||
fprintf(f, " %5d", ti + 1);
|
||||
speedTotals.Values[ti] = 0;
|
||||
}
|
||||
fprintf(f, "\n\n");
|
||||
|
||||
UInt64 numSteps = 0;
|
||||
for (UInt32 i = 0; i < numIterations; i++)
|
||||
{
|
||||
for (int pow = 10; pow < 32; pow++)
|
||||
{
|
||||
UInt32 bufSize = (UInt32)1 << pow;
|
||||
if (bufSize > dictionary)
|
||||
break;
|
||||
fprintf(f, "%2d: ", pow);
|
||||
UInt64 speed;
|
||||
for (UInt32 ti = 0; ti < numThreads; ti++)
|
||||
{
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
RINOK(CrcBench(ti + 1, bufSize, speed));
|
||||
PrintNumber(f, (speed >> 20), 5);
|
||||
speedTotals.Values[ti] += speed;
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
numSteps++;
|
||||
}
|
||||
}
|
||||
if (numSteps != 0)
|
||||
{
|
||||
fprintf(f, "\nAvg:");
|
||||
for (UInt32 ti = 0; ti < numThreads; ti++)
|
||||
PrintNumber(f, ((speedTotals.Values[ti] / numSteps) >> 20), 5);
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
return S_OK;
|
||||
CPrintBenchCallback callback;
|
||||
callback._file = f;
|
||||
callback.NewLine();
|
||||
return Bench(EXTERNAL_CODECS_LOC_VARS
|
||||
&callback, NULL, props, numIterations, true);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../UI/Common/Property.h"
|
||||
|
||||
HRESULT LzmaBenchCon(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
|
||||
|
||||
HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
|
||||
HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const CObjectVector<CProperty> props, UInt32 numIterations, FILE *f);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -628,14 +628,6 @@ SOURCE=..\Common\UpdateProduce.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\WorkDir.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\WorkDir.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ZipRegistry.h
|
||||
# End Source File
|
||||
# End Group
|
||||
@@ -676,6 +668,14 @@ SOURCE=..\..\Common\FilterCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\MethodProps.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\MethodProps.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -182,7 +182,7 @@ HRESULT CExtractCallbackConsole::OpenResult(const wchar_t * /* name */, HRESULT
|
||||
if (result == E_OUTOFMEMORY)
|
||||
(*OutStream) << "Can't allocate required memory";
|
||||
else
|
||||
(*OutStream) << NError::MyFormatMessage(result);
|
||||
(*OutStream) << NError::MyFormatMessageW(result);
|
||||
}
|
||||
(*OutStream) << endl;
|
||||
NumArchiveErrors++;
|
||||
@@ -218,11 +218,7 @@ HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
|
||||
if (result == E_OUTOFMEMORY)
|
||||
(*OutStream) << kMemoryExceptionMessage;
|
||||
else
|
||||
{
|
||||
UString message;
|
||||
NError::MyFormatMessage(result, message);
|
||||
(*OutStream) << message;
|
||||
}
|
||||
(*OutStream) << NError::MyFormatMessageW(result);
|
||||
(*OutStream) << endl;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -437,8 +437,8 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
|
||||
UInt64 arcPackSize = 0;
|
||||
if (!stdInMode)
|
||||
{
|
||||
NFile::NFind::CFileInfoW fi;
|
||||
if (!fi.Find(archiveName) || fi.IsDir())
|
||||
NFile::NFind::CFileInfo fi;
|
||||
if (!fi.Find(us2fs(archiveName)) || fi.IsDir())
|
||||
{
|
||||
g_StdOut << endl << "Error: " << archiveName << " is not file" << endl;
|
||||
numErrors++;
|
||||
@@ -477,7 +477,7 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
|
||||
else if (result == E_OUTOFMEMORY)
|
||||
g_StdOut << "Can't allocate required memory";
|
||||
else
|
||||
g_StdOut << NError::MyFormatMessage(result);
|
||||
g_StdOut << NError::MyFormatMessageW(result);
|
||||
g_StdOut << endl;
|
||||
numErrors++;
|
||||
continue;
|
||||
|
||||
@@ -39,7 +39,9 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NCommandLineParser;
|
||||
|
||||
#ifdef _WIN32
|
||||
HINSTANCE g_hInstance = 0;
|
||||
#endif
|
||||
extern CStdOutStream *g_StdStream;
|
||||
|
||||
static const char *kCopyrightString = "\n7-Zip"
|
||||
@@ -111,7 +113,7 @@ static const char *kUserErrorMessage = "Incorrect command line";
|
||||
static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
|
||||
static const char *kUnsupportedArcTypeMessage = "Unsupported archive type";
|
||||
|
||||
static const wchar_t *kDefaultSfxModule = L"7zCon.sfx";
|
||||
static CFSTR kDefaultSfxModule = FTEXT("7zCon.sfx");
|
||||
|
||||
static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExitCode::EEnum code)
|
||||
{
|
||||
@@ -338,20 +340,6 @@ int Main2(
|
||||
}
|
||||
else if (options.Command.CommandType == NCommandType::kBenchmark)
|
||||
{
|
||||
if (options.Method.CompareNoCase(L"CRC") == 0)
|
||||
{
|
||||
HRESULT res = CrcBenchCon((FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
|
||||
if (res != S_OK)
|
||||
{
|
||||
if (res == S_FALSE)
|
||||
{
|
||||
stdStream << "\nCRC Error\n";
|
||||
return NExitCode::kFatalError;
|
||||
}
|
||||
throw CSystemException(res);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HRESULT res;
|
||||
#ifdef EXTERNAL_CODECS
|
||||
@@ -360,11 +348,11 @@ int Main2(
|
||||
if (res != S_OK)
|
||||
throw CSystemException(res);
|
||||
#endif
|
||||
res = LzmaBenchCon(
|
||||
res = BenchCon(
|
||||
#ifdef EXTERNAL_CODECS
|
||||
compressCodecsInfo, &externalCodecs,
|
||||
#endif
|
||||
(FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
|
||||
options.Properties, options.NumIterations, (FILE *)stdStream);
|
||||
if (res != S_OK)
|
||||
{
|
||||
if (res == S_FALSE)
|
||||
@@ -410,7 +398,7 @@ int Main2(
|
||||
eo.YesToAll = options.YesToAll;
|
||||
eo.CalcCrc = options.CalcCrc;
|
||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
||||
eo.Properties = options.ExtractProperties;
|
||||
eo.Properties = options.Properties;
|
||||
#endif
|
||||
UString errorMessage;
|
||||
CDecompressStat stat;
|
||||
@@ -480,7 +468,7 @@ int Main2(
|
||||
numErrors);
|
||||
if (numErrors > 0)
|
||||
{
|
||||
g_StdOut << endl << "Errors: " << numErrors;
|
||||
g_StdOut << endl << "Errors: " << numErrors << endl;
|
||||
return NExitCode::kFatalError;
|
||||
}
|
||||
if (result != S_OK)
|
||||
@@ -551,12 +539,12 @@ int Main2(
|
||||
}
|
||||
if (!errorInfo.FileName.IsEmpty())
|
||||
{
|
||||
message += errorInfo.FileName;
|
||||
message += fs2us(errorInfo.FileName);
|
||||
message += L"\n";
|
||||
}
|
||||
if (!errorInfo.FileName2.IsEmpty())
|
||||
{
|
||||
message += errorInfo.FileName2;
|
||||
message += fs2us(errorInfo.FileName2);
|
||||
message += L"\n";
|
||||
}
|
||||
if (errorInfo.SystemError != 0)
|
||||
|
||||
@@ -79,9 +79,8 @@ int MY_CDECL main
|
||||
(*g_StdStream) << endl << kUserBreak;
|
||||
return (NExitCode::kUserBreak);
|
||||
}
|
||||
UString message;
|
||||
NError::MyFormatMessage(systemError.ErrorCode, message);
|
||||
(*g_StdStream) << endl << endl << "System error:" << endl << message << endl;
|
||||
(*g_StdStream) << endl << endl << "System error:" << endl <<
|
||||
NError::MyFormatMessageW(systemError.ErrorCode) << endl;
|
||||
return (NExitCode::kFatalError);
|
||||
}
|
||||
catch(NExitCode::EEnum &exitCode)
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
|
||||
#include "PercentPrinter.h"
|
||||
|
||||
const int kPaddingSize = 2;
|
||||
const int kPercentsSize = 4;
|
||||
const int kMaxExtraSize = kPaddingSize + 32 + kPercentsSize;
|
||||
static const unsigned kPaddingSize = 2;
|
||||
static const unsigned kPercentsSize = 4;
|
||||
static const unsigned kMaxExtraSize = kPaddingSize + 32 + kPercentsSize;
|
||||
|
||||
static void ClearPrev(char *p, int num)
|
||||
static void ClearPrev(char *p, unsigned num)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
for (i = 0; i < num; i++) *p++ = '\b';
|
||||
for (i = 0; i < num; i++) *p++ = ' ';
|
||||
for (i = 0; i < num; i++) *p++ = '\b';
|
||||
@@ -51,18 +51,30 @@ void CPercentPrinter::PrintNewLine()
|
||||
void CPercentPrinter::RePrintRatio()
|
||||
{
|
||||
char s[32];
|
||||
ConvertUInt64ToString(((m_Total == 0) ? 0 : (m_CurValue * 100 / m_Total)), s);
|
||||
int size = (int)strlen(s);
|
||||
s[size++] = '%';
|
||||
s[size] = '\0';
|
||||
unsigned size;
|
||||
{
|
||||
char c = '%';
|
||||
UInt64 value = 0;
|
||||
if (m_Total == (UInt64)(Int64)-1)
|
||||
{
|
||||
value = m_CurValue >> 20;
|
||||
c = 'M';
|
||||
}
|
||||
else if (m_Total != 0)
|
||||
value = m_CurValue * 100 / m_Total;
|
||||
ConvertUInt64ToString(value, s);
|
||||
size = (unsigned)strlen(s);
|
||||
s[size++] = c;
|
||||
s[size] = '\0';
|
||||
}
|
||||
|
||||
int extraSize = kPaddingSize + MyMax(size, kPercentsSize);
|
||||
unsigned extraSize = kPaddingSize + MyMax(size, kPercentsSize);
|
||||
if (extraSize < m_NumExtraChars)
|
||||
extraSize = m_NumExtraChars;
|
||||
|
||||
char fullString[kMaxExtraSize * 3];
|
||||
char *p = fullString;
|
||||
int i;
|
||||
unsigned i;
|
||||
if (m_NumExtraChars == 0)
|
||||
{
|
||||
for (i = 0; i < extraSize; i++)
|
||||
@@ -73,7 +85,7 @@ void CPercentPrinter::RePrintRatio()
|
||||
for (i = 0; i < m_NumExtraChars; i++)
|
||||
*p++ = '\b';
|
||||
m_NumExtraChars = extraSize;
|
||||
for (; size < m_NumExtraChars; size++)
|
||||
for (; size < extraSize; size++)
|
||||
*p++ = ' ';
|
||||
MyStringCopy(p, s);
|
||||
(*OutStream) << fullString;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// PercentPrinter.h
|
||||
|
||||
#ifndef __PERCENTPRINTER_H
|
||||
#define __PERCENTPRINTER_H
|
||||
#ifndef __PERCENT_PRINTER_H
|
||||
#define __PERCENT_PRINTER_H
|
||||
|
||||
#include "Common/Types.h"
|
||||
#include "Common/StdOutStream.h"
|
||||
|
||||
class CPercentPrinter
|
||||
@@ -12,12 +11,12 @@ class CPercentPrinter
|
||||
UInt64 m_PrevValue;
|
||||
UInt64 m_CurValue;
|
||||
UInt64 m_Total;
|
||||
int m_NumExtraChars;
|
||||
unsigned m_NumExtraChars;
|
||||
public:
|
||||
CStdOutStream *OutStream;
|
||||
|
||||
CPercentPrinter(UInt64 minStepSize = 1): m_MinStepSize(minStepSize),
|
||||
m_PrevValue(0), m_CurValue(0), m_Total(1), m_NumExtraChars(0) {}
|
||||
m_PrevValue(0), m_CurValue(0), m_Total((UInt64)(Int64)-1), m_NumExtraChars(0) {}
|
||||
void SetTotal(UInt64 total) { m_Total = total; m_PrevValue = 0; }
|
||||
void SetRatio(UInt64 doneValue) { m_CurValue = doneValue; }
|
||||
void PrintString(const char *s);
|
||||
|
||||
@@ -54,6 +54,7 @@ WIN_OBJS = \
|
||||
$O\FilePathAutoRename.obj \
|
||||
$O\FileStreams.obj \
|
||||
$O\FilterCoder.obj \
|
||||
$O\MethodProps.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
@@ -77,7 +78,6 @@ UI_COMMON_OBJS = \
|
||||
$O\UpdateCallback.obj \
|
||||
$O\UpdatePair.obj \
|
||||
$O\UpdateProduce.obj \
|
||||
$O\WorkDir.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/COM.h"
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Memory.h"
|
||||
#include "Windows/Menu.h"
|
||||
#include "Windows/Process.h"
|
||||
@@ -20,7 +22,6 @@
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "../FileManager/FormatUtils.h"
|
||||
#include "../FileManager/ProgramLocation.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "../FileManager/LangUtils.h"
|
||||
@@ -338,8 +339,9 @@ static const char *kExtractExludeExtensions =
|
||||
static const char *kNoOpenAsExtensions =
|
||||
" 7z arj bz2 cab chm cpio dmg flv gz lha lzh lzma rar swm tar tbz2 tgz wim xar xz z zip ";
|
||||
|
||||
static bool FindExt(const char *p, const UString &name)
|
||||
static bool FindExt(const char *p, const FString &nameF)
|
||||
{
|
||||
const UString name = fs2us(nameF);
|
||||
int extPos = name.ReverseFind('.');
|
||||
if (extPos < 0)
|
||||
return false;
|
||||
@@ -357,7 +359,7 @@ static bool FindExt(const char *p, const UString &name)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool DoNeedExtract(const UString &name)
|
||||
static bool DoNeedExtract(const FString &name)
|
||||
{
|
||||
return !FindExt(kExtractExludeExtensions, name);
|
||||
}
|
||||
@@ -408,11 +410,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
if (_fileNames.Size() == 1 && currentCommandID + 6 <= commandIDLast)
|
||||
{
|
||||
const UString &fileName = _fileNames.Front();
|
||||
UString folderPrefix;
|
||||
NFile::NDirectory::GetOnlyDirPrefix(fileName, folderPrefix);
|
||||
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
if (!fileInfo.Find(fileName))
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
if (!fileInfo.Find(us2fs(fileName)))
|
||||
return E_FAIL;
|
||||
if (!fileInfo.IsDir() && DoNeedExtract(fileInfo.Name))
|
||||
{
|
||||
@@ -473,10 +472,10 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
if (_fileNames.Size() > 0 && currentCommandID + 10 <= commandIDLast)
|
||||
{
|
||||
bool needExtract = false;
|
||||
for(int i = 0; i < _fileNames.Size(); i++)
|
||||
for (int i = 0; i < _fileNames.Size(); i++)
|
||||
{
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
if (!fileInfo.Find(_fileNames[i]))
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
if (!fileInfo.Find(us2fs(_fileNames[i])))
|
||||
return E_FAIL;
|
||||
if (!fileInfo.IsDir() && DoNeedExtract(fileInfo.Name))
|
||||
needExtract = true;
|
||||
@@ -484,10 +483,10 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
const UString &fileName = _fileNames.Front();
|
||||
if (needExtract)
|
||||
{
|
||||
UString folderPrefix;
|
||||
NFile::NDirectory::GetOnlyDirPrefix(fileName, folderPrefix);
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
if (!fileInfo.Find(fileName))
|
||||
FString folderPrefix;
|
||||
NFile::NDirectory::GetOnlyDirPrefix(us2fs(fileName), folderPrefix);
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
if (!fileInfo.Find(us2fs(fileName)))
|
||||
return E_FAIL;
|
||||
// Extract
|
||||
if ((contextMenuFlags & NContextMenuFlags::kExtract) != 0)
|
||||
@@ -497,8 +496,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = folderPrefix;
|
||||
commandMapItem.Folder += GetSubFolderNameForExtract(fileInfo.Name) + UString(WCHAR_PATH_SEPARATOR);
|
||||
commandMapItem.Folder = fs2us(folderPrefix);
|
||||
commandMapItem.Folder += GetSubFolderNameForExtract(fs2us(fileInfo.Name)) + UString(WCHAR_PATH_SEPARATOR);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
@@ -512,7 +511,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = folderPrefix;
|
||||
commandMapItem.Folder = fs2us(folderPrefix);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
@@ -524,13 +523,13 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
FillCommand(kExtractTo, s, commandMapItem);
|
||||
UString folder;
|
||||
if (_fileNames.Size() == 1)
|
||||
folder = GetSubFolderNameForExtract(fileInfo.Name);
|
||||
folder = GetSubFolderNameForExtract(fs2us(fileInfo.Name));
|
||||
else
|
||||
folder = L'*';
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = folderPrefix;
|
||||
commandMapItem.Folder = fs2us(folderPrefix);
|
||||
commandMapItem.Folder += folder;
|
||||
s = MyFormatNew(s, GetQuotedReducedString(folder + UString(WCHAR_PATH_SEPARATOR)));
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
|
||||
@@ -548,8 +547,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
UString archiveName = CreateArchiveName(fileName, _fileNames.Size() > 1, false);
|
||||
UString archiveName7z = archiveName + L".7z";
|
||||
UString archiveNameZip = archiveName + L".zip";
|
||||
UString archivePathPrefix;
|
||||
NFile::NDirectory::GetOnlyDirPrefix(fileName, archivePathPrefix);
|
||||
FString archivePathPrefix;
|
||||
NFile::NDirectory::GetOnlyDirPrefix(us2fs(fileName), archivePathPrefix);
|
||||
|
||||
// Compress
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompress) != 0)
|
||||
@@ -558,7 +557,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = archivePathPrefix;
|
||||
commandMapItem.Folder = fs2us(archivePathPrefix);
|
||||
commandMapItem.ArcName = archiveName;
|
||||
FillCommand(kCompress, mainString, commandMapItem);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
|
||||
@@ -586,7 +585,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = archivePathPrefix;
|
||||
commandMapItem.Folder = fs2us(archivePathPrefix);
|
||||
commandMapItem.ArcName = archiveName7z;
|
||||
commandMapItem.ArcType = L"7z";
|
||||
s = MyFormatNew(s, GetQuotedReducedString(archiveName7z));
|
||||
@@ -618,7 +617,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
if (_dropMode)
|
||||
commandMapItem.Folder = _dropPath;
|
||||
else
|
||||
commandMapItem.Folder = archivePathPrefix;
|
||||
commandMapItem.Folder = fs2us(archivePathPrefix);
|
||||
commandMapItem.ArcName = archiveNameZip;
|
||||
commandMapItem.ArcType = L"zip";
|
||||
s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip));
|
||||
@@ -675,9 +674,7 @@ int CZipContextMenu::FindVerb(const UString &verb)
|
||||
|
||||
static UString Get7zFmPath()
|
||||
{
|
||||
UString path;
|
||||
GetProgramFolderPath(path);
|
||||
return path + L"7zFM.exe";
|
||||
return fs2us(NWindows::NDLL::GetModuleDirPrefix()) + L"7zFM.exe";
|
||||
}
|
||||
|
||||
STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
|
||||
|
||||
@@ -35,16 +35,6 @@ using namespace NWindows;
|
||||
HINSTANCE g_hInstance = 0;
|
||||
HWND g_HWND = 0;
|
||||
|
||||
UString HResultToMessage(HRESULT errorCode)
|
||||
{
|
||||
UString message;
|
||||
if (!NError::MyFormatMessage(errorCode, message))
|
||||
message.Empty();
|
||||
if (message.IsEmpty())
|
||||
message = L"Error";
|
||||
return message;
|
||||
}
|
||||
|
||||
LONG g_DllRefCount = 0; // Reference count of this DLL.
|
||||
|
||||
static LPCWSTR kShellExtName = L"7-Zip Shell Extension";
|
||||
@@ -191,14 +181,15 @@ static BOOL RegisterServer(CLSID clsid, LPCWSTR title)
|
||||
if (!GetStringFromIID(clsid, clsidString, MAX_PATH))
|
||||
return FALSE;
|
||||
|
||||
UString modulePath;
|
||||
if (!NDLL::MyGetModuleFileName(g_hInstance, modulePath))
|
||||
FString modulePath;
|
||||
if (!NDLL::MyGetModuleFileName(modulePath))
|
||||
return FALSE;
|
||||
UString modulePathU = fs2us(modulePath);
|
||||
|
||||
CRegItem clsidEntries[] =
|
||||
{
|
||||
HKEY_CLASSES_ROOT, kClsidMask, NULL, title,
|
||||
HKEY_CLASSES_ROOT, kClsidInprocMask, NULL, modulePath,
|
||||
HKEY_CLASSES_ROOT, kClsidInprocMask, NULL, modulePathU,
|
||||
HKEY_CLASSES_ROOT, kClsidInprocMask, L"ThreadingModel", L"Apartment",
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
@@ -449,8 +449,7 @@ bool WasEscPressed()
|
||||
|
||||
void ShowErrorMessage(DWORD errorCode)
|
||||
{
|
||||
UString message;
|
||||
NError::MyFormatMessage(errorCode, message);
|
||||
UString message = NError::MyFormatMessageW(errorCode);
|
||||
message.Replace(L"\x0D", L"");
|
||||
message.Replace(L"\x0A", L" ");
|
||||
g_StartupInfo.ShowMessage(UnicodeStringToMultiByte(message, CP_OEMCP));
|
||||
|
||||
@@ -87,12 +87,12 @@ class COpenArchiveCallback:
|
||||
|
||||
DWORD m_PrevTickCount;
|
||||
|
||||
NWindows::NFile::NFind::CFileInfoW _fileInfo;
|
||||
NWindows::NFile::NFind::CFileInfo _fileInfo;
|
||||
public:
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
UString _folderPrefix;
|
||||
FString _folderPrefix;
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP3(
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
}
|
||||
void ShowMessage();
|
||||
|
||||
void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
|
||||
void LoadFileInfo(const FString &folderPrefix, const FString &fileName)
|
||||
{
|
||||
_folderPrefix = folderPrefix;
|
||||
if (!_fileInfo.Find(_folderPrefix + fileName))
|
||||
@@ -251,7 +251,7 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **in
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
*inStream = NULL;
|
||||
UString fullPath = _folderPrefix + name;
|
||||
FString fullPath = _folderPrefix + us2fs(name);
|
||||
if (!_fileInfo.Find(fullPath))
|
||||
return S_FALSE;
|
||||
if (_fileInfo.IsDir())
|
||||
@@ -333,16 +333,15 @@ HRESULT OpenArchive(const CSysString &fileName,
|
||||
|
||||
static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
||||
{
|
||||
UString normalizedName = name;
|
||||
FString normalizedName = us2fs(name);
|
||||
normalizedName.Trim();
|
||||
UString fullName;
|
||||
int fileNamePartStartIndex;
|
||||
NFile::NDirectory::MyGetFullPathName(normalizedName, fullName, fileNamePartStartIndex);
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
FString fullName;
|
||||
NFile::NDirectory::MyGetFullPathName(normalizedName, fullName);
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
if (!fileInfo.Find(fullName))
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileInfo.IsDir())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
|
||||
CMyComPtr<IInFolderArchive> archiveHandler;
|
||||
@@ -360,9 +359,11 @@ static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
||||
|
||||
// if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
|
||||
openArchiveCallbackSpec->Init();
|
||||
openArchiveCallbackSpec->LoadFileInfo(
|
||||
fullName.Left(fileNamePartStartIndex),
|
||||
fullName.Mid(fileNamePartStartIndex));
|
||||
{
|
||||
FString dirPrefix, fileName;
|
||||
NFile::NDirectory::GetFullPathAndSplit(fullName, dirPrefix, fileName);
|
||||
openArchiveCallbackSpec->LoadFileInfo(dirPrefix, fileName);
|
||||
}
|
||||
|
||||
// ::OutputDebugStringA("before OpenArchive\n");
|
||||
|
||||
@@ -449,7 +450,7 @@ EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, INT_PTR item)
|
||||
if(fileName.IsEmpty())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileName.Length() >= 2 &&
|
||||
fileName[0] == '\"' && fileName[fileName.Length() - 1] == '\"')
|
||||
fileName[0] == '\"' && fileName.Back() == '\"')
|
||||
fileName = fileName.Mid(1, fileName.Length() - 2);
|
||||
|
||||
return MyOpenFilePlugin(fileName);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
CPlugin::CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName):
|
||||
CPlugin::CPlugin(const FString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName):
|
||||
m_ArchiveHandler(archiveHandler),
|
||||
m_FileName(fileName),
|
||||
_archiveTypeName(archiveTypeName)
|
||||
@@ -532,10 +532,10 @@ static void InsertSeparator(InfoPanelLine *lines, int &numItems)
|
||||
void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
{
|
||||
info->StructSize = sizeof(*info);
|
||||
info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS| OPIF_USEHIGHLIGHTING|
|
||||
info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS | OPIF_USEHIGHLIGHTING |
|
||||
OPIF_ADDDOTS | OPIF_COMPAREFATTIME;
|
||||
|
||||
COPY_STR_LIMITED(m_FileNameBuffer, UnicodeStringToMultiByte(m_FileName, CP_OEMCP));
|
||||
COPY_STR_LIMITED(m_FileNameBuffer, UnicodeStringToMultiByte(fs2us(m_FileName), CP_OEMCP));
|
||||
info->HostFile = m_FileNameBuffer; // test it it is not static
|
||||
|
||||
COPY_STR_LIMITED(m_CurrentDirBuffer, UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP));
|
||||
@@ -545,10 +545,9 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
|
||||
UString name;
|
||||
{
|
||||
UString fullName;
|
||||
int index;
|
||||
NFile::NDirectory::MyGetFullPathName(m_FileName, fullName, index);
|
||||
name = fullName.Mid(index);
|
||||
FString dirPrefix, fileName;
|
||||
NFile::NDirectory::GetFullPathAndSplit(m_FileName, dirPrefix, fileName);
|
||||
name = fs2us(fileName);
|
||||
}
|
||||
|
||||
m_PannelTitle =
|
||||
@@ -852,14 +851,14 @@ int CPlugin::ProcessKey(int key, unsigned int controlState)
|
||||
}
|
||||
if ((controlState & PKF_ALT) != 0 && key == VK_F6)
|
||||
{
|
||||
UString folderPath;
|
||||
FString folderPath;
|
||||
if (!NFile::NDirectory::GetOnlyDirPrefix(m_FileName, folderPath))
|
||||
return FALSE;
|
||||
PanelInfo panelInfo;
|
||||
g_StartupInfo.ControlGetActivePanelInfo(panelInfo);
|
||||
GetFilesReal(panelInfo.SelectedItems,
|
||||
panelInfo.SelectedItemsNumber, FALSE,
|
||||
UnicodeStringToMultiByte(folderPath, CP_OEMCP), OPM_SILENT, true);
|
||||
UnicodeStringToMultiByte(fs2us(folderPath), CP_OEMCP), OPM_SILENT, true);
|
||||
g_StartupInfo.Control(this, FCTL_UPDATEPANEL, NULL);
|
||||
g_StartupInfo.Control(this, FCTL_REDRAWPANEL, NULL);
|
||||
g_StartupInfo.Control(this, FCTL_UPDATEANOTHERPANEL, NULL);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/WorkDir.h"
|
||||
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
@@ -36,9 +38,10 @@ class CPlugin
|
||||
void EnterToDirectory(const UString &dirName);
|
||||
void GetPathParts(UStringVector &pathParts);
|
||||
void GetCurrentDir();
|
||||
HRESULT AfterUpdate(CWorkDirTempFile &tempFile, const UStringVector &pathVector);
|
||||
public:
|
||||
UString m_FileName;
|
||||
NWindows::NFile::NFind::CFileInfoW m_FileInfo;
|
||||
FString m_FileName;
|
||||
NWindows::NFile::NFind::CFileInfo m_FileInfo;
|
||||
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
CMyComPtr<IFolderFolder> _folder;
|
||||
@@ -48,7 +51,7 @@ public:
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName);
|
||||
CPlugin(const FString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName);
|
||||
~CPlugin();
|
||||
|
||||
void ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex);
|
||||
|
||||
@@ -2,20 +2,11 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "../Common/WorkDir.h"
|
||||
|
||||
#include "Messages.h"
|
||||
#include "Plugin.h"
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
using namespace NFar;
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDirectory;
|
||||
|
||||
static LPCWSTR kTempArchivePrefix = L"7zA";
|
||||
|
||||
int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
{
|
||||
@@ -67,18 +58,10 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
g_StartupInfo.GetMsgString(NMessageID::kDeleting), 48);
|
||||
}
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
workDirInfo.Load();
|
||||
|
||||
UString workDir = GetWorkDir(workDirInfo, m_FileName);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
CTempFileW tempFile;
|
||||
UString tempFileName;
|
||||
if (tempFile.Create(workDir, kTempArchivePrefix, tempFileName) == 0)
|
||||
CWorkDirTempFile tempFile;
|
||||
if (tempFile.CreateTempFile(m_FileName) != S_OK)
|
||||
return FALSE;
|
||||
|
||||
|
||||
CRecordVector<UINT32> indices;
|
||||
indices.Reserve(numItems);
|
||||
int i;
|
||||
@@ -101,61 +84,23 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
outArchive->SetFolder(_folder);
|
||||
|
||||
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
|
||||
|
||||
|
||||
result = outArchive->DeleteItems(
|
||||
tempFileName,
|
||||
&indices.Front(), indices.Size(),
|
||||
updateCallback);
|
||||
result = outArchive->DeleteItems(tempFile.OutStream, &indices.Front(), indices.Size(), updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
result = AfterUpdate(tempFile, pathVector);
|
||||
}
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->Close();
|
||||
|
||||
if (!DeleteFileAlways(m_FileName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
tempFile.DisableDeleting();
|
||||
if (!MyMoveFile(tempFileName, m_FileName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
result = m_ArchiveHandler->ReOpen(NULL);
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Restore _folder;
|
||||
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
for (i = 0; i < pathVector.Size(); i++)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(pathVector[i], &newFolder);
|
||||
if (!newFolder)
|
||||
break;
|
||||
_folder = newFolder;
|
||||
}
|
||||
GetCurrentDir();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -194,9 +194,11 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
#ifdef UNDER_CE
|
||||
destPathU = L"\\";
|
||||
#else
|
||||
if (!NFile::NDirectory::MyGetCurrentDirectory(destPathU))
|
||||
FString destPathF = us2fs(destPathU);
|
||||
if (!NFile::NDirectory::MyGetCurrentDirectory(destPathF))
|
||||
throw 318016;
|
||||
NFile::NName::NormalizeDirPathPrefix(destPathU);
|
||||
NFile::NName::NormalizeDirPathPrefix(destPathF);
|
||||
destPathU = fs2us(destPathF);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -251,7 +253,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
passwordIsDefined = !password.IsEmpty();
|
||||
}
|
||||
|
||||
NFile::NDirectory::CreateComplexDirectory(destPathU);
|
||||
NFile::NDirectory::CreateComplexDirectory(us2fs(destPathU));
|
||||
|
||||
/*
|
||||
vector<int> realIndices;
|
||||
|
||||
@@ -7,15 +7,10 @@
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
#include "../Common/WorkDir.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
@@ -30,13 +25,11 @@ using namespace NFar;
|
||||
|
||||
using namespace NUpdateArchive;
|
||||
|
||||
static const char *kHelpTopic = "Update";
|
||||
|
||||
static LPCWSTR kTempArcivePrefix = L"7zA";
|
||||
static const char *kHelpTopic = "Update";
|
||||
|
||||
static const char *kArchiveHistoryKeyName = "7-ZipArcName";
|
||||
|
||||
static UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
|
||||
static const UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
|
||||
|
||||
static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
|
||||
{
|
||||
@@ -47,18 +40,39 @@ static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
|
||||
realNames.Add(UString(L"x"));
|
||||
NCOM::CPropVariant value = (UInt32)method;
|
||||
CRecordVector<const wchar_t *> names;
|
||||
for(int i = 0; i < realNames.Size(); i++)
|
||||
for (int i = 0; i < realNames.Size(); i++)
|
||||
names.Add(realNames[i]);
|
||||
RINOK(setProperties->SetProperties(&names.Front(), &value, names.Size()));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CPlugin::AfterUpdate(CWorkDirTempFile &tempFile, const UStringVector &pathVector)
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->Close();
|
||||
|
||||
RINOK(tempFile.MoveToOriginal(true));
|
||||
|
||||
RINOK(m_ArchiveHandler->ReOpen(NULL)); // check it
|
||||
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
for (int i = 0; i < pathVector.Size(); i++)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(pathVector[i], &newFolder);
|
||||
if (!newFolder)
|
||||
break;
|
||||
_folder = newFolder;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
struct PluginPanelItem *panelItems, int numItems,
|
||||
int moveMode, int opMode)
|
||||
{
|
||||
if(moveMode != 0)
|
||||
if (moveMode != 0)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported);
|
||||
return NFileOperationReturnCode::kError;
|
||||
@@ -153,20 +167,14 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
|
||||
compressionInfo.Save();
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
workDirInfo.Load();
|
||||
UString workDir = GetWorkDir(workDirInfo, m_FileName);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
CTempFileW tempFile;
|
||||
UString tempFileName;
|
||||
if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
|
||||
CWorkDirTempFile tempFile;;
|
||||
if (tempFile.CreateTempFile(m_FileName) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
|
||||
|
||||
/*
|
||||
CSysStringVector fileNames;
|
||||
for(int i = 0; i < numItems; i++)
|
||||
for (int i = 0; i < numItems; i++)
|
||||
{
|
||||
const PluginPanelItem &panelItem = panelItems[i];
|
||||
CSysString fullName;
|
||||
@@ -189,44 +197,28 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// Save FolderItem;
|
||||
UStringVector aPathVector;
|
||||
GetPathParts(aPathVector);
|
||||
UStringVector pathVector;
|
||||
GetPathParts(pathVector);
|
||||
|
||||
/*
|
||||
UString anArchivePrefix;
|
||||
for(i = aPathVector.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
anArchivePrefix += aPathVector[i];
|
||||
anArchivePrefix += wchar_t(NName::kDirDelimiter);
|
||||
}
|
||||
/////////////////////////////////
|
||||
*/
|
||||
|
||||
UStringVector fileNames;
|
||||
fileNames.Reserve(numItems);
|
||||
for(i = 0; i < numItems; i++)
|
||||
for (i = 0; i < numItems; i++)
|
||||
fileNames.Add(MultiByteToUnicodeString(panelItems[i].FindData.cFileName, CP_OEMCP));
|
||||
CRecordVector<const wchar_t *> fileNamePointers;
|
||||
fileNamePointers.Reserve(numItems);
|
||||
for(i = 0; i < numItems; i++)
|
||||
for (i = 0; i < numItems; i++)
|
||||
fileNamePointers.Add(fileNames[i]);
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive);
|
||||
if(result != S_OK)
|
||||
if (result != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
outArchive->SetFolder(_folder);
|
||||
|
||||
// CSysString aCurrentFolder;
|
||||
// MyGetCurrentDirectory(aCurrentFolder);
|
||||
// outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
|
||||
outArchive->SetFiles(L"",
|
||||
&fileNamePointers.Front(), fileNamePointers.Size());
|
||||
outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size());
|
||||
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
|
||||
@@ -239,42 +231,14 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
|
||||
result = outArchive->DoOperation2(tempFileName, actionSetByte, NULL, updateCallback);
|
||||
result = outArchive->DoOperation2(tempFile.OutStream, actionSetByte, NULL, updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
|
||||
/*
|
||||
HRESULT result = Compress(fileNames, anArchivePrefix, *actionSet,
|
||||
m_ProxyHandler.get(),
|
||||
m_ArchiverInfo.ClassID, compressionInfo.Method == 0,
|
||||
compressionInfo.Method == 2, tempFileName, progressBoxPointer);
|
||||
*/
|
||||
|
||||
if (result != S_OK)
|
||||
if (result == S_OK)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
return NFileOperationReturnCode::kError;
|
||||
result = AfterUpdate(tempFile, pathVector);
|
||||
}
|
||||
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->Close();
|
||||
|
||||
// m_FolderItem = NULL;
|
||||
|
||||
if (!DeleteFileAlways(m_FileName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
tempFile.DisableDeleting();
|
||||
if (!MyMoveFile(tempFileName, m_FileName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
m_ArchiveHandler->ReOpen(NULL);
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
@@ -282,37 +246,17 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
}
|
||||
|
||||
/*
|
||||
if(m_ProxyHandler->ReInit(NULL) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
*/
|
||||
|
||||
////////////////////////////
|
||||
// Restore FolderItem;
|
||||
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
for (i = 0; i < aPathVector.Size(); i++)
|
||||
if (moveMode != 0)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(aPathVector[i], &newFolder);
|
||||
if(!newFolder )
|
||||
break;
|
||||
_folder = newFolder;
|
||||
}
|
||||
|
||||
/*
|
||||
if(moveMode != 0)
|
||||
{
|
||||
for(int i = 0; i < numItems; i++)
|
||||
for (int i = 0; i < numItems; i++)
|
||||
{
|
||||
const PluginPanelItem &aPluginPanelItem = panelItems[i];
|
||||
const PluginPanelItem &pluginPanelItem = panelItems[i];
|
||||
bool result;
|
||||
if(NFile::NFind::NAttributes::IsDir(aPluginPanelItem.FindData.dwFileAttributes))
|
||||
result = NFile::NDirectory::RemoveDirectoryWithSubItems(
|
||||
aPluginPanelItem.FindData.cFileName);
|
||||
if (NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
|
||||
result = NFile::NDirectory::RemoveDirectoryWithSubItems(pluginPanelItem.FindData.cFileName);
|
||||
else
|
||||
result = NFile::NDirectory::DeleteFileAlways(
|
||||
aPluginPanelItem.FindData.cFileName);
|
||||
if(!result)
|
||||
result = NFile::NDirectory::DeleteFileAlways(pluginPanelItem.FindData.cFileName);
|
||||
if (!result)
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
}
|
||||
@@ -361,11 +305,11 @@ void CParsedPath::ParsePath(const UString &path)
|
||||
case NPathType::kLocal:
|
||||
{
|
||||
int posDiskDelimiter = path.Find(kDiskDelimiter);
|
||||
if(posDiskDelimiter >= 0)
|
||||
if (posDiskDelimiter >= 0)
|
||||
{
|
||||
curPos = posDiskDelimiter + 1;
|
||||
if (path.Length() > curPos)
|
||||
if(path[curPos] == kDirDelimiter)
|
||||
if (path[curPos] == kDirDelimiter)
|
||||
curPos++;
|
||||
}
|
||||
break;
|
||||
@@ -373,7 +317,7 @@ void CParsedPath::ParsePath(const UString &path)
|
||||
case NPathType::kUNC:
|
||||
{
|
||||
int curPos = path.Find(kDirDelimiter, 2);
|
||||
if(curPos < 0)
|
||||
if (curPos < 0)
|
||||
curPos = path.Length();
|
||||
else
|
||||
curPos++;
|
||||
@@ -386,7 +330,7 @@ void CParsedPath::ParsePath(const UString &path)
|
||||
UString CParsedPath::MergePath() const
|
||||
{
|
||||
UString result = Prefix;
|
||||
for(int i = 0; i < PathParts.Size(); i++)
|
||||
for (int i = 0; i < PathParts.Size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
result += kDirDelimiter;
|
||||
@@ -409,20 +353,20 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
|
||||
UStringVector fileNames;
|
||||
int i;
|
||||
for(i = 0; i < pluginPanelItems.Size(); i++)
|
||||
for (i = 0; i < pluginPanelItems.Size(); i++)
|
||||
{
|
||||
const PluginPanelItem &panelItem = pluginPanelItems[i];
|
||||
UString fullName;
|
||||
if (strcmp(panelItem.FindData.cFileName, "..") == 0 &&
|
||||
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
|
||||
return E_FAIL;
|
||||
if (strcmp(panelItem.FindData.cFileName, ".") == 0 &&
|
||||
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
|
||||
return E_FAIL;
|
||||
UString fileNameUnicode = MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP);
|
||||
if (!MyGetFullPathName(fileNameUnicode, fullName))
|
||||
FString fullPath;
|
||||
FString fileNameUnicode = us2fs(MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP));
|
||||
if (!MyGetFullPathName(fileNameUnicode, fullPath))
|
||||
return E_FAIL;
|
||||
fileNames.Add(fullName);
|
||||
fileNames.Add(fs2us(fullPath));
|
||||
}
|
||||
|
||||
NCompression::CInfo compressionInfo;
|
||||
@@ -453,7 +397,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
{
|
||||
CParsedPath parsedPath;
|
||||
parsedPath.ParsePath(fileNames.Front());
|
||||
if(parsedPath.PathParts.Size() == 0)
|
||||
if (parsedPath.PathParts.Size() == 0)
|
||||
return E_FAIL;
|
||||
if (fileNames.Size() == 1 || parsedPath.PathParts.Size() == 1)
|
||||
{
|
||||
@@ -589,7 +533,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
{
|
||||
CIntVector indices;
|
||||
CSysStringVector archiverNames;
|
||||
for(int i = 0; i < codecs->Formats.Size(); i++)
|
||||
for (int i = 0; i < codecs->Formats.Size(); i++)
|
||||
{
|
||||
const CArcInfoEx &arc = codecs->Formats[i];
|
||||
if (arc.UpdateEnabled)
|
||||
@@ -602,7 +546,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT,
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdateSelectArchiverMenuTitle),
|
||||
NULL, archiverNames, archiverIndex);
|
||||
if(index >= 0)
|
||||
if (index >= 0)
|
||||
{
|
||||
const CArcInfoEx &prevArchiverInfo = codecs->Formats[prevFormat];
|
||||
if (prevArchiverInfo.KeepName)
|
||||
@@ -653,18 +597,12 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
workDirInfo.Load();
|
||||
|
||||
UString fullArchiveName;
|
||||
if (!MyGetFullPathName(archiveName, fullArchiveName))
|
||||
FString fullArchiveName;
|
||||
if (!MyGetFullPathName(us2fs(archiveName), fullArchiveName))
|
||||
return E_FAIL;
|
||||
|
||||
UString workDir = GetWorkDir(workDirInfo, fullArchiveName);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
CTempFileW tempFile;
|
||||
UString tempFileName;
|
||||
if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
|
||||
return E_FAIL;
|
||||
|
||||
CWorkDirTempFile tempFile;
|
||||
RINOK(tempFile.CreateTempFile(fullArchiveName));
|
||||
|
||||
CScreenRestorer screenRestorer;
|
||||
CProgressBox progressBox;
|
||||
@@ -678,12 +616,12 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
|
||||
|
||||
|
||||
NFind::CFileInfoW fileInfo;
|
||||
NFind::CFileInfo fileInfo;
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
|
||||
CMyComPtr<IInFolderArchive> archiveHandler;
|
||||
if(fileInfo.Find(fullArchiveName))
|
||||
if (fileInfo.Find(fullArchiveName))
|
||||
{
|
||||
if (fileInfo.IsDir())
|
||||
throw "There is Directory with such name";
|
||||
@@ -702,7 +640,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
throw "Type of existing archive differs from specified type";
|
||||
HRESULT result = archiveHandler.QueryInterface(
|
||||
IID_IOutFolderArchive, &outArchive);
|
||||
if(result != S_OK)
|
||||
if (result != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return E_FAIL;
|
||||
@@ -726,15 +664,11 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
|
||||
CRecordVector<const wchar_t *> fileNamePointers;
|
||||
fileNamePointers.Reserve(fileNames.Size());
|
||||
for(i = 0; i < fileNames.Size(); i++)
|
||||
for (i = 0; i < fileNames.Size(); i++)
|
||||
fileNamePointers.Add(fileNames[i]);
|
||||
|
||||
outArchive->SetFolder(NULL);
|
||||
// CSysString aCurrentFolder;
|
||||
// MyGetCurrentDirectory(aCurrentFolder);
|
||||
// outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
|
||||
outArchive->SetFiles(L"",
|
||||
&fileNamePointers.Front(), fileNamePointers.Size());
|
||||
outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size());
|
||||
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
|
||||
@@ -749,7 +683,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
|
||||
HRESULT result = outArchive->DoOperation(
|
||||
codecs, archiverIndex,
|
||||
tempFileName, actionSetByte,
|
||||
tempFile.OutStream, actionSetByte,
|
||||
NULL, updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
@@ -760,21 +694,14 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
return result;
|
||||
}
|
||||
|
||||
if(archiveHandler)
|
||||
if (archiveHandler)
|
||||
{
|
||||
archiveHandler->Close();
|
||||
if (!DeleteFileAlways(fullArchiveName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
}
|
||||
tempFile.DisableDeleting();
|
||||
if (!MyMoveFile(tempFileName, fullArchiveName))
|
||||
if (!tempFile.MoveToOriginal(archiveHandler != NULL))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "Windows/COM.h"
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
#include "Windows/Thread.h"
|
||||
@@ -31,7 +33,7 @@ using namespace NFind;
|
||||
extern DWORD g_ComCtl32Version;
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
static LPCWSTR kTempDirPrefix = L"7zE";
|
||||
static CFSTR kTempDirPrefix = FTEXT("7zE");
|
||||
|
||||
void CPanelCallbackImp::OnTab()
|
||||
{
|
||||
@@ -374,7 +376,7 @@ static void ReducePathToRealFileSystemPath(UString &path)
|
||||
{
|
||||
while (!path.IsEmpty())
|
||||
{
|
||||
if (NFind::DoesDirExist(path))
|
||||
if (NFind::DoesDirExist(us2fs(path)))
|
||||
{
|
||||
NName::NormalizeDirPathPrefix(path);
|
||||
break;
|
||||
@@ -510,6 +512,8 @@ UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
|
||||
return info;
|
||||
}
|
||||
|
||||
bool IsCorrectFsName(const UString name);
|
||||
|
||||
void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
{
|
||||
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
|
||||
@@ -599,10 +603,10 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
|
||||
if (indices.Size() > 1 ||
|
||||
(!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) ||
|
||||
NFind::DoesDirExist(destPath) ||
|
||||
NFind::DoesDirExist(us2fs(destPath)) ||
|
||||
srcPanel.IsArcFolder())
|
||||
{
|
||||
NDirectory::CreateComplexDirectory(destPath);
|
||||
NDirectory::CreateComplexDirectory(us2fs(destPath));
|
||||
NName::NormalizeDirPathPrefix(destPath);
|
||||
if (!CheckFolderPath(destPath))
|
||||
{
|
||||
@@ -616,11 +620,16 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!IsCorrectFsName(destPath))
|
||||
{
|
||||
srcPanel.MessageBoxError(E_INVALIDARG);
|
||||
return;
|
||||
}
|
||||
int pos = destPath.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
if (pos >= 0)
|
||||
{
|
||||
UString prefix = destPath.Left(pos + 1);
|
||||
NDirectory::CreateComplexDirectory(prefix);
|
||||
NDirectory::CreateComplexDirectory(us2fs(prefix));
|
||||
if (!CheckFolderPath(prefix))
|
||||
{
|
||||
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
|
||||
@@ -645,8 +654,8 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
|
||||
bool useSrcPanel = (!useDestPanel || !srcPanel.IsFsOrDrivesFolder() || destPanel.IsFSFolder());
|
||||
bool useTemp = useSrcPanel && useDestPanel;
|
||||
NFile::NDirectory::CTempDirectoryW tempDirectory;
|
||||
UString tempDirPrefix;
|
||||
NFile::NDirectory::CTempDir tempDirectory;
|
||||
FString tempDirPrefix;
|
||||
if (useTemp)
|
||||
{
|
||||
tempDirectory.Create(kTempDirPrefix);
|
||||
@@ -662,7 +671,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
HRESULT result;
|
||||
if (useSrcPanel)
|
||||
{
|
||||
UString folder = useTemp ? tempDirPrefix : destPath;
|
||||
UString folder = useTemp ? fs2us(tempDirPrefix) : destPath;
|
||||
result = srcPanel.CopyTo(indices, folder, move, true, 0);
|
||||
if (result != S_OK)
|
||||
{
|
||||
@@ -681,7 +690,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
UStringVector filePaths;
|
||||
UString folderPrefix;
|
||||
if (useTemp)
|
||||
folderPrefix = tempDirPrefix;
|
||||
folderPrefix = fs2us(tempDirPrefix);
|
||||
else
|
||||
folderPrefix = srcPanel._currentFolderPrefix;
|
||||
filePaths.Reserve(indices.Size());
|
||||
|
||||
@@ -202,7 +202,7 @@ public:
|
||||
void SelectSpec(bool selectMode) { GetFocusedPanel().SelectSpec(selectMode); }
|
||||
void SelectByType(bool selectMode) { GetFocusedPanel().SelectByType(selectMode); }
|
||||
|
||||
void RefreshStatusBar() { GetFocusedPanel().RefreshStatusBar(); }
|
||||
void Refresh_StatusBar() { GetFocusedPanel().Refresh_StatusBar(); }
|
||||
|
||||
void SetListViewMode(UInt32 index) { GetFocusedPanel().SetListViewMode(index); }
|
||||
UInt32 GetListViewMode() { return GetFocusedPanel().GetListViewMode(); }
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#include "BrowseDialog.h"
|
||||
|
||||
#ifdef USE_MY_BROWSE_DIALOG
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
#include "BrowseDialog.h"
|
||||
#include "LangUtils.h"
|
||||
#include "PropertyNameRes.h"
|
||||
|
||||
@@ -60,7 +61,7 @@ bool CBrowseDialog::OnInit()
|
||||
_list.Attach(GetItem(IDC_BROWSE_LIST));
|
||||
|
||||
#ifndef UNDER_CE
|
||||
_list.SetUnicodeFormat(true);
|
||||
_list.SetUnicodeFormat();
|
||||
#endif
|
||||
|
||||
#ifndef _SFX
|
||||
@@ -191,8 +192,8 @@ int CBrowseDialog::CompareItems(LPARAM lParam1, LPARAM lParam2)
|
||||
{
|
||||
if (lParam1 == kParentIndex) return -1;
|
||||
if (lParam2 == kParentIndex) return 1;
|
||||
const CFileInfoW &f1 = _files[(int)lParam1];
|
||||
const CFileInfoW &f2 = _files[(int)lParam2];
|
||||
const CFileInfo &f1 = _files[(int)lParam1];
|
||||
const CFileInfo &f2 = _files[(int)lParam2];
|
||||
|
||||
bool isDir1 = f1.IsDir();
|
||||
bool isDir2 = f2.IsDir();
|
||||
@@ -225,12 +226,12 @@ static HRESULT GetNormalizedError()
|
||||
|
||||
HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selectedName)
|
||||
{
|
||||
CEnumeratorW enumerator(pathPrefix + L'*');
|
||||
CObjectVector<CFileInfoW> files;
|
||||
CEnumerator enumerator(us2fs(pathPrefix + L'*'));
|
||||
CObjectVector<CFileInfo> files;
|
||||
for (;;)
|
||||
{
|
||||
bool found;
|
||||
CFileInfoW fi;
|
||||
CFileInfo fi;
|
||||
if (!enumerator.Next(fi, found))
|
||||
return GetNormalizedError();
|
||||
if (!found)
|
||||
@@ -278,16 +279,17 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
|
||||
|
||||
for (int i = 0; i < _files.Size(); i++)
|
||||
{
|
||||
const CFileInfoW &fi = _files[i];
|
||||
const CFileInfo &fi = _files[i];
|
||||
item.iItem = index;
|
||||
if (fi.Name.CompareNoCase(selectedName) == 0)
|
||||
const UString name = fs2us(fi.Name);
|
||||
if (name.CompareNoCase(selectedName) == 0)
|
||||
cursorIndex = item.iItem;
|
||||
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
|
||||
int subItem = 0;
|
||||
item.iSubItem = subItem++;
|
||||
item.lParam = i;
|
||||
item.pszText = (wchar_t *)(const wchar_t *)fi.Name;
|
||||
item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, Path + fi.Name);
|
||||
item.pszText = (wchar_t *)(const wchar_t *)name;
|
||||
item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, Path + name);
|
||||
if (item.iImage < 0)
|
||||
item.iImage = 0;
|
||||
_list.InsertItem(&item);
|
||||
@@ -325,7 +327,7 @@ HRESULT CBrowseDialog::Reload()
|
||||
{
|
||||
int fileIndex = GetRealItemIndex(index);
|
||||
if (fileIndex != kParentIndex)
|
||||
selectedCur = _files[fileIndex].Name;
|
||||
selectedCur = fs2us(_files[fileIndex].Name);
|
||||
}
|
||||
return Reload(Path, selectedCur);
|
||||
}
|
||||
@@ -443,13 +445,13 @@ void CBrowseDialog::FinishOnOK()
|
||||
OpenParentFolder();
|
||||
return;
|
||||
}
|
||||
const CFileInfoW &file = _files[fileIndex];
|
||||
const CFileInfo &file = _files[fileIndex];
|
||||
if (file.IsDir() != FolderMode)
|
||||
{
|
||||
ShowSelectError();
|
||||
return;
|
||||
}
|
||||
Path += file.Name;
|
||||
Path += fs2us(file.Name);
|
||||
}
|
||||
End(IDOK);
|
||||
}
|
||||
@@ -464,7 +466,7 @@ void CBrowseDialog::OnItemEnter()
|
||||
OpenParentFolder();
|
||||
else
|
||||
{
|
||||
const CFileInfoW &file = _files[fileIndex];
|
||||
const CFileInfo &file = _files[fileIndex];
|
||||
if (!file.IsDir())
|
||||
{
|
||||
if (!FolderMode)
|
||||
@@ -473,7 +475,7 @@ void CBrowseDialog::OnItemEnter()
|
||||
ShowSelectError();
|
||||
return;
|
||||
}
|
||||
HRESULT res = Reload(Path + file.Name + WCHAR_PATH_SEPARATOR, L"");
|
||||
HRESULT res = Reload(Path + fs2us(file.Name) + WCHAR_PATH_SEPARATOR, L"");
|
||||
if (res != S_OK)
|
||||
ShowError(HResultToMessage(res));
|
||||
}
|
||||
@@ -481,6 +483,8 @@ void CBrowseDialog::OnItemEnter()
|
||||
|
||||
void CBrowseDialog::OnOK()
|
||||
{
|
||||
// When we press "Enter" in listview, windows sends message to first Button.
|
||||
// We check that message was from listview;
|
||||
if (GetFocus() == _list)
|
||||
{
|
||||
OnItemEnter();
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
#define __BROWSE_DIALOG_H
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define USE_MY_BROWSE_DIALOG
|
||||
#endif
|
||||
|
||||
#ifdef USE_MY_BROWSE_DIALOG
|
||||
|
||||
#include "Windows/FileFind.h"
|
||||
|
||||
@@ -16,7 +20,7 @@
|
||||
class CBrowseDialog: public NWindows::NControl::CModalDialog
|
||||
{
|
||||
NWindows::NControl::CListView _list;
|
||||
CObjectVector<NWindows::NFile::NFind::CFileInfoW> _files;
|
||||
CObjectVector<NWindows::NFile::NFind::CFileInfo> _files;
|
||||
CExtToIconMap _extToIconMap;
|
||||
int _sortIndex;
|
||||
bool _ascending;
|
||||
|
||||
@@ -2,12 +2,18 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileFind.h"
|
||||
|
||||
#include "../../Common/FilePathAutoRename.h"
|
||||
|
||||
#ifndef _SFX
|
||||
#include "../Common/ZipRegistry.h"
|
||||
#endif
|
||||
|
||||
#include "../GUI/ExtractRes.h"
|
||||
|
||||
#include "ExtractCallback.h"
|
||||
@@ -177,6 +183,11 @@ STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackImp::MessageError(const char *message, const FString &path)
|
||||
{
|
||||
return MessageError(GetUnicodeString(message) + fs2us(path));
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *message)
|
||||
{
|
||||
AddErrorMessage(message);
|
||||
@@ -296,7 +307,7 @@ HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, boo
|
||||
MyLoadStringW(IDS_MEM_ERROR);
|
||||
#endif
|
||||
else
|
||||
NError::MyFormatMessage(result, message2);
|
||||
message2 = NError::MyFormatMessageW(result);
|
||||
message += message2;
|
||||
}
|
||||
MessageError(message);
|
||||
@@ -339,11 +350,19 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
CPasswordDialog dialog;
|
||||
#ifndef _SFX
|
||||
bool showPassword = NExtract::Read_ShowPassword();
|
||||
dialog.ShowPassword = showPassword;
|
||||
#endif
|
||||
ProgressDialog->WaitCreating();
|
||||
if (dialog.Create(*ProgressDialog) == IDCANCEL)
|
||||
return E_ABORT;
|
||||
Password = dialog.Password;
|
||||
PasswordIsDefined = true;
|
||||
#ifndef _SFX
|
||||
if (dialog.ShowPassword != showPassword)
|
||||
NExtract::Save_ShowPassword(dialog.ShowPassword);
|
||||
#endif
|
||||
}
|
||||
return StringToBstr(Password, password);
|
||||
}
|
||||
@@ -366,19 +385,16 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
|
||||
*writeAnswer = BoolToInt(false);
|
||||
|
||||
UString destPathSpec = destPath;
|
||||
UString destPathSys = destPathSpec;
|
||||
FString destPathSys = us2fs(destPath);
|
||||
bool srcIsFolderSpec = IntToBool(srcIsFolder);
|
||||
CFileInfoW destFileInfo;
|
||||
CFileInfo destFileInfo;
|
||||
if (destFileInfo.Find(destPathSys))
|
||||
{
|
||||
if (srcIsFolderSpec)
|
||||
{
|
||||
if (!destFileInfo.IsDir())
|
||||
{
|
||||
UString message = UString(L"can not replace file \'")
|
||||
+ destPathSpec +
|
||||
UString(L"\' with folder with same name");
|
||||
RINOK(MessageError(message));
|
||||
RINOK(MessageError("can not replace file with folder with same name: ", destPathSys));
|
||||
return E_ABORT;
|
||||
}
|
||||
*writeAnswer = BoolToInt(false);
|
||||
@@ -386,10 +402,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
|
||||
}
|
||||
if (destFileInfo.IsDir())
|
||||
{
|
||||
UString message = UString(L"can not replace folder \'")
|
||||
+ destPathSpec +
|
||||
UString(L"\' with file with same name");
|
||||
RINOK(MessageError(message));
|
||||
RINOK(MessageError("can not replace folder with file with same name: ", destPathSys));
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
@@ -432,19 +445,15 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
|
||||
{
|
||||
if (!AutoRenamePath(destPathSys))
|
||||
{
|
||||
UString message = UString(L"can not create name of file ")
|
||||
+ destPathSys;
|
||||
RINOK(MessageError(message));
|
||||
RINOK(MessageError("can not create name for file: ", destPathSys));
|
||||
return E_ABORT;
|
||||
}
|
||||
destPathResultTemp = destPathSys;
|
||||
destPathResultTemp = fs2us(destPathSys);
|
||||
}
|
||||
else
|
||||
if (!NFile::NDirectory::DeleteFileAlways(destPathSys))
|
||||
{
|
||||
UString message = UString(L"can not delete output file ")
|
||||
+ destPathSys;
|
||||
RINOK(MessageError(message));
|
||||
RINOK(MessageError("can not delete output file: ", destPathSys));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class CExtractCallbackImp:
|
||||
#endif
|
||||
public CMyUnknownImp
|
||||
{
|
||||
HRESULT MessageError(const char *message, const FString &path);
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN2(IFolderOperationsExtractCallback)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback)
|
||||
|
||||
@@ -33,7 +33,9 @@ using namespace NFind;
|
||||
|
||||
#define MENU_HEIGHT 26
|
||||
|
||||
#ifdef _WIN32
|
||||
HINSTANCE g_hInstance;
|
||||
#endif
|
||||
HWND g_HWND;
|
||||
bool g_OpenArchive = false;
|
||||
static UString g_MainPath;
|
||||
@@ -114,7 +116,7 @@ public:
|
||||
};
|
||||
|
||||
static bool g_CanChangeSplitter = false;
|
||||
static UINT32 g_SplitterPos = 0;
|
||||
static UInt32 g_SplitterPos = 0;
|
||||
static CSplitterPos g_Splitter;
|
||||
static bool g_PanelsInfoDefined = false;
|
||||
|
||||
@@ -208,7 +210,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
ySize = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
UINT32 numPanels, currentPanel;
|
||||
UInt32 numPanels, currentPanel;
|
||||
g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos);
|
||||
if (g_PanelsInfoDefined)
|
||||
{
|
||||
@@ -409,6 +411,30 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
/*
|
||||
#ifndef _WIN64
|
||||
#ifndef UNDER_CE
|
||||
{
|
||||
HMODULE hMod = GetModuleHandle("Kernel32.dll");
|
||||
if (hMod)
|
||||
{
|
||||
typedef BOOL (WINAPI *PSETDEP)(DWORD);
|
||||
#define MY_PROCESS_DEP_ENABLE 1
|
||||
PSETDEP procSet = (PSETDEP)GetProcAddress(hMod,"SetProcessDEPPolicy");
|
||||
if (procSet)
|
||||
procSet(MY_PROCESS_DEP_ENABLE);
|
||||
|
||||
typedef BOOL (WINAPI *HSI)(HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
|
||||
HSI hsi = (HSI)GetProcAddress(hMod, "HeapSetInformation");
|
||||
#define MY_HeapEnableTerminationOnCorruption ((HEAP_INFORMATION_CLASS)1)
|
||||
if (hsi)
|
||||
hsi(NULL, MY_HeapEnableTerminationOnCorruption, NULL, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
|
||||
NT_CHECK
|
||||
SetLargePageSize();
|
||||
|
||||
@@ -639,7 +665,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
bool needOpenFile = false;
|
||||
if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
|
||||
{
|
||||
if (NFile::NFind::DoesFileExist(g_MainPath))
|
||||
if (NFile::NFind::DoesFileExist(us2fs(g_MainPath)))
|
||||
needOpenFile = true;
|
||||
}
|
||||
HRESULT res = g_App.Create(hWnd, g_MainPath, g_ArcFormat, xSizes, archiveIsOpened, encrypted);
|
||||
@@ -665,8 +691,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
if (res == E_OUTOFMEMORY)
|
||||
message = LangString(IDS_MEM_ERROR, 0x0200060B);
|
||||
else
|
||||
if (!NError::MyFormatMessage(res, message))
|
||||
message = L"Error";
|
||||
message = NError::MyFormatMessageW(res);
|
||||
}
|
||||
}
|
||||
MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
|
||||
|
||||
@@ -26,9 +26,9 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
static const wchar_t *kVolPrefix = L"\\\\.\\";
|
||||
static CFSTR kVolPrefix = FTEXT("\\\\.\\");
|
||||
|
||||
UString CDriveInfo::GetDeviceFileIoName() const
|
||||
FString CDriveInfo::GetDeviceFileIoName() const
|
||||
{
|
||||
return kVolPrefix + Name;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ struct CPhysTempBuffer
|
||||
~CPhysTempBuffer() { MidFree(buffer); }
|
||||
};
|
||||
|
||||
static HRESULT CopyFileSpec(LPCWSTR fromPath, LPCWSTR toPath, bool writeToDisk, UInt64 fileSize,
|
||||
static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt64 fileSize,
|
||||
UInt32 bufferSize, UInt64 progressStart, IProgress *progress)
|
||||
{
|
||||
NFile::NIO::CInFile inFile;
|
||||
@@ -120,17 +120,17 @@ STDMETHODIMP CFSDrives::LoadItems()
|
||||
{
|
||||
_drives.Clear();
|
||||
|
||||
UStringVector driveStrings;
|
||||
FStringVector driveStrings;
|
||||
MyGetLogicalDriveStrings(driveStrings);
|
||||
for (int i = 0; i < driveStrings.Size(); i++)
|
||||
{
|
||||
CDriveInfo di;
|
||||
|
||||
const UString &driveName = driveStrings[i];
|
||||
const FString &driveName = driveStrings[i];
|
||||
|
||||
di.FullSystemName = driveName;
|
||||
|
||||
di.Name = di.FullSystemName.Left(di.FullSystemName.Length() - 1);
|
||||
if (!driveName.IsEmpty())
|
||||
di.Name = driveName.Left(driveName.Length() - 1);
|
||||
di.ClusterSize = 0;
|
||||
di.DriveSize = 0;
|
||||
di.FreeSpace = 0;
|
||||
@@ -150,14 +150,11 @@ STDMETHODIMP CFSDrives::LoadItems()
|
||||
}
|
||||
if (needRead)
|
||||
{
|
||||
UString volumeName, fileSystemName;
|
||||
DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
|
||||
NFile::NSystem::MyGetVolumeInformation(driveName,
|
||||
volumeName,
|
||||
di.VolumeName,
|
||||
&volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
|
||||
fileSystemName);
|
||||
di.VolumeName = volumeName;
|
||||
di.FileSystemName = fileSystemName;
|
||||
di.FileSystemName);
|
||||
|
||||
NFile::NSystem::MyGetDiskFreeSpace(driveName,
|
||||
di.ClusterSize, di.DriveSize, di.FreeSpace);
|
||||
@@ -198,7 +195,7 @@ STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CFSDrives::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
HRESULT CFSDrives::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
if (_volumeMode)
|
||||
@@ -232,7 +229,7 @@ STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
|
||||
STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
{
|
||||
return BindToFolderSpec(name, resultFolder);
|
||||
return BindToFolderSpec(us2fs(name), resultFolder);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
@@ -252,7 +249,7 @@ STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value)
|
||||
case kpidType: prop = L"FSDrives"; break;
|
||||
case kpidPath:
|
||||
if (_volumeMode)
|
||||
prop = kVolPrefix;
|
||||
prop = fs2us(kVolPrefix);
|
||||
else
|
||||
prop = LangString(IDS_COMPUTER, 0x03020300) + UString(WCHAR_PATH_SEPARATOR);
|
||||
break;
|
||||
@@ -325,7 +322,7 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
UString destPath = path;
|
||||
if (destPath.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
|
||||
bool directName = (destPath.Back() != WCHAR_PATH_SEPARATOR);
|
||||
if (directName)
|
||||
{
|
||||
if (numItems > 1)
|
||||
@@ -339,18 +336,18 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
int index = indices[i];
|
||||
const CDriveInfo &di = _drives[index];
|
||||
UString destPath2 = destPath;
|
||||
UString name = di.Name;
|
||||
UString name = fs2us(di.Name);
|
||||
if (!directName)
|
||||
{
|
||||
UString destName = name;
|
||||
if (!destName.IsEmpty() && destName[destName.Length() - 1] == L':')
|
||||
if (!destName.IsEmpty() && destName.Back() == L':')
|
||||
{
|
||||
destName.Delete(destName.Length() - 1);
|
||||
destName.DeleteBack();
|
||||
destName += GetExt(index);
|
||||
}
|
||||
destPath2 += destName;
|
||||
}
|
||||
UString srcPath = di.GetDeviceFileIoName();
|
||||
FString srcPath = di.GetDeviceFileIoName();
|
||||
|
||||
UInt64 fileSize = 0;
|
||||
if (GetLength(index, fileSize) != S_OK)
|
||||
@@ -363,16 +360,16 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
Int32 writeAskResult;
|
||||
CMyComBSTR destPathResult;
|
||||
RINOK(callback->AskWrite(srcPath, BoolToInt(false), NULL, &fileSize,
|
||||
RINOK(callback->AskWrite(fs2us(srcPath), BoolToInt(false), NULL, &fileSize,
|
||||
destPath2, &destPathResult, &writeAskResult));
|
||||
if (!IntToBool(writeAskResult))
|
||||
continue;
|
||||
|
||||
RINOK(callback->SetCurrentFilePath(srcPath));
|
||||
RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
|
||||
|
||||
static const UInt32 kBufferSize = (4 << 20);
|
||||
UInt32 bufferSize = (di.DriveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
|
||||
RINOK(CopyFileSpec(srcPath, destPathResult, false, fileSize, bufferSize, completedSize, callback));
|
||||
RINOK(CopyFileSpec(srcPath, us2fs(destPathResult), false, fileSize, bufferSize, completedSize, callback));
|
||||
completedSize += fileSize;
|
||||
}
|
||||
return S_OK;
|
||||
@@ -393,6 +390,11 @@ STDMETHODIMP CFSDrives::CopyFrom(const wchar_t * /* fromFolderPath */,
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
struct CDriveInfo
|
||||
{
|
||||
UString Name;
|
||||
UString FullSystemName;
|
||||
FString Name;
|
||||
FString FullSystemName;
|
||||
bool KnownSizes;
|
||||
UInt64 DriveSize;
|
||||
UInt64 FreeSpace;
|
||||
@@ -21,7 +21,7 @@ struct CDriveInfo
|
||||
UString FileSystemName;
|
||||
UINT DriveType;
|
||||
|
||||
UString GetDeviceFileIoName() const;
|
||||
FString GetDeviceFileIoName() const;
|
||||
};
|
||||
|
||||
class CFSDrives:
|
||||
@@ -33,7 +33,7 @@ class CFSDrives:
|
||||
CObjectVector<CDriveInfo> _drives;
|
||||
bool _volumeMode;
|
||||
|
||||
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
|
||||
UString GetExt(int index) const;
|
||||
HRESULT GetLength(int index, UInt64 &length) const;
|
||||
public:
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace NWindows {
|
||||
namespace NFile {
|
||||
|
||||
bool GetLongPath(LPCWSTR path, UString &longPath);
|
||||
bool GetLongPath(CFSTR path, UString &longPath);
|
||||
|
||||
}}
|
||||
|
||||
@@ -47,7 +47,7 @@ static STATPROPSTG kProps[] =
|
||||
{ NULL, kpidPrefix, VT_BSTR}
|
||||
};
|
||||
|
||||
HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
|
||||
HRESULT CFSFolder::Init(const FString &path, IFolderFolder *parentFolder)
|
||||
{
|
||||
_parentFolder = parentFolder;
|
||||
_path = path;
|
||||
@@ -65,25 +65,25 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
|
||||
{
|
||||
DWORD lastError = GetLastError();
|
||||
CFindFile findFile;
|
||||
CFileInfoW fi;
|
||||
if (!findFile.FindFirst(_path + UString(L"*"), fi))
|
||||
CFileInfo fi;
|
||||
if (!findFile.FindFirst(_path + FCHAR_ANY_MASK, fi))
|
||||
return lastError;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
|
||||
static HRESULT GetFolderSize(const FString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
|
||||
{
|
||||
RINOK(progress->SetCompleted(NULL));
|
||||
numFiles = numFolders = size = 0;
|
||||
CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*"));
|
||||
CFileInfoW fi;
|
||||
CEnumerator enumerator(path + FSTRING_PATH_SEPARATOR FSTRING_ANY_MASK);
|
||||
CFileInfo fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
if (fi.IsDir())
|
||||
{
|
||||
UInt64 subFolders, subFiles, subSize;
|
||||
RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fi.Name, subFolders, subFiles, subSize, progress));
|
||||
RINOK(GetFolderSize(path + FCHAR_PATH_SEPARATOR + fi.Name, subFolders, subFiles, subSize, progress));
|
||||
numFolders += subFolders;
|
||||
numFolders++;
|
||||
numFiles += subFiles;
|
||||
@@ -98,10 +98,10 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
|
||||
HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const FString &path)
|
||||
{
|
||||
{
|
||||
CEnumeratorW enumerator(path + L"*");
|
||||
CEnumerator enumerator(path + FCHAR_ANY_MASK);
|
||||
CDirItem fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
@@ -128,7 +128,7 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
|
||||
{
|
||||
CDirItem &item = dirItem.Files[i];
|
||||
if (item.IsDir())
|
||||
LoadSubItems(item, path + item.Name + WCHAR_PATH_SEPARATOR);
|
||||
LoadSubItems(item, path + item.Name + FCHAR_PATH_SEPARATOR);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ STDMETHODIMP CFSFolder::LoadItems()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const wchar_t *kDescriptionFileName = L"descript.ion";
|
||||
static CFSTR kDescriptionFileName = FTEXT("descript.ion");
|
||||
|
||||
bool CFSFolder::LoadComments()
|
||||
{
|
||||
@@ -244,10 +244,10 @@ STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
|
||||
*/
|
||||
|
||||
#ifndef UNDER_CE
|
||||
static bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
|
||||
static bool MyGetCompressedFileSizeW(CFSTR fileName, UInt64 &size)
|
||||
{
|
||||
DWORD highPart;
|
||||
DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
|
||||
DWORD lowPart = ::GetCompressedFileSizeW(fs2us(fileName), &highPart);
|
||||
if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
|
||||
{
|
||||
#ifdef WIN_LONG_PATH
|
||||
@@ -274,7 +274,7 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
|
||||
switch(propID)
|
||||
{
|
||||
case kpidIsDir: prop = fi.IsDir(); break;
|
||||
case kpidName: prop = fi.Name; break;
|
||||
case kpidName: prop = fs2us(fi.Name); break;
|
||||
case kpidSize: if (!fi.IsDir()) prop = fi.Size; break;
|
||||
case kpidPackSize:
|
||||
#ifdef UNDER_CE
|
||||
@@ -298,7 +298,7 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
|
||||
{
|
||||
LoadComments();
|
||||
UString comment;
|
||||
if (_comments.GetValue(GetRelPath(fi), comment))
|
||||
if (_comments.GetValue(fs2us(GetRelPath(fi)), comment))
|
||||
prop = comment;
|
||||
break;
|
||||
}
|
||||
@@ -313,29 +313,29 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
HRESULT CFSFolder::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
CFSFolder *folderSpec = new CFSFolder;
|
||||
CMyComPtr<IFolderFolder> subFolder = folderSpec;
|
||||
RINOK(folderSpec->Init(_path + name + UString(WCHAR_PATH_SEPARATOR), 0));
|
||||
RINOK(folderSpec->Init(_path + name + FCHAR_PATH_SEPARATOR, 0));
|
||||
*resultFolder = subFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
UString CFSFolder::GetPrefix(const CDirItem &item) const
|
||||
FString CFSFolder::GetPrefix(const CDirItem &item) const
|
||||
{
|
||||
UString path;
|
||||
FString path;
|
||||
CDirItem *cur = item.Parent;
|
||||
while (cur->Parent != 0)
|
||||
{
|
||||
path = cur->Name + UString(WCHAR_PATH_SEPARATOR) + path;
|
||||
path = cur->Name + FCHAR_PATH_SEPARATOR + path;
|
||||
cur = cur->Parent;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
UString CFSFolder::GetRelPath(const CDirItem &item) const
|
||||
FString CFSFolder::GetRelPath(const CDirItem &item) const
|
||||
{
|
||||
return GetPrefix(item) + item.Name;
|
||||
}
|
||||
@@ -351,7 +351,7 @@ STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
|
||||
STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
{
|
||||
return BindToFolderSpec(name, resultFolder);
|
||||
return BindToFolderSpec(us2fs(name), resultFolder);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
@@ -365,11 +365,11 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
}
|
||||
if (_path.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
int pos = _path.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
int pos = _path.ReverseFind(FCHAR_PATH_SEPARATOR);
|
||||
if (pos < 0 || pos != _path.Length() - 1)
|
||||
return E_FAIL;
|
||||
UString parentPath = _path.Left(pos);
|
||||
pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
FString parentPath = _path.Left(pos);
|
||||
pos = parentPath.ReverseFind(FCHAR_PATH_SEPARATOR);
|
||||
if (pos < 0)
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
@@ -382,17 +382,17 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
UString parentPathReduced = parentPath.Left(pos);
|
||||
FString parentPathReduced = parentPath.Left(pos);
|
||||
parentPath = parentPath.Left(pos + 1);
|
||||
#ifndef UNDER_CE
|
||||
pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
pos = parentPathReduced.ReverseFind(FCHAR_PATH_SEPARATOR);
|
||||
if (pos == 1)
|
||||
{
|
||||
if (parentPath[0] != WCHAR_PATH_SEPARATOR)
|
||||
if (parentPath[0] != FCHAR_PATH_SEPARATOR)
|
||||
return E_FAIL;
|
||||
CNetFolder *netFolderSpec = new CNetFolder;
|
||||
CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
|
||||
netFolderSpec->Init(parentPath);
|
||||
netFolderSpec->Init(fs2us(parentPath));
|
||||
*resultFolder = netFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
|
||||
switch(propID)
|
||||
{
|
||||
case kpidType: prop = L"FSFolder"; break;
|
||||
case kpidPath: prop = _path; break;
|
||||
case kpidPath: prop = fs2us(_path); break;
|
||||
}
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
@@ -532,13 +532,13 @@ STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgr
|
||||
return result;
|
||||
}
|
||||
|
||||
HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
|
||||
HRESULT CFSFolder::GetComplexName(CFSTR name, FString &resultPath)
|
||||
{
|
||||
UString newName = name;
|
||||
FString newName = name;
|
||||
resultPath = _path + newName;
|
||||
if (newName.Length() < 1)
|
||||
return S_OK;
|
||||
if (newName[0] == WCHAR_PATH_SEPARATOR)
|
||||
if (newName[0] == FCHAR_PATH_SEPARATOR)
|
||||
{
|
||||
resultPath = newName;
|
||||
return S_OK;
|
||||
@@ -552,11 +552,11 @@ HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
|
||||
|
||||
STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */)
|
||||
{
|
||||
UString processedName;
|
||||
RINOK(GetComplexName(name, processedName));
|
||||
if(NDirectory::MyCreateDirectory(processedName))
|
||||
FString processedName;
|
||||
RINOK(GetComplexName(us2fs(name), processedName));
|
||||
if (NDirectory::MyCreateDirectory(processedName))
|
||||
return S_OK;
|
||||
if(::GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
if (::GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
return ::GetLastError();
|
||||
if (!NDirectory::CreateComplexDirectory(processedName))
|
||||
return ::GetLastError();
|
||||
@@ -565,8 +565,8 @@ STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progres
|
||||
|
||||
STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */)
|
||||
{
|
||||
UString processedName;
|
||||
RINOK(GetComplexName(name, processedName));
|
||||
FString processedName;
|
||||
RINOK(GetComplexName(us2fs(name), processedName));
|
||||
NIO::COutFile outFile;
|
||||
if (!outFile.Create(processedName, false))
|
||||
return ::GetLastError();
|
||||
@@ -576,8 +576,8 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress
|
||||
STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */)
|
||||
{
|
||||
const CDirItem &fi = *_refs[index];
|
||||
const UString fullPrefix = _path + GetPrefix(fi);
|
||||
if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + newName))
|
||||
const FString fullPrefix = _path + GetPrefix(fi);
|
||||
if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + us2fs(newName)))
|
||||
return GetLastError();
|
||||
return S_OK;
|
||||
}
|
||||
@@ -588,7 +588,7 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
const CDirItem &fi = *_refs[indices[i]];
|
||||
const UString fullPath = _path + GetRelPath(fi);
|
||||
const FString fullPath = _path + GetRelPath(fi);
|
||||
bool result;
|
||||
if (fi.IsDir())
|
||||
result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
|
||||
@@ -614,7 +614,7 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
|
||||
{
|
||||
case kpidComment:
|
||||
{
|
||||
UString filename = fi.Name;
|
||||
UString filename = fs2us(fi.Name);
|
||||
filename.Trim();
|
||||
if (value->vt == VT_EMPTY)
|
||||
_comments.DeletePair(filename);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// FSFolder.h
|
||||
|
||||
#ifndef __FSFOLDER_H
|
||||
#define __FSFOLDER_H
|
||||
#ifndef __FS_FOLDER_H
|
||||
#define __FS_FOLDER_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace NFsFolder {
|
||||
|
||||
class CFSFolder;
|
||||
|
||||
struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
|
||||
struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfo
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
bool CompressedSizeIsDefined;
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
|
||||
|
||||
private:
|
||||
UString _path;
|
||||
FString _path;
|
||||
CDirItem _root;
|
||||
CRecordVector<CDirItem *> _refs;
|
||||
|
||||
@@ -90,24 +90,24 @@ private:
|
||||
HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
|
||||
UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
|
||||
HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
|
||||
HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
|
||||
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
HRESULT GetComplexName(CFSTR name, FString &resultPath);
|
||||
HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
|
||||
|
||||
bool LoadComments();
|
||||
bool SaveComments();
|
||||
HRESULT LoadSubItems(CDirItem &dirItem, const UString &path);
|
||||
HRESULT LoadSubItems(CDirItem &dirItem, const FString &path);
|
||||
void AddRefs(CDirItem &dirItem);
|
||||
public:
|
||||
HRESULT Init(const UString &path, IFolderFolder *parentFolder);
|
||||
HRESULT Init(const FString &path, IFolderFolder *parentFolder);
|
||||
#ifdef UNDER_CE
|
||||
HRESULT InitToRoot() { return Init(L"\\", NULL); }
|
||||
HRESULT InitToRoot() { return Init(FTEXT("\\"), NULL); }
|
||||
#endif
|
||||
|
||||
CFSFolder() : _flatMode(false) {}
|
||||
|
||||
UString GetPrefix(const CDirItem &item) const;
|
||||
UString GetRelPath(const CDirItem &item) const;
|
||||
UString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
|
||||
FString GetPrefix(const CDirItem &item) const;
|
||||
FString GetRelPath(const CDirItem &item) const;
|
||||
FString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
|
||||
|
||||
void Clear()
|
||||
{
|
||||
@@ -116,8 +116,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,13 +102,7 @@ typedef BOOL (WINAPI * CopyFileExPointerW)(
|
||||
IN DWORD dwCopyFlags
|
||||
);
|
||||
|
||||
#ifndef _UNICODE
|
||||
static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
static CSysString GetSysPath(LPCWSTR sysPath)
|
||||
{ return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
|
||||
#endif
|
||||
|
||||
static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
|
||||
static bool MyCopyFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, UInt64 &completedSize)
|
||||
{
|
||||
CProgressInfo progressInfo;
|
||||
progressInfo.Progress = progress;
|
||||
@@ -128,8 +122,8 @@ static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
|
||||
CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
|
||||
My_GetProcAddress(::GetModuleHandleW(k_DllName), "CopyFileExW");
|
||||
if (copyFunctionW == 0)
|
||||
return BOOLToBool(::CopyFileW(existingFile, newFile, TRUE));
|
||||
if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
|
||||
return BOOLToBool(::CopyFileW(fs2us(existingFile), fs2us(newFile), TRUE));
|
||||
if (copyFunctionW(fs2us(existingFile), fs2us(newFile), CopyProgressRoutine,
|
||||
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
|
||||
return true;
|
||||
#ifdef WIN_LONG_PATH
|
||||
@@ -150,13 +144,13 @@ static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
|
||||
"CopyFileExA");
|
||||
if (copyFunction != 0)
|
||||
{
|
||||
if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
|
||||
if (copyFunction(fs2fas(existingFile), fs2fas(newFile),
|
||||
CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
|
||||
return true;
|
||||
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return false;
|
||||
}
|
||||
return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
|
||||
return BOOLToBool(::CopyFile(fs2fas(existingFile), fs2fas(newFile), TRUE));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -169,7 +163,7 @@ typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
|
||||
IN DWORD dwFlags
|
||||
);
|
||||
|
||||
static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
|
||||
static bool MyMoveFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, UInt64 &completedSize)
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
// if (IsItWindows2000orHigher())
|
||||
@@ -184,7 +178,7 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
|
||||
if (moveFunction != 0)
|
||||
{
|
||||
if (moveFunction(
|
||||
existingFile, newFile, CopyProgressRoutine,
|
||||
fs2us(existingFile), fs2us(newFile), CopyProgressRoutine,
|
||||
&progressInfo, MOVEFILE_COPY_ALLOWED))
|
||||
return true;
|
||||
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
@@ -207,41 +201,48 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
|
||||
return NDirectory::MyMoveFile(existingFile, newFile);
|
||||
}
|
||||
|
||||
static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
|
||||
const wchar_t *message, const FString &fileName)
|
||||
{
|
||||
return callback->ShowMessage(message + fs2us(fileName));
|
||||
}
|
||||
|
||||
static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
|
||||
const char *message, const FString &fileName)
|
||||
{
|
||||
return SendMessageError(callback, MultiByteToUnicodeString(message), fileName);
|
||||
}
|
||||
|
||||
static HRESULT MyCopyFile(
|
||||
const UString &srcPath,
|
||||
const CFileInfoW &srcFileInfo,
|
||||
const UString &destPathSpec,
|
||||
const FString &srcPath,
|
||||
const CFileInfo &srcFileInfo,
|
||||
const FString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UInt64 &completedSize)
|
||||
{
|
||||
UString destPath = destPathSpec;
|
||||
FString destPath = destPathSpec;
|
||||
if (destPath.CompareNoCase(srcPath) == 0)
|
||||
{
|
||||
UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, "can not copy file onto itself: ", destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
Int32 writeAskResult;
|
||||
CMyComBSTR destPathResult;
|
||||
RINOK(callback->AskWrite(
|
||||
srcPath,
|
||||
fs2us(srcPath),
|
||||
BoolToInt(false),
|
||||
&srcFileInfo.MTime, &srcFileInfo.Size,
|
||||
destPath,
|
||||
fs2us(destPath),
|
||||
&destPathResult,
|
||||
&writeAskResult));
|
||||
if (IntToBool(writeAskResult))
|
||||
{
|
||||
UString destPathNew = UString(destPathResult);
|
||||
RINOK(callback->SetCurrentFilePath(srcPath));
|
||||
FString destPathNew = us2fs(destPathResult);
|
||||
RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
|
||||
if (!MyCopyFile(srcPath, destPathNew, callback, completedSize))
|
||||
{
|
||||
UString message = NError::MyFormatMessageW(GetLastError()) +
|
||||
UString(L" \'") +
|
||||
UString(destPathNew) +
|
||||
UString(L"\'");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, NError::MyFormatMessageW(GetLastError()) + L" : ", destPathNew));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
@@ -249,44 +250,41 @@ static HRESULT MyCopyFile(
|
||||
return callback->SetCompleted(&completedSize);
|
||||
}
|
||||
|
||||
static UString CombinePath(const UString &folderPath, const UString &fileName)
|
||||
static FString CombinePath(const FString &folderPath, const FString &fileName)
|
||||
{
|
||||
return folderPath + UString(WCHAR_PATH_SEPARATOR) + fileName;
|
||||
return folderPath + FCHAR_PATH_SEPARATOR + fileName;
|
||||
}
|
||||
|
||||
static HRESULT CopyFolder(
|
||||
const UString &srcPath,
|
||||
const UString &destPathSpec,
|
||||
const FString &srcPath,
|
||||
const FString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UInt64 &completedSize)
|
||||
{
|
||||
RINOK(callback->SetCompleted(&completedSize));
|
||||
|
||||
const UString destPath = destPathSpec;
|
||||
const FString destPath = destPathSpec;
|
||||
int len = srcPath.Length();
|
||||
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
|
||||
{
|
||||
if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
|
||||
if (destPath.Length() == len || destPath[len] == FCHAR_PATH_SEPARATOR)
|
||||
{
|
||||
UString message = UString(L"can not copy folder \'") +
|
||||
destPath + UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, "can not copy folder onto itself: ", destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NDirectory::CreateComplexDirectory(destPath))
|
||||
{
|
||||
UString message = UString(L"can not create folder ") + destPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, "can not create folder: ", destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
CEnumeratorW enumerator(CombinePath(srcPath, L"*"));
|
||||
CEnumerator enumerator(CombinePath(srcPath, FSTRING_ANY_MASK));
|
||||
CFileInfoEx fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
const UString srcPath2 = CombinePath(srcPath, fi.Name);
|
||||
const UString destPath2 = CombinePath(destPath, fi.Name);
|
||||
const FString srcPath2 = CombinePath(srcPath, fi.Name);
|
||||
const FString destPath2 = CombinePath(destPath, fi.Name);
|
||||
if (fi.IsDir())
|
||||
{
|
||||
RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize))
|
||||
@@ -313,7 +311,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
UString destPath = path;
|
||||
if (destPath.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
|
||||
bool directName = (destPath.Back() != WCHAR_PATH_SEPARATOR);
|
||||
if (directName)
|
||||
{
|
||||
if (numItems > 1)
|
||||
@@ -337,10 +335,10 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
const CDirItem &fi = *_refs[indices[i]];
|
||||
UString destPath2 = destPath;
|
||||
FString destPath2 = us2fs(destPath);
|
||||
if (!directName)
|
||||
destPath2 += fi.Name;
|
||||
UString srcPath = _path + GetPrefix(fi) + fi.Name;
|
||||
FString srcPath = _path + GetPrefix(fi) + fi.Name;
|
||||
if (fi.IsDir())
|
||||
{
|
||||
RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
|
||||
@@ -356,40 +354,35 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
/////////////////////////////////////////////////
|
||||
// Move Operations
|
||||
|
||||
HRESULT MyMoveFile(
|
||||
const UString &srcPath,
|
||||
const CFileInfoW &srcFileInfo,
|
||||
const UString &destPathSpec,
|
||||
static HRESULT MyMoveFile(
|
||||
const FString &srcPath,
|
||||
const CFileInfo &srcFileInfo,
|
||||
const FString &destPath,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UInt64 &completedSize)
|
||||
{
|
||||
UString destPath = destPathSpec;
|
||||
if (destPath.CompareNoCase(srcPath) == 0)
|
||||
{
|
||||
UString message = UString(L"can not move file \'")
|
||||
+ destPath +
|
||||
UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, "can not move file onto itself: ", srcPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
Int32 writeAskResult;
|
||||
CMyComBSTR destPathResult;
|
||||
RINOK(callback->AskWrite(
|
||||
srcPath,
|
||||
fs2us(srcPath),
|
||||
BoolToInt(false),
|
||||
&srcFileInfo.MTime, &srcFileInfo.Size,
|
||||
destPath,
|
||||
fs2us(destPath),
|
||||
&destPathResult,
|
||||
&writeAskResult));
|
||||
if (IntToBool(writeAskResult))
|
||||
{
|
||||
UString destPathNew = UString(destPathResult);
|
||||
RINOK(callback->SetCurrentFilePath(srcPath));
|
||||
FString destPathNew = us2fs(destPathResult);
|
||||
RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
|
||||
if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
|
||||
{
|
||||
UString message = UString(L"can not move to file ") + destPathNew;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, "can not move to file: ", destPathNew));
|
||||
}
|
||||
}
|
||||
completedSize += srcFileInfo.Size;
|
||||
@@ -397,21 +390,18 @@ HRESULT MyMoveFile(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT MyMoveFolder(
|
||||
const UString &srcPath,
|
||||
const UString &destPathSpec,
|
||||
static HRESULT MyMoveFolder(
|
||||
const FString &srcPath,
|
||||
const FString &destPath,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UInt64 &completedSize)
|
||||
{
|
||||
UString destPath = destPathSpec;
|
||||
int len = srcPath.Length();
|
||||
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
|
||||
{
|
||||
if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
|
||||
if (destPath.Length() == len || destPath[len] == FCHAR_PATH_SEPARATOR)
|
||||
{
|
||||
UString message = UString(L"can not move folder \'") +
|
||||
destPath + UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, "can not move folder onto itself: ", destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
@@ -421,17 +411,16 @@ HRESULT MyMoveFolder(
|
||||
|
||||
if (!NDirectory::CreateComplexDirectory(destPath))
|
||||
{
|
||||
UString message = UString(L"can not create folder ") + destPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, "can not create folder: ", destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
{
|
||||
CEnumeratorW enumerator(CombinePath(srcPath, L"*"));
|
||||
CEnumerator enumerator(CombinePath(srcPath, FSTRING_ANY_MASK));
|
||||
CFileInfoEx fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
const UString srcPath2 = CombinePath(srcPath, fi.Name);
|
||||
const UString destPath2 = CombinePath(destPath, fi.Name);
|
||||
const FString srcPath2 = CombinePath(srcPath, fi.Name);
|
||||
const FString destPath2 = CombinePath(destPath, fi.Name);
|
||||
if (fi.IsDir())
|
||||
{
|
||||
RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
|
||||
@@ -444,8 +433,7 @@ HRESULT MyMoveFolder(
|
||||
}
|
||||
if (!NDirectory::MyRemoveDirectory(srcPath))
|
||||
{
|
||||
UString message = UString(L"can not remove folder") + srcPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, "can not remove folder: ", srcPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
return S_OK;
|
||||
@@ -465,10 +453,10 @@ STDMETHODIMP CFSFolder::MoveTo(
|
||||
RINOK(callback->SetTotal(totalSize));
|
||||
RINOK(callback->SetNumFiles(numFiles));
|
||||
|
||||
UString destPath = path;
|
||||
FString destPath = us2fs(path);
|
||||
if (destPath.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
|
||||
bool directName = (destPath.Back() != FCHAR_PATH_SEPARATOR);
|
||||
if (directName)
|
||||
{
|
||||
if (numItems > 1)
|
||||
@@ -477,9 +465,7 @@ STDMETHODIMP CFSFolder::MoveTo(
|
||||
else
|
||||
if (!NDirectory::CreateComplexDirectory(destPath))
|
||||
{
|
||||
UString message = UString(L"can not create folder ") +
|
||||
destPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
RINOK(SendMessageError(callback, "can not create folder: ", destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
@@ -488,10 +474,10 @@ STDMETHODIMP CFSFolder::MoveTo(
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
const CDirItem &fi = *_refs[indices[i]];
|
||||
UString destPath2 = destPath;
|
||||
FString destPath2 = destPath;
|
||||
if (!directName)
|
||||
destPath2 += fi.Name;
|
||||
UString srcPath = _path + GetPrefix(fi) + fi.Name;
|
||||
FString srcPath = _path + GetPrefix(fi) + fi.Name;
|
||||
if (fi.IsDir())
|
||||
{
|
||||
RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
|
||||
@@ -515,7 +501,7 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
|
||||
{
|
||||
UString path = (UString)fromFolderPath + itemsPaths[i];
|
||||
|
||||
CFileInfoW fi;
|
||||
CFileInfo fi;
|
||||
if (!FindFile(path, fi))
|
||||
return ::GetLastError();
|
||||
if (fi.IsDir())
|
||||
@@ -544,4 +530,9 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Thread.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
@@ -11,11 +12,9 @@
|
||||
#include "LangUtils.h"
|
||||
#include "OpenCallback.h"
|
||||
#include "PluginLoader.h"
|
||||
#include "RegistryAssociations.h"
|
||||
#include "RegistryPlugins.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NRegistryAssociations;
|
||||
|
||||
struct CThreadArchiveOpen
|
||||
{
|
||||
@@ -56,9 +55,29 @@ static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &
|
||||
}
|
||||
*/
|
||||
|
||||
static const FChar kExtensionDelimiter = FTEXT('.');
|
||||
|
||||
static void SplitNameToPureNameAndExtension(const FString &fullName,
|
||||
FString &pureName, FString &extensionDelimiter, FString &extension)
|
||||
{
|
||||
int index = fullName.ReverseFind(kExtensionDelimiter);
|
||||
if (index < 0)
|
||||
{
|
||||
pureName = fullName;
|
||||
extensionDelimiter.Empty();
|
||||
extension.Empty();
|
||||
}
|
||||
else
|
||||
{
|
||||
pureName = fullName.Left(index);
|
||||
extensionDelimiter = kExtensionDelimiter;
|
||||
extension = fullName.Mid(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT OpenFileFolderPlugin(
|
||||
IInStream *inStream,
|
||||
const UString &path,
|
||||
const FString &path,
|
||||
const UString &arcFormat,
|
||||
HMODULE *module,
|
||||
IFolderFolder **resultFolder,
|
||||
@@ -68,11 +87,11 @@ HRESULT OpenFileFolderPlugin(
|
||||
CObjectVector<CPluginInfo> plugins;
|
||||
ReadFileFolderPluginInfoList(plugins);
|
||||
|
||||
UString extension, name, pureName, dot;
|
||||
FString extension, name, pureName, dot;
|
||||
|
||||
int slashPos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
UString dirPrefix;
|
||||
UString fileName;
|
||||
int slashPos = path.ReverseFind(FCHAR_PATH_SEPARATOR);
|
||||
FString dirPrefix;
|
||||
FString fileName;
|
||||
if (slashPos >= 0)
|
||||
{
|
||||
dirPrefix = path.Left(slashPos + 1);
|
||||
@@ -81,7 +100,7 @@ HRESULT OpenFileFolderPlugin(
|
||||
else
|
||||
fileName = path;
|
||||
|
||||
NFile::NName::SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
|
||||
SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
|
||||
|
||||
/*
|
||||
if (!extension.IsEmpty())
|
||||
@@ -124,12 +143,12 @@ HRESULT OpenFileFolderPlugin(
|
||||
t.OpenCallbackSpec->ParentWindow = parentWindow;
|
||||
|
||||
if (inStream)
|
||||
t.OpenCallbackSpec->SetSubArchiveName(fileName);
|
||||
t.OpenCallbackSpec->SetSubArchiveName(fs2us(fileName));
|
||||
else
|
||||
t.OpenCallbackSpec->LoadFileInfo(dirPrefix, fileName);
|
||||
|
||||
t.InStream = inStream;
|
||||
t.Path = path;
|
||||
t.Path = fs2us(path);
|
||||
t.ArcFormat = arcFormat;
|
||||
|
||||
UString progressTitle = LangString(IDS_OPENNING, 0x03020283);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef __FILE_FOLDER_PLUGIN_OPEN_H
|
||||
#define __FILE_FOLDER_PLUGIN_OPEN_H
|
||||
|
||||
HRESULT OpenFileFolderPlugin(IInStream *inStream, const UString &path, const UString &arcFormat,
|
||||
HRESULT OpenFileFolderPlugin(IInStream *inStream, const FString &path, const UString &arcFormat,
|
||||
HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,73 +2,39 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
#include "FilePlugins.h"
|
||||
#include "PluginLoader.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
using namespace NRegistryAssociations;
|
||||
|
||||
int CExtDatabase::FindExtInfoBig(const UString &ext)
|
||||
int CExtDatabase::FindExt(const UString &ext)
|
||||
{
|
||||
for (int i = 0; i < ExtBigItems.Size(); i++)
|
||||
if (ExtBigItems[i].Ext.CompareNoCase(ext) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CExtDatabase::FindPlugin(const UString &plugin)
|
||||
{
|
||||
for (int i = 0; i < Plugins.Size(); i++)
|
||||
if (Plugins[i].Name.CompareNoCase(plugin) == 0)
|
||||
for (int i = 0; i < Exts.Size(); i++)
|
||||
if (Exts[i].Ext.CompareNoCase(ext) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CExtDatabase::Read()
|
||||
{
|
||||
/*
|
||||
CObjectVector<CExtInfo> extItems;
|
||||
ReadInternalAssociations(extItems);
|
||||
*/
|
||||
ReadFileFolderPluginInfoList(Plugins);
|
||||
/*
|
||||
for (int i = 0; i < extItems.Size(); i++)
|
||||
{
|
||||
const CExtInfo &extInfo = extItems[i];
|
||||
CExtInfoBig extInfoBig;
|
||||
extInfoBig.Ext = extInfo.Ext;
|
||||
extInfoBig.Associated = false;
|
||||
for (int p = 0; p < extInfo.Plugins.Size(); p++)
|
||||
{
|
||||
int pluginIndex = FindPlugin(extInfo.Plugins[p]);
|
||||
if (pluginIndex >= 0)
|
||||
extInfoBig.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, true));
|
||||
}
|
||||
ExtBigItems.Add(extInfoBig);
|
||||
}
|
||||
*/
|
||||
for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++)
|
||||
{
|
||||
const CPluginInfo &pluginInfo = Plugins[pluginIndex];
|
||||
const CPluginInfo &plugin = Plugins[pluginIndex];
|
||||
|
||||
CPluginLibrary pluginLibrary;
|
||||
CPluginLibrary pluginLib;
|
||||
CMyComPtr<IFolderManager> folderManager;
|
||||
|
||||
if (pluginInfo.FilePath.IsEmpty())
|
||||
if (plugin.FilePath.IsEmpty())
|
||||
folderManager = new CArchiveFolderManager;
|
||||
else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath,
|
||||
pluginInfo.ClassID, &folderManager) != S_OK)
|
||||
else if (pluginLib.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK)
|
||||
continue;
|
||||
CMyComBSTR extBSTR;
|
||||
if (folderManager->GetExtensions(&extBSTR) != S_OK)
|
||||
return;
|
||||
const UString ext2 = (const wchar_t *)extBSTR;
|
||||
UStringVector exts;
|
||||
SplitString(ext2, exts);
|
||||
SplitString((const wchar_t *)extBSTR, exts);
|
||||
for (int i = 0; i < exts.Size(); i++)
|
||||
{
|
||||
const UString &ext = exts[i];
|
||||
@@ -76,44 +42,28 @@ void CExtDatabase::Read()
|
||||
if (ext == L"cab")
|
||||
continue;
|
||||
#endif
|
||||
int index = FindExtInfoBig(ext);
|
||||
if (index < 0)
|
||||
{
|
||||
CExtInfoBig extInfo;
|
||||
extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
|
||||
extInfo.Associated = false;
|
||||
extInfo.Ext = ext;
|
||||
ExtBigItems.Add(extInfo);
|
||||
}
|
||||
|
||||
Int32 iconIndex;
|
||||
CMyComBSTR iconPath;
|
||||
CPluginToIcon plugPair;
|
||||
plugPair.PluginIndex = pluginIndex;
|
||||
if (folderManager->GetIconPath(ext, &iconPath, &iconIndex) == S_OK)
|
||||
if (iconPath != 0)
|
||||
{
|
||||
plugPair.IconPath = (const wchar_t *)iconPath;
|
||||
plugPair.IconIndex = iconIndex;
|
||||
}
|
||||
|
||||
int index = FindExt(ext);
|
||||
if (index >= 0)
|
||||
Exts[index].Plugins.Add(plugPair);
|
||||
else
|
||||
{
|
||||
CExtInfoBig &extInfo = ExtBigItems[index];
|
||||
int pluginIndexIndex = extInfo.FindPlugin(pluginIndex);
|
||||
if (pluginIndexIndex < 0)
|
||||
extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
|
||||
CExtPlugins extInfo;
|
||||
extInfo.Plugins.Add(plugPair);
|
||||
extInfo.Ext = ext;
|
||||
Exts.Add(extInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CExtDatabase::Save()
|
||||
{
|
||||
/*
|
||||
CObjectVector<CExtInfo> extItems;
|
||||
for (int i = 0; i < ExtBigItems.Size(); i++)
|
||||
{
|
||||
const CExtInfoBig &extInfoBig = ExtBigItems[i];
|
||||
CExtInfo extInfo;
|
||||
// extInfo.Enabled = extInfoBig.Associated;
|
||||
extInfo.Ext = extInfoBig.Ext;
|
||||
for (int p = 0; p < extInfoBig.PluginsPairs.Size(); p++)
|
||||
{
|
||||
CPluginEnabledPair pluginPair = extInfoBig.PluginsPairs[p];
|
||||
if (pluginPair.Enabled)
|
||||
extInfo.Plugins.Add(Plugins[pluginPair.Index].Name);
|
||||
}
|
||||
extItems.Add(extInfo);
|
||||
}
|
||||
WriteInternalAssociations(extItems);
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,54 +1,33 @@
|
||||
// FilePlugins.h
|
||||
|
||||
#ifndef __FILEPLUGINS_H
|
||||
#define __FILEPLUGINS_H
|
||||
#ifndef __FILE_PLUGINS_H
|
||||
#define __FILE_PLUGINS_H
|
||||
|
||||
#include "RegistryPlugins.h"
|
||||
#include "RegistryAssociations.h"
|
||||
|
||||
struct CPluginEnabledPair
|
||||
struct CPluginToIcon
|
||||
{
|
||||
int Index;
|
||||
bool Enabled;
|
||||
CPluginEnabledPair(int index, bool enabled): Index(index),Enabled(enabled) {}
|
||||
int PluginIndex;
|
||||
UString IconPath;
|
||||
int IconIndex;
|
||||
|
||||
CPluginToIcon(): IconIndex(-1) {}
|
||||
};
|
||||
|
||||
struct CExtInfoBig
|
||||
struct CExtPlugins
|
||||
{
|
||||
UString Ext;
|
||||
bool Associated;
|
||||
CRecordVector<CPluginEnabledPair> PluginsPairs;
|
||||
int FindPlugin(int pluginIndex)
|
||||
{
|
||||
for (int i = 0; i < PluginsPairs.Size(); i++)
|
||||
if (PluginsPairs[i].Index == pluginIndex)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
CObjectVector<CPluginToIcon> Plugins;
|
||||
};
|
||||
|
||||
class CExtDatabase
|
||||
{
|
||||
int FindExt(const UString &ext);
|
||||
public:
|
||||
CObjectVector<CExtInfoBig> ExtBigItems;
|
||||
CObjectVector<CExtPlugins> Exts;
|
||||
CObjectVector<CPluginInfo> Plugins;
|
||||
int FindExtInfoBig(const UString &ext);
|
||||
int FindPlugin(const UString &plugin);
|
||||
|
||||
UString GetMainPluginNameForExtItem(int extIndex) const
|
||||
{
|
||||
const CExtInfoBig &extInfo = ExtBigItems[extIndex];
|
||||
if (extInfo.PluginsPairs.IsEmpty())
|
||||
return UString();
|
||||
else
|
||||
return Plugins[extInfo.PluginsPairs.Front().Index].Name;
|
||||
}
|
||||
|
||||
|
||||
void Read();
|
||||
void Save();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ bool CFoldersPage::OnInit()
|
||||
m_WorkPath.Init(*this, IDC_FOLDERS_WORK_EDIT_PATH);
|
||||
m_ButtonSetWorkPath.Init(*this, IDC_FOLDERS_WORK_BUTTON_PATH);
|
||||
|
||||
m_WorkPath.SetText(m_WorkDirInfo.Path);
|
||||
m_WorkPath.SetText(fs2us(m_WorkDirInfo.Path));
|
||||
|
||||
MyEnableControls();
|
||||
|
||||
@@ -66,7 +66,9 @@ void CFoldersPage::MyEnableControls()
|
||||
|
||||
void CFoldersPage::GetWorkDir(NWorkDir::CInfo &workDirInfo)
|
||||
{
|
||||
m_WorkPath.GetText(workDirInfo.Path);
|
||||
UString s;
|
||||
m_WorkPath.GetText(s);
|
||||
workDirInfo.Path = us2fs(s);
|
||||
workDirInfo.ForRemovableOnly = IsButtonCheckedBool(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE);
|
||||
workDirInfo.Mode = NWorkDir::NMode::EEnum(GetWorkMode());
|
||||
}
|
||||
@@ -143,7 +145,7 @@ LONG CFoldersPage::OnApply()
|
||||
return PSNRET_NOERROR;
|
||||
}
|
||||
|
||||
static LPCWSTR kFoldersTopic = L"fm/plugins/7-zip/options.htm#folders";
|
||||
static LPCWSTR kFoldersTopic = L"fm/options.htm#folders";
|
||||
|
||||
void CFoldersPage::OnNotifyHelp()
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <HtmlHelp.h>
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/DLL.h"
|
||||
#include "HelpUtils.h"
|
||||
#include "ProgramLocation.h"
|
||||
|
||||
static LPCWSTR kHelpFileName = L"7-zip.chm::/";
|
||||
|
||||
@@ -17,11 +17,7 @@ void ShowHelpWindow(HWND, LPCWSTR)
|
||||
#else
|
||||
void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
|
||||
{
|
||||
UString path;
|
||||
if (!::GetProgramFolderPath(path))
|
||||
return;
|
||||
path += kHelpFileName;
|
||||
path += topicFile;
|
||||
HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);
|
||||
FString path = NWindows::NDLL::GetModuleDirPrefix();
|
||||
HtmlHelp(hwnd, GetSystemString(fs2us(path) + kHelpFileName + topicFile), HH_DISPLAY_TOPIC, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -70,8 +70,9 @@ FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B)
|
||||
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath, \
|
||||
const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress) x; \
|
||||
STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) x; \
|
||||
STDMETHOD(CopyFromFile)(UInt32 index, const wchar_t *fullFilePath, IProgress *progress) x; \
|
||||
|
||||
FOLDER_INTERFACE(IFolderOperations, 0x06)
|
||||
FOLDER_INTERFACE(IFolderOperations, 0x12)
|
||||
{
|
||||
INTERFACE_FolderOperations(PURE)
|
||||
};
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "LangUtils.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/StringToInt.h"
|
||||
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/Synchronization.h"
|
||||
#include "Windows/Window.h"
|
||||
#include "Windows/FileFind.h"
|
||||
|
||||
#include "LangUtils.h"
|
||||
#include "RegistryUtils.h"
|
||||
#include "ProgramLocation.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -20,20 +22,23 @@ UString g_LangID;
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
static FString GetLangDirPrefix()
|
||||
{
|
||||
return NDLL::GetModuleDirPrefix() + FString(FTEXT("Lang") FSTRING_PATH_SEPARATOR);
|
||||
}
|
||||
|
||||
void ReloadLang()
|
||||
{
|
||||
ReadRegLang(g_LangID);
|
||||
g_Lang.Clear();
|
||||
if (!g_LangID.IsEmpty() && g_LangID != L"-")
|
||||
{
|
||||
UString langPath = g_LangID;
|
||||
FString langPath = us2fs(g_LangID);
|
||||
if (langPath.Find(WCHAR_PATH_SEPARATOR) < 0)
|
||||
{
|
||||
if (langPath.Find(L'.') < 0)
|
||||
langPath += L".txt";
|
||||
UString folderPath;
|
||||
if (GetProgramFolderPath(folderPath))
|
||||
langPath = folderPath + UString(L"Lang" WSTRING_PATH_SEPARATOR) + langPath;
|
||||
if (langPath.Find(FTEXT('.')) < 0)
|
||||
langPath += FTEXT(".txt");
|
||||
langPath = GetLangDirPrefix() + langPath;
|
||||
}
|
||||
g_Lang.Open(langPath);
|
||||
}
|
||||
@@ -51,7 +56,7 @@ void LoadLangOneTime()
|
||||
ReloadLang();
|
||||
}
|
||||
|
||||
void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems)
|
||||
void LangSetDlgItemsText(HWND dialogWindow, const CIDLangPair *idLangPairs, int numItems)
|
||||
{
|
||||
for (int i = 0; i < numItems; i++)
|
||||
{
|
||||
@@ -85,30 +90,26 @@ UString LangString(UINT resourceID, UInt32 langID)
|
||||
UString message;
|
||||
if (g_Lang.GetMessage(langID, message))
|
||||
return message;
|
||||
return NWindows::MyLoadStringW(resourceID);
|
||||
return MyLoadStringW(resourceID);
|
||||
}
|
||||
|
||||
void LoadLangs(CObjectVector<CLangEx> &langs)
|
||||
{
|
||||
langs.Clear();
|
||||
UString folderPath;
|
||||
if (!::GetProgramFolderPath(folderPath))
|
||||
return;
|
||||
folderPath += L"Lang" WSTRING_PATH_SEPARATOR;
|
||||
NWindows::NFile::NFind::CEnumeratorW enumerator(folderPath + L"*.txt");
|
||||
NWindows::NFile::NFind::CFileInfoW fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
const FString dirPrefix = GetLangDirPrefix();
|
||||
NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt"));
|
||||
NFile::NFind::CFileInfo fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
if (fileInfo.IsDir())
|
||||
if (fi.IsDir())
|
||||
continue;
|
||||
const int kExtSize = 4;
|
||||
const FString ext = fi.Name.Right(kExtSize);
|
||||
if (ext.CompareNoCase(FTEXT(".txt")) != 0)
|
||||
continue;
|
||||
CLangEx lang;
|
||||
UString filePath = folderPath + fileInfo.Name;
|
||||
const int kExtSize = 4;
|
||||
const UString ext = fileInfo.Name.Right(kExtSize);
|
||||
if (ext.CompareNoCase(L".txt") != 0)
|
||||
continue;
|
||||
lang.ShortName = fileInfo.Name.Left(fileInfo.Name.Length() - kExtSize);
|
||||
if (lang.Lang.Open(filePath))
|
||||
lang.ShortName = fs2us(fi.Name.Left(fi.Name.Length() - kExtSize));
|
||||
if (lang.Lang.Open(dirPrefix + fi.Name))
|
||||
langs.Add(lang);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// LangUtils.h
|
||||
|
||||
#ifndef __LANGUTILS_H
|
||||
#define __LANGUTILS_H
|
||||
#ifndef __LANG_UTILS_H
|
||||
#define __LANG_UTILS_H
|
||||
|
||||
#include "Common/Lang.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
@@ -26,7 +26,7 @@ struct CLangEx
|
||||
|
||||
void LoadLangs(CObjectVector<CLangEx> &langs);
|
||||
|
||||
void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems);
|
||||
void LangSetDlgItemsText(HWND dialogWindow, const CIDLangPair *idLangPairs, int numItems);
|
||||
void LangSetWindowText(HWND window, UInt32 langID);
|
||||
|
||||
UString LangString(UInt32 langID);
|
||||
|
||||
@@ -125,17 +125,12 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
|
||||
}
|
||||
case 'A':
|
||||
{
|
||||
// probably that code is unused ?
|
||||
/*
|
||||
bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
|
||||
if (ctrl)
|
||||
{
|
||||
int numItems = _listView.GetItemCount();
|
||||
for (int i = 0; i < numItems; i++)
|
||||
_listView.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
|
||||
_listView.SelectAll();
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ static CIDLangPair kIDLangPairs[] =
|
||||
{ IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS, 0x01000310}
|
||||
};
|
||||
|
||||
static LPCWSTR kSystemTopic = L"fm/plugins/7-zip/options.htm#system";
|
||||
static LPCWSTR kSystemTopic = L"fm/options.htm#sevenZip";
|
||||
|
||||
struct CContextMenuItem
|
||||
{
|
||||
|
||||
@@ -51,10 +51,7 @@ bool CMessagesDialog::OnInit()
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
#endif
|
||||
_messageList.Attach(GetItem(IDC_MESSAGE_LIST));
|
||||
|
||||
#ifndef UNDER_CE
|
||||
_messageList.SetUnicodeFormat(true);
|
||||
#endif
|
||||
_messageList.SetUnicodeFormat();
|
||||
|
||||
_messageList.InsertColumn(0, L"", 30);
|
||||
|
||||
|
||||
@@ -513,6 +513,13 @@ bool ExecuteFileCommand(int id)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void MyBenchmark(bool totalMode)
|
||||
{
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]);
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]);
|
||||
Benchmark(totalMode);
|
||||
}
|
||||
|
||||
bool OnMenuCommand(HWND hWnd, int id)
|
||||
{
|
||||
if (ExecuteFileCommand(id))
|
||||
@@ -538,31 +545,31 @@ bool OnMenuCommand(HWND hWnd, int id)
|
||||
break;
|
||||
case IDM_SELECT_ALL:
|
||||
g_App.SelectAll(true);
|
||||
g_App.RefreshStatusBar();
|
||||
g_App.Refresh_StatusBar();
|
||||
break;
|
||||
case IDM_DESELECT_ALL:
|
||||
g_App.SelectAll(false);
|
||||
g_App.RefreshStatusBar();
|
||||
g_App.Refresh_StatusBar();
|
||||
break;
|
||||
case IDM_INVERT_SELECTION:
|
||||
g_App.InvertSelection();
|
||||
g_App.RefreshStatusBar();
|
||||
g_App.Refresh_StatusBar();
|
||||
break;
|
||||
case IDM_SELECT:
|
||||
g_App.SelectSpec(true);
|
||||
g_App.RefreshStatusBar();
|
||||
g_App.Refresh_StatusBar();
|
||||
break;
|
||||
case IDM_DESELECT:
|
||||
g_App.SelectSpec(false);
|
||||
g_App.RefreshStatusBar();
|
||||
g_App.Refresh_StatusBar();
|
||||
break;
|
||||
case IDM_SELECT_BY_TYPE:
|
||||
g_App.SelectByType(true);
|
||||
g_App.RefreshStatusBar();
|
||||
g_App.Refresh_StatusBar();
|
||||
break;
|
||||
case IDM_DESELECT_BY_TYPE:
|
||||
g_App.SelectByType(false);
|
||||
g_App.RefreshStatusBar();
|
||||
g_App.Refresh_StatusBar();
|
||||
break;
|
||||
|
||||
//View
|
||||
@@ -646,13 +653,9 @@ bool OnMenuCommand(HWND hWnd, int id)
|
||||
OptionsDialog(hWnd, g_hInstance);
|
||||
break;
|
||||
|
||||
case IDM_BENCHMARK:
|
||||
{
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]);
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]);
|
||||
Benchmark();
|
||||
break;
|
||||
}
|
||||
case IDM_BENCHMARK: MyBenchmark(false); break;
|
||||
case IDM_BENCHMARK2: MyBenchmark(true); break;
|
||||
|
||||
// Help
|
||||
case IDM_HELP_CONTENTS:
|
||||
ShowHelpWindow(NULL, kFMHelpTopic);
|
||||
|
||||
@@ -136,8 +136,8 @@ STDMETHODIMP CNetFolder::LoadItems()
|
||||
resource.RemoteName = _path + resource.Name;
|
||||
|
||||
NFile::NFind::CFindFile findFile;
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
if (!findFile.FindFirst(resource.RemoteName + UString(WCHAR_PATH_SEPARATOR) + UString(L"*"), fileInfo))
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
if (!findFile.FindFirst(us2fs(resource.RemoteName) + FString(FCHAR_PATH_SEPARATOR) + FCHAR_ANY_MASK, fileInfo))
|
||||
continue;
|
||||
resource.Usage = RESOURCEUSAGE_CONNECTABLE;
|
||||
resource.LocalNameIsDefined = false;
|
||||
@@ -185,7 +185,7 @@ STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder
|
||||
{
|
||||
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
|
||||
CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
|
||||
RINOK(fsFolderSpec->Init(resource.RemoteName + WCHAR_PATH_SEPARATOR, this));
|
||||
RINOK(fsFolderSpec->Init(us2fs(resource.RemoteName + WCHAR_PATH_SEPARATOR), this));
|
||||
*resultFolder = subFolder.Detach();
|
||||
}
|
||||
else
|
||||
@@ -253,7 +253,7 @@ STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
|
||||
if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER ||
|
||||
resource.Usage == RESOURCEUSAGE_CONNECTABLE)
|
||||
{
|
||||
if (GetRealIconIndex(resource.RemoteName, 0, iconIndexTemp))
|
||||
if (GetRealIconIndex(us2fs(resource.RemoteName), 0, iconIndexTemp))
|
||||
{
|
||||
*iconIndex = iconIndexTemp;
|
||||
return S_OK;
|
||||
@@ -261,7 +261,7 @@ STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetRealIconIndex(TEXT(""), FILE_ATTRIBUTE_DIRECTORY, iconIndexTemp))
|
||||
if (GetRealIconIndex(FTEXT(""), FILE_ATTRIBUTE_DIRECTORY, iconIndexTemp))
|
||||
{
|
||||
*iconIndex = iconIndexTemp;
|
||||
return S_OK;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "OpenCallback.h"
|
||||
#include "PasswordDialog.h"
|
||||
|
||||
@@ -82,16 +84,15 @@ STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
|
||||
IInStream **inStream)
|
||||
STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream)
|
||||
{
|
||||
*inStream = NULL;
|
||||
if (_subArchiveMode)
|
||||
return S_FALSE;
|
||||
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
|
||||
UString fullPath = _folderPrefix + name;
|
||||
FString fullPath = _folderPrefix + us2fs(name);
|
||||
if (!fileInfo.Find(fullPath))
|
||||
return S_FALSE;
|
||||
_fileInfo = fileInfo;
|
||||
@@ -111,6 +112,8 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
CPasswordDialog dialog;
|
||||
bool showPassword = NExtract::Read_ShowPassword();
|
||||
dialog.ShowPassword = showPassword;
|
||||
|
||||
ProgressDialog.WaitCreating();
|
||||
if (dialog.Create(ProgressDialog) == IDCANCEL)
|
||||
@@ -118,6 +121,8 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
|
||||
|
||||
Password = dialog.Password;
|
||||
PasswordIsDefined = true;
|
||||
if (dialog.ShowPassword != showPassword)
|
||||
NExtract::Save_ShowPassword(dialog.ShowPassword);
|
||||
}
|
||||
return StringToBstr(Password, password);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ class COpenArchiveCallback:
|
||||
public ICryptoGetTextPassword,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
UString _folderPrefix;
|
||||
NWindows::NFile::NFind::CFileInfoW _fileInfo;
|
||||
FString _folderPrefix;
|
||||
NWindows::NFile::NFind::CFileInfo _fileInfo;
|
||||
NWindows::NSynchronization::CCriticalSection _criticalSection;
|
||||
bool _subArchiveMode;
|
||||
UString _subArchiveName;
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
_subArchiveMode = false;
|
||||
}
|
||||
*/
|
||||
void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
|
||||
void LoadFileInfo(const FString &folderPrefix, const FString &fileName)
|
||||
{
|
||||
_folderPrefix = folderPrefix;
|
||||
if (!_fileInfo.Find(_folderPrefix + fileName))
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "App.h"
|
||||
#include "LangUtils.h"
|
||||
#include "MyLoadMenu.h"
|
||||
#include "ProgramLocation.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
@@ -42,11 +41,10 @@ static void ShowMenuErrorMessage(const wchar_t *m)
|
||||
|
||||
static int DllRegisterServer2(const char *name)
|
||||
{
|
||||
NWindows::NDLL::CLibrary lib;
|
||||
NDLL::CLibrary lib;
|
||||
|
||||
UString prefix;
|
||||
GetProgramFolderPath(prefix);
|
||||
if (!lib.Load(prefix + L"7-zip.dll"))
|
||||
FString prefix = NDLL::GetModuleDirPrefix();
|
||||
if (!lib.Load(prefix + FTEXT("7-zip.dll")))
|
||||
{
|
||||
ShowMenuErrorMessage(L"7-Zip cannot load 7-zip.dll");
|
||||
return E_FAIL;
|
||||
@@ -94,7 +92,7 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */)
|
||||
CFoldersPage foldersPage;
|
||||
|
||||
CObjectVector<NControl::CPageInfo> pages;
|
||||
UINT32 langIDs[] = { 0x03010300,
|
||||
const UInt32 langIDs[] = { 0x03010300,
|
||||
// 0x03010100,
|
||||
0xFFFFFFFF,
|
||||
0x01000200, 0x03010200, 0x03010400, 0x01000400};
|
||||
|
||||
@@ -79,6 +79,7 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
|
||||
_mainWindow = mainWindow;
|
||||
_processTimer = true;
|
||||
_processNotify = true;
|
||||
_processStatusBar = true;
|
||||
|
||||
_panelCallback = panelCallback;
|
||||
_appState = appState;
|
||||
@@ -91,8 +92,11 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
|
||||
|
||||
if (!currentFolderPrefix.IsEmpty())
|
||||
if (currentFolderPrefix[0] == L'.')
|
||||
if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp))
|
||||
cfp = currentFolderPrefix;
|
||||
{
|
||||
FString cfpF;
|
||||
if (NFile::NDirectory::MyGetFullPathName(us2fs(currentFolderPrefix), cfpF))
|
||||
cfp = fs2us(cfpF);
|
||||
}
|
||||
RINOK(BindToPath(cfp, arcFormat, archiveIsOpened, encrypted));
|
||||
|
||||
if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
|
||||
@@ -104,7 +108,7 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
|
||||
|
||||
LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(message)
|
||||
switch (message)
|
||||
{
|
||||
case kShiftSelectMessage:
|
||||
OnShiftSelectMessage();
|
||||
@@ -117,12 +121,15 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return 0;
|
||||
case kOpenItemChanged:
|
||||
return OnOpenItemChanged(lParam);
|
||||
case kRefreshStatusBar:
|
||||
OnRefreshStatusBar();
|
||||
case kRefresh_StatusBar:
|
||||
if (_processStatusBar)
|
||||
Refresh_StatusBar();
|
||||
return 0;
|
||||
case kRefreshHeaderComboBox:
|
||||
#ifdef UNDER_CE
|
||||
case kRefresh_HeaderComboBox:
|
||||
LoadFullPathAndShow();
|
||||
return 0;
|
||||
#endif
|
||||
case WM_TIMER:
|
||||
OnTimer();
|
||||
return 0;
|
||||
@@ -139,15 +146,6 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return CWindow2::OnMessage(message, wParam, lParam);
|
||||
}
|
||||
|
||||
static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CWindow tempDialog(hwnd);
|
||||
CMyListView *w = (CMyListView *)(tempDialog.GetUserDataLongPtr());
|
||||
if (w == NULL)
|
||||
return 0;
|
||||
return w->OnMessage(message, wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (message == WM_CHAR)
|
||||
@@ -187,7 +185,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
// bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
|
||||
// bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
|
||||
bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
|
||||
switch(wParam)
|
||||
switch (wParam)
|
||||
{
|
||||
/*
|
||||
case VK_RETURN:
|
||||
@@ -233,12 +231,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
_panel->_lastFocusedIsList = true;
|
||||
_panel->_panelCallback->PanelWasFocused();
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
|
||||
else
|
||||
#endif
|
||||
return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
|
||||
return CListView2::OnMessage(message, wParam, lParam);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -365,21 +358,9 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
|
||||
HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL))
|
||||
return false;
|
||||
|
||||
#ifndef UNDER_CE
|
||||
_listView.SetUnicodeFormat(true);
|
||||
#endif
|
||||
|
||||
_listView.SetUserDataLongPtr(LONG_PTR(&_listView));
|
||||
_listView.SetUnicodeFormat();
|
||||
_listView._panel = this;
|
||||
|
||||
#ifndef _UNICODE
|
||||
if(g_IsNT)
|
||||
_listView._origWindowProc =
|
||||
(WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
|
||||
else
|
||||
#endif
|
||||
_listView._origWindowProc =
|
||||
(WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
|
||||
_listView.SetWindowProc();
|
||||
|
||||
_listView.SetImageList(GetSysImageList(true), LVSIL_SMALL);
|
||||
_listView.SetImageList(GetSysImageList(false), LVSIL_NORMAL);
|
||||
@@ -552,7 +533,6 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
|
||||
|
||||
// InitListCtrl();
|
||||
RefreshListCtrl();
|
||||
RefreshStatusBar();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -614,7 +594,7 @@ bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
|
||||
|
||||
bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */)
|
||||
{
|
||||
switch(header->code)
|
||||
switch (header->code)
|
||||
{
|
||||
case RBN_HEIGHTCHANGE:
|
||||
{
|
||||
@@ -790,9 +770,10 @@ void CPanel::ChangeFlatMode()
|
||||
}
|
||||
|
||||
|
||||
void CPanel::RefreshStatusBar()
|
||||
void CPanel::Post_Refresh_StatusBar()
|
||||
{
|
||||
PostMessage(kRefreshStatusBar);
|
||||
if (_processStatusBar)
|
||||
PostMessage(kRefresh_StatusBar);
|
||||
}
|
||||
|
||||
void CPanel::AddToArchive()
|
||||
@@ -953,6 +934,12 @@ void CPanel::TestArchives()
|
||||
extracter.ExtractCallbackSpec = new CExtractCallbackImp;
|
||||
extracter.ExtractCallback = extracter.ExtractCallbackSpec;
|
||||
extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog;
|
||||
if (!_parentFolders.IsEmpty())
|
||||
{
|
||||
const CFolderLink &fl = _parentFolders.Back();
|
||||
extracter.ExtractCallbackSpec->PasswordIsDefined = fl.UsePassword;
|
||||
extracter.ExtractCallbackSpec->Password = fl.Password;
|
||||
}
|
||||
|
||||
if (indices.IsEmpty())
|
||||
return;
|
||||
|
||||
@@ -85,13 +85,14 @@ public:
|
||||
|
||||
struct CTempFileInfo
|
||||
{
|
||||
UString ItemName;
|
||||
UString FolderPath;
|
||||
UString FilePath;
|
||||
NWindows::NFile::NFind::CFileInfoW FileInfo;
|
||||
UInt32 FileIndex; // index of file in folder
|
||||
UString RelPath; // Relative path of file from Folder
|
||||
FString FolderPath;
|
||||
FString FilePath;
|
||||
NWindows::NFile::NFind::CFileInfo FileInfo;
|
||||
bool NeedDelete;
|
||||
|
||||
CTempFileInfo(): NeedDelete(false) {}
|
||||
CTempFileInfo(): FileIndex((UInt32)(Int32)-1), NeedDelete(false) {}
|
||||
void DeleteDirAndFile() const
|
||||
{
|
||||
if (NeedDelete)
|
||||
@@ -100,7 +101,7 @@ struct CTempFileInfo
|
||||
NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath);
|
||||
}
|
||||
}
|
||||
bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
|
||||
bool WasChanged(const NWindows::NFile::NFind::CFileInfo &newFileInfo) const
|
||||
{
|
||||
return newFileInfo.Size != FileInfo.Size ||
|
||||
CompareFileTime(&newFileInfo.MTime, &FileInfo.MTime) != 0;
|
||||
@@ -118,7 +119,7 @@ struct CFolderLink: public CTempFileInfo
|
||||
UString VirtualPath;
|
||||
CFolderLink(): UsePassword(false), IsVirtual(false) {}
|
||||
|
||||
bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
|
||||
bool WasChanged(const NWindows::NFile::NFind::CFileInfo &newFileInfo) const
|
||||
{
|
||||
return IsVirtual || CTempFileInfo::WasChanged(newFileInfo);
|
||||
}
|
||||
@@ -131,18 +132,19 @@ enum MyMessages
|
||||
kReLoadMessage,
|
||||
kSetFocusToListView,
|
||||
kOpenItemChanged,
|
||||
kRefreshStatusBar,
|
||||
kRefreshHeaderComboBox
|
||||
kRefresh_StatusBar
|
||||
#ifdef UNDER_CE
|
||||
, kRefresh_HeaderComboBox
|
||||
#endif
|
||||
};
|
||||
|
||||
UString GetFolderPath(IFolderFolder * folder);
|
||||
|
||||
class CPanel;
|
||||
|
||||
class CMyListView: public NWindows::NControl::CListView
|
||||
class CMyListView: public NWindows::NControl::CListView2
|
||||
{
|
||||
public:
|
||||
WNDPROC _origWindowProc;
|
||||
CPanel *_panel;
|
||||
LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
@@ -482,34 +484,33 @@ public:
|
||||
|
||||
bool _processTimer;
|
||||
bool _processNotify;
|
||||
bool _processStatusBar;
|
||||
|
||||
class CDisableTimerProcessing
|
||||
{
|
||||
bool _processTimerMem;
|
||||
bool _processNotifyMem;
|
||||
bool _processStatusBarMem;
|
||||
|
||||
CPanel &_panel;
|
||||
public:
|
||||
|
||||
CDisableTimerProcessing(CPanel &panel): _panel(panel)
|
||||
{
|
||||
Disable();
|
||||
}
|
||||
CDisableTimerProcessing(CPanel &panel): _panel(panel) { Disable(); }
|
||||
~CDisableTimerProcessing() { Restore(); }
|
||||
void Disable()
|
||||
{
|
||||
_processTimerMem = _panel._processTimer;
|
||||
_processNotifyMem = _panel._processNotify;
|
||||
_processStatusBarMem = _panel._processStatusBar;
|
||||
_panel._processTimer = false;
|
||||
_panel._processNotify = false;
|
||||
_panel._processStatusBar = false;
|
||||
}
|
||||
void Restore()
|
||||
{
|
||||
_panel._processTimer = _processTimerMem;
|
||||
_panel._processNotify = _processNotifyMem;
|
||||
}
|
||||
~CDisableTimerProcessing()
|
||||
{
|
||||
Restore();
|
||||
_panel._processStatusBar = _processStatusBarMem;
|
||||
}
|
||||
CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
|
||||
};
|
||||
@@ -544,11 +545,11 @@ public:
|
||||
const UString &virtualFilePath,
|
||||
const UString &arcFormat,
|
||||
bool &encrypted);
|
||||
HRESULT OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted);
|
||||
HRESULT OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted);
|
||||
HRESULT OpenItemAsArchive(int index);
|
||||
void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
|
||||
bool editMode);
|
||||
HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password);
|
||||
HRESULT OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, bool usePassword, const UString &password);
|
||||
LRESULT OnOpenItemChanged(LPARAM lParam);
|
||||
|
||||
void OpenItem(int index, bool tryInternal, bool tryExternal);
|
||||
@@ -565,8 +566,8 @@ public:
|
||||
void ChangeFlatMode();
|
||||
bool GetFlatMode() const { return _flatMode; }
|
||||
|
||||
void RefreshStatusBar();
|
||||
void OnRefreshStatusBar();
|
||||
void Post_Refresh_StatusBar();
|
||||
void Refresh_StatusBar();
|
||||
|
||||
void AddToArchive();
|
||||
|
||||
|
||||
@@ -29,13 +29,13 @@ static const UInt32 kBufSize = (1 << 15);
|
||||
struct CDirEnumerator
|
||||
{
|
||||
bool FlatMode;
|
||||
UString BasePrefix;
|
||||
UStringVector FileNames;
|
||||
FString BasePrefix;
|
||||
FStringVector FileNames;
|
||||
|
||||
CObjectVector<NFind::CEnumeratorW> Enumerators;
|
||||
UStringVector Prefixes;
|
||||
CObjectVector<NFind::CEnumerator> Enumerators;
|
||||
FStringVector Prefixes;
|
||||
int Index;
|
||||
HRESULT GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath);
|
||||
HRESULT GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &fullPath);
|
||||
void Init();
|
||||
|
||||
CDirEnumerator(): FlatMode(false) {};
|
||||
@@ -54,7 +54,7 @@ static HRESULT GetNormalizedError()
|
||||
return (errorCode == 0) ? E_FAIL : errorCode;
|
||||
}
|
||||
|
||||
HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath)
|
||||
HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &resPath)
|
||||
{
|
||||
filled = false;
|
||||
for (;;)
|
||||
@@ -63,8 +63,8 @@ HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, U
|
||||
{
|
||||
if (Index >= FileNames.Size())
|
||||
return S_OK;
|
||||
const UString &path = FileNames[Index];
|
||||
int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
const FString &path = FileNames[Index];
|
||||
int pos = path.ReverseFind(FCHAR_PATH_SEPARATOR);
|
||||
resPath.Empty();
|
||||
if (pos >= 0)
|
||||
resPath = path.Left(pos + 1);
|
||||
@@ -106,8 +106,8 @@ HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, U
|
||||
resPath += fileInfo.Name;
|
||||
if (!FlatMode && fileInfo.IsDir())
|
||||
{
|
||||
UString prefix = resPath + WCHAR_PATH_SEPARATOR;
|
||||
Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)NName::kAnyStringWildcard));
|
||||
FString prefix = resPath + FCHAR_PATH_SEPARATOR;
|
||||
Enumerators.Add(NFind::CEnumerator(BasePrefix + prefix + FCHAR_ANY_MASK));
|
||||
Prefixes.Add(prefix);
|
||||
}
|
||||
filled = true;
|
||||
@@ -212,13 +212,13 @@ HRESULT CThreadCrc::ProcessVirt()
|
||||
|
||||
for (;;)
|
||||
{
|
||||
NFind::CFileInfoW fileInfo;
|
||||
NFind::CFileInfo fileInfo;
|
||||
bool filled;
|
||||
UString resPath;
|
||||
FString resPath;
|
||||
HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
|
||||
if (errorCode != 0)
|
||||
{
|
||||
ErrorPath1 = resPath;
|
||||
SetErrorPath1(resPath);
|
||||
return errorCode;
|
||||
}
|
||||
if (!filled)
|
||||
@@ -228,7 +228,7 @@ HRESULT CThreadCrc::ProcessVirt()
|
||||
totalSize += fileInfo.Size;
|
||||
NumFilesScan++;
|
||||
}
|
||||
sync.SetCurrentFileName(scanningStr + resPath);
|
||||
sync.SetCurrentFileName(scanningStr + fs2us(resPath));
|
||||
sync.SetProgress(totalSize, 0);
|
||||
RINOK(sync.SetPosAndCheckPaused(0));
|
||||
}
|
||||
@@ -239,13 +239,13 @@ HRESULT CThreadCrc::ProcessVirt()
|
||||
|
||||
for (;;)
|
||||
{
|
||||
NFind::CFileInfoW fileInfo;
|
||||
NFind::CFileInfo fileInfo;
|
||||
bool filled;
|
||||
UString resPath;
|
||||
FString resPath;
|
||||
HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
|
||||
if (errorCode != 0)
|
||||
{
|
||||
ErrorPath1 = resPath;
|
||||
SetErrorPath1(resPath);
|
||||
return errorCode;
|
||||
}
|
||||
if (!filled)
|
||||
@@ -263,10 +263,10 @@ HRESULT CThreadCrc::ProcessVirt()
|
||||
if (!inFile.Open(Enumerator.BasePrefix + resPath))
|
||||
{
|
||||
errorCode = GetNormalizedError();
|
||||
ErrorPath1 = resPath;
|
||||
SetErrorPath1(resPath);
|
||||
return errorCode;
|
||||
}
|
||||
sync.SetCurrentFileName(resPath);
|
||||
sync.SetCurrentFileName(fs2us(resPath));
|
||||
sync.SetNumFilesCur(NumFiles);
|
||||
NumFiles++;
|
||||
for (;;)
|
||||
@@ -275,7 +275,7 @@ HRESULT CThreadCrc::ProcessVirt()
|
||||
if (!inFile.Read(buffer, kBufSize, processedSize))
|
||||
{
|
||||
errorCode = GetNormalizedError();
|
||||
ErrorPath1 = resPath;
|
||||
SetErrorPath1(resPath);
|
||||
return errorCode;
|
||||
}
|
||||
if (processedSize == 0)
|
||||
@@ -323,8 +323,8 @@ void CApp::CalculateCrc()
|
||||
{
|
||||
CThreadCrc t;
|
||||
for (int i = 0; i < indices.Size(); i++)
|
||||
t.Enumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i]));
|
||||
t.Enumerator.BasePrefix = srcPanel.GetFsPath();
|
||||
t.Enumerator.FileNames.Add(us2fs(srcPanel.GetItemRelPath(indices[i])));
|
||||
t.Enumerator.BasePrefix = us2fs(srcPanel.GetFsPath());
|
||||
t.Enumerator.FlatMode = GetFlatMode();
|
||||
|
||||
t.ProgressDialog.ShowCompressionInfo = false;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "Windows/Memory.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Shell.h"
|
||||
|
||||
#include "../Common/ArchiveName.h"
|
||||
@@ -26,7 +27,7 @@ using namespace NWindows;
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
static wchar_t *kTempDirPrefix = L"7zE";
|
||||
static CFSTR kTempDirPrefix = FTEXT("7zE");
|
||||
static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
@@ -304,12 +305,12 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
|
||||
// CSelectedState selState;
|
||||
// SaveSelectedState(selState);
|
||||
|
||||
UString dirPrefix;
|
||||
NFile::NDirectory::CTempDirectoryW tempDirectory;
|
||||
FString dirPrefix;
|
||||
NFile::NDirectory::CTempDir tempDirectory;
|
||||
|
||||
bool isFSFolder = IsFSFolder();
|
||||
if (isFSFolder)
|
||||
dirPrefix = _currentFolderPrefix;
|
||||
dirPrefix = us2fs(_currentFolderPrefix);
|
||||
else
|
||||
{
|
||||
tempDirectory.Create(kTempDirPrefix);
|
||||
@@ -330,7 +331,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
|
||||
s = GetItemRelPath(index);
|
||||
else
|
||||
s = GetItemName(index);
|
||||
names.Add(dirPrefix + s);
|
||||
names.Add(fs2us(dirPrefix) + s);
|
||||
}
|
||||
if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names))
|
||||
return;
|
||||
@@ -341,7 +342,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
|
||||
dropSourceSpec->NeedExtract = !isFSFolder;
|
||||
dropSourceSpec->Panel = this;
|
||||
dropSourceSpec->Indices = indices;
|
||||
dropSourceSpec->Folder = dirPrefix;
|
||||
dropSourceSpec->Folder = fs2us(dirPrefix);
|
||||
dropSourceSpec->DataObjectSpec = dataObjectSpec;
|
||||
dropSourceSpec->DataObject = dataObjectSpec;
|
||||
|
||||
@@ -748,9 +749,9 @@ void CPanel::CompressDropFiles(HDROP dr)
|
||||
}
|
||||
*/
|
||||
|
||||
static bool IsFolderInTemp(const UString &path)
|
||||
static bool IsFolderInTemp(const FString &path)
|
||||
{
|
||||
UString tempPath;
|
||||
FString tempPath;
|
||||
if (!NFile::NDirectory::MyGetTempPath(tempPath))
|
||||
return false;
|
||||
if (tempPath.IsEmpty())
|
||||
@@ -760,9 +761,10 @@ static bool IsFolderInTemp(const UString &path)
|
||||
|
||||
static bool AreThereNamesFromTemp(const UStringVector &fileNames)
|
||||
{
|
||||
UString tempPath;
|
||||
if (!NFile::NDirectory::MyGetTempPath(tempPath))
|
||||
FString tempPathF;
|
||||
if (!NFile::NDirectory::MyGetTempPath(tempPathF))
|
||||
return false;
|
||||
UString tempPath = fs2us(tempPathF);
|
||||
if (tempPath.IsEmpty())
|
||||
return false;
|
||||
for (int i = 0; i < fileNames.Size(); i++)
|
||||
@@ -784,8 +786,10 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo
|
||||
UString folderPath2 = folderPath;
|
||||
if (folderPath2.IsEmpty())
|
||||
{
|
||||
NFile::NDirectory::GetOnlyDirPrefix(fileNames.Front(), folderPath2);
|
||||
if (IsFolderInTemp(folderPath2))
|
||||
FString folderPath2F;
|
||||
NFile::NDirectory::GetOnlyDirPrefix(us2fs(fileNames.Front()), folderPath2F);
|
||||
folderPath2 = fs2us(folderPath2F);
|
||||
if (IsFolderInTemp(folderPath2F))
|
||||
folderPath2 = ROOT_FS_FOLDER;
|
||||
}
|
||||
const UString archiveName = CreateArchiveName(fileNames.Front(), (fileNames.Size() > 1), false);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Wildcard.h"
|
||||
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../../PropID.h"
|
||||
@@ -73,11 +74,11 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
|
||||
CloseOpenFolders();
|
||||
UString sysPath = fullPath;
|
||||
CFileInfoW fileInfo;
|
||||
CFileInfo fileInfo;
|
||||
UStringVector reducedParts;
|
||||
while (!sysPath.IsEmpty())
|
||||
{
|
||||
if (fileInfo.Find(sysPath))
|
||||
if (fileInfo.Find(us2fs(sysPath)))
|
||||
break;
|
||||
int pos = sysPath.ReverseFind(WCHAR_PATH_SEPARATOR);
|
||||
if (pos < 0)
|
||||
@@ -104,17 +105,14 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
}
|
||||
else
|
||||
{
|
||||
UString dirPrefix;
|
||||
if (!NDirectory::GetOnlyDirPrefix(sysPath, dirPrefix))
|
||||
dirPrefix.Empty();
|
||||
if (_folder->BindToFolder(dirPrefix, &newFolder) == S_OK)
|
||||
FString dirPrefix, fileName;
|
||||
NDirectory::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
|
||||
if (_folder->BindToFolder(fs2us(dirPrefix), &newFolder) == S_OK)
|
||||
{
|
||||
_folder = newFolder;
|
||||
LoadFullPath();
|
||||
UString fileName;
|
||||
if (NDirectory::GetOnlyName(sysPath, fileName))
|
||||
{
|
||||
HRESULT res = OpenItemAsArchive(fileName, arcFormat, encrypted);
|
||||
HRESULT res = OpenItemAsArchive(fs2us(fileName), arcFormat, encrypted);
|
||||
if (res != S_FALSE)
|
||||
{
|
||||
RINOK(res);
|
||||
@@ -176,14 +174,14 @@ void CPanel::LoadFullPath()
|
||||
{
|
||||
const CFolderLink &folderLink = _parentFolders[i];
|
||||
_currentFolderPrefix += GetFolderPath(folderLink.ParentFolder);
|
||||
_currentFolderPrefix += folderLink.ItemName;
|
||||
_currentFolderPrefix += folderLink.RelPath;
|
||||
_currentFolderPrefix += WCHAR_PATH_SEPARATOR;
|
||||
}
|
||||
if (_folder)
|
||||
_currentFolderPrefix += GetFolderPath(_folder);
|
||||
}
|
||||
|
||||
static int GetRealIconIndex(LPCWSTR path, DWORD attributes)
|
||||
static int GetRealIconIndex(CFSTR path, DWORD attributes)
|
||||
{
|
||||
int index = -1;
|
||||
if (GetRealIconIndex(path, attributes, index) != 0)
|
||||
@@ -209,15 +207,22 @@ void CPanel::LoadFullPathAndShow()
|
||||
#else
|
||||
1
|
||||
#endif
|
||||
&& path[path.Length() - 1] == WCHAR_PATH_SEPARATOR)
|
||||
path.Delete(path.Length() - 1);
|
||||
&& path.Back() == WCHAR_PATH_SEPARATOR)
|
||||
path.DeleteBack();
|
||||
|
||||
CFileInfoW info;
|
||||
DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
|
||||
if (info.Find(path))
|
||||
attrib = info.Attrib;
|
||||
|
||||
item.iImage = GetRealIconIndex(path, attrib);
|
||||
|
||||
// GetRealIconIndex is slow for direct DVD/UDF path. So we use dummy path
|
||||
UString excludePrefix = L"\\\\.\\";
|
||||
UString path2 = L"_TestFolder_";
|
||||
if (excludePrefix != path.Left(excludePrefix.Length()))
|
||||
{
|
||||
path2 = path;
|
||||
CFileInfo info;
|
||||
if (info.Find(us2fs(path)))
|
||||
attrib = info.Attrib;
|
||||
}
|
||||
item.iImage = GetRealIconIndex(us2fs(path2), attrib);
|
||||
|
||||
if (item.iImage >= 0)
|
||||
{
|
||||
@@ -356,11 +361,11 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
|
||||
UString name = pathParts[i];
|
||||
sumPass += name;
|
||||
sumPass += WCHAR_PATH_SEPARATOR;
|
||||
CFileInfoW info;
|
||||
CFileInfo info;
|
||||
DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
|
||||
if (info.Find(sumPass))
|
||||
if (info.Find(us2fs(sumPass)))
|
||||
attrib = info.Attrib;
|
||||
AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(sumPass, attrib), i, false);
|
||||
AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(us2fs(sumPass), attrib), i, false);
|
||||
ComboBoxPaths.Add(sumPass);
|
||||
}
|
||||
|
||||
@@ -374,16 +379,16 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
|
||||
name = RootFolder_GetName_Computer(iconIndex);
|
||||
AddComboBoxItem(name, iconIndex, 0, true);
|
||||
|
||||
UStringVector driveStrings;
|
||||
FStringVector driveStrings;
|
||||
MyGetLogicalDriveStrings(driveStrings);
|
||||
for (i = 0; i < driveStrings.Size(); i++)
|
||||
{
|
||||
UString s = driveStrings[i];
|
||||
ComboBoxPaths.Add(s);
|
||||
FString s = driveStrings[i];
|
||||
ComboBoxPaths.Add(fs2us(s));
|
||||
int iconIndex = GetRealIconIndex(s, 0);
|
||||
if (s.Length() > 0 && s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
|
||||
s.Delete(s.Length() - 1);
|
||||
AddComboBoxItem(s, iconIndex, 1, false);
|
||||
if (s.Length() > 0 && s.Back() == FCHAR_PATH_SEPARATOR)
|
||||
s.DeleteBack();
|
||||
AddComboBoxItem(fs2us(s), iconIndex, 1, false);
|
||||
}
|
||||
|
||||
name = RootFolder_GetName_Network(iconIndex);
|
||||
@@ -407,9 +412,8 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
|
||||
{
|
||||
PostMessage(kSetFocusToListView);
|
||||
#ifdef UNDER_CE
|
||||
PostMessage(kRefreshHeaderComboBox);
|
||||
PostMessage(kRefresh_HeaderComboBox);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -522,7 +526,7 @@ void CPanel::OpenParentFolder()
|
||||
CFolderLink &link = _parentFolders.Back();
|
||||
_folder = link.ParentFolder;
|
||||
_library.Attach(link.Library.Detach());
|
||||
focucedName = link.ItemName;
|
||||
focucedName = link.RelPath;
|
||||
if (_parentFolders.Size() > 1)
|
||||
OpenParentArchiveFolder();
|
||||
_parentFolders.DeleteBack();
|
||||
@@ -540,7 +544,6 @@ void CPanel::OpenParentFolder()
|
||||
// ::SetCurrentDirectory(::_currentFolderPrefix);
|
||||
RefreshListCtrl(focucedName, -1, true, selectedItems);
|
||||
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
|
||||
RefreshStatusBar();
|
||||
}
|
||||
|
||||
void CPanel::CloseOpenFolders()
|
||||
@@ -607,7 +610,6 @@ void CPanel::OpenFolder(int index)
|
||||
LoadFullPath();
|
||||
// ::SetCurrentDirectory(::_currentFolderPrefix);
|
||||
RefreshListCtrl();
|
||||
UINT state = LVIS_SELECTED;
|
||||
_listView.SetItemState(_listView.GetFocusedItem(), state, state);
|
||||
_listView.SetItemState_Selected(_listView.GetFocusedItem());
|
||||
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <tlhelp32.h>
|
||||
|
||||
#include "Common/AutoPtr.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Process.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/Thread.h"
|
||||
@@ -33,8 +36,122 @@ using namespace NDirectory;
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
static wchar_t *kTempDirPrefix = L"7zO";
|
||||
static CFSTR kTempDirPrefix = FTEXT("7zO");
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
class CProcessSnapshot
|
||||
{
|
||||
HANDLE _handle;
|
||||
public:
|
||||
CProcessSnapshot(): _handle(INVALID_HANDLE_VALUE) {};
|
||||
~CProcessSnapshot() { Close(); }
|
||||
|
||||
bool Close()
|
||||
{
|
||||
if (_handle == INVALID_HANDLE_VALUE)
|
||||
return true;
|
||||
if (!::CloseHandle(_handle))
|
||||
return false;
|
||||
_handle = INVALID_HANDLE_VALUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Create()
|
||||
{
|
||||
_handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
return (_handle != INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
bool GetFirstProcess(PROCESSENTRY32 *pe) { return BOOLToBool(Process32First(_handle, pe)); }
|
||||
bool GetNextProcess(PROCESSENTRY32 *pe) { return BOOLToBool(Process32Next(_handle, pe)); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
typedef DWORD (WINAPI *GetProcessIdFunc)(HANDLE process);
|
||||
|
||||
class CChildProcesses
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
CRecordVector<DWORD> _ids;
|
||||
#endif
|
||||
public:
|
||||
CRecordVector<HANDLE> Handles;
|
||||
CRecordVector<bool> NeedWait;
|
||||
|
||||
~CChildProcesses() { CloseAll(); }
|
||||
void DisableWait(int index) { NeedWait[index] = false; }
|
||||
|
||||
void CloseAll()
|
||||
{
|
||||
for (int i = 0; i < Handles.Size(); i++)
|
||||
{
|
||||
HANDLE h = Handles[i];
|
||||
if (h != NULL)
|
||||
CloseHandle(h);
|
||||
}
|
||||
Handles.Clear();
|
||||
NeedWait.Clear();
|
||||
}
|
||||
|
||||
void AddProcess(HANDLE h)
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
GetProcessIdFunc func = (GetProcessIdFunc)::GetProcAddress(::GetModuleHandleA("kernel32.dll"), "GetProcessId");
|
||||
if (func)
|
||||
_ids.AddToUniqueSorted(func(h));
|
||||
#endif
|
||||
Handles.Add(h);
|
||||
NeedWait.Add(true);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
CRecordVector<DWORD> ids, parents;
|
||||
{
|
||||
CProcessSnapshot snapshot;
|
||||
if (snapshot.Create())
|
||||
{
|
||||
PROCESSENTRY32 pe;
|
||||
memset(&pe, 0, sizeof(pe));
|
||||
pe.dwSize = sizeof(pe);
|
||||
BOOL res = snapshot.GetFirstProcess(&pe);
|
||||
while (res)
|
||||
{
|
||||
ids.Add(pe.th32ProcessID);
|
||||
parents.Add(pe.th32ParentProcessID);
|
||||
res = snapshot.GetNextProcess(&pe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ids.Size(); i++)
|
||||
{
|
||||
DWORD id = ids[i];
|
||||
if (_ids.FindInSorted(parents[i]) >= 0 &&
|
||||
_ids.FindInSorted(id) < 0)
|
||||
{
|
||||
HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, id);
|
||||
if (hProcess)
|
||||
{
|
||||
_ids.AddToUniqueSorted(id);
|
||||
Handles.Add(hProcess);
|
||||
NeedWait.Add(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i == ids.Size())
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
static bool IsNameVirus(const UString &name)
|
||||
{
|
||||
@@ -43,11 +160,12 @@ static bool IsNameVirus(const UString &name)
|
||||
|
||||
struct CTmpProcessInfo: public CTempFileInfo
|
||||
{
|
||||
HANDLE ProcessHandle;
|
||||
CChildProcesses Processes;
|
||||
HWND Window;
|
||||
UString FullPathFolderPrefix;
|
||||
bool UsePassword;
|
||||
UString Password;
|
||||
|
||||
CTmpProcessInfo(): UsePassword(false) {}
|
||||
};
|
||||
|
||||
@@ -56,8 +174,8 @@ class CTmpProcessInfoRelease
|
||||
CTmpProcessInfo *_tmpProcessInfo;
|
||||
public:
|
||||
bool _needDelete;
|
||||
CTmpProcessInfoRelease(CTmpProcessInfo &tmpProcessInfo):
|
||||
_tmpProcessInfo(&tmpProcessInfo), _needDelete(true) {}
|
||||
CTmpProcessInfoRelease(CTmpProcessInfo &tpi):
|
||||
_tmpProcessInfo(&tpi), _needDelete(true) {}
|
||||
~CTmpProcessInfoRelease()
|
||||
{
|
||||
if (_needDelete)
|
||||
@@ -96,7 +214,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
|
||||
|
||||
UString password;
|
||||
RINOK(OpenFileFolderPlugin(inStream,
|
||||
folderLink.FilePath.IsEmpty() ? virtualFilePath : folderLink.FilePath,
|
||||
folderLink.FilePath.IsEmpty() ? us2fs(virtualFilePath) : folderLink.FilePath,
|
||||
arcFormat,
|
||||
&library, &newFolder, GetParent(), encrypted, password));
|
||||
|
||||
@@ -157,13 +275,14 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CPanel::OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted)
|
||||
HRESULT CPanel::OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted)
|
||||
{
|
||||
CTempFileInfo tfi;
|
||||
tfi.ItemName = name;
|
||||
tfi.FolderPath = _currentFolderPrefix;
|
||||
tfi.FilePath = _currentFolderPrefix + name;
|
||||
return OpenItemAsArchive(NULL, tfi, _currentFolderPrefix + name, arcFormat, encrypted);
|
||||
tfi.RelPath = relPath;
|
||||
tfi.FolderPath = us2fs(_currentFolderPrefix);
|
||||
const UString fullPath = _currentFolderPrefix + relPath;
|
||||
tfi.FilePath = us2fs(fullPath);
|
||||
return OpenItemAsArchive(NULL, tfi, fullPath, arcFormat, encrypted);
|
||||
}
|
||||
|
||||
HRESULT CPanel::OpenItemAsArchive(int index)
|
||||
@@ -180,21 +299,21 @@ HRESULT CPanel::OpenParentArchiveFolder()
|
||||
CDisableTimerProcessing disableTimerProcessing1(*this);
|
||||
if (_parentFolders.Size() < 2)
|
||||
return S_OK;
|
||||
const CFolderLink &folderLinkPrev = _parentFolders[_parentFolders.Size() - 2];
|
||||
const CFolderLink &folderLink = _parentFolders.Back();
|
||||
NFind::CFileInfoW newFileInfo;
|
||||
NFind::CFileInfo newFileInfo;
|
||||
if (newFileInfo.Find(folderLink.FilePath))
|
||||
{
|
||||
if (folderLink.WasChanged(newFileInfo))
|
||||
{
|
||||
UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
|
||||
0x03020280, folderLink.ItemName);
|
||||
UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, 0x03020280, folderLink.RelPath);
|
||||
if (::MessageBoxW(HWND(*this), message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
|
||||
{
|
||||
if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName,
|
||||
folderLink.UsePassword, folderLink.Password) != S_OK)
|
||||
if (OnOpenItemChanged(folderLink.FileIndex, folderLink.FilePath,
|
||||
folderLinkPrev.UsePassword, folderLinkPrev.Password) != S_OK)
|
||||
{
|
||||
::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
|
||||
0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
0x03020281, fs2us(folderLink.FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
@@ -263,9 +382,11 @@ static HRESULT StartEditApplication(const UString &path, HWND window, CProcess &
|
||||
#ifdef UNDER_CE
|
||||
command = L"\\Windows\\";
|
||||
#else
|
||||
if (!MyGetWindowsDirectory(command))
|
||||
FString winDir;
|
||||
if (!MyGetWindowsDirectory(winDir))
|
||||
return 0;
|
||||
NFile::NName::NormalizeDirPathPrefix(command);
|
||||
NFile::NName::NormalizeDirPathPrefix(winDir);
|
||||
command = fs2us(winDir);
|
||||
#endif
|
||||
command += L"notepad.exe";
|
||||
}
|
||||
@@ -466,8 +587,8 @@ class CThreadCopyFrom: public CProgressThreadVirt
|
||||
{
|
||||
HRESULT ProcessVirt();
|
||||
public:
|
||||
UString PathPrefix;
|
||||
UString Name;
|
||||
UString FullPath;
|
||||
UInt32 ItemIndex;
|
||||
|
||||
CMyComPtr<IFolderOperations> FolderOperations;
|
||||
CMyComPtr<IProgress> UpdateCallback;
|
||||
@@ -476,14 +597,10 @@ public:
|
||||
|
||||
HRESULT CThreadCopyFrom::ProcessVirt()
|
||||
{
|
||||
UStringVector fileNames;
|
||||
CRecordVector<const wchar_t *> fileNamePointers;
|
||||
fileNames.Add(Name);
|
||||
fileNamePointers.Add(fileNames[0]);
|
||||
return FolderOperations->CopyFrom(PathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), UpdateCallback);
|
||||
return FolderOperations->CopyFromFile(ItemIndex, FullPath, UpdateCallback);
|
||||
}
|
||||
|
||||
HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName,
|
||||
HRESULT CPanel::OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath,
|
||||
bool usePassword, const UString &password)
|
||||
{
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
@@ -497,41 +614,48 @@ HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item
|
||||
t.UpdateCallbackSpec = new CUpdateCallback100Imp;
|
||||
t.UpdateCallback = t.UpdateCallbackSpec;
|
||||
t.UpdateCallbackSpec->ProgressDialog = &t.ProgressDialog;
|
||||
t.Name = itemName;
|
||||
t.PathPrefix = folderPath;
|
||||
NName::NormalizeDirPathPrefix(t.PathPrefix);
|
||||
t.ItemIndex = index;
|
||||
t.FullPath = fullFilePath;
|
||||
t.FolderOperations = folderOperations;
|
||||
t.UpdateCallbackSpec->Init(usePassword, password);
|
||||
RINOK(t.Create(itemName, (HWND)*this));
|
||||
RINOK(t.Create(GetItemName(index), (HWND)*this));
|
||||
return t.Result;
|
||||
}
|
||||
|
||||
LRESULT CPanel::OnOpenItemChanged(LPARAM lParam)
|
||||
{
|
||||
CTmpProcessInfo &tmpProcessInfo = *(CTmpProcessInfo *)lParam;
|
||||
// LoadCurrentPath()
|
||||
if (tmpProcessInfo.FullPathFolderPrefix != _currentFolderPrefix)
|
||||
CTmpProcessInfo &tpi = *(CTmpProcessInfo *)lParam;
|
||||
if (tpi.FullPathFolderPrefix != _currentFolderPrefix)
|
||||
return 0;
|
||||
UInt32 fileIndex = tpi.FileIndex;
|
||||
UInt32 numItems;
|
||||
_folder->GetNumberOfItems(&numItems);
|
||||
|
||||
// This code is not 100% OK for cases when there are several files with
|
||||
// tpi.RelPath name and there are changes in archive before update.
|
||||
// So tpi.FileIndex can point to another file.
|
||||
|
||||
if (fileIndex >= numItems || GetItemRelPath(fileIndex) != tpi.RelPath)
|
||||
{
|
||||
UInt32 i;
|
||||
for (i = 0; i < numItems; i++)
|
||||
if (GetItemRelPath(i) == tpi.RelPath)
|
||||
break;
|
||||
if (i == numItems)
|
||||
return 0;
|
||||
fileIndex = i;
|
||||
}
|
||||
|
||||
CSelectedState state;
|
||||
SaveSelectedState(state);
|
||||
|
||||
HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName,
|
||||
tmpProcessInfo.UsePassword, tmpProcessInfo.Password);
|
||||
HRESULT result = OnOpenItemChanged(fileIndex, tpi.FilePath, tpi.UsePassword, tpi.Password);
|
||||
if (result != S_OK)
|
||||
return 0;
|
||||
RefreshListCtrl(state);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
class CTmpProcessInfoList
|
||||
{
|
||||
public:
|
||||
CObjectVector<CTmpProcessInfo> _items;
|
||||
} g_TmpProcessInfoList;
|
||||
*/
|
||||
|
||||
class CExitEventLauncher
|
||||
{
|
||||
public:
|
||||
@@ -547,42 +671,64 @@ public:
|
||||
static THREAD_FUNC_DECL MyThreadFunction(void *param)
|
||||
{
|
||||
CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr((CTmpProcessInfo *)param);
|
||||
const CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
|
||||
CTmpProcessInfo *tpi = tmpProcessInfoPtr.get();
|
||||
CChildProcesses &processes = tpi->Processes;
|
||||
|
||||
HANDLE hProcess = tmpProcessInfo->ProcessHandle;
|
||||
HANDLE events[2] = { g_ExitEventLauncher._exitEvent, hProcess};
|
||||
DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
|
||||
::CloseHandle(hProcess);
|
||||
if (waitResult == WAIT_OBJECT_0 + 0)
|
||||
return 0;
|
||||
if (waitResult != WAIT_OBJECT_0 + 1)
|
||||
return 1;
|
||||
Sleep(200);
|
||||
NFind::CFileInfoW newFileInfo;
|
||||
if (newFileInfo.Find(tmpProcessInfo->FilePath))
|
||||
for (;;)
|
||||
{
|
||||
if (tmpProcessInfo->WasChanged(newFileInfo))
|
||||
CRecordVector<HANDLE> handles;
|
||||
CRecordVector<int> indices;
|
||||
for (int i = 0; i < processes.Handles.Size(); i++)
|
||||
{
|
||||
if (processes.NeedWait[i])
|
||||
{
|
||||
handles.Add(processes.Handles[i]);
|
||||
indices.Add(i);
|
||||
}
|
||||
}
|
||||
if (handles.IsEmpty())
|
||||
break;
|
||||
|
||||
handles.Add(g_ExitEventLauncher._exitEvent);
|
||||
|
||||
DWORD waitResult = ::WaitForMultipleObjects(handles.Size(), &handles.Front(), FALSE, INFINITE);
|
||||
|
||||
if (waitResult >= (DWORD)handles.Size() - 1)
|
||||
{
|
||||
processes.CloseAll();
|
||||
return waitResult >= (DWORD)handles.Size() ? 1 : 0;
|
||||
}
|
||||
processes.Update();
|
||||
processes.DisableWait(indices[waitResult]);
|
||||
}
|
||||
|
||||
NFind::CFileInfo newFileInfo;
|
||||
if (newFileInfo.Find(tpi->FilePath))
|
||||
{
|
||||
if (tpi->WasChanged(newFileInfo))
|
||||
{
|
||||
UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
|
||||
0x03020280, tmpProcessInfo->ItemName);
|
||||
0x03020280, tpi->RelPath);
|
||||
if (::MessageBoxW(g_HWND, message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
|
||||
{
|
||||
if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
|
||||
if (SendMessage(tpi->Window, kOpenItemChanged, 0, (LONG_PTR)tpi) != 1)
|
||||
{
|
||||
::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
|
||||
0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
0x03020281, fs2us(tpi->FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tmpProcessInfo->DeleteDirAndFile();
|
||||
tpi->DeleteDirAndFile();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode)
|
||||
{
|
||||
const UString name = GetItemName(index);
|
||||
const UString relPath = GetItemRelPath(index);
|
||||
|
||||
if (IsNameVirus(name))
|
||||
{
|
||||
MessageBoxErrorLang(IDS_VIRUS, 0x03020284);
|
||||
@@ -598,18 +744,22 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
|
||||
bool tryAsArchive = tryInternal && (!tryExternal || !DoItemAlwaysStart(name));
|
||||
|
||||
UString fullVirtPath = _currentFolderPrefix + name;
|
||||
UString fullVirtPath = _currentFolderPrefix + relPath;
|
||||
|
||||
NFile::NDirectory::CTempDirectoryW tempDirectory;
|
||||
tempDirectory.Create(kTempDirPrefix);
|
||||
UString tempDir = tempDirectory.GetPath();
|
||||
UString tempDirNorm = tempDir;
|
||||
NFile::NDirectory::CTempDir tempDirectory;
|
||||
if (!tempDirectory.Create(kTempDirPrefix))
|
||||
{
|
||||
MessageBoxLastError();
|
||||
return;
|
||||
}
|
||||
FString tempDir = tempDirectory.GetPath();
|
||||
FString tempDirNorm = tempDir;
|
||||
NFile::NName::NormalizeDirPathPrefix(tempDirNorm);
|
||||
|
||||
UString tempFilePath = tempDirNorm + GetCorrectFsPath(name);
|
||||
FString tempFilePath = tempDirNorm + us2fs(GetCorrectFsPath(name));
|
||||
|
||||
CTempFileInfo tempFileInfo;
|
||||
tempFileInfo.ItemName = name;
|
||||
tempFileInfo.FileIndex = index;
|
||||
tempFileInfo.RelPath = relPath;
|
||||
tempFileInfo.FolderPath = tempDir;
|
||||
tempFileInfo.FilePath = tempFilePath;
|
||||
tempFileInfo.NeedDelete = true;
|
||||
@@ -655,7 +805,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
password = fl.Password;
|
||||
}
|
||||
|
||||
HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages, usePassword, password);
|
||||
HRESULT result = CopyTo(indices, fs2us(tempDirNorm), false, true, &messages, usePassword, password);
|
||||
|
||||
if (_parentFolders.Size() > 0)
|
||||
{
|
||||
@@ -686,17 +836,17 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
}
|
||||
|
||||
CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo());
|
||||
CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
|
||||
tmpProcessInfo->FolderPath = tempDir;
|
||||
tmpProcessInfo->FilePath = tempFilePath;
|
||||
tmpProcessInfo->NeedDelete = true;
|
||||
tmpProcessInfo->UsePassword = usePassword;
|
||||
tmpProcessInfo->Password = password;
|
||||
CTmpProcessInfo *tpi = tmpProcessInfoPtr.get();
|
||||
tpi->FolderPath = tempDir;
|
||||
tpi->FilePath = tempFilePath;
|
||||
tpi->NeedDelete = true;
|
||||
tpi->UsePassword = usePassword;
|
||||
tpi->Password = password;
|
||||
|
||||
if (!tmpProcessInfo->FileInfo.Find(tempFilePath))
|
||||
if (!tpi->FileInfo.Find(tempFilePath))
|
||||
return;
|
||||
|
||||
CTmpProcessInfoRelease tmpProcessInfoRelease(*tmpProcessInfo);
|
||||
CTmpProcessInfoRelease tmpProcessInfoRelease(*tpi);
|
||||
|
||||
if (!tryExternal)
|
||||
return;
|
||||
@@ -704,20 +854,21 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
CProcess process;
|
||||
HRESULT res;
|
||||
if (editMode)
|
||||
res = StartEditApplication(tempFilePath, (HWND)*this, process);
|
||||
res = StartEditApplication(fs2us(tempFilePath), (HWND)*this, process);
|
||||
else
|
||||
res = StartApplication(tempDirNorm, tempFilePath, (HWND)*this, process);
|
||||
res = StartApplication(fs2us(tempDirNorm), fs2us(tempFilePath), (HWND)*this, process);
|
||||
|
||||
if ((HANDLE)process == 0)
|
||||
return;
|
||||
|
||||
tmpProcessInfo->Window = (HWND)(*this);
|
||||
tmpProcessInfo->FullPathFolderPrefix = _currentFolderPrefix;
|
||||
tmpProcessInfo->ItemName = name;
|
||||
tmpProcessInfo->ProcessHandle = process.Detach();
|
||||
tpi->Window = (HWND)(*this);
|
||||
tpi->FullPathFolderPrefix = _currentFolderPrefix;
|
||||
tpi->FileIndex = index;
|
||||
tpi->RelPath = relPath;
|
||||
tpi->Processes.AddProcess(process.Detach());
|
||||
|
||||
NWindows::CThread thread;
|
||||
if (thread.Create(MyThreadFunction, tmpProcessInfo) != S_OK)
|
||||
if (thread.Create(MyThreadFunction, tpi) != S_OK)
|
||||
throw 271824;
|
||||
tempDirectory.DisableDeleting();
|
||||
tmpProcessInfoPtr.release();
|
||||
@@ -744,7 +895,7 @@ void DeleteOldTempFiles()
|
||||
UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
|
||||
searchWildCard += WCHAR(NName::kAnyStringWildcard);
|
||||
NFind::CEnumeratorW enumerator(searchWildCard);
|
||||
NFind::CFileInfoW fileInfo;
|
||||
NFind::CFileInfo fileInfo;
|
||||
while(enumerator.Next(fileInfo))
|
||||
{
|
||||
if (!fileInfo.IsDir())
|
||||
|
||||
@@ -416,7 +416,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
||||
if (_currentFolderPrefix.IsEmpty())
|
||||
{
|
||||
int iconIndexTemp;
|
||||
GetRealIconIndex(itemName + WCHAR_PATH_SEPARATOR, attrib, iconIndexTemp);
|
||||
GetRealIconIndex(us2fs(itemName) + FCHAR_PATH_SEPARATOR, attrib, iconIndexTemp);
|
||||
item.iImage = iconIndexTemp;
|
||||
}
|
||||
else
|
||||
@@ -450,6 +450,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
||||
/*
|
||||
_listView.UpdateWindow();
|
||||
*/
|
||||
Refresh_StatusBar();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -458,7 +459,7 @@ void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
|
||||
indices.Clear();
|
||||
/*
|
||||
int itemIndex = -1;
|
||||
while ((itemIndex = _listView.GetNextItem(itemIndex, LVNI_SELECTED)) != -1)
|
||||
while ((itemIndex = _listView.GetNextSelectedItem(itemIndex)) != -1)
|
||||
{
|
||||
LPARAM param;
|
||||
if (_listView.GetItemParam(itemIndex, param))
|
||||
@@ -481,7 +482,7 @@ void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
|
||||
int focusedItem = _listView.GetFocusedItem();
|
||||
if (focusedItem >= 0)
|
||||
{
|
||||
if (_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
|
||||
if (_listView.IsItemSelected(focusedItem))
|
||||
{
|
||||
int realIndex = GetRealItemIndex(focusedItem);
|
||||
if (realIndex != kParentIndex)
|
||||
@@ -565,8 +566,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
|
||||
if (focusedItem >= 0)
|
||||
{
|
||||
int realIndex = GetRealItemIndex(focusedItem);
|
||||
if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0) &&
|
||||
_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
|
||||
if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0) && _listView.IsItemSelected(focusedItem))
|
||||
indices.Insert(0, realIndex);
|
||||
}
|
||||
|
||||
@@ -787,7 +787,6 @@ void CPanel::OnReload()
|
||||
HRESULT res = RefreshListCtrlSaveFocused();
|
||||
if (res != S_OK)
|
||||
MessageBoxError(res);
|
||||
OnRefreshStatusBar();
|
||||
}
|
||||
|
||||
void CPanel::OnTimer()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user