Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2017-04-30 03:00:00 +0300
committerKornel <kornel@geekhood.net>2017-05-05 20:56:20 +0300
commit2efa10565ac395d2ce9a679ead46e70fb2f963eb (patch)
tree84c8df4deb69ec44ea15af9378f24347db55c357 /CPP/7zip/UI/Agent
parent603abd5528c97346e9448c0ff47949f818fe558c (diff)
17.0017.00
Diffstat (limited to 'CPP/7zip/UI/Agent')
-rw-r--r--CPP/7zip/UI/Agent/Agent.cpp55
-rw-r--r--CPP/7zip/UI/Agent/Agent.h22
-rw-r--r--CPP/7zip/UI/Agent/AgentOut.cpp49
-rw-r--r--CPP/7zip/UI/Agent/AgentProxy.cpp4
-rw-r--r--CPP/7zip/UI/Agent/ArchiveFolderOut.cpp39
-rw-r--r--CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp12
6 files changed, 118 insertions, 63 deletions
diff --git a/CPP/7zip/UI/Agent/Agent.cpp b/CPP/7zip/UI/Agent/Agent.cpp
index a9021ef9..9b841ce2 100644
--- a/CPP/7zip/UI/Agent/Agent.cpp
+++ b/CPP/7zip/UI/Agent/Agent.cpp
@@ -523,6 +523,21 @@ static const wchar_t *GetExtension(const wchar_t *name)
}
}
+
+int CAgentFolder::CompareItems3(UInt32 index1, UInt32 index2, PROPID propID)
+{
+ NCOM::CPropVariant prop1, prop2;
+ // Name must be first property
+ GetProperty(index1, propID, &prop1);
+ GetProperty(index2, propID, &prop2);
+ if (prop1.vt != prop2.vt)
+ return MyCompare(prop1.vt, prop2.vt);
+ if (prop1.vt == VT_BSTR)
+ return MyStringCompareNoCase(prop1.bstrVal, prop2.bstrVal);
+ return prop1.Compare(prop2);
+}
+
+
int CAgentFolder::CompareItems2(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw)
{
unsigned realIndex1, realIndex2;
@@ -651,21 +666,10 @@ int CAgentFolder::CompareItems2(UInt32 index1, UInt32 index2, PROPID propID, Int
if (propIsRaw)
return CompareRawProps(_agentSpec->_archiveLink.GetArchiveGetRawProps(), arcIndex1, arcIndex2, propID);
- NCOM::CPropVariant prop1, prop2;
- // Name must be first property
- GetProperty(index1, propID, &prop1);
- GetProperty(index2, propID, &prop2);
- if (prop1.vt != prop2.vt)
- {
- return MyCompare(prop1.vt, prop2.vt);
- }
- if (prop1.vt == VT_BSTR)
- {
- return _wcsicmp(prop1.bstrVal, prop2.bstrVal);
- }
- return prop1.Compare(prop2);
+ return CompareItems3(index1, index2, propID);
}
+
STDMETHODIMP_(Int32) CAgentFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw)
{
try {
@@ -811,23 +815,12 @@ STDMETHODIMP_(Int32) CAgentFolder::CompareItems(UInt32 index1, UInt32 index2, PR
return CompareRawProps(_agentSpec->_archiveLink.GetArchiveGetRawProps(), arcIndex1, arcIndex2, propID);
}
- NCOM::CPropVariant prop1, prop2;
- // Name must be first property
- GetProperty(index1, propID, &prop1);
- GetProperty(index2, propID, &prop2);
- if (prop1.vt != prop2.vt)
- {
- return MyCompare(prop1.vt, prop2.vt);
- }
- if (prop1.vt == VT_BSTR)
- {
- return _wcsicmp(prop1.bstrVal, prop2.bstrVal);
- }
- return prop1.Compare(prop2);
+ return CompareItems3(index1, index2, propID);
} catch(...) { return 0; }
}
+
HRESULT CAgentFolder::BindToFolder_Internal(unsigned proxyDirIndex, IFolderFolder **resultFolder)
{
/*
@@ -1246,7 +1239,7 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
case kpidNumSubFiles: prop = dir.NumSubFiles; break;
// case kpidName: prop = dir.Name; break;
// case kpidPath: prop = _proxy2->GetFullPathPrefix(_proxyDirIndex); break;
- case kpidType: prop = UString(L"7-Zip.") + _agentSpec->ArchiveType; break;
+ case kpidType: prop = UString("7-Zip.") + _agentSpec->ArchiveType; break;
case kpidCRC: if (dir.CrcIsDefined) prop = dir.Crc; break;
}
@@ -1262,7 +1255,7 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
case kpidNumSubFiles: prop = dir.NumSubFiles; break;
case kpidName: prop = dir.Name; break;
case kpidPath: prop = _proxy->GetDirPath_as_Prefix(_proxyDirIndex); break;
- case kpidType: prop = UString(L"7-Zip.") + _agentSpec->ArchiveType; break;
+ case kpidType: prop = UString("7-Zip.") + _agentSpec->ArchiveType; break;
case kpidCRC: if (dir.CrcIsDefined) prop = dir.Crc; break;
}
}
@@ -1582,9 +1575,9 @@ STDMETHODIMP CAgent::Open(
if (Read_ShowDeleted())
{
COptionalOpenProperties &optPair = optProps.AddNew();
- optPair.FormatName = L"ntfs";
- // optPair.Props.AddNew().Name = L"LS";
- optPair.Props.AddNew().Name = L"LD";
+ optPair.FormatName = "ntfs";
+ // optPair.Props.AddNew().Name = "LS";
+ optPair.Props.AddNew().Name = "LD";
}
*/
diff --git a/CPP/7zip/UI/Agent/Agent.h b/CPP/7zip/UI/Agent/Agent.h
index 9d70c7a1..ae4026d6 100644
--- a/CPP/7zip/UI/Agent/Agent.h
+++ b/CPP/7zip/UI/Agent/Agent.h
@@ -43,7 +43,8 @@ enum AGENT_OP
AGENT_OP_Delete,
AGENT_OP_CreateFolder,
AGENT_OP_Rename,
- AGENT_OP_CopyFromFile
+ AGENT_OP_CopyFromFile,
+ AGENT_OP_Comment
};
class CAgentFolder:
@@ -101,6 +102,7 @@ public:
STDMETHOD(GetFolderArcProps)(IFolderArcProps **object);
STDMETHOD_(Int32, CompareItems)(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw);
+ int CompareItems3(UInt32 index1, UInt32 index2, PROPID propID);
int CompareItems2(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw);
// IArchiveFolder
@@ -205,6 +207,10 @@ public:
const UInt32 *indices, UInt32 numItems, const wchar_t *newItemName,
IFolderArchiveUpdateCallback *updateCallback100);
+ HRESULT CommentItem(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);
@@ -262,7 +268,7 @@ public:
UString GetTypeOfArc(const CArc &arc) const
{
if (arc.FormatIndex < 0)
- return L"Parser";
+ return UString("Parser");
return g_CodecsObj->GetFormatNamePtr(arc.FormatIndex);
}
@@ -277,12 +283,12 @@ public:
if (arc.ErrorInfo.ErrorFormatIndex >= 0)
{
if (arc.ErrorInfo.ErrorFormatIndex == arc.FormatIndex)
- s2.AddAscii("Warning: The archive is open with offset");
+ s2 += "Warning: The archive is open with offset";
else
{
- s2.AddAscii("Can not open the file as [");
+ s2 += "Can not open the file as [";
s2 += g_CodecsObj->GetFormatNamePtr(arc.ErrorInfo.ErrorFormatIndex);
- s2.AddAscii("] archive");
+ s2 += "] archive";
}
}
@@ -290,16 +296,16 @@ public:
{
if (!s2.IsEmpty())
s2.Add_LF();
- s2.AddAscii("\n[");
+ s2 += "\n[";
s2 += GetTypeOfArc(arc);
- s2.AddAscii("]: ");
+ s2 += "]: ";
s2 += arc.ErrorInfo.ErrorMessage;
}
if (!s2.IsEmpty())
{
if (!s.IsEmpty())
- s.AddAscii("--------------------\n");
+ s += "--------------------\n";
s += arc.Path;
s.Add_LF();
s += s2;
diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp
index 1302d8c7..40876d76 100644
--- a/CPP/7zip/UI/Agent/AgentOut.cpp
+++ b/CPP/7zip/UI/Agent/AgentOut.cpp
@@ -589,6 +589,55 @@ HRESULT CAgent::RenameItem(ISequentialOutStream *outArchiveStream,
return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
}
+
+HRESULT CAgent::CommentItem(ISequentialOutStream *outArchiveStream,
+ const UInt32 *indices, UInt32 numItems, const wchar_t *newItemName,
+ IFolderArchiveUpdateCallback *updateCallback100)
+{
+ if (!CanUpdate())
+ return E_NOTIMPL;
+ if (numItems != 1)
+ return E_INVALIDARG;
+ if (!_archiveLink.IsOpen)
+ return E_FAIL;
+
+ CRecordVector<CUpdatePair2> updatePairs;
+ CUpdateCallbackAgent updateCallbackAgent;
+ updateCallbackAgent.SetCallback(updateCallback100);
+ CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
+ CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
+
+ const int mainRealIndex = _agentFolder->GetRealIndex(indices[0]);
+
+ if (mainRealIndex < 0)
+ return E_NOTIMPL;
+
+ UInt32 numItemsInArchive;
+ RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
+
+ UString newName = newItemName;
+
+ for (UInt32 i = 0; i < numItemsInArchive; i++)
+ {
+ CUpdatePair2 up2;
+ up2.SetAs_NoChangeArcItem(i);
+ if ((int)i == mainRealIndex)
+ up2.NewProps = true;
+ updatePairs.Add(up2);
+ }
+
+ updateCallbackSpec->Callback = &updateCallbackAgent;
+ updateCallbackSpec->UpdatePairs = &updatePairs;
+ updateCallbackSpec->CommentIndex = mainRealIndex;
+ updateCallbackSpec->Comment = &newName;
+
+ SetInArchiveInterfaces(this, updateCallbackSpec);
+
+ return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
+}
+
+
+
HRESULT CAgent::UpdateOneFile(ISequentialOutStream *outArchiveStream,
const UInt32 *indices, UInt32 numItems, const wchar_t *diskFilePath,
IFolderArchiveUpdateCallback *updateCallback100)
diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp
index eb07efd8..7f550f75 100644
--- a/CPP/7zip/UI/Agent/AgentProxy.cpp
+++ b/CPP/7zip/UI/Agent/AgentProxy.cpp
@@ -316,7 +316,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
if (numLevels <= kLevelLimit)
{
if (numLevels == kLevelLimit)
- name.SetFromAscii("[LONG_PATH]");
+ name = "[LONG_PATH]";
else
name.SetFrom(s + namePos, j - namePos);
curItem = AddDir(curItem, -1, name);
@@ -569,7 +569,7 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
{
// Dirs[1] - for alt streams of root dir
CProxyDir2 &dir = Dirs.AddNew();
- dir.PathPrefix = L':';
+ dir.PathPrefix = ':';
}
Files.Alloc(numItems);
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
index 325d6426..ecbfe58b 100644
--- a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
@@ -30,9 +30,11 @@ void CAgentFolder::GetPathParts(UStringVector &pathParts, bool &isAltStreamFolde
static bool DeleteEmptyFolderAndEmptySubFolders(const FString &path)
{
NFind::CFileInfo fileInfo;
- FString pathPrefix = path + FCHAR_PATH_SEPARATOR;
+ FString pathPrefix = path;
+ pathPrefix.Add_PathSepar();
{
- NFind::CEnumerator enumerator(pathPrefix + FCHAR_ANY_MASK);
+ NFind::CEnumerator enumerator;
+ enumerator.SetDirPrefix(pathPrefix);
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDir())
@@ -112,6 +114,9 @@ HRESULT CAgentFolder::CommonUpdateOperation(
case AGENT_OP_Rename:
result = _agentSpec->RenameItem(tailStream, indices, numItems, newItemName, updateCallback100);
break;
+ case AGENT_OP_Comment:
+ result = _agentSpec->CommentItem(tailStream, indices, numItems, newItemName, updateCallback100);
+ break;
case AGENT_OP_CopyFromFile:
result = _agentSpec->UpdateOneFile(tailStream, indices, numItems, newItemName, updateCallback100);
break;
@@ -274,7 +279,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
{
if (updateCallback100)
{
- UString s2 = L"Error: ";
+ UString s2 ("Error: ");
s2 += s;
RINOK(updateCallback100->UpdateErrorMessage(s2));
return E_FAIL;
@@ -304,13 +309,9 @@ STDMETHODIMP CAgentFolder::CopyFrom(Int32 moveMode,
STDMETHODIMP CAgentFolder::CopyFromFile(UInt32 destIndex, const wchar_t *itemPath, IProgress *progress)
{
COM_TRY_BEGIN
- CUIntVector indices;
- indices.Add(destIndex);
- {
- return CommonUpdateOperation(AGENT_OP_CopyFromFile, false, itemPath,
- &NUpdateArchive::k_ActionSet_Add,
- &indices.Front(), indices.Size(), progress);
- }
+ return CommonUpdateOperation(AGENT_OP_CopyFromFile, false, itemPath,
+ &NUpdateArchive::k_ActionSet_Add,
+ &destIndex, 1, progress);
COM_TRY_END
}
@@ -347,10 +348,8 @@ STDMETHODIMP CAgentFolder::CreateFolder(const wchar_t *name, IProgress *progress
STDMETHODIMP CAgentFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress)
{
COM_TRY_BEGIN
- CUIntVector indices;
- indices.Add(index);
return CommonUpdateOperation(AGENT_OP_Rename, false, newName, NULL,
- &indices.Front(), indices.Size(), progress);
+ &index, 1, progress);
COM_TRY_END
}
@@ -359,8 +358,16 @@ STDMETHODIMP CAgentFolder::CreateFile(const wchar_t * /* name */, IProgress * /*
return E_NOTIMPL;
}
-STDMETHODIMP CAgentFolder::SetProperty(UInt32 /* index */, PROPID /* propID */,
- const PROPVARIANT * /* value */, IProgress * /* progress */)
+STDMETHODIMP CAgentFolder::SetProperty(UInt32 index, PROPID propID,
+ const PROPVARIANT *value, IProgress *progress)
{
- return E_NOTIMPL;
+ COM_TRY_BEGIN
+ if (propID != kpidComment || value->vt != VT_BSTR)
+ return E_NOTIMPL;
+ if (!_agentSpec || !_agentSpec->GetTypeOfArc(_agentSpec->GetArc()).IsEqualTo_Ascii_NoCase("zip"))
+ return E_NOTIMPL;
+
+ return CommonUpdateOperation(AGENT_OP_Comment, false, value->bstrVal, NULL,
+ &index, 1, progress);
+ COM_TRY_END
}
diff --git a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
index e2813c80..d450eefe 100644
--- a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
+++ b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
@@ -22,10 +22,10 @@ void CUpdateCallbackAgent::SetCallback(IFolderArchiveUpdateCallback *callback)
}
}
-HRESULT CUpdateCallbackAgent::SetNumItems(UInt64 numItems)
+HRESULT CUpdateCallbackAgent::SetNumItems(const CArcToDoStat &stat)
{
if (Callback)
- return Callback->SetNumFiles(numItems);
+ return Callback->SetNumFiles(stat.Get_NumDataItems_Total());
return S_OK;
}
@@ -82,9 +82,9 @@ HRESULT CUpdateCallbackAgent::OpenFileError(const FString &path, DWORD systemErr
if (Callback)
{
- UString s = L"WARNING: ";
+ UString s ("WARNING: ");
s += NError::MyFormatMessage(systemError);
- s += L": ";
+ s += ": ";
s += fs2us(path);
RINOK(Callback->UpdateErrorMessage(s));
return S_FALSE;
@@ -106,9 +106,9 @@ HRESULT CUpdateCallbackAgent::ReadingFileError(const FString &path, DWORD system
}
else if (Callback)
{
- UString s = L"ERROR: ";
+ UString s ("ERROR: ");
s += NError::MyFormatMessage(systemError);
- s += L": ";
+ s += ": ";
s += fs2us(path);
RINOK(Callback->UpdateErrorMessage(s));
}