mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-15 00:11:40 -06:00
3.13
This commit is contained in:
8
7zip/UI/Far/CLSIDConst.cpp
Executable file
8
7zip/UI/Far/CLSIDConst.cpp
Executable file
@@ -0,0 +1,8 @@
|
||||
// CLSIDConst.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <initguid.h>
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
#include "../../IPassword.h"
|
||||
347
7zip/UI/Far/CompressEngine.cpp
Executable file
347
7zip/UI/Far/CompressEngine.cpp
Executable file
@@ -0,0 +1,347 @@
|
||||
// CompressEngine.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ProxyHandler.h"
|
||||
#include "CompressEngine.h"
|
||||
#include "UpdateEngine.h"
|
||||
|
||||
#include "../../Archiver/Common/CompressEngineCommon.h"
|
||||
#include "../../Archiver/Common/OpenEngine2.h"
|
||||
#include "../../Archiver/Common/UpdateProducer.h"
|
||||
#include "../../Archiver/Common/UpdateUtils.h"
|
||||
|
||||
#include "Windows/File/Name.h"
|
||||
#include "Windows/File/Find.h"
|
||||
#include "Windows/File/Directory.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/Error.h"
|
||||
|
||||
#include "../../../WinWrappers/PropVariantConversions.h"
|
||||
|
||||
// #include "CompressDialog.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
// #include "ArchiveStyleDirItemInfo.h"
|
||||
|
||||
#include "Interface/FileStreams.h"
|
||||
|
||||
#include "Messages.h"
|
||||
#include "Far/FarUtils.h"
|
||||
// #include "ZipViewUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NName;
|
||||
using namespace NCOM;
|
||||
|
||||
using namespace NFar;
|
||||
using namespace NUpdateArchive;
|
||||
|
||||
#define RETURN_IF_NOT_S_OK(x) { HRESULT aResult = (x); if(aResult != S_OK) return aResult; }
|
||||
|
||||
static LPCTSTR kTempArcivePrefix = "7zi";
|
||||
|
||||
static void GetFileTime(CProxyHandler *aProxyHandler, LPCITEMIDLIST anItemIDList,
|
||||
FILETIME &aFileTime)
|
||||
{
|
||||
CPropVariant aProperty;
|
||||
aProxyHandler->GetPropertyValue(anItemIDList, kaipidLastWriteTime, &aProperty);
|
||||
if (aProperty.vt == VT_FILETIME)
|
||||
aFileTime = aProperty.filetime;
|
||||
else if (aProperty.vt == VT_EMPTY)
|
||||
aFileTime = aProxyHandler->m_ArchiveFileInfo.LastWriteTime;
|
||||
else
|
||||
throw 4190407;
|
||||
}
|
||||
|
||||
void EnumerateInArchiveItems(CProxyHandler *aProxyHandler,
|
||||
const CArchiveFolderItem &anItem, const UString &aPrefix,
|
||||
CArchiveItemInfoVector &anArchiveItems)
|
||||
{
|
||||
for(int i = 0; i < anItem.m_FileSubItems.Size(); i++)
|
||||
{
|
||||
const CArchiveFolderFileItem &aFileItem = anItem.m_FileSubItems[i];
|
||||
CArchiveItemInfo anItemInfo;
|
||||
|
||||
GetFileTime(aProxyHandler, aFileItem.m_Properties, anItemInfo.LastWriteTime);
|
||||
|
||||
CPropVariant aProperty;
|
||||
aProxyHandler->GetPropertyValue(aFileItem.m_Properties, kaipidSize, &aProperty);
|
||||
if (anItemInfo.SizeIsDefined = (aProperty.vt != VT_EMPTY))
|
||||
anItemInfo.Size = ConvertPropVariantToUINT64(aProperty);
|
||||
anItemInfo.IsDirectory = false;
|
||||
anItemInfo.Name = aPrefix + aFileItem.m_Name;
|
||||
anItemInfo.Censored = true; // test it
|
||||
anItemInfo.IndexInServer = aProxyHandler->GetHandlerItemIndex(aFileItem.m_Properties);
|
||||
anArchiveItems.Add(anItemInfo);
|
||||
}
|
||||
for(i = 0; i < anItem.m_DirSubItems.Size(); i++)
|
||||
{
|
||||
const CArchiveFolderItem &aDirItem = anItem.m_DirSubItems[i];
|
||||
if(!aDirItem.m_IsLeaf)
|
||||
continue;
|
||||
CArchiveItemInfo anItemInfo;
|
||||
GetFileTime(aProxyHandler, aDirItem.m_Properties, anItemInfo.LastWriteTime);
|
||||
anItemInfo.IsDirectory = true;
|
||||
anItemInfo.SizeIsDefined = false;
|
||||
anItemInfo.Name = aPrefix + aDirItem.m_Name;
|
||||
anItemInfo.Censored = true; // test it
|
||||
anItemInfo.IndexInServer = aProxyHandler->GetHandlerItemIndex(
|
||||
aDirItem.m_Properties);
|
||||
anArchiveItems.Add(anItemInfo);
|
||||
EnumerateInArchiveItems(aProxyHandler, aDirItem, anItemInfo.Name +
|
||||
wchar_t(kDirDelimiter), anArchiveItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const char *kExtension = _T(".zip");
|
||||
|
||||
|
||||
HRESULT Compress(const CSysStringVector &aFileNames,
|
||||
const UString &anArchiveNamePrefix,
|
||||
const CActionSet &anActionSet, CProxyHandler *aProxyHandler,
|
||||
const CLSID &aClassID, bool aStoreMode, bool aMaximizeRatioMode,
|
||||
CSysString &anArchiveName, CProgressBox *aProgressBox)
|
||||
{
|
||||
CComPtr<IOutArchiveHandler> anOutArchive;
|
||||
CArchiveItemInfoVector anArchiveItems;
|
||||
if(aProxyHandler != NULL)
|
||||
{
|
||||
HRESULT aResult = aProxyHandler->m_ArchiveHandler.QueryInterface(&anOutArchive);
|
||||
if(aResult != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return E_FAIL;
|
||||
}
|
||||
EnumerateInArchiveItems(aProxyHandler,
|
||||
aProxyHandler->m_FolderItemHead, L"", anArchiveItems);
|
||||
}
|
||||
else
|
||||
{
|
||||
HRESULT aResult = anOutArchive.CoCreateInstance(aClassID);
|
||||
if (aResult != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
CArchiveStyleDirItemInfoVector aDirItems;
|
||||
|
||||
EnumerateItems(aFileNames, anArchiveNamePrefix, aDirItems, CP_OEMCP);
|
||||
|
||||
CUpdatePairInfoVector anUpdatePairs;
|
||||
|
||||
NFileTimeType::EEnum aFileTimeType;
|
||||
UINT32 aValue;
|
||||
RETURN_IF_NOT_S_OK(anOutArchive->GetFileTimeType(&aValue));
|
||||
|
||||
switch(aValue)
|
||||
{
|
||||
case NFileTimeType::kWindows:
|
||||
case NFileTimeType::kDOS:
|
||||
case NFileTimeType::kUnix:
|
||||
aFileTimeType = NFileTimeType::EEnum(aValue);
|
||||
break;
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
GetUpdatePairInfoList(aDirItems, anArchiveItems, aFileTimeType, anUpdatePairs);
|
||||
|
||||
CUpdatePairInfo2Vector anOperationChain;
|
||||
UpdateProduce(aDirItems, anArchiveItems, anUpdatePairs, anActionSet,
|
||||
anOperationChain);
|
||||
|
||||
CComObjectNoLock<CUpdateCallBackImp> *anUpdateCallBackSpec =
|
||||
new CComObjectNoLock<CUpdateCallBackImp>;
|
||||
CComPtr<IUpdateCallBack> anUpdateCallBack(anUpdateCallBackSpec );
|
||||
|
||||
anUpdateCallBackSpec->Init(&aDirItems, &anArchiveItems, &anOperationChain,
|
||||
aProgressBox);
|
||||
|
||||
CComObjectNoLock<COutFileStream> *anOutStreamSpec =
|
||||
new CComObjectNoLock<COutFileStream>;
|
||||
CComPtr<IOutStream> anOutStream(anOutStreamSpec);
|
||||
|
||||
{
|
||||
CSysString aResultPath;
|
||||
int aPos;
|
||||
if(! NFile::NDirectory::MyGetFullPathName(anArchiveName, aResultPath, aPos))
|
||||
throw 141716;
|
||||
NFile::NDirectory::CreateComplexDirectory(aResultPath.Left(aPos));
|
||||
}
|
||||
if (!anOutStreamSpec->Open(anArchiveName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
HRESULT aResult = anOutArchive->UpdateItems(anOutStream, anOperationChain.Size(),
|
||||
BoolToMyBool(aStoreMode), BoolToMyBool(aMaximizeRatioMode), anUpdateCallBack);
|
||||
return aResult;
|
||||
}
|
||||
|
||||
|
||||
// The returned string ends with a backslash
|
||||
|
||||
|
||||
/*
|
||||
|
||||
void CompressArchive(const CSysStringVector &aFileNames)
|
||||
{
|
||||
if (aFileNames.Size() == 0)
|
||||
return;
|
||||
CSysString aResultPath;
|
||||
{
|
||||
CParsedPath aParsedPath;
|
||||
aParsedPath.ParsePath(aFileNames.Front());
|
||||
if(aParsedPath.PathParts.Size() == 0)
|
||||
return; // Error
|
||||
if (aFileNames.Size() == 1 || aParsedPath.PathParts.Size() == 1)
|
||||
{
|
||||
CSysString aPureName, aDot, anExtension;
|
||||
SplitNameToPureNameAndExtension(aParsedPath.PathParts.Back(),
|
||||
aPureName, aDot, anExtension);
|
||||
// aParsedPath.PathParts.Back() = aPureName;
|
||||
// aResultPath = aParsedPath.MergePath();
|
||||
aResultPath = aPureName;
|
||||
}
|
||||
else
|
||||
{
|
||||
aParsedPath.PathParts.DeleteBack();
|
||||
// aResultPath = aParsedPath.MergePath();
|
||||
// aResultPath += NFile::NName::kDirDelimiter;
|
||||
// aResultPath += aParsedPath.PathParts.Back();
|
||||
aResultPath = aParsedPath.PathParts.Back();
|
||||
}
|
||||
aResultPath += kExtension;
|
||||
}
|
||||
CSysString aCurrentDir;
|
||||
{
|
||||
CParsedPath aParsedPath;
|
||||
aParsedPath.ParsePath(aFileNames.Front());
|
||||
aParsedPath.PathParts.DeleteBack();
|
||||
aCurrentDir = aParsedPath.MergePath();
|
||||
if (aParsedPath.PathParts.Size() > 0)
|
||||
aCurrentDir += NFile::NName::kDirDelimiter;
|
||||
}
|
||||
|
||||
|
||||
CCompressDialog aDialog;
|
||||
|
||||
|
||||
|
||||
CZipRegistryManager aZipRegistryManager;
|
||||
aDialog.m_ZipRegistryManager = &aZipRegistryManager;
|
||||
|
||||
NZipRootRegistry::CArchiverInfoVector anArchiverInfoList;
|
||||
NZipRootRegistry::ReadArchiverInfoList(anArchiverInfoList);
|
||||
aDialog.m_ArchiverInfoList.Clear();
|
||||
for(int i = 0; i < anArchiverInfoList.Size(); i++)
|
||||
{
|
||||
NZipRootRegistry::CArchiverInfo anArchiverInfo = anArchiverInfoList[i];
|
||||
if (anArchiverInfo.UpdateEnabled)
|
||||
aDialog.m_ArchiverInfoList.Add(anArchiverInfo);
|
||||
}
|
||||
if(aDialog.m_ArchiverInfoList.Size() == 0)
|
||||
{
|
||||
AfxMessageBox("No Update Engines");
|
||||
return;
|
||||
}
|
||||
|
||||
aDialog.m_Info.ArchiveName = aResultPath;
|
||||
aDialog.m_Info.CurrentDirPrefix = aCurrentDir;
|
||||
|
||||
if(aDialog.DoModal() != IDOK)
|
||||
return;
|
||||
|
||||
CSysString anArcPath;
|
||||
if (!aDialog.m_Info.GetFullPathName(anArcPath))
|
||||
{
|
||||
AfxMessageBox("Incorrect archive path");;
|
||||
return;
|
||||
}
|
||||
const CActionSet *anActionSet;
|
||||
switch(aDialog.m_Info.UpdateMode)
|
||||
{
|
||||
case NCompressDialog::NUpdateMode::kAdd:
|
||||
anActionSet = &kAddActionSet;
|
||||
break;
|
||||
case NCompressDialog::NUpdateMode::kUpdate:
|
||||
anActionSet = &kUpdateActionSet;
|
||||
break;
|
||||
case NCompressDialog::NUpdateMode::kFresh:
|
||||
anActionSet = &kFreshActionSet;
|
||||
break;
|
||||
case NCompressDialog::NUpdateMode::kSynchronize:
|
||||
anActionSet = &kSynchronizeActionSet;
|
||||
break;
|
||||
default:
|
||||
throw 1091756;
|
||||
}
|
||||
|
||||
|
||||
NZipSettings::NWorkDir::CInfo aWorkDirInfo;
|
||||
aZipRegistryManager.ReadWorkDirInfo(aWorkDirInfo);
|
||||
CSysString aWorkDir = GetWorkDir(aWorkDirInfo, anArcPath);
|
||||
NFile::NDirectory::CreateComplexDirectory(aWorkDir);
|
||||
|
||||
NFile::NDirectory::CTempFile aTempFile;
|
||||
CSysString aTempFileName;
|
||||
if (aTempFile.Create(aWorkDir, kTempArcivePrefix, aTempFileName) == 0)
|
||||
return;
|
||||
|
||||
CProxyHandler *aProxyHandler;
|
||||
NFind::CFileInfo aFileInfo;
|
||||
if(NFind::FindFile(anArcPath, aFileInfo))
|
||||
{
|
||||
if (aFileInfo.IsDirectory())
|
||||
{
|
||||
CString aMessage;
|
||||
AfxFormatString1(aMessage, IDS_CANT_UPDATE_ARCHIVE, anArcPath);
|
||||
AfxMessageBox(aMessage);
|
||||
return;
|
||||
}
|
||||
bool aHandlerIsNew;
|
||||
if (!g_HandlersManager.GetProxyHandler(anArcPath, &aProxyHandler, aHandlerIsNew))
|
||||
{
|
||||
CString aMessage;
|
||||
AfxFormatString1(aMessage, IDS_CANT_UPDATE_ARCHIVE, anArcPath);
|
||||
AfxMessageBox(aMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
aProxyHandler = NULL;
|
||||
|
||||
|
||||
HRESULT aResult = Compress(aFileNames, *anActionSet, aProxyHandler,
|
||||
aDialog.m_ArchiverInfoList[aDialog.m_Info.ArchiverInfoIndex].ClassID,
|
||||
aDialog.m_Info.Method == NCompressDialog::NMethod::kStore,
|
||||
aDialog.m_Info.Method == NCompressDialog::NMethod::kMaximum,
|
||||
aTempFileName);
|
||||
if (aResult != S_OK)
|
||||
{
|
||||
ShowErrorMessage(aResult);
|
||||
return;
|
||||
}
|
||||
if(aProxyHandler != 0) // Update
|
||||
{
|
||||
if (!NFile::NDirectory::DeleteFileAlways(anArcPath))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
aTempFile.DisableDeleting();
|
||||
if (!MoveFile(aTempFileName, anArcPath))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
23
7zip/UI/Far/CompressEngine.h
Executable file
23
7zip/UI/Far/CompressEngine.h
Executable file
@@ -0,0 +1,23 @@
|
||||
// CompressEngine.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __COMPRESSENGINE_H
|
||||
#define __COMPRESSENGINE_H
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "../../Archiver/Common/CompressEngineCommon.h"
|
||||
#include "ProxyHandler.h"
|
||||
|
||||
#include "Far/ProgressBox.h"
|
||||
|
||||
|
||||
HRESULT Compress(const CSysStringVector &aFileNames,
|
||||
const UString &anArchiveNamePrefix,
|
||||
const NUpdateArchive::CActionSet &anActionSet, CProxyHandler *aProxyHandler,
|
||||
const CLSID &aClassID, bool aStoreMode, bool aMaximizeRatioMode,
|
||||
CSysString &anArchiveName, CProgressBox *aProgressBox);
|
||||
|
||||
// void CompressArchive(const CSysStringVector &aFileNames);
|
||||
|
||||
#endif
|
||||
165
7zip/UI/Far/ExtractEngine.cpp
Executable file
165
7zip/UI/Far/ExtractEngine.cpp
Executable file
@@ -0,0 +1,165 @@
|
||||
// ExtractEngine.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ExtractEngine.h"
|
||||
#include "Far/FarUtils.h"
|
||||
|
||||
#include "Messages.h"
|
||||
|
||||
#include "OverwriteDialog.h"
|
||||
|
||||
#include "Common/WildCard.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
extern void PrintMessage(const char *message);
|
||||
|
||||
CExtractCallBackImp::~CExtractCallBackImp()
|
||||
{
|
||||
}
|
||||
|
||||
void CExtractCallBackImp::Init(
|
||||
UINT codePage,
|
||||
CProgressBox *progressBox,
|
||||
bool passwordIsDefined,
|
||||
const UString &password)
|
||||
{
|
||||
m_PasswordIsDefined = passwordIsDefined;
|
||||
m_Password = password;
|
||||
m_CodePage = codePage;
|
||||
m_ProgressBox = progressBox;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::SetTotal(UINT64 size)
|
||||
{
|
||||
if (m_ProgressBox != 0)
|
||||
{
|
||||
m_ProgressBox->SetTotal(size);
|
||||
m_ProgressBox->PrintCompeteValue(0);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::SetCompleted(const UINT64 *completeValue)
|
||||
{
|
||||
if(WasEscPressed())
|
||||
return E_ABORT;
|
||||
if (m_ProgressBox != 0 && completeValue != NULL)
|
||||
m_ProgressBox->PrintCompeteValue(*completeValue);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::AskOverwrite(
|
||||
const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *aNewTime, const UINT64 *newSize,
|
||||
INT32 *answer)
|
||||
{
|
||||
NOverwriteDialog::CFileInfo oldFileInfo, newFileInfo;
|
||||
oldFileInfo.Time = *existTime;
|
||||
if (oldFileInfo.SizeIsDefined = (existSize != NULL))
|
||||
oldFileInfo.Size = *existSize;
|
||||
oldFileInfo.Name = UnicodeStringToMultiByte(existName, m_CodePage);
|
||||
|
||||
|
||||
newFileInfo.Time = *aNewTime;
|
||||
|
||||
if (newFileInfo.SizeIsDefined = (newSize != NULL))
|
||||
newFileInfo.Size = *newSize;
|
||||
newFileInfo.Name = UnicodeStringToMultiByte(newName, m_CodePage);
|
||||
|
||||
NOverwriteDialog::NResult::EEnum result =
|
||||
NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case NOverwriteDialog::NResult::kCancel:
|
||||
// *answer = NOverwriteAnswer::kCancel;
|
||||
// break;
|
||||
return E_ABORT;
|
||||
case NOverwriteDialog::NResult::kNo:
|
||||
*answer = NOverwriteAnswer::kNo;
|
||||
break;
|
||||
case NOverwriteDialog::NResult::kNoToAll:
|
||||
*answer = NOverwriteAnswer::kNoToAll;
|
||||
break;
|
||||
case NOverwriteDialog::NResult::kYesToAll:
|
||||
*answer = NOverwriteAnswer::kYesToAll;
|
||||
break;
|
||||
case NOverwriteDialog::NResult::kYes:
|
||||
*answer = NOverwriteAnswer::kYes;
|
||||
break;
|
||||
case NOverwriteDialog::NResult::kAutoRename:
|
||||
*answer = NOverwriteAnswer::kAutoRename;
|
||||
break;
|
||||
default:
|
||||
throw 20413;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, INT32 askExtractMode)
|
||||
{
|
||||
m_CurrentFilePath = name;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::MessageError(const wchar_t *message)
|
||||
{
|
||||
CSysString s = UnicodeStringToMultiByte(message, CP_OEMCP);
|
||||
if (g_StartupInfo.ShowMessage(s) == -1)
|
||||
return E_ABORT;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::SetOperationResult(INT32 operationResult)
|
||||
{
|
||||
switch(operationResult)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kOK:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
UINT idMessage;
|
||||
switch(operationResult)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
|
||||
idMessage = NMessageID::kExtractUnsupportedMethod;
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kCRCError:
|
||||
idMessage = NMessageID::kExtractCRCFailed;
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kDataError:
|
||||
idMessage = NMessageID::kExtractDataError;
|
||||
break;
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
char buffer[512];
|
||||
sprintf(buffer, g_StartupInfo.GetMsgString(idMessage),
|
||||
GetSystemString(m_CurrentFilePath, m_CodePage));
|
||||
if (g_StartupInfo.ShowMessage(buffer) == -1)
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
extern HRESULT GetPassword(UString &password);
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::CryptoGetTextPassword(BSTR *password)
|
||||
{
|
||||
if (!m_PasswordIsDefined)
|
||||
{
|
||||
RINOK(GetPassword(m_Password));
|
||||
m_PasswordIsDefined = true;
|
||||
}
|
||||
CMyComBSTR tempName = m_Password;
|
||||
*password = tempName.Detach();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
69
7zip/UI/Far/ExtractEngine.h
Executable file
69
7zip/UI/Far/ExtractEngine.h
Executable file
@@ -0,0 +1,69 @@
|
||||
// ExtractEngine.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __EXTRACTENGINE_H
|
||||
#define __EXTRACTENGINE_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Common/String.h"
|
||||
#include "Far/ProgressBox.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
class CExtractCallBackImp:
|
||||
public IFolderArchiveExtractCallback,
|
||||
public ICryptoGetTextPassword,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
|
||||
|
||||
// IProgress
|
||||
STDMETHOD(SetTotal)(UINT64 size);
|
||||
STDMETHOD(SetCompleted)(const UINT64 *completeValue);
|
||||
|
||||
// IExtractCallBack
|
||||
STDMETHOD(AskOverwrite)(
|
||||
const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UINT64 *newSize,
|
||||
INT32 *result);
|
||||
STDMETHOD (PrepareOperation)(const wchar_t *name, INT32 askExtractMode);
|
||||
|
||||
STDMETHOD(MessageError)(const wchar_t *message);
|
||||
STDMETHOD(SetOperationResult)(INT32 resultEOperationResult);
|
||||
// ICryptoGetTextPassword
|
||||
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
|
||||
|
||||
private:
|
||||
UString m_CurrentFilePath;
|
||||
|
||||
struct CProcessedFileInfo
|
||||
{
|
||||
FILETIME UTCLastWriteTime;
|
||||
bool IsDirectory;
|
||||
UINT32 Attributes;
|
||||
} m_ProcessedFileInfo;
|
||||
|
||||
CProgressBox *m_ProgressBox;
|
||||
UINT m_CodePage;
|
||||
|
||||
bool m_PasswordIsDefined;
|
||||
UString m_Password;
|
||||
|
||||
void CreateComplexDirectory(const UStringVector &dirPathParts);
|
||||
/*
|
||||
void GetPropertyValue(LPITEMIDLIST anItemIDList, PROPID aPropId,
|
||||
PROPVARIANT *aValue);
|
||||
bool IsEncrypted(LPITEMIDLIST anItemIDList);
|
||||
*/
|
||||
void AddErrorMessage(LPCTSTR message);
|
||||
public:
|
||||
~CExtractCallBackImp();
|
||||
void Init(UINT codePage,
|
||||
CProgressBox *progressBox,
|
||||
bool passwordIsDefined, const UString &password);
|
||||
};
|
||||
|
||||
#endif
|
||||
20
7zip/UI/Far/Far.def
Executable file
20
7zip/UI/Far/Far.def
Executable file
@@ -0,0 +1,20 @@
|
||||
; 7-ZipFar.def : Declares the module parameters for the DLL.
|
||||
|
||||
LIBRARY "7-ZipFar"
|
||||
DESCRIPTION '7-ZipFar Windows Dynamic Link Library'
|
||||
|
||||
EXPORTS
|
||||
SetStartupInfo = _SetStartupInfo@4
|
||||
OpenPlugin = _OpenPlugin@8
|
||||
OpenFilePlugin = _OpenFilePlugin@12
|
||||
ClosePlugin = _ClosePlugin@4
|
||||
GetFindData = _GetFindData@16
|
||||
FreeFindData = _FreeFindData@12
|
||||
SetDirectory = _SetDirectory@12
|
||||
GetPluginInfo = _GetPluginInfo@4
|
||||
Configure = _Configure@4
|
||||
GetOpenPluginInfo = _GetOpenPluginInfo@8
|
||||
GetFiles = _GetFiles@24
|
||||
PutFiles = _PutFiles@20
|
||||
DeleteFiles = _DeleteFiles@16
|
||||
ProcessKey = _ProcessKey@12
|
||||
529
7zip/UI/Far/Far.dsp
Executable file
529
7zip/UI/Far/Far.dsp
Executable file
@@ -0,0 +1,529 @@
|
||||
# Microsoft Developer Studio Project File - Name="Far" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Far - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Far.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Far.mak" CFG="Far - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Far - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Far - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Far - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\Far\Plugins\7-Zip\7-ZipFar.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Far - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\Far\Plugins\7-Zip\7-ZipFar.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Far - Win32 Release"
|
||||
# Name "Far - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CLSIDConst.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Far.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Far.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"StdAfx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Wildcard.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Wildcard.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Plugin"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ExtractEngine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ExtractEngine.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Main.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Messages.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OverwriteDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OverwriteDialog.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Plugin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Plugin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PluginCommon.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PluginDelete.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PluginRead.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PluginWrite.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\UpdateCallback100.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\UpdateCallback100.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Far"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\FarPlugin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\FarUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\FarUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\ProgressBox.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\ProgressBox.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Defs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Error.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Error.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileDir.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileDir.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileFind.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileFind.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileIO.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileIO.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileName.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileName.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariantConversions.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariantConversions.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Registry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Registry.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "UI Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiverInfo.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiverInfo.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DefaultName.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DefaultName.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DirItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\EnumDirItems.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\EnumDirItems.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ExtractingFilePath.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ExtractingFilePath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\HandlerLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OpenArchive.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OpenArchive.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\PropIDUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\PropIDUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\SortUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\SortUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateAction.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateAction.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdatePair.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdatePair.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateProduce.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateProduce.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\WorkDir.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\WorkDir.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ZipRegistry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ZipRegistry.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Agent"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\Agent.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\Agent.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\AgentOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\AgentProxy.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\AgentProxy.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\ArchiveExtractCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\ArchiveExtractCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\ArchiveUpdateCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\ArchiveUpdateCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\IFolderArchive.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7-zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilePathAutoRename.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilePathAutoRename.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FileStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FileStreams.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
7zip/UI/Far/Far.dsw
Executable file
29
7zip/UI/Far/Far.dsw
Executable file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Far"=.\Far.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
121
7zip/UI/Far/Far.rc
Executable file
121
7zip/UI/Far/Far.rc
Executable file
@@ -0,0 +1,121 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Russian resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
|
||||
#pragma code_page(1251)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Russian resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,13,0,0
|
||||
PRODUCTVERSION 3,13,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "Igor Pavlov\0"
|
||||
VALUE "FileDescription", "7-Zip FAR Plugin\0"
|
||||
VALUE "FileVersion", "3, 13, 0, 0\0"
|
||||
VALUE "InternalName", "7-ZipFar\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2003 Igor Pavlov\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "7-ZipFar.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "7-Zip\0"
|
||||
VALUE "ProductVersion", "3, 13, 0, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
615
7zip/UI/Far/Main.cpp
Executable file
615
7zip/UI/Far/Main.cpp
Executable file
@@ -0,0 +1,615 @@
|
||||
// Test Align for updating !!!!!!!!!!!!!!!!!!
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
// #include <locale.h>
|
||||
#include <initguid.h>
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Common/WildCard.h"
|
||||
#include "Common/DynamicBuffer.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Defs.h"
|
||||
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileIO.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "Far/FarUtils.h"
|
||||
#include "Far/ProgressBox.h"
|
||||
|
||||
#include "Messages.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "../Common/DefaultName.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
#include "../Agent/Agent.h"
|
||||
// #include "../../Compress/Interface/CompressInterface.h"
|
||||
#include "../../IPassword.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
static const char *kCommandPrefix = "7-zip";
|
||||
|
||||
static const int kDescriptionMaxSize = 256;
|
||||
|
||||
static const char *kRegisrtryMainKeyName = "";
|
||||
|
||||
static const char *kRegisrtryValueNameEnabled = "UsedByDefault3";
|
||||
static bool kPluginEnabledDefault = true;
|
||||
|
||||
static const char *kHelpTopicConfig = "Config";
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void WINAPI SetStartupInfo(struct PluginStartupInfo *info);
|
||||
HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char *Data,
|
||||
unsigned int DataSize);
|
||||
HANDLE WINAPI OpenPlugin(int openFrom, int item);
|
||||
void WINAPI ClosePlugin(HANDLE plugin);
|
||||
int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems,
|
||||
int *itemsNumber, int OpMode);
|
||||
void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber);
|
||||
int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, char *destPath, int opMode);
|
||||
int WINAPI SetDirectory(HANDLE plugin, char *dir, int opMode);
|
||||
void WINAPI GetPluginInfo(struct PluginInfo *info);
|
||||
int WINAPI Configure(int itemNumber);
|
||||
void WINAPI GetOpenPluginInfo(HANDLE plugin, struct OpenPluginInfo *info);
|
||||
int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, int opMode);
|
||||
int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems,
|
||||
int itemsNumber, int opMode);
|
||||
int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState);
|
||||
};
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct COptions
|
||||
{
|
||||
bool Enabled;
|
||||
} g_Options;
|
||||
|
||||
static const char *kPliginNameForRegestry = "7-ZIP";
|
||||
|
||||
// #define MY_TRY_BEGIN MY_TRY_BEGIN NCOM::CComInitializer aComInitializer;
|
||||
|
||||
void WINAPI SetStartupInfo(struct PluginStartupInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
g_StartupInfo.Init(*info, kPliginNameForRegestry);
|
||||
g_Options.Enabled = g_StartupInfo.QueryRegKeyValue(
|
||||
HKEY_CURRENT_USER, kRegisrtryMainKeyName,
|
||||
kRegisrtryValueNameEnabled, kPluginEnabledDefault);
|
||||
MY_TRY_END1("SetStartupInfo");
|
||||
}
|
||||
|
||||
class COpenArchiveCallback:
|
||||
public IArchiveOpenCallback,
|
||||
public IArchiveOpenVolumeCallback,
|
||||
public IProgress,
|
||||
public ICryptoGetTextPassword,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
DWORD m_StartTickValue;
|
||||
bool m_MessageBoxIsShown;
|
||||
CMessageBox *m_MessageBox;
|
||||
UINT64 m_NumFiles;
|
||||
UINT64 m_NumFilesMax;
|
||||
UINT64 m_NumFilesPrev;
|
||||
bool m_NumFilesDefined;
|
||||
UINT64 m_NumBytes;
|
||||
bool m_NumBytesDefined;
|
||||
UINT32 m_PrevTickCount;
|
||||
|
||||
NWindows::NFile::NFind::CFileInfoW _fileInfo;
|
||||
public:
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
UString _folderPrefix;
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP3(
|
||||
IArchiveOpenVolumeCallback,
|
||||
IProgress,
|
||||
ICryptoGetTextPassword
|
||||
)
|
||||
|
||||
// IProgress
|
||||
STDMETHOD(SetTotal)(UINT64 total);
|
||||
STDMETHOD(SetCompleted)(const UINT64 *aCompleteValue);
|
||||
|
||||
// IArchiveOpenCallback
|
||||
STDMETHOD(SetTotal)(const UINT64 *numFiles, const UINT64 *numBytes);
|
||||
STDMETHOD(SetCompleted)(const UINT64 *numFiles, const UINT64 *numBytes);
|
||||
|
||||
// IArchiveOpenVolumeCallback
|
||||
STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream);
|
||||
|
||||
// ICryptoGetTextPassword
|
||||
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
|
||||
|
||||
void Init(CMessageBox *messageBox)
|
||||
{
|
||||
PasswordIsDefined = false;
|
||||
|
||||
m_NumFilesMax = 0;
|
||||
m_MessageBoxIsShown = false;
|
||||
m_PrevTickCount = GetTickCount();
|
||||
m_MessageBox = messageBox;
|
||||
}
|
||||
void ShowMessage(const UINT64 *completed);
|
||||
|
||||
void LoadFileInfo(const UString &folderPrefix,
|
||||
const UString &fileName)
|
||||
{
|
||||
_folderPrefix = folderPrefix;
|
||||
if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo))
|
||||
throw 1;
|
||||
}
|
||||
};
|
||||
|
||||
void COpenArchiveCallback::ShowMessage(const UINT64 *completed)
|
||||
{
|
||||
UINT32 currentTime = GetTickCount();
|
||||
if (!m_MessageBoxIsShown)
|
||||
{
|
||||
if (currentTime - m_PrevTickCount < 400)
|
||||
return;
|
||||
m_MessageBox->Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kReading), 2, 30);
|
||||
m_MessageBoxIsShown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentTime - m_PrevTickCount < 200)
|
||||
return;
|
||||
}
|
||||
m_PrevTickCount = currentTime;
|
||||
char aMessage[256];
|
||||
sprintf(aMessage, "%5I64u", m_NumFilesMax);
|
||||
char aMessage2[256];
|
||||
aMessage2[0] = '\0';
|
||||
if (completed != NULL)
|
||||
sprintf(aMessage2, "%5I64u", *completed);
|
||||
const char *aMessages[2] =
|
||||
{aMessage, aMessage2 };
|
||||
m_MessageBox->ShowProcessMessages(aMessages);
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 *numFiles, const UINT64 *numBytes)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
m_NumFilesDefined = (numFiles != NULL);
|
||||
if (m_NumFilesDefined)
|
||||
m_NumFiles = *numFiles;
|
||||
m_NumBytesDefined = (numBytes != NULL);
|
||||
if (m_NumBytesDefined)
|
||||
m_NumBytes = *numBytes;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 *numFiles, const UINT64 *numBytes)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
if (numFiles == NULL)
|
||||
return S_OK;
|
||||
m_NumFilesMax = *numFiles;
|
||||
// if (*numFiles % 100 != 0)
|
||||
// return S_OK;
|
||||
ShowMessage(NULL);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 total)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
/*
|
||||
aNumFilesDefined = (numFiles != NULL);
|
||||
if (aNumFilesDefined)
|
||||
aNumFiles = *numFiles;
|
||||
aNumBytesDefined = (numBytes != NULL);
|
||||
if (aNumBytesDefined)
|
||||
aNumBytes = *numBytes;
|
||||
*/
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 *completed)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
if (completed == NULL)
|
||||
return S_OK;
|
||||
// if (*completed % 100 != 0)
|
||||
// return S_OK;
|
||||
ShowMessage(completed);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
|
||||
IInStream **inStream)
|
||||
{
|
||||
*inStream = NULL;
|
||||
UString fullPath = _folderPrefix + name;
|
||||
if (!NWindows::NFile::NFind::FindFile(fullPath, _fileInfo))
|
||||
return S_FALSE;
|
||||
if (_fileInfo.IsDirectory())
|
||||
return S_FALSE;
|
||||
CInFileStream *inFile = new CInFileStream;
|
||||
CMyComPtr<IInStream> inStreamTemp = inFile;
|
||||
if (!inFile->Open(fullPath))
|
||||
return ::GetLastError();
|
||||
*inStream = inStreamTemp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case kpidName:
|
||||
propVariant = GetUnicodeString(_fileInfo.Name, CP_OEMCP);
|
||||
break;
|
||||
case kpidIsFolder:
|
||||
propVariant = _fileInfo.IsDirectory();
|
||||
break;
|
||||
case kpidSize:
|
||||
propVariant = _fileInfo.Size;
|
||||
break;
|
||||
case kpidAttributes:
|
||||
propVariant = (UINT32)_fileInfo.Attributes;
|
||||
break;
|
||||
case kpidLastAccessTime:
|
||||
propVariant = _fileInfo.LastAccessTime;
|
||||
break;
|
||||
case kpidCreationTime:
|
||||
propVariant = _fileInfo.CreationTime;
|
||||
break;
|
||||
case kpidLastWriteTime:
|
||||
propVariant = _fileInfo.LastWriteTime;
|
||||
break;
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT GetPassword(UString &password)
|
||||
{
|
||||
password.Empty();
|
||||
CInitDialogItem initItems[]=
|
||||
{
|
||||
{ DI_DOUBLEBOX, 3, 1, 72, 4, false, false, 0, false, NMessageID::kGetPasswordTitle, NULL, NULL },
|
||||
{ DI_TEXT, 5, 2, 0, 0, false, false, DIF_SHOWAMPERSAND, false, NMessageID::kEnterPasswordForFile, NULL, NULL },
|
||||
{ DI_PSWEDIT, 5, 3, 70, 3, true, false, 0, true, -1, "", NULL }
|
||||
};
|
||||
|
||||
const int kNumItems = sizeof(initItems)/sizeof(initItems[0]);
|
||||
FarDialogItem dialogItems[kNumItems];
|
||||
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumItems);
|
||||
|
||||
// sprintf(DialogItems[1].Data,GetMsg(MGetPasswordForFile),FileName);
|
||||
if (g_StartupInfo.ShowDialog(76, 6, NULL, dialogItems, kNumItems) < 0)
|
||||
return (E_ABORT);
|
||||
|
||||
AString oemPassword = dialogItems[2].Data;
|
||||
password = MultiByteToUnicodeString(oemPassword, CP_OEMCP);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
|
||||
{
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
RINOK(GetPassword(Password));
|
||||
PasswordIsDefined = true;
|
||||
}
|
||||
CMyComBSTR temp = Password;
|
||||
*password = temp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT OpenArchive(const CSysString &fileName,
|
||||
IInFolderArchive **archiveHandlerResult,
|
||||
CArchiverInfo &archiverInfoResult,
|
||||
UString &defaultName,
|
||||
IArchiveOpenCallback *openArchiveCallback)
|
||||
{
|
||||
HRESULT OpenArchive(const CSysString &fileName,
|
||||
#ifndef EXCLUDE_COM
|
||||
HMODULE *module,
|
||||
#endif
|
||||
IInArchive **archive,
|
||||
CArchiverInfo &archiverInfoResult,
|
||||
IArchiveOpenCallback *openArchiveCallback);
|
||||
}
|
||||
*/
|
||||
|
||||
static HANDLE MyOpenFilePlugin(const char *name)
|
||||
{
|
||||
UINT codePage = ::AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
|
||||
UString normalizedName = GetUnicodeString(name, codePage);
|
||||
normalizedName.Trim();
|
||||
UString fullName;
|
||||
int fileNamePartStartIndex;
|
||||
NFile::NDirectory::MyGetFullPathName(normalizedName, fullName, fileNamePartStartIndex);
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
if (!NFile::NFind::FindFile(fullName, fileInfo))
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileInfo.IsDirectory())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
|
||||
CMyComPtr<IInFolderArchive> archiveHandler;
|
||||
|
||||
// CArchiverInfo archiverInfoResult;
|
||||
// ::OutputDebugString("before OpenArchive\n");
|
||||
|
||||
COpenArchiveCallback *openArchiveCallbackSpec = new COpenArchiveCallback;
|
||||
|
||||
CMyComPtr<IArchiveOpenCallback> openArchiveCallback = openArchiveCallbackSpec;
|
||||
|
||||
// if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
|
||||
CScreenRestorer screenRestorer;
|
||||
CMessageBox m_MessageBox;
|
||||
{
|
||||
screenRestorer.Save();
|
||||
}
|
||||
openArchiveCallbackSpec->Init(&m_MessageBox);
|
||||
openArchiveCallbackSpec->LoadFileInfo(
|
||||
fullName.Left(fileNamePartStartIndex),
|
||||
fullName.Mid(fileNamePartStartIndex));
|
||||
|
||||
// ::OutputDebugString("before OpenArchive\n");
|
||||
|
||||
// UString defaultName;
|
||||
|
||||
archiveHandler = new CAgent;
|
||||
CMyComBSTR archiveType;
|
||||
HRESULT result = archiveHandler->Open(
|
||||
GetUnicodeString(fullName, CP_OEMCP), &archiveType, openArchiveCallback);
|
||||
/*
|
||||
HRESULT result = ::OpenArchive(fullName, &archiveHandler,
|
||||
archiverInfoResult, defaultName, openArchiveCallback);
|
||||
*/
|
||||
if (result != S_OK)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
// ::OutputDebugString("after OpenArchive\n");
|
||||
|
||||
/*
|
||||
std::auto_ptr<CProxyHandler> aProxyHandler(new CProxyHandler());
|
||||
|
||||
if(aProxyHandler->Init(archiveHandler,
|
||||
fileInfo,
|
||||
GetDefaultName(fullName, archiverInfoResult.Extension),
|
||||
openArchiveCallbackSpec) != S_OK)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
// ::OutputDebugString("after Init\n");
|
||||
*/
|
||||
|
||||
CPlugin *plugin = new CPlugin(
|
||||
fullName,
|
||||
// defaultName,
|
||||
archiveHandler,
|
||||
(const wchar_t *)archiveType
|
||||
);
|
||||
if (plugin == NULL)
|
||||
return(INVALID_HANDLE_VALUE);
|
||||
plugin->PasswordIsDefined = openArchiveCallbackSpec->PasswordIsDefined;
|
||||
plugin->Password = openArchiveCallbackSpec->Password;
|
||||
|
||||
return (HANDLE)(plugin);
|
||||
}
|
||||
|
||||
HANDLE WINAPI OpenFilePlugin(char *name,
|
||||
const unsigned char *data, unsigned int dataSize)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
if (name == NULL || (!g_Options.Enabled))
|
||||
{
|
||||
// if (!Opt.ProcessShiftF1)
|
||||
return(INVALID_HANDLE_VALUE);
|
||||
}
|
||||
return MyOpenFilePlugin(name);
|
||||
MY_TRY_END2("OpenFilePlugin", INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
HANDLE WINAPI OpenPlugin(int openFrom, int item)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
if(openFrom == OPEN_COMMANDLINE)
|
||||
{
|
||||
CSysString fileName = (const char *)item;
|
||||
if(fileName.IsEmpty())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileName.Length() >= 2 &&
|
||||
fileName[0] == '\"' && fileName[fileName.Length() - 1] == '\"')
|
||||
fileName = fileName.Mid(1, fileName.Length() - 2);
|
||||
|
||||
return MyOpenFilePlugin(fileName);
|
||||
}
|
||||
if(openFrom == OPEN_PLUGINSMENU)
|
||||
{
|
||||
switch(item)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
PluginPanelItem pluginPanelItem;
|
||||
if(!g_StartupInfo.ControlGetActivePanelCurrentItemInfo(pluginPanelItem))
|
||||
throw 142134;
|
||||
return MyOpenFilePlugin(pluginPanelItem.FindData.cFileName);
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
CObjectVector<PluginPanelItem> pluginPanelItem;
|
||||
if(!g_StartupInfo.ControlGetActivePanelSelectedOrCurrentItems(pluginPanelItem))
|
||||
throw 142134;
|
||||
if (CompressFiles(pluginPanelItem) == S_OK)
|
||||
{
|
||||
int t = g_StartupInfo.ControlClearPanelSelection();
|
||||
g_StartupInfo.ControlRequestActivePanel(FCTL_UPDATEPANEL, NULL);
|
||||
g_StartupInfo.ControlRequestActivePanel(FCTL_REDRAWPANEL, NULL);
|
||||
g_StartupInfo.ControlRequestActivePanel(FCTL_UPDATEANOTHERPANEL, NULL);
|
||||
g_StartupInfo.ControlRequestActivePanel(FCTL_REDRAWANOTHERPANEL, NULL);
|
||||
}
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
default:
|
||||
throw 4282215;
|
||||
}
|
||||
}
|
||||
return INVALID_HANDLE_VALUE;
|
||||
MY_TRY_END2("OpenPlugin", INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
void WINAPI ClosePlugin(HANDLE plugin)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
delete (CPlugin *)plugin;
|
||||
MY_TRY_END1("ClosePlugin");
|
||||
}
|
||||
|
||||
int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems,
|
||||
int *itemsNumber,int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->GetFindData(panelItems, itemsNumber, opMode));
|
||||
MY_TRY_END2("GetFindData", FALSE);
|
||||
}
|
||||
|
||||
void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
((CPlugin *)plugin)->FreeFindData(panelItems, itemsNumber);
|
||||
MY_TRY_END1("FreeFindData");
|
||||
}
|
||||
|
||||
int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, char *destPath, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->GetFiles(panelItems, itemsNumber, move, destPath, opMode));
|
||||
MY_TRY_END2("GetFiles", NFileOperationReturnCode::kError);
|
||||
}
|
||||
|
||||
int WINAPI SetDirectory(HANDLE plugin, char *dir, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->SetDirectory(dir, opMode));
|
||||
MY_TRY_END2("SetDirectory", FALSE);
|
||||
}
|
||||
|
||||
void WINAPI GetPluginInfo(struct PluginInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
|
||||
info->StructSize = sizeof(*info);
|
||||
info->Flags = 0;
|
||||
info->DiskMenuStrings = NULL;
|
||||
info->DiskMenuNumbers = NULL;
|
||||
info->DiskMenuStringsNumber = 0;
|
||||
static const char *pluginMenuStrings[2];
|
||||
pluginMenuStrings[0] = g_StartupInfo.GetMsgString(NMessageID::kOpenArchiveMenuString);
|
||||
pluginMenuStrings[1] = g_StartupInfo.GetMsgString(NMessageID::kCreateArchiveMenuString);
|
||||
info->PluginMenuStrings = (char **)pluginMenuStrings;
|
||||
info->PluginMenuStringsNumber = 2;
|
||||
static const char *pluginCfgStrings[1];
|
||||
pluginCfgStrings[0] = g_StartupInfo.GetMsgString(NMessageID::kOpenArchiveMenuString);
|
||||
info->PluginConfigStrings = (char **)pluginCfgStrings;
|
||||
info->PluginConfigStringsNumber = sizeof(pluginCfgStrings) / sizeof(pluginCfgStrings[0]);
|
||||
info->CommandPrefix = (char *)kCommandPrefix;
|
||||
MY_TRY_END1("GetPluginInfo");
|
||||
}
|
||||
|
||||
int WINAPI Configure(int itemNumber)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
|
||||
const int kEnabledCheckBoxIndex = 1;
|
||||
|
||||
const int kYSize = 7;
|
||||
|
||||
struct CInitDialogItem initItems[]=
|
||||
{
|
||||
{ DI_DOUBLEBOX, 3, 1, 72, kYSize - 2, false, false, 0, false, NMessageID::kConfigTitle, NULL, NULL },
|
||||
{ DI_CHECKBOX, 5, 2, 0, 0, true, g_Options.Enabled, 0, false, NMessageID::kConfigPluginEnabled, NULL, NULL },
|
||||
{ DI_TEXT, 5, 3, 0, 0, false, false, DIF_BOXCOLOR | DIF_SEPARATOR, false, -1, "", NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kOk, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kCancel, NULL, NULL },
|
||||
};
|
||||
|
||||
const int kNumDialogItems = sizeof(initItems) / sizeof(initItems[0]);
|
||||
const int kOkButtonIndex = kNumDialogItems - 2;
|
||||
|
||||
FarDialogItem dialogItems[kNumDialogItems];
|
||||
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems);
|
||||
|
||||
int askCode = g_StartupInfo.ShowDialog(76, kYSize,
|
||||
kHelpTopicConfig, dialogItems, kNumDialogItems);
|
||||
|
||||
if (askCode != kOkButtonIndex)
|
||||
return (FALSE);
|
||||
|
||||
g_Options.Enabled = BOOLToBool(dialogItems[kEnabledCheckBoxIndex].Selected);
|
||||
|
||||
g_StartupInfo.SetRegKeyValue(HKEY_CURRENT_USER, kRegisrtryMainKeyName,
|
||||
kRegisrtryValueNameEnabled, g_Options.Enabled);
|
||||
return(TRUE);
|
||||
MY_TRY_END2("Configure", FALSE);
|
||||
}
|
||||
|
||||
void WINAPI GetOpenPluginInfo(HANDLE plugin,struct OpenPluginInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
((CPlugin *)plugin)->GetOpenPluginInfo(info);
|
||||
MY_TRY_END1("GetOpenPluginInfo");
|
||||
}
|
||||
|
||||
int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->PutFiles(panelItems, itemsNumber, move, opMode));
|
||||
MY_TRY_END2("PutFiles", NFileOperationReturnCode::kError);
|
||||
}
|
||||
|
||||
int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems,
|
||||
int itemsNumber, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->DeleteFiles(panelItems, itemsNumber, opMode));
|
||||
MY_TRY_END2("DeleteFiles", FALSE);
|
||||
}
|
||||
|
||||
int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return (((CPlugin *)plugin)->ProcessKey(key, controlState));
|
||||
MY_TRY_END2("ProcessKey", FALSE);
|
||||
}
|
||||
152
7zip/UI/Far/Messages.h
Executable file
152
7zip/UI/Far/Messages.h
Executable file
@@ -0,0 +1,152 @@
|
||||
// SevenZip/ Messages.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __SEVENZIP_MESSAGES_H
|
||||
#define __SEVENZIP_MESSAGES_H
|
||||
|
||||
namespace NMessageID {
|
||||
|
||||
enum EEnum
|
||||
{
|
||||
kOk,
|
||||
kCancel,
|
||||
|
||||
kWarning,
|
||||
kError,
|
||||
|
||||
kArchiveType,
|
||||
|
||||
kProperties,
|
||||
|
||||
kYes,
|
||||
kNo,
|
||||
|
||||
kName,
|
||||
kExtension,
|
||||
kIsFolder,
|
||||
kSize,
|
||||
kPackedSize,
|
||||
kAttributes,
|
||||
kCreationTime,
|
||||
kLastAccessTime,
|
||||
kLastWriteTime,
|
||||
kSolid,
|
||||
kCommented,
|
||||
kEncrypted,
|
||||
kSplitBefore,
|
||||
kSplitAfter,
|
||||
kDictionarySize,
|
||||
kCRC,
|
||||
kType,
|
||||
kAnti,
|
||||
kMethod,
|
||||
kHostOS,
|
||||
kFileSystem,
|
||||
kUser,
|
||||
kGroup,
|
||||
kBlock,
|
||||
kComment,
|
||||
|
||||
kGetPasswordTitle,
|
||||
kEnterPasswordForFile,
|
||||
|
||||
kExtractTitle,
|
||||
kExtractTo,
|
||||
|
||||
kExtractPathMode,
|
||||
kExtractPathFull,
|
||||
kExtractPathCurrent,
|
||||
kExtractPathNo,
|
||||
|
||||
kExtractOwerwriteMode,
|
||||
kExtractOwerwriteAsk,
|
||||
kExtractOwerwritePrompt,
|
||||
kExtractOwerwriteSkip,
|
||||
kExtractOwerwriteAutoRename,
|
||||
|
||||
kExtractFilesMode,
|
||||
kExtractFilesSelected,
|
||||
kExtractFilesAll,
|
||||
|
||||
kExtractPassword,
|
||||
|
||||
kExtractExtract,
|
||||
kExtractCancel,
|
||||
|
||||
kExtractCanNotOpenOutputFile,
|
||||
|
||||
kExtractUnsupportedMethod,
|
||||
kExtractCRCFailed,
|
||||
kExtractDataError,
|
||||
|
||||
kOverwriteTitle,
|
||||
kOverwriteMessage1,
|
||||
kOverwriteMessageWouldYouLike,
|
||||
kOverwriteMessageWithtTisOne,
|
||||
|
||||
kOverwriteBytes,
|
||||
kOverwriteModifiedOn,
|
||||
|
||||
kOverwriteYes,
|
||||
kOverwriteYesToAll,
|
||||
kOverwriteNo,
|
||||
kOverwriteNoToAll,
|
||||
kOverwriteAutoRename,
|
||||
kOverwriteCancel,
|
||||
|
||||
kUpdateNotSupportedForThisArchive,
|
||||
|
||||
kDeleteTitle,
|
||||
kDeleteFile,
|
||||
kDeleteFiles,
|
||||
kDeleteNumberOfFiles,
|
||||
kDeleteDelete,
|
||||
kDeleteCancel,
|
||||
|
||||
kUpdateTitle,
|
||||
kUpdateAddToArchive,
|
||||
|
||||
kUpdateMethod,
|
||||
kUpdateMethodStore,
|
||||
kUpdateMethodFastest,
|
||||
kUpdateMethodFast,
|
||||
kUpdateMethodNormal,
|
||||
kUpdateMethodMaximum,
|
||||
kUpdateMethodUltra,
|
||||
|
||||
kUpdateMode,
|
||||
kUpdateModeAdd,
|
||||
kUpdateModeUpdate,
|
||||
kUpdateModeFreshen,
|
||||
kUpdateModeSynchronize,
|
||||
|
||||
kUpdateAdd,
|
||||
kUpdateSelectArchiver,
|
||||
|
||||
kUpdateSelectArchiverMenuTitle,
|
||||
|
||||
// kArcReadFiles,
|
||||
|
||||
kWaitTitle,
|
||||
|
||||
kReading,
|
||||
kExtracting,
|
||||
kDeleting,
|
||||
kUpdating,
|
||||
|
||||
// kReadingList,
|
||||
|
||||
kMoveIsNotSupported,
|
||||
|
||||
kOpenArchiveMenuString,
|
||||
kCreateArchiveMenuString,
|
||||
|
||||
kConfigTitle,
|
||||
|
||||
kConfigPluginEnabled
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
106
7zip/UI/Far/OverwriteDialog.cpp
Executable file
106
7zip/UI/Far/OverwriteDialog.cpp
Executable file
@@ -0,0 +1,106 @@
|
||||
// OverwriteDialog.cpp : implementation file
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "OverwriteDialog.h"
|
||||
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Far/FarUtils.h"
|
||||
#include "Messages.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
namespace NOverwriteDialog {
|
||||
|
||||
static const char *kHelpTopic = "OverwriteDialog";
|
||||
|
||||
struct CFileInfoStrings
|
||||
{
|
||||
CSysString Size;
|
||||
CSysString Time;
|
||||
};
|
||||
|
||||
void SetFileInfoStrings(const CFileInfo &fileInfo,
|
||||
CFileInfoStrings &fileInfoStrings)
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
if (fileInfo.SizeIsDefined)
|
||||
{
|
||||
sprintf(buffer, "%I64u ", fileInfo.Size);
|
||||
fileInfoStrings.Size = buffer;
|
||||
fileInfoStrings.Size += g_StartupInfo.GetMsgString(NMessageID::kOverwriteBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileInfoStrings.Size = "";
|
||||
}
|
||||
|
||||
FILETIME localFileTime;
|
||||
if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
|
||||
throw 4190402;
|
||||
UString timeString = ConvertFileTimeToString2(localFileTime);
|
||||
|
||||
fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn);
|
||||
fileInfoStrings.Time += " ";
|
||||
fileInfoStrings.Time += GetSystemString(timeString, CP_OEMCP);
|
||||
}
|
||||
|
||||
NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInfo)
|
||||
{
|
||||
const int kYSize = 20;
|
||||
const int kXSize = 76;
|
||||
|
||||
CFileInfoStrings oldFileInfoStrings;
|
||||
CFileInfoStrings newFileInfoStrings;
|
||||
|
||||
SetFileInfoStrings(oldFileInfo, oldFileInfoStrings);
|
||||
SetFileInfoStrings(newFileInfo, newFileInfoStrings);
|
||||
|
||||
struct CInitDialogItem anInitItems[]={
|
||||
{ DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, NMessageID::kOverwriteTitle, NULL, NULL },
|
||||
{ DI_TEXT, 5, 2, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessage1, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 3, 3, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
|
||||
|
||||
{ DI_TEXT, 5, 4, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWouldYouLike, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 7, 6, 0, 0, false, false, 0, false, -1, oldFileInfo.Name, NULL },
|
||||
{ DI_TEXT, 7, 7, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Size, NULL },
|
||||
{ DI_TEXT, 7, 8, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Time, NULL },
|
||||
|
||||
{ DI_TEXT, 5, 10, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWithtTisOne, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 7, 12, 0, 0, false, false, 0, false, -1, newFileInfo.Name, NULL },
|
||||
{ DI_TEXT, 7, 13, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Size, NULL },
|
||||
{ DI_TEXT, 7, 14, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Time, NULL },
|
||||
|
||||
{ DI_TEXT, 3, kYSize - 5, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
|
||||
|
||||
{ DI_BUTTON, 0, kYSize - 4, 0, 0, true, false, DIF_CENTERGROUP, true, NMessageID::kOverwriteYes, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 4, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kOverwriteYesToAll, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 4, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kOverwriteNo, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 4, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kOverwriteNoToAll, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kOverwriteAutoRename, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kOverwriteCancel, NULL, NULL }
|
||||
};
|
||||
|
||||
const int kNumDialogItems = sizeof(anInitItems) / sizeof(anInitItems[0]);
|
||||
FarDialogItem aDialogItems[kNumDialogItems];
|
||||
g_StartupInfo.InitDialogItems(anInitItems, aDialogItems, kNumDialogItems);
|
||||
int anAskCode = g_StartupInfo.ShowDialog(kXSize, kYSize,
|
||||
NULL, aDialogItems, kNumDialogItems);
|
||||
const int kButtonStartPos = kNumDialogItems - 6;
|
||||
if (anAskCode >= kButtonStartPos && anAskCode < kNumDialogItems)
|
||||
return NResult::EEnum(anAskCode - kButtonStartPos);
|
||||
return NResult::kCancel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
35
7zip/UI/Far/OverwriteDialog.h
Executable file
35
7zip/UI/Far/OverwriteDialog.h
Executable file
@@ -0,0 +1,35 @@
|
||||
// OverwriteDialog.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef OVERWRITEDIALOG_H
|
||||
#define OVERWRITEDIALOG_H
|
||||
|
||||
#include "Common/String.h"
|
||||
|
||||
namespace NOverwriteDialog {
|
||||
|
||||
struct CFileInfo
|
||||
{
|
||||
bool SizeIsDefined;
|
||||
UINT64 Size;
|
||||
FILETIME Time;
|
||||
CSysString Name;
|
||||
};
|
||||
namespace NResult
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kYes,
|
||||
kYesToAll,
|
||||
kNo,
|
||||
kNoToAll,
|
||||
kAutoRename,
|
||||
kCancel,
|
||||
};
|
||||
}
|
||||
NResult::EEnum Execute(const CFileInfo &anOldFileInfo, const CFileInfo &aNewFileInfo);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
690
7zip/UI/Far/Plugin.cpp
Executable file
690
7zip/UI/Far/Plugin.cpp
Executable file
@@ -0,0 +1,690 @@
|
||||
// Plugin.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
// #include "Windows/Time.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
#include "Far/FarUtils.h"
|
||||
|
||||
#include "../Common/PropIDUtils.h"
|
||||
|
||||
#include "Common/WildCard.h"
|
||||
|
||||
#include "Messages.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
CSysString ConvertPropertyToString2(const PROPVARIANT &propVariant, PROPID propID)
|
||||
{
|
||||
if (propVariant.vt == VT_BSTR)
|
||||
return GetSystemString(propVariant.bstrVal, CP_OEMCP);
|
||||
if (propVariant.vt != VT_BOOL)
|
||||
return GetSystemString(ConvertPropertyToString(propVariant, propID), CP_OEMCP);
|
||||
int messageID = VARIANT_BOOLToBool(propVariant.boolVal) ?
|
||||
NMessageID::kYes : NMessageID::kNo;
|
||||
return g_StartupInfo.GetMsgString(messageID);
|
||||
}
|
||||
|
||||
CPlugin::CPlugin(const UString &fileName,
|
||||
// const UString &defaultName,
|
||||
IInFolderArchive *archiveHandler,
|
||||
UString archiveTypeName
|
||||
):
|
||||
m_ArchiveHandler(archiveHandler),
|
||||
m_FileName(fileName),
|
||||
_archiveTypeName(archiveTypeName)
|
||||
// , m_DefaultName(defaultName)
|
||||
// , m_ArchiverInfo(archiverInfo)
|
||||
{
|
||||
if (!NFile::NFind::FindFile(m_FileName, m_FileInfo))
|
||||
throw "error";
|
||||
archiveHandler->BindToRootFolder(&_folder);
|
||||
}
|
||||
|
||||
CPlugin::~CPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
static void MyGetFileTime(IFolderFolder *anArchiveFolder, UINT32 itemIndex,
|
||||
PROPID propID, FILETIME &fileTime)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (anArchiveFolder->GetProperty(itemIndex, propID, &propVariant) != S_OK)
|
||||
throw 271932;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
{
|
||||
fileTime.dwHighDateTime = 0;
|
||||
fileTime.dwLowDateTime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (propVariant.vt != VT_FILETIME)
|
||||
throw 4191730;
|
||||
fileTime = propVariant.filetime;
|
||||
}
|
||||
}
|
||||
|
||||
void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UINT32 itemIndex)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (_folder->GetProperty(itemIndex, kpidName, &propVariant) != S_OK)
|
||||
throw 271932;
|
||||
|
||||
if (propVariant.vt != VT_BSTR)
|
||||
throw 272340;
|
||||
|
||||
CSysString oemString = UnicodeStringToMultiByte(propVariant.bstrVal, CP_OEMCP);
|
||||
strcpy(panelItem.FindData.cFileName, oemString);
|
||||
panelItem.FindData.cAlternateFileName[0] = 0;
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidAttributes, &propVariant) != S_OK)
|
||||
throw 271932;
|
||||
if (propVariant.vt == VT_UI4)
|
||||
panelItem.FindData.dwFileAttributes = propVariant.ulVal;
|
||||
else if (propVariant.vt == VT_EMPTY)
|
||||
panelItem.FindData.dwFileAttributes = m_FileInfo.Attributes;
|
||||
else
|
||||
throw 21631;
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidIsFolder, &propVariant) != S_OK)
|
||||
throw 271932;
|
||||
if (propVariant.vt == VT_BOOL)
|
||||
{
|
||||
if (VARIANT_BOOLToBool(propVariant.boolVal))
|
||||
panelItem.FindData.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
}
|
||||
else if (propVariant.vt != VT_EMPTY)
|
||||
throw 21632;
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidSize, &propVariant) != S_OK)
|
||||
throw 271932;
|
||||
UINT64 length;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
length = 0;
|
||||
else
|
||||
length = ::ConvertPropVariantToUINT64(propVariant);
|
||||
panelItem.FindData.nFileSizeLow = UINT32(length);
|
||||
panelItem.FindData.nFileSizeHigh = UINT32(length >> 32);
|
||||
|
||||
MyGetFileTime(_folder, itemIndex, kpidCreationTime, panelItem.FindData.ftCreationTime);
|
||||
MyGetFileTime(_folder, itemIndex, kpidLastAccessTime, panelItem.FindData.ftLastAccessTime);
|
||||
MyGetFileTime(_folder, itemIndex, kpidLastWriteTime, panelItem.FindData.ftLastWriteTime);
|
||||
|
||||
if (panelItem.FindData.ftLastWriteTime.dwHighDateTime == 0 &&
|
||||
panelItem.FindData.ftLastWriteTime.dwLowDateTime == 0)
|
||||
panelItem.FindData.ftLastWriteTime = m_FileInfo.LastWriteTime;
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidPackedSize, &propVariant) != S_OK)
|
||||
throw 271932;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
length = 0;
|
||||
else
|
||||
length = ::ConvertPropVariantToUINT64(propVariant);
|
||||
panelItem.PackSize = UINT32(length);
|
||||
panelItem.PackSizeHigh = UINT32(length >> 32);
|
||||
|
||||
panelItem.Flags = 0;
|
||||
panelItem.NumberOfLinks = 0;
|
||||
|
||||
panelItem.Description = NULL;
|
||||
panelItem.Owner = NULL;
|
||||
panelItem.CustomColumnData = NULL;
|
||||
panelItem.CustomColumnNumber = 0;
|
||||
|
||||
panelItem.Reserved[0] = 0;
|
||||
panelItem.Reserved[1] = 0;
|
||||
panelItem.Reserved[2] = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int CPlugin::GetFindData(PluginPanelItem **panelItems,
|
||||
int *itemsNumber, int opMode)
|
||||
{
|
||||
// CScreenRestorer screenRestorer;
|
||||
if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
|
||||
{
|
||||
/*
|
||||
screenRestorer.Save();
|
||||
const char *aMsgItems[]=
|
||||
{
|
||||
g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kReadingList)
|
||||
};
|
||||
g_StartupInfo.ShowMessage(0, NULL, aMsgItems,
|
||||
sizeof(aMsgItems) / sizeof(aMsgItems[0]), 0);
|
||||
*/
|
||||
}
|
||||
|
||||
UINT32 numItems;
|
||||
_folder->GetNumberOfItems(&numItems);
|
||||
*panelItems = new PluginPanelItem[numItems];
|
||||
try
|
||||
{
|
||||
for(int i = 0; i < numItems; i++)
|
||||
{
|
||||
PluginPanelItem &panelItem = (*panelItems)[i];
|
||||
ReadPluginPanelItem(panelItem, i);
|
||||
panelItem.UserData = i;
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete [](*panelItems);
|
||||
throw;
|
||||
}
|
||||
*itemsNumber = numItems;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
void CPlugin::FreeFindData(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber)
|
||||
{
|
||||
for(int i = 0; i < itemsNumber; i++)
|
||||
if(panelItems[i].Description != NULL)
|
||||
delete []panelItems[i].Description;
|
||||
delete []panelItems;
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::EnterToDirectory(const UString &aDirName)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(aDirName, &newFolder);
|
||||
if(newFolder == NULL)
|
||||
if (aDirName.IsEmpty())
|
||||
return;
|
||||
else
|
||||
throw 40325;
|
||||
_folder = newFolder;
|
||||
}
|
||||
|
||||
int CPlugin::SetDirectory(const char *aszDir, int opMode)
|
||||
{
|
||||
UString aDir = MultiByteToUnicodeString(aszDir, CP_OEMCP);
|
||||
if (aDir == L"\\")
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
}
|
||||
else if (aDir == L"..")
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToParentFolder(&newFolder);
|
||||
if (newFolder == NULL)
|
||||
throw 40312;
|
||||
_folder = newFolder;
|
||||
}
|
||||
else if (aDir.IsEmpty())
|
||||
EnterToDirectory(aDir);
|
||||
else
|
||||
{
|
||||
if (aDir[0] == L'\\')
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
aDir = aDir.Mid(1);
|
||||
}
|
||||
UStringVector pathParts;
|
||||
SplitPathToParts(aDir, pathParts);
|
||||
for(int i = 0; i < pathParts.Size(); i++)
|
||||
EnterToDirectory(pathParts[i]);
|
||||
}
|
||||
m_CurrentDir.Empty();
|
||||
UStringVector pathParts;
|
||||
GetPathParts(pathParts);
|
||||
for (int i = 0; i < pathParts.Size(); i++)
|
||||
{
|
||||
m_CurrentDir += L'\\';
|
||||
m_CurrentDir += pathParts[i];
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPlugin::GetPathParts(UStringVector &pathParts)
|
||||
{
|
||||
pathParts.Clear();
|
||||
CMyComPtr<IFolderFolder> folderItem = _folder;
|
||||
while (true)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
folderItem->BindToParentFolder(&newFolder);
|
||||
if (newFolder == NULL)
|
||||
break;
|
||||
CMyComBSTR name;
|
||||
folderItem->GetName(&name);
|
||||
pathParts.Insert(0, (const wchar_t *)name);
|
||||
folderItem = newFolder;
|
||||
}
|
||||
}
|
||||
|
||||
static char *kPluginFormatName = "7-ZIP";
|
||||
|
||||
|
||||
struct CPROPIDToName
|
||||
{
|
||||
PROPID PropID;
|
||||
int PluginID;
|
||||
};
|
||||
|
||||
static CPROPIDToName kPROPIDToName[] =
|
||||
{
|
||||
{ kpidName, NMessageID::kName },
|
||||
{ kpidExtension, NMessageID::kExtension },
|
||||
{ kpidIsFolder, NMessageID::kIsFolder },
|
||||
{ kpidSize, NMessageID::kSize },
|
||||
{ kpidPackedSize, NMessageID::kPackedSize },
|
||||
{ kpidAttributes, NMessageID::kAttributes },
|
||||
{ kpidCreationTime, NMessageID::kCreationTime },
|
||||
{ kpidLastAccessTime, NMessageID::kLastAccessTime },
|
||||
{ kpidLastWriteTime, NMessageID::kLastWriteTime },
|
||||
{ kpidSolid, NMessageID::kSolid },
|
||||
{ kpidCommented, NMessageID::kCommented },
|
||||
{ kpidEncrypted, NMessageID::kEncrypted },
|
||||
{ kpidSplitBefore, NMessageID::kSplitBefore },
|
||||
{ kpidSplitAfter, NMessageID::kSplitAfter },
|
||||
{ kpidDictionarySize, NMessageID::kDictionarySize },
|
||||
{ kpidCRC, NMessageID::kCRC },
|
||||
{ kpidType, NMessageID::kType },
|
||||
{ kpidIsAnti, NMessageID::kAnti },
|
||||
{ kpidMethod, NMessageID::kMethod },
|
||||
{ kpidHostOS, NMessageID::kHostOS },
|
||||
{ kpidFileSystem, NMessageID::kFileSystem },
|
||||
{ kpidUser, NMessageID::kUser },
|
||||
{ kpidGroup, NMessageID::kGroup },
|
||||
{ kpidBlock, NMessageID::kBlock },
|
||||
{ kpidComment, NMessageID::kComment }
|
||||
};
|
||||
|
||||
static const int kNumPROPIDToName = sizeof(kPROPIDToName) / sizeof(kPROPIDToName[0]);
|
||||
|
||||
static int FindPropertyToName(PROPID propID)
|
||||
{
|
||||
for(int i = 0; i < kNumPROPIDToName; i++)
|
||||
if(kPROPIDToName[i].PropID == propID)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
struct CPropertyIDInfo
|
||||
{
|
||||
PROPID PropID;
|
||||
const char *FarID;
|
||||
int Width;
|
||||
// char CharID;
|
||||
};
|
||||
|
||||
static CPropertyIDInfo kPropertyIDInfos[] =
|
||||
{
|
||||
{ kpidName, "N", 0},
|
||||
{ kpidSize, "S", 8},
|
||||
{ kpidPackedSize, "P", 8},
|
||||
{ kpidAttributes, "A", 0},
|
||||
{ kpidCreationTime, "DC", 14},
|
||||
{ kpidLastAccessTime, "DA", 14},
|
||||
{ kpidLastWriteTime, "DM", 14},
|
||||
|
||||
{ kpidSolid, NULL, 0, 'S'},
|
||||
{ kpidEncrypted, NULL, 0, 'P'}
|
||||
|
||||
{ kpidDictionarySize, IDS_PROPERTY_DICTIONARY_SIZE },
|
||||
{ kpidSplitBefore, NULL, 'B'},
|
||||
{ kpidSplitAfter, NULL, 'A'},
|
||||
{ kpidComment, , NULL, 'C'},
|
||||
{ kpidCRC, IDS_PROPERTY_CRC }
|
||||
// { kpidType, L"Type" }
|
||||
};
|
||||
|
||||
static const int kNumPropertyIDInfos = sizeof(kPropertyIDInfos) /
|
||||
sizeof(kPropertyIDInfos[0]);
|
||||
|
||||
static int FindPropertyInfo(PROPID propID)
|
||||
{
|
||||
for(int i = 0; i < kNumPropertyIDInfos; i++)
|
||||
if(kPropertyIDInfos[i].PropID == propID)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
// char *g_Titles[] = { "a", "f", "v" };
|
||||
static void SmartAddToString(AString &aDestString, const char *aSrcString)
|
||||
{
|
||||
if (!aDestString.IsEmpty())
|
||||
aDestString += ',';
|
||||
aDestString += aSrcString;
|
||||
}
|
||||
|
||||
/*
|
||||
void CPlugin::AddColumn(PROPID propID)
|
||||
{
|
||||
int index = FindPropertyInfo(propID);
|
||||
if (index >= 0)
|
||||
{
|
||||
for(int i = 0; i < m_ProxyHandler->m_InternalProperties.Size(); i++)
|
||||
{
|
||||
const CArchiveItemProperty &aHandlerProperty = m_ProxyHandler->m_InternalProperties[i];
|
||||
if (aHandlerProperty.ID == propID)
|
||||
break;
|
||||
}
|
||||
if (i == m_ProxyHandler->m_InternalProperties.Size())
|
||||
return;
|
||||
|
||||
const CPropertyIDInfo &aPropertyIDInfo = kPropertyIDInfos[index];
|
||||
SmartAddToString(PanelModeColumnTypes, aPropertyIDInfo.FarID);
|
||||
char aTmp[32];
|
||||
itoa(aPropertyIDInfo.Width, aTmp, 10);
|
||||
SmartAddToString(PanelModeColumnWidths, aTmp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
{
|
||||
info->StructSize = sizeof(*info);
|
||||
info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS| OPIF_USEHIGHLIGHTING|
|
||||
OPIF_ADDDOTS | OPIF_COMPAREFATTIME;
|
||||
|
||||
UINT codePage = ::AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
|
||||
strcpy(m_FileNameBuffer, UnicodeStringToMultiByte(m_FileName, codePage));
|
||||
info->HostFile = m_FileNameBuffer; // test it it is not static
|
||||
|
||||
strcpy(m_CurrentDirBuffer, UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP));
|
||||
info->CurDir = m_CurrentDirBuffer;
|
||||
|
||||
info->Format = kPluginFormatName;
|
||||
|
||||
UString name;
|
||||
{
|
||||
UString fullName;
|
||||
int index;
|
||||
NFile::NDirectory::MyGetFullPathName(m_FileName, fullName, index);
|
||||
name = fullName.Mid(index);
|
||||
}
|
||||
|
||||
m_PannelTitle =
|
||||
UString(L' ') +
|
||||
_archiveTypeName +
|
||||
UString(L':') +
|
||||
name +
|
||||
UString(L' ');
|
||||
if(!m_CurrentDir.IsEmpty())
|
||||
{
|
||||
// m_PannelTitle += '\\';
|
||||
m_PannelTitle += m_CurrentDir;
|
||||
}
|
||||
|
||||
strcpy(m_PannelTitleBuffer, UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP));
|
||||
info->PanelTitle = m_PannelTitleBuffer;
|
||||
|
||||
memset(m_InfoLines,0,sizeof(m_InfoLines));
|
||||
strcpy(m_InfoLines[0].Text,"");
|
||||
m_InfoLines[0].Separator = TRUE;
|
||||
|
||||
strcpy(m_InfoLines[1].Text, g_StartupInfo.GetMsgString(NMessageID::kArchiveType));
|
||||
strcpy(m_InfoLines[1].Data, UnicodeStringToMultiByte(_archiveTypeName, CP_OEMCP));
|
||||
|
||||
int numItems = 2;
|
||||
UINT32 numProps;
|
||||
if (m_ArchiveHandler->GetNumberOfArchiveProperties(&numProps) == S_OK)
|
||||
{
|
||||
for (UINT32 i = 0; i < numProps && numItems < 30; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
if (m_ArchiveHandler->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK)
|
||||
continue;
|
||||
|
||||
InfoPanelLine &item = m_InfoLines[numItems];
|
||||
int index = FindPropertyToName(propID);
|
||||
if (index < 0)
|
||||
{
|
||||
if (name != 0)
|
||||
strcpy(item.Text, UnicodeStringToMultiByte(
|
||||
(const wchar_t *)name, CP_OEMCP));
|
||||
else
|
||||
strcpy(item.Text, "");
|
||||
}
|
||||
else
|
||||
strcpy(item.Text, g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID));
|
||||
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (m_ArchiveHandler->GetArchiveProperty(propID, &propVariant) != S_OK)
|
||||
continue;
|
||||
CSysString s = ConvertPropertyToString2(propVariant, propID);
|
||||
strcpy(item.Data, s);
|
||||
numItems++;
|
||||
}
|
||||
}
|
||||
|
||||
//m_InfoLines[1].Separator = 0;
|
||||
|
||||
info->InfoLines = m_InfoLines;
|
||||
info->InfoLinesNumber = numItems;
|
||||
|
||||
|
||||
info->DescrFiles = NULL;
|
||||
info->DescrFilesNumber = 0;
|
||||
|
||||
PanelModeColumnTypes.Empty();
|
||||
PanelModeColumnWidths.Empty();
|
||||
|
||||
/*
|
||||
AddColumn(kpidName);
|
||||
AddColumn(kpidSize);
|
||||
AddColumn(kpidPackedSize);
|
||||
AddColumn(kpidLastWriteTime);
|
||||
AddColumn(kpidCreationTime);
|
||||
AddColumn(kpidLastAccessTime);
|
||||
AddColumn(kpidAttributes);
|
||||
|
||||
PanelMode.ColumnTypes = (char *)(const char *)PanelModeColumnTypes;
|
||||
PanelMode.ColumnWidths = (char *)(const char *)PanelModeColumnWidths;
|
||||
PanelMode.ColumnTitles = NULL;
|
||||
PanelMode.FullScreen = TRUE;
|
||||
PanelMode.DetailedStatus = FALSE;
|
||||
PanelMode.AlignExtensions = FALSE;
|
||||
PanelMode.CaseConversion = FALSE;
|
||||
PanelMode.StatusColumnTypes = "N";
|
||||
PanelMode.StatusColumnWidths = "0";
|
||||
PanelMode.Reserved[0] = 0;
|
||||
PanelMode.Reserved[1] = 0;
|
||||
|
||||
info->PanelModesArray = &PanelMode;
|
||||
info->PanelModesNumber = 1;
|
||||
*/
|
||||
|
||||
info->PanelModesArray = NULL;
|
||||
info->PanelModesNumber = 0;
|
||||
|
||||
info->StartPanelMode = 0;
|
||||
info->StartSortMode = 0;
|
||||
info->KeyBar = NULL;
|
||||
info->ShortcutData = NULL;
|
||||
}
|
||||
|
||||
struct CArchiveItemProperty
|
||||
{
|
||||
AString Name;
|
||||
PROPID ID;
|
||||
VARTYPE Type;
|
||||
};
|
||||
|
||||
HRESULT CPlugin::ShowAttributesWindow()
|
||||
{
|
||||
PluginPanelItem pluginPanelItem;
|
||||
if (!g_StartupInfo.ControlGetActivePanelCurrentItemInfo(pluginPanelItem))
|
||||
return S_FALSE;
|
||||
if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 &&
|
||||
NFile::NFind::NAttributes::IsDirectory(pluginPanelItem.FindData.dwFileAttributes))
|
||||
return S_FALSE;
|
||||
int itemIndex = pluginPanelItem.UserData;
|
||||
|
||||
CObjectVector<CArchiveItemProperty> properties;
|
||||
UINT32 numProps;
|
||||
RINOK(m_ArchiveHandler->GetNumberOfProperties(&numProps));
|
||||
int i;
|
||||
for (i = 0; i < numProps; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
RINOK(m_ArchiveHandler->GetPropertyInfo(i, &name, &propID, &vt));
|
||||
CArchiveItemProperty destProperty;
|
||||
destProperty.Type = vt;
|
||||
destProperty.ID = propID;
|
||||
if (destProperty.ID == kpidPath)
|
||||
destProperty.ID = kpidName;
|
||||
AString propName;
|
||||
{
|
||||
if (name != NULL)
|
||||
destProperty.Name = UnicodeStringToMultiByte(
|
||||
(const wchar_t *)name, CP_OEMCP);
|
||||
else
|
||||
destProperty.Name = "Error";
|
||||
}
|
||||
properties.Add(destProperty);
|
||||
}
|
||||
|
||||
/*
|
||||
LPCITEMIDLIST aProperties;
|
||||
if (index < m_FolderItem->m_DirSubItems.Size())
|
||||
{
|
||||
const CArchiveFolderItem &anItem = m_FolderItem->m_DirSubItems[index];
|
||||
aProperties = anItem.m_Properties;
|
||||
}
|
||||
else
|
||||
{
|
||||
const CArchiveFolderFileItem &anItem =
|
||||
m_FolderItem->m_FileSubItems[index - m_FolderItem->m_DirSubItems.Size()];
|
||||
aProperties = anItem.m_Properties;
|
||||
}
|
||||
*/
|
||||
|
||||
const int kPathIndex = 2;
|
||||
const int kOkButtonIndex = 4;
|
||||
int size = 2;
|
||||
CRecordVector<CInitDialogItem> initDialogItems;
|
||||
|
||||
int xSize = 70;
|
||||
CInitDialogItem initDialogItem =
|
||||
{ DI_DOUBLEBOX, 3, 1, xSize - 4, size - 2, false, false, 0, false, NMessageID::kProperties, NULL, NULL };
|
||||
initDialogItems.Add(initDialogItem);
|
||||
AStringVector aValues;
|
||||
|
||||
for (i = 0; i < properties.Size(); i++)
|
||||
{
|
||||
const CArchiveItemProperty &property = properties[i];
|
||||
|
||||
CInitDialogItem initDialogItem =
|
||||
{ DI_TEXT, 5, 3 + i, 0, 0, false, false, 0, false, 0, NULL, NULL };
|
||||
int index = FindPropertyToName(property.ID);
|
||||
if (index < 0)
|
||||
{
|
||||
initDialogItem.DataMessageId = -1;
|
||||
initDialogItem.DataString = property.Name;
|
||||
}
|
||||
else
|
||||
initDialogItem.DataMessageId = kPROPIDToName[index].PluginID;
|
||||
initDialogItems.Add(initDialogItem);
|
||||
|
||||
NCOM::CPropVariant propVariant;
|
||||
RINOK(_folder->GetProperty(itemIndex,
|
||||
property.ID, &propVariant));
|
||||
CSysString aString = ConvertPropertyToString2(propVariant, property.ID);
|
||||
aValues.Add(aString);
|
||||
|
||||
{
|
||||
CInitDialogItem initDialogItem =
|
||||
{ DI_TEXT, 30, 3 + i, 0, 0, false, false, 0, false, -1, NULL, NULL };
|
||||
initDialogItems.Add(initDialogItem);
|
||||
}
|
||||
}
|
||||
|
||||
int numLines = aValues.Size();
|
||||
for(i = 0; i < numLines; i++)
|
||||
{
|
||||
CInitDialogItem &initDialogItem = initDialogItems[1 + i * 2 + 1];
|
||||
initDialogItem.DataString = aValues[i];
|
||||
}
|
||||
|
||||
int numDialogItems = initDialogItems.Size();
|
||||
|
||||
CRecordVector<FarDialogItem> dialogItems;
|
||||
dialogItems.Reserve(numDialogItems);
|
||||
for(i = 0; i < numDialogItems; i++)
|
||||
dialogItems.Add(FarDialogItem());
|
||||
g_StartupInfo.InitDialogItems(&initDialogItems.Front(),
|
||||
&dialogItems.Front(), numDialogItems);
|
||||
|
||||
int maxLen = 0;
|
||||
for (i = 0; i < numLines; i++)
|
||||
{
|
||||
FarDialogItem &dialogItem = dialogItems[1 + i * 2];
|
||||
int len = strlen(dialogItem.Data);
|
||||
if (len > maxLen)
|
||||
maxLen = len;
|
||||
}
|
||||
int maxLen2 = 0;
|
||||
const int kSpace = 10;
|
||||
for (i = 0; i < numLines; i++)
|
||||
{
|
||||
FarDialogItem &dialogItem = dialogItems[1 + i * 2 + 1];
|
||||
int len = strlen(dialogItem.Data);
|
||||
if (len > maxLen2)
|
||||
maxLen2 = len;
|
||||
dialogItem.X1 = maxLen + kSpace;
|
||||
}
|
||||
size = numLines + 6;
|
||||
xSize = maxLen + kSpace + maxLen2 + 5;
|
||||
FarDialogItem &aFirstDialogItem = dialogItems.Front();
|
||||
aFirstDialogItem.Y2 = size - 2;
|
||||
aFirstDialogItem.X2 = xSize - 4;
|
||||
|
||||
int askCode = g_StartupInfo.ShowDialog(xSize, size, NULL, &dialogItems.Front(), numDialogItems);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int CPlugin::ProcessKey(int aKey, unsigned int controlState)
|
||||
{
|
||||
if (controlState == PKF_CONTROL && aKey == 'A')
|
||||
{
|
||||
HRESULT result = ShowAttributesWindow();
|
||||
if (result == S_OK)
|
||||
return TRUE;
|
||||
if (result == S_FALSE)
|
||||
return FALSE;
|
||||
throw "Error";
|
||||
}
|
||||
if ((controlState & PKF_ALT) != 0 && aKey == VK_F6)
|
||||
{
|
||||
UString 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);
|
||||
g_StartupInfo.Control(this, FCTL_UPDATEPANEL, NULL);
|
||||
g_StartupInfo.Control(this, FCTL_REDRAWPANEL, NULL);
|
||||
g_StartupInfo.Control(this, FCTL_UPDATEANOTHERPANEL, NULL);
|
||||
g_StartupInfo.Control(this, FCTL_REDRAWANOTHERPANEL, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
108
7zip/UI/Far/Plugin.h
Executable file
108
7zip/UI/Far/Plugin.h
Executable file
@@ -0,0 +1,108 @@
|
||||
// Far/Plugin.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __FAR_PLUGIN_H
|
||||
#define __FAR_PLUGIN_H
|
||||
|
||||
#include "Windows/COM.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Common/MyCom.h"
|
||||
#include "Far/FarUtils.h"
|
||||
|
||||
#include "../Common/ArchiverInfo.h"
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
class CPlugin
|
||||
{
|
||||
NWindows::NCOM::CComInitializer m_ComInitializer;
|
||||
UString m_CurrentDir;
|
||||
|
||||
UString m_PannelTitle;
|
||||
|
||||
InfoPanelLine m_InfoLines[30]; // Change it;
|
||||
|
||||
char m_FileNameBuffer[1024];
|
||||
char m_CurrentDirBuffer[1024];
|
||||
char m_PannelTitleBuffer[1024];
|
||||
|
||||
AString PanelModeColumnTypes;
|
||||
AString PanelModeColumnWidths;
|
||||
PanelMode PanelMode;
|
||||
void AddColumn(PROPID aPropID);
|
||||
|
||||
|
||||
void EnterToDirectory(const UString &aDirName);
|
||||
|
||||
void GetPathParts(UStringVector &aPathParts);
|
||||
public:
|
||||
UString m_FileName;
|
||||
// UString m_DefaultName;
|
||||
NWindows::NFile::NFind::CFileInfoW m_FileInfo;
|
||||
|
||||
// std::auto_ptr<CProxyHandler> m_ProxyHandler;
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
CMyComPtr<IFolderFolder> _folder;
|
||||
|
||||
// CArchiverInfo m_ArchiverInfo;
|
||||
UString _archiveTypeName;
|
||||
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
|
||||
CPlugin(const UString &fileName,
|
||||
// const UString &aDefaultName,
|
||||
IInFolderArchive *archiveHandler,
|
||||
UString archiveTypeName
|
||||
);
|
||||
~CPlugin();
|
||||
|
||||
void ReadValueSafe(PROPID aPropID, NWindows::NCOM::CPropVariant aPropVariant);
|
||||
void ReadPluginPanelItem(PluginPanelItem &aPanelItem, UINT32 anItemIndex);
|
||||
|
||||
int GetFindData(PluginPanelItem **pPanelItem,int *pItemsNumber,int OpMode);
|
||||
void FreeFindData(PluginPanelItem *PanelItem,int ItemsNumber);
|
||||
int SetDirectory(const char *aDir, int opMode);
|
||||
void GetOpenPluginInfo(struct OpenPluginInfo *anInfo);
|
||||
|
||||
int DeleteFiles(PluginPanelItem *aPanelItems, int itemsNumber, int opMode);
|
||||
|
||||
|
||||
/*
|
||||
void AddRealIndexOfFile(const CArchiveFolderItem &aFolder, int anIndexInVector,
|
||||
std::vector<int> &aRealIndexes);
|
||||
void AddRealIndexes(const CArchiveFolderItem &anItem,
|
||||
std::vector<int> &aRealIndexes);
|
||||
void GetRealIndexes(PluginPanelItem *aPanelItems, int itemsNumber,
|
||||
std::vector<int> &aRealIndexes);
|
||||
*/
|
||||
|
||||
HRESULT ExtractFiles(
|
||||
bool aDecompressAllItems,
|
||||
const UINT32 *anIndexes,
|
||||
UINT32 numIndices,
|
||||
bool aSilent,
|
||||
NExtractionMode::NPath::EEnum aPathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
const UString &destPath,
|
||||
bool aPasswordIsDefined, const UString &password);
|
||||
|
||||
NFar::NFileOperationReturnCode::EEnum GetFiles(struct PluginPanelItem *aPanelItem, int itemsNumber,
|
||||
int move, char *destPath, int opMode);
|
||||
|
||||
NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *aPanelItems,
|
||||
int itemsNumber, int move, const char *_aDestPath, int opMode, bool aShowBox);
|
||||
|
||||
NFar::NFileOperationReturnCode::EEnum PutFiles(struct PluginPanelItem *aPanelItems, int itemsNumber,
|
||||
int move, int opMode);
|
||||
|
||||
HRESULT ShowAttributesWindow();
|
||||
|
||||
int ProcessKey(int aKey, unsigned int aControlState);
|
||||
};
|
||||
|
||||
HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &aPluginPanelItems);
|
||||
|
||||
#endif
|
||||
54
7zip/UI/Far/PluginCommon.cpp
Executable file
54
7zip/UI/Far/PluginCommon.cpp
Executable file
@@ -0,0 +1,54 @@
|
||||
// SevenZip/Plugin.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace std;
|
||||
using namespace NFar;
|
||||
|
||||
/*
|
||||
void CPlugin::AddRealIndexOfFile(const CArchiveFolderItem &aFolder,
|
||||
int anIndexInVector, vector<int> &aRealIndexes)
|
||||
{
|
||||
const CArchiveFolderFileItem &anItem = aFolder.m_FileSubItems[anIndexInVector];
|
||||
int aHandlerItemIndex = m_ProxyHandler->GetHandlerItemIndex(anItem.m_Properties);
|
||||
if(aHandlerItemIndex < 0)
|
||||
throw "error";
|
||||
aRealIndexes.push_back(aHandlerItemIndex);
|
||||
}
|
||||
|
||||
void CPlugin::AddRealIndexes(const CArchiveFolderItem &anItem,
|
||||
vector<int> &aRealIndexes)
|
||||
{
|
||||
int aHandlerItemIndex = m_ProxyHandler->GetHandlerItemIndex(anItem.m_Properties);
|
||||
if(aHandlerItemIndex >= 0) // test -1 value
|
||||
aRealIndexes.push_back(aHandlerItemIndex);
|
||||
for(int i = 0; i < anItem.m_DirSubItems.Size(); i++)
|
||||
AddRealIndexes(anItem.m_DirSubItems[i], aRealIndexes);
|
||||
for(i = 0; i < anItem.m_FileSubItems.Size(); i++)
|
||||
AddRealIndexOfFile(anItem, i , aRealIndexes);
|
||||
}
|
||||
|
||||
|
||||
void CPlugin::GetRealIndexes(PluginPanelItem *aPanelItems, int anItemsNumber,
|
||||
vector<int> &aRealIndexes)
|
||||
{
|
||||
aRealIndexes.clear();
|
||||
for(int i = 0; i < anItemsNumber; i++)
|
||||
{
|
||||
int anIndex = aPanelItems[i].UserData;
|
||||
if (anIndex < m_FolderItem->m_DirSubItems.Size())
|
||||
{
|
||||
const CArchiveFolderItem &anItem = m_FolderItem->m_DirSubItems[anIndex];
|
||||
AddRealIndexes(anItem, aRealIndexes);
|
||||
}
|
||||
else
|
||||
AddRealIndexOfFile(*m_FolderItem, anIndex - m_FolderItem->m_DirSubItems.Size(),
|
||||
aRealIndexes);
|
||||
}
|
||||
sort(aRealIndexes.begin(), aRealIndexes.end());
|
||||
}
|
||||
|
||||
*/
|
||||
169
7zip/UI/Far/PluginDelete.cpp
Executable file
169
7zip/UI/Far/PluginDelete.cpp
Executable file
@@ -0,0 +1,169 @@
|
||||
// PluginDelete.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
#include "Messages.h"
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
#include "../Common/WorkDir.h"
|
||||
// #include "../Common/OpenEngine2.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
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)
|
||||
{
|
||||
if (numItems == 0)
|
||||
return FALSE;
|
||||
/*
|
||||
if (!m_ArchiverInfo.UpdateEnabled)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return FALSE;
|
||||
}
|
||||
*/
|
||||
if ((opMode & OPM_SILENT) == 0)
|
||||
{
|
||||
const char *msgItems[]=
|
||||
{
|
||||
g_StartupInfo.GetMsgString(NMessageID::kDeleteTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kDeleteFiles),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kDeleteDelete),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kDeleteCancel)
|
||||
};
|
||||
char msg[1024];
|
||||
if (numItems == 1)
|
||||
{
|
||||
sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteFile),
|
||||
panelItems[0].FindData.cFileName);
|
||||
msgItems[1] = msg;
|
||||
}
|
||||
else if (numItems > 1)
|
||||
{
|
||||
sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteNumberOfFiles),
|
||||
numItems);
|
||||
msgItems[1] = msg;
|
||||
}
|
||||
if (g_StartupInfo.ShowMessage(FMSG_WARNING, NULL, msgItems,
|
||||
sizeof(msgItems) / sizeof(msgItems[0]), 2) != 0)
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
CScreenRestorer screenRestorer;
|
||||
CProgressBox progressBox;
|
||||
CProgressBox *progressBoxPointer = NULL;
|
||||
if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
|
||||
{
|
||||
screenRestorer.Save();
|
||||
|
||||
progressBoxPointer = &progressBox;
|
||||
progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kDeleting), 1 << 17);
|
||||
}
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
ReadWorkDirInfo(workDirInfo);
|
||||
|
||||
UString workDir = GetWorkDir(workDirInfo, m_FileName);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
CTempFileW tempFile;
|
||||
UString tempFileName;
|
||||
if (tempFile.Create(workDir, kTempArchivePrefix, tempFileName) == 0)
|
||||
return FALSE;
|
||||
|
||||
|
||||
CRecordVector<UINT32> indices;
|
||||
indices.Reserve(numItems);
|
||||
for(int i = 0; i < numItems; i++)
|
||||
indices.Add(panelItems[i].UserData);
|
||||
|
||||
////////////////////////////
|
||||
// Save _folder;
|
||||
|
||||
UStringVector pathVector;
|
||||
GetPathParts(pathVector);
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
HRESULT result = m_ArchiveHandler.QueryInterface(
|
||||
IID_IOutFolderArchive, &outArchive);
|
||||
if(result != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return FALSE;
|
||||
}
|
||||
outArchive->SetFolder(_folder);
|
||||
|
||||
CUpdateCallBack100Imp *updateCallbackSpec = new CUpdateCallBack100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(m_ArchiveHandler, &progressBox);
|
||||
|
||||
|
||||
result = outArchive->DeleteItems(
|
||||
tempFileName,
|
||||
&indices.Front(), indices.Size(),
|
||||
updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
304
7zip/UI/Far/PluginRead.cpp
Executable file
304
7zip/UI/Far/PluginRead.cpp
Executable file
@@ -0,0 +1,304 @@
|
||||
// PluginRead.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Messages.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "ExtractEngine.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace NFar;
|
||||
using namespace NWindows;
|
||||
|
||||
static const char *kHelpTopicExtrFromSevenZip = "Extract";
|
||||
|
||||
static const char kDirDelimiter = '\\';
|
||||
|
||||
static const char *kExractPathHistoryName = "7-ZipExtractPath";
|
||||
|
||||
HRESULT CPlugin::ExtractFiles(
|
||||
bool decompressAllItems,
|
||||
const UINT32 *indices,
|
||||
UINT32 numIndices,
|
||||
bool silent,
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
const UString &destPath,
|
||||
bool passwordIsDefined, const UString &password)
|
||||
{
|
||||
CScreenRestorer screenRestorer;
|
||||
CProgressBox progressBox;
|
||||
CProgressBox *progressBoxPointer = NULL;
|
||||
if (!silent)
|
||||
{
|
||||
screenRestorer.Save();
|
||||
|
||||
progressBoxPointer = &progressBox;
|
||||
progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kExtracting), 1 << 17);
|
||||
}
|
||||
|
||||
|
||||
CExtractCallBackImp *extractCallbackSpec = new CExtractCallBackImp;
|
||||
CMyComPtr<IFolderArchiveExtractCallback> extractCallback(extractCallbackSpec);
|
||||
|
||||
extractCallbackSpec->Init(
|
||||
CP_OEMCP,
|
||||
progressBoxPointer,
|
||||
/*
|
||||
GetDefaultName(m_FileName, m_ArchiverInfo.Extension),
|
||||
m_FileInfo.LastWriteTime, m_FileInfo.Attributes,
|
||||
*/
|
||||
passwordIsDefined, password);
|
||||
|
||||
if (decompressAllItems)
|
||||
return m_ArchiveHandler->Extract(pathMode, overwriteMode,
|
||||
destPath, BoolToInt(false), extractCallback);
|
||||
else
|
||||
{
|
||||
CMyComPtr<IArchiveFolder> archiveFolder;
|
||||
_folder.QueryInterface(IID_IArchiveFolder, &archiveFolder);
|
||||
|
||||
return archiveFolder->Extract(indices, numIndices, pathMode, overwriteMode,
|
||||
destPath, BoolToInt(false), extractCallback);
|
||||
}
|
||||
}
|
||||
|
||||
NFileOperationReturnCode::EEnum CPlugin::GetFiles(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, char *_aDestPath, int opMode)
|
||||
{
|
||||
return GetFilesReal(panelItems, itemsNumber, move,
|
||||
_aDestPath, opMode, (opMode & OPM_SILENT) == 0);
|
||||
}
|
||||
|
||||
NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, const char *_aDestPath, int opMode, bool showBox)
|
||||
{
|
||||
if(move != 0)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
CSysString destPath = _aDestPath;
|
||||
NFile::NName::NormalizeDirPathPrefix(destPath);
|
||||
|
||||
bool extractSelectedFiles = true;
|
||||
NExtraction::CInfo extractionInfo;
|
||||
extractionInfo.PathMode = NExtraction::NPathMode::kCurrentPathnames;
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kWithoutPrompt;
|
||||
|
||||
bool silent = (opMode & OPM_SILENT) != 0;
|
||||
bool decompressAllItems = false;
|
||||
UString password = Password;
|
||||
bool passwordIsDefined = PasswordIsDefined;
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
const int kPathIndex = 2;
|
||||
|
||||
ReadExtractionInfo(extractionInfo);
|
||||
|
||||
const int kPathModeRadioIndex = 4;
|
||||
const int kOverwriteModeRadioIndex = kPathModeRadioIndex + 4;
|
||||
const int kFilesModeIndex = kOverwriteModeRadioIndex + 5;
|
||||
const int kYSize = 18;
|
||||
|
||||
const int kXMid = 38;
|
||||
|
||||
AString oemPassword = UnicodeStringToMultiByte(password, CP_OEMCP);
|
||||
|
||||
struct CInitDialogItem initItems[]={
|
||||
{ DI_DOUBLEBOX, 3, 1, 72, kYSize - 2, false, false, 0, false, NMessageID::kExtractTitle, NULL, NULL },
|
||||
{ DI_TEXT, 5, 2, 0, 0, false, false, 0, false, NMessageID::kExtractTo, NULL, NULL },
|
||||
|
||||
{ DI_EDIT, 5, 3, 70, 3, true, false, DIF_HISTORY, false, -1, destPath, kExractPathHistoryName},
|
||||
// { DI_EDIT, 5, 3, 70, 3, true, false, 0, false, -1, destPath, NULL},
|
||||
|
||||
{ DI_SINGLEBOX, 4, 5, kXMid - 2, 5 + 4, false, false, 0, false, NMessageID::kExtractPathMode, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 6, 0, 0, false,
|
||||
extractionInfo.PathMode == NExtraction::NPathMode::kFullPathnames,
|
||||
DIF_GROUP, false, NMessageID::kExtractPathFull, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 7, 0, 0, false,
|
||||
extractionInfo.PathMode == NExtraction::NPathMode::kCurrentPathnames,
|
||||
0, false, NMessageID::kExtractPathCurrent, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 8, 0, 0, false,
|
||||
extractionInfo.PathMode == NExtraction::NPathMode::kNoPathnames,
|
||||
false, 0, NMessageID::kExtractPathNo, NULL, NULL },
|
||||
|
||||
{ DI_SINGLEBOX, kXMid, 5, 70, 5 + 5, false, false, 0, false, NMessageID::kExtractOwerwriteMode, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtraction::NOverwriteMode::kAskBefore,
|
||||
DIF_GROUP, false, NMessageID::kExtractOwerwriteAsk, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtraction::NOverwriteMode::kWithoutPrompt,
|
||||
0, false, NMessageID::kExtractOwerwritePrompt, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtraction::NOverwriteMode::kSkipExisting,
|
||||
0, false, NMessageID::kExtractOwerwriteSkip, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 9, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtraction::NOverwriteMode::kAutoRename,
|
||||
0, false, NMessageID::kExtractOwerwriteAutoRename, NULL, NULL },
|
||||
|
||||
{ DI_SINGLEBOX, 4, 10, kXMid- 2, 10 + 3, false, false, 0, false, NMessageID::kExtractFilesMode, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 11, 0, 0, false, true, DIF_GROUP, false, NMessageID::kExtractFilesSelected, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 12, 0, 0, false, false, 0, false, NMessageID::kExtractFilesAll, NULL, NULL },
|
||||
|
||||
{ DI_SINGLEBOX, kXMid, 11, 70, 11 + 2, false, false, 0, false, NMessageID::kExtractPassword, NULL, NULL },
|
||||
{ DI_PSWEDIT, kXMid + 2, 12, 70 - 2, 12, false, false, 0, false, -1, oemPassword, NULL},
|
||||
|
||||
{ DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
|
||||
|
||||
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kExtractExtract, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kExtractCancel, NULL, NULL }
|
||||
};
|
||||
|
||||
const int kNumDialogItems = sizeof(initItems) / sizeof(initItems[0]);
|
||||
const int kOkButtonIndex = kNumDialogItems - 2;
|
||||
const int kPasswordIndex = kNumDialogItems - 4;
|
||||
|
||||
FarDialogItem dialogItems[kNumDialogItems];
|
||||
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems);
|
||||
while(true)
|
||||
{
|
||||
int askCode = g_StartupInfo.ShowDialog(76, kYSize,
|
||||
kHelpTopicExtrFromSevenZip, dialogItems, kNumDialogItems);
|
||||
if (askCode != kOkButtonIndex)
|
||||
return NFileOperationReturnCode::kInterruptedByUser;
|
||||
destPath = dialogItems[kPathIndex].Data;
|
||||
destPath.Trim();
|
||||
if (destPath.IsEmpty())
|
||||
{
|
||||
if(!NFile::NDirectory::MyGetCurrentDirectory(destPath))
|
||||
throw 318016;
|
||||
NFile::NName::NormalizeDirPathPrefix(destPath);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(destPath[destPath.Length() - 1] == kDirDelimiter)
|
||||
break;
|
||||
}
|
||||
g_StartupInfo.ShowMessage("You must specify directory path");
|
||||
}
|
||||
|
||||
if (dialogItems[kPathModeRadioIndex].Selected)
|
||||
extractionInfo.PathMode = NExtraction::NPathMode::kFullPathnames;
|
||||
else if (dialogItems[kPathModeRadioIndex + 1].Selected)
|
||||
extractionInfo.PathMode = NExtraction::NPathMode::kCurrentPathnames;
|
||||
else if (dialogItems[kPathModeRadioIndex + 2].Selected)
|
||||
extractionInfo.PathMode = NExtraction::NPathMode::kNoPathnames;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
if (dialogItems[kOverwriteModeRadioIndex].Selected)
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kAskBefore;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 1].Selected)
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kWithoutPrompt;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 2].Selected)
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kSkipExisting;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 3].Selected)
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kAutoRename;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
if (dialogItems[kFilesModeIndex].Selected)
|
||||
decompressAllItems = false;
|
||||
else if (dialogItems[kFilesModeIndex + 1].Selected)
|
||||
decompressAllItems = true;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
SaveExtractionInfo(extractionInfo);
|
||||
|
||||
if (dialogItems[kFilesModeIndex].Selected)
|
||||
extractSelectedFiles = true;
|
||||
else if (dialogItems[kFilesModeIndex + 1].Selected)
|
||||
extractSelectedFiles = false;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
oemPassword = dialogItems[kPasswordIndex].Data;
|
||||
password = MultiByteToUnicodeString(oemPassword, CP_OEMCP);
|
||||
passwordIsDefined = !password.IsEmpty();
|
||||
}
|
||||
|
||||
NFile::NDirectory::CreateComplexDirectory(destPath);
|
||||
|
||||
/*
|
||||
vector<int> realIndices;
|
||||
if (!decompressAllItems)
|
||||
GetRealIndexes(panelItems, itemsNumber, realIndices);
|
||||
*/
|
||||
CRecordVector<UINT32> indices;
|
||||
indices.Reserve(itemsNumber);
|
||||
for (int i = 0; i < itemsNumber; i++)
|
||||
indices.Add(panelItems[i].UserData);
|
||||
|
||||
NExtractionMode::NPath::EEnum pathMode;
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode;
|
||||
switch (extractionInfo.OverwriteMode)
|
||||
{
|
||||
case NExtraction::NOverwriteMode::kAskBefore:
|
||||
overwriteMode = NExtractionMode::NOverwrite::kAskBefore;
|
||||
break;
|
||||
case NExtraction::NOverwriteMode::kWithoutPrompt:
|
||||
overwriteMode = NExtractionMode::NOverwrite::kWithoutPrompt;
|
||||
break;
|
||||
case NExtraction::NOverwriteMode::kSkipExisting:
|
||||
overwriteMode = NExtractionMode::NOverwrite::kSkipExisting;
|
||||
break;
|
||||
case NExtraction::NOverwriteMode::kAutoRename:
|
||||
overwriteMode = NExtractionMode::NOverwrite::kAutoRename;
|
||||
break;
|
||||
default:
|
||||
throw 12334454;
|
||||
}
|
||||
switch (extractionInfo.PathMode)
|
||||
{
|
||||
case NExtraction::NPathMode::kFullPathnames:
|
||||
pathMode = NExtractionMode::NPath::kFullPathnames;
|
||||
break;
|
||||
case NExtraction::NPathMode::kCurrentPathnames:
|
||||
pathMode = NExtractionMode::NPath::kCurrentPathnames;
|
||||
break;
|
||||
case NExtraction::NPathMode::kNoPathnames:
|
||||
pathMode = NExtractionMode::NPath::kNoPathnames;
|
||||
break;
|
||||
default:
|
||||
throw 12334455;
|
||||
}
|
||||
HRESULT result = ExtractFiles(decompressAllItems, &indices.Front(), itemsNumber,
|
||||
!showBox, pathMode, overwriteMode,
|
||||
MultiByteToUnicodeString(destPath, CP_OEMCP),
|
||||
passwordIsDefined, password);
|
||||
// HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox,
|
||||
// extractionInfo, destPath, passwordIsDefined, password);
|
||||
if (result != S_OK)
|
||||
{
|
||||
if (result == E_ABORT)
|
||||
return NFileOperationReturnCode::kInterruptedByUser;
|
||||
ShowErrorMessage(result);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
// if(move != 0)
|
||||
// {
|
||||
// if(DeleteFiles(panelItems, itemsNumber, opMode) == FALSE)
|
||||
// return NFileOperationReturnCode::kError;
|
||||
// }
|
||||
return NFileOperationReturnCode::kSuccess;
|
||||
}
|
||||
712
7zip/UI/Far/PluginWrite.cpp
Executable file
712
7zip/UI/Far/PluginWrite.cpp
Executable file
@@ -0,0 +1,712 @@
|
||||
// PluginWrite.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Messages.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/UpdatePairBasic.h"
|
||||
// #include "../Common/CompressEngineCommon.h"
|
||||
#include "../Common/WorkDir.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
#include "Far/ProgressBox.h"
|
||||
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
/*
|
||||
#include "../../Archiver/Common/DefaultName.h"
|
||||
#include "../../Archiver/Common/OpenEngine2.h"
|
||||
*/
|
||||
|
||||
// #include "CompressEngine.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDirectory;
|
||||
using namespace NFar;
|
||||
|
||||
using namespace NUpdateArchive;
|
||||
|
||||
static const char *kHelpTopic = "Update";
|
||||
|
||||
static LPCWSTR kTempArcivePrefix = L"7zA";
|
||||
|
||||
static const char *kArchiveHistoryKeyName = "7-ZipArcName";
|
||||
|
||||
static UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
|
||||
|
||||
static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
|
||||
{
|
||||
CMyComPtr<ISetProperties> aSetProperties;
|
||||
if (outArchive->QueryInterface(&aSetProperties) == S_OK)
|
||||
{
|
||||
CMyComBSTR comBSTR = L"x";
|
||||
CObjectVector<CMyComBSTR> realNames;
|
||||
std::vector<NCOM::CPropVariant> values;
|
||||
realNames.Add(comBSTR);
|
||||
values.push_back(NCOM::CPropVariant((UINT32)method));
|
||||
|
||||
std::vector<BSTR> names;
|
||||
for(int i = 0; i < realNames.Size(); i++)
|
||||
names.push_back(realNames[i]);
|
||||
RINOK(aSetProperties->SetProperties(&names.front(),
|
||||
&values.front(), names.size()));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
struct PluginPanelItem *panelItems, int numItems,
|
||||
int moveMode, int opMode)
|
||||
{
|
||||
if(moveMode != 0)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
if (numItems == 0)
|
||||
return NFileOperationReturnCode::kError;
|
||||
|
||||
/*
|
||||
if (!m_ArchiverInfo.UpdateEnabled)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
*/
|
||||
|
||||
const int kYSize = 14;
|
||||
const int kXMid = 38;
|
||||
|
||||
NCompression::CInfo compressionInfo;
|
||||
ReadCompressionInfo(compressionInfo);
|
||||
|
||||
int methodIndex = 0;
|
||||
for (int i = sizeof(g_MethodMap) / sizeof(g_MethodMap[0]) - 1; i >= 0; i--)
|
||||
if (compressionInfo.Level >= g_MethodMap[i])
|
||||
{
|
||||
methodIndex = i;
|
||||
break;
|
||||
}
|
||||
|
||||
const int kMethodRadioIndex = 2;
|
||||
const int kModeRadioIndex = kMethodRadioIndex + 7;
|
||||
|
||||
struct CInitDialogItem initItems[]={
|
||||
{ DI_DOUBLEBOX, 3, 1, 72, kYSize - 2, false, false, 0, false, NMessageID::kUpdateTitle, NULL, NULL },
|
||||
{ DI_SINGLEBOX, 4, 2, kXMid - 2, 2 + 7, false, false, 0, false, NMessageID::kUpdateMethod, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 3, 0, 0, methodIndex == 0, methodIndex == 0,
|
||||
DIF_GROUP, false, NMessageID::kUpdateMethodStore, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 4, 0, 0, methodIndex == 1, methodIndex == 1,
|
||||
0, false, NMessageID::kUpdateMethodFastest, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 5, 0, 0, methodIndex == 2, methodIndex == 2,
|
||||
0, false, NMessageID::kUpdateMethodFast, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 6, 0, 0, methodIndex == 3, methodIndex == 3,
|
||||
0, false, NMessageID::kUpdateMethodNormal, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 7, 0, 0, methodIndex == 4, methodIndex == 4,
|
||||
0, false, NMessageID::kUpdateMethodMaximum, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 8, 0, 0, methodIndex == 5, methodIndex == 5,
|
||||
0, false, NMessageID::kUpdateMethodUltra, NULL, NULL },
|
||||
|
||||
{ DI_SINGLEBOX, kXMid, 2, 70, 2 + 5, false, false, 0, false, NMessageID::kUpdateMode, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 3, 0, 0, false, true,
|
||||
DIF_GROUP, false, NMessageID::kUpdateModeAdd, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 4, 0, 0, false, false,
|
||||
0, false, NMessageID::kUpdateModeUpdate, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false, false,
|
||||
0, false, NMessageID::kUpdateModeFreshen, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, false,
|
||||
0, false, NMessageID::kUpdateModeSynchronize, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
|
||||
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kUpdateAdd, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kCancel, NULL, NULL }
|
||||
};
|
||||
|
||||
const int kNumDialogItems = sizeof(initItems) / sizeof(initItems[0]);
|
||||
const int kOkButtonIndex = kNumDialogItems - 2;
|
||||
FarDialogItem dialogItems[kNumDialogItems];
|
||||
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems);
|
||||
int askCode = g_StartupInfo.ShowDialog(76, kYSize,
|
||||
kHelpTopic, dialogItems, kNumDialogItems);
|
||||
if (askCode != kOkButtonIndex)
|
||||
return NFileOperationReturnCode::kInterruptedByUser;
|
||||
|
||||
compressionInfo.Level = g_MethodMap[0];
|
||||
for (i = 0; i < sizeof(g_MethodMap)/ sizeof(g_MethodMap[0]); i++)
|
||||
if (dialogItems[kMethodRadioIndex + i].Selected)
|
||||
compressionInfo.Level = g_MethodMap[i];
|
||||
|
||||
const CActionSet *actionSet;
|
||||
|
||||
if (dialogItems[kModeRadioIndex].Selected)
|
||||
actionSet = &kAddActionSet;
|
||||
else if (dialogItems[kModeRadioIndex + 1].Selected)
|
||||
actionSet = &kUpdateActionSet;
|
||||
else if (dialogItems[kModeRadioIndex + 2].Selected)
|
||||
actionSet = &kFreshActionSet;
|
||||
else if (dialogItems[kModeRadioIndex + 3].Selected)
|
||||
actionSet = &kSynchronizeActionSet;
|
||||
else
|
||||
throw 51751;
|
||||
|
||||
SaveCompressionInfo(compressionInfo);
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
ReadWorkDirInfo(workDirInfo);
|
||||
UString workDir = GetWorkDir(workDirInfo, m_FileName);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
CTempFileW tempFile;
|
||||
UString tempFileName;
|
||||
if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
|
||||
return NFileOperationReturnCode::kError;
|
||||
|
||||
|
||||
/*
|
||||
CSysStringVector fileNames;
|
||||
for(int i = 0; i < numItems; i++)
|
||||
{
|
||||
const PluginPanelItem &panelItem = panelItems[i];
|
||||
CSysString fullName;
|
||||
if (!MyGetFullPathName(panelItem.FindData.cFileName, fullName))
|
||||
return NFileOperationReturnCode::kError;
|
||||
fileNames.Add(fullName);
|
||||
}
|
||||
*/
|
||||
|
||||
CScreenRestorer screenRestorer;
|
||||
CProgressBox progressBox;
|
||||
CProgressBox *progressBoxPointer = NULL;
|
||||
if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
|
||||
{
|
||||
screenRestorer.Save();
|
||||
|
||||
progressBoxPointer = &progressBox;
|
||||
progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 1 << 16);
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// Save FolderItem;
|
||||
UStringVector aPathVector;
|
||||
GetPathParts(aPathVector);
|
||||
|
||||
/*
|
||||
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++)
|
||||
fileNames.Add(MultiByteToUnicodeString(panelItems[i].FindData.cFileName, CP_OEMCP));
|
||||
CRecordVector<const wchar_t *> fileNamePointers;
|
||||
fileNamePointers.Reserve(numItems);
|
||||
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)
|
||||
{
|
||||
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());
|
||||
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = actionSet->StateActions[i];
|
||||
|
||||
CUpdateCallBack100Imp *updateCallbackSpec = new CUpdateCallBack100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(m_ArchiveHandler, &progressBox);
|
||||
|
||||
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
|
||||
result = outArchive->DoOperation(NULL, NULL,
|
||||
tempFileName, 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)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
_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);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
/*
|
||||
if(m_ProxyHandler->ReInit(NULL) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
*/
|
||||
|
||||
////////////////////////////
|
||||
// Restore FolderItem;
|
||||
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
for (i = 0; i < aPathVector.Size(); i++)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(aPathVector[i], &newFolder);
|
||||
if(!newFolder )
|
||||
break;
|
||||
_folder = newFolder;
|
||||
}
|
||||
|
||||
/*
|
||||
if(moveMode != 0)
|
||||
{
|
||||
for(int i = 0; i < numItems; i++)
|
||||
{
|
||||
const PluginPanelItem &aPluginPanelItem = panelItems[i];
|
||||
bool result;
|
||||
if(NFile::NFind::NAttributes::IsDirectory(aPluginPanelItem.FindData.dwFileAttributes))
|
||||
result = NFile::NDirectory::RemoveDirectoryWithSubItems(
|
||||
aPluginPanelItem.FindData.cFileName);
|
||||
else
|
||||
result = NFile::NDirectory::DeleteFileAlways(
|
||||
aPluginPanelItem.FindData.cFileName);
|
||||
if(!result)
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return NFileOperationReturnCode::kSuccess;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// {23170F69-40C1-278A-1000-000100030000}
|
||||
DEFINE_GUID(CLSID_CAgentArchiveHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00);
|
||||
*/
|
||||
|
||||
HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
{
|
||||
if (pluginPanelItems.Size() == 0)
|
||||
return E_FAIL;
|
||||
|
||||
UStringVector fileNames;
|
||||
for(int i = 0; i < pluginPanelItems.Size(); i++)
|
||||
{
|
||||
const PluginPanelItem &panelItem = pluginPanelItems[i];
|
||||
CSysString fullName;
|
||||
if (strcmp(panelItem.FindData.cFileName, "..") == 0 &&
|
||||
NFind::NAttributes::IsDirectory(panelItem.FindData.dwFileAttributes))
|
||||
return E_FAIL;
|
||||
if (strcmp(panelItem.FindData.cFileName, ".") == 0 &&
|
||||
NFind::NAttributes::IsDirectory(panelItem.FindData.dwFileAttributes))
|
||||
return E_FAIL;
|
||||
if (!MyGetFullPathName(panelItem.FindData.cFileName, fullName))
|
||||
return E_FAIL;
|
||||
fileNames.Add(MultiByteToUnicodeString(fullName, CP_OEMCP));
|
||||
}
|
||||
|
||||
NCompression::CInfo compressionInfo;
|
||||
// CZipRegistryManager aZipRegistryManager;
|
||||
ReadCompressionInfo(compressionInfo);
|
||||
|
||||
int archiverIndex = 0;
|
||||
|
||||
CObjectVector<CArchiverInfo> archiverInfoList;
|
||||
{
|
||||
CObjectVector<CArchiverInfo> fullArchiverInfoList;
|
||||
ReadArchiverInfoList(fullArchiverInfoList);
|
||||
for (int i = 0; i < fullArchiverInfoList.Size(); i++)
|
||||
{
|
||||
const CArchiverInfo &archiverInfo = fullArchiverInfoList[i];
|
||||
if (archiverInfo.UpdateEnabled)
|
||||
{
|
||||
if (archiverInfo.Name.CollateNoCase(compressionInfo.ArchiveType) == 0)
|
||||
archiverIndex = archiverInfoList.Size();
|
||||
archiverInfoList.Add(archiverInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (archiverInfoList.IsEmpty())
|
||||
throw "There is no update achivers";
|
||||
|
||||
|
||||
UString resultPath;
|
||||
{
|
||||
NName::CParsedPath parsedPath;
|
||||
parsedPath.ParsePath(fileNames.Front());
|
||||
if(parsedPath.PathParts.Size() == 0)
|
||||
return E_FAIL;
|
||||
if (fileNames.Size() == 1 || parsedPath.PathParts.Size() == 1)
|
||||
{
|
||||
// CSysString pureName, dot, extension;
|
||||
resultPath = parsedPath.PathParts.Back();
|
||||
}
|
||||
else
|
||||
{
|
||||
parsedPath.PathParts.DeleteBack();
|
||||
resultPath = parsedPath.PathParts.Back();
|
||||
}
|
||||
}
|
||||
UString archiveNameSrc = resultPath;
|
||||
UString archiveName = archiveNameSrc;
|
||||
|
||||
const CArchiverInfo &archiverInfo = archiverInfoList[archiverIndex];
|
||||
int prevFormat = archiverIndex;
|
||||
|
||||
if (!archiverInfo.KeepName)
|
||||
{
|
||||
int dotPos = archiveName.ReverseFind('.');
|
||||
int slashPos = MyMax(archiveName.ReverseFind('\\'), archiveName.ReverseFind('/'));
|
||||
if (dotPos > slashPos)
|
||||
archiveName = archiveName.Left(dotPos);
|
||||
}
|
||||
archiveName += L'.';
|
||||
archiveName += archiverInfo.GetMainExtension();
|
||||
|
||||
const CActionSet *actionSet = &kAddActionSet;
|
||||
|
||||
while(true)
|
||||
{
|
||||
AString archiveNameA = UnicodeStringToMultiByte(archiveName, CP_OEMCP);
|
||||
const int kYSize = 16;
|
||||
const int kXMid = 38;
|
||||
|
||||
const int kArchiveNameIndex = 2;
|
||||
const int kMethodRadioIndex = kArchiveNameIndex + 2;
|
||||
const int kModeRadioIndex = kMethodRadioIndex + 7;
|
||||
|
||||
const CArchiverInfo &archiverInfo = archiverInfoList[archiverIndex];
|
||||
|
||||
char updateAddToArchiveString[512];
|
||||
sprintf(updateAddToArchiveString,
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), GetSystemString(archiverInfo.Name), CP_OEMCP);
|
||||
|
||||
int methodIndex = 0;
|
||||
for (int i = sizeof(g_MethodMap) / sizeof(g_MethodMap[0]) - 1; i >= 0; i--)
|
||||
if (compressionInfo.Level >= g_MethodMap[i])
|
||||
{
|
||||
methodIndex = i;
|
||||
break;
|
||||
}
|
||||
|
||||
struct CInitDialogItem initItems[]=
|
||||
{
|
||||
{ DI_DOUBLEBOX, 3, 1, 72, kYSize - 2, false, false, 0, false, NMessageID::kUpdateTitle, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 5, 2, 0, 0, false, false, 0, false, -1, updateAddToArchiveString, NULL },
|
||||
|
||||
{ DI_EDIT, 5, 3, 70, 3, true, false, DIF_HISTORY, false, -1, archiveNameA, kArchiveHistoryKeyName},
|
||||
// { DI_EDIT, 5, 3, 70, 3, true, false, 0, false, -1, archiveName, NULL},
|
||||
|
||||
{ DI_SINGLEBOX, 4, 4, kXMid - 2, 4 + 7, false, false, 0, false, NMessageID::kUpdateMethod, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 5, 0, 0, false, methodIndex == 0,
|
||||
DIF_GROUP, false, NMessageID::kUpdateMethodStore, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 6, 0, 0, false, methodIndex == 1,
|
||||
0, false, NMessageID::kUpdateMethodFastest, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 7, 0, 0, false, methodIndex == 2,
|
||||
0, false, NMessageID::kUpdateMethodFast, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 8, 0, 0, false, methodIndex == 3,
|
||||
0, false, NMessageID::kUpdateMethodNormal, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 9, 0, 0, false, methodIndex == 4,
|
||||
false, 0, NMessageID::kUpdateMethodMaximum, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 10, 0, 0, false, methodIndex == 5,
|
||||
false, 0, NMessageID::kUpdateMethodUltra, NULL, NULL },
|
||||
|
||||
{ DI_SINGLEBOX, kXMid, 4, 70, 4 + 5, false, false, 0, false, NMessageID::kUpdateMode, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false,
|
||||
actionSet == &kAddActionSet,
|
||||
DIF_GROUP, false, NMessageID::kUpdateModeAdd, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false,
|
||||
actionSet == &kUpdateActionSet,
|
||||
0, false, NMessageID::kUpdateModeUpdate, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false,
|
||||
actionSet == &kFreshActionSet,
|
||||
0, false, NMessageID::kUpdateModeFreshen, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false,
|
||||
actionSet == &kSynchronizeActionSet,
|
||||
0, false, NMessageID::kUpdateModeSynchronize, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
|
||||
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kUpdateAdd, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kUpdateSelectArchiver, NULL, NULL },
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kCancel, NULL, NULL }
|
||||
};
|
||||
|
||||
const int kNumDialogItems = sizeof(initItems) / sizeof(initItems[0]);
|
||||
|
||||
const int kOkButtonIndex = kNumDialogItems - 3;
|
||||
const int kSelectarchiverButtonIndex = kNumDialogItems - 2;
|
||||
|
||||
FarDialogItem dialogItems[kNumDialogItems];
|
||||
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems);
|
||||
int askCode = g_StartupInfo.ShowDialog(76, kYSize,
|
||||
kHelpTopic, dialogItems, kNumDialogItems);
|
||||
|
||||
archiveNameA = dialogItems[kArchiveNameIndex].Data;
|
||||
archiveNameA.Trim();
|
||||
archiveName = MultiByteToUnicodeString(archiveNameA, CP_OEMCP);
|
||||
|
||||
compressionInfo.Level = g_MethodMap[0];
|
||||
for (i = 0; i < sizeof(g_MethodMap)/ sizeof(g_MethodMap[0]); i++)
|
||||
if (dialogItems[kMethodRadioIndex + i].Selected)
|
||||
compressionInfo.Level = g_MethodMap[i];
|
||||
|
||||
if (dialogItems[kModeRadioIndex].Selected)
|
||||
actionSet = &kAddActionSet;
|
||||
else if (dialogItems[kModeRadioIndex + 1].Selected)
|
||||
actionSet = &kUpdateActionSet;
|
||||
else if (dialogItems[kModeRadioIndex + 2].Selected)
|
||||
actionSet = &kFreshActionSet;
|
||||
else if (dialogItems[kModeRadioIndex + 3].Selected)
|
||||
actionSet = &kSynchronizeActionSet;
|
||||
else
|
||||
throw 51751;
|
||||
|
||||
if (askCode == kSelectarchiverButtonIndex)
|
||||
{
|
||||
CSysStringVector archiverNames;
|
||||
for(int i = 0; i < archiverInfoList.Size(); i++)
|
||||
archiverNames.Add(GetSystemString(archiverInfoList[i].Name,
|
||||
CP_OEMCP));
|
||||
|
||||
int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT,
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdateSelectArchiverMenuTitle),
|
||||
NULL, archiverNames, archiverIndex);
|
||||
if(index >= 0)
|
||||
{
|
||||
const CArchiverInfo &prevArchiverInfo = archiverInfoList[prevFormat];
|
||||
if (prevArchiverInfo.KeepName)
|
||||
{
|
||||
const UString &prevExtension = prevArchiverInfo.GetMainExtension();
|
||||
const int prevExtensionLen = prevExtension.Length();
|
||||
if (archiveName.Right(prevExtensionLen).CompareNoCase(prevExtension) == 0)
|
||||
{
|
||||
int pos = archiveName.Length() - prevExtensionLen;
|
||||
UString temp = archiveName.Left(pos);
|
||||
if (pos > 1)
|
||||
{
|
||||
int dotPos = archiveName.ReverseFind('.');
|
||||
if (dotPos == pos - 1)
|
||||
archiveName = archiveName.Left(dotPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
archiverIndex = index;
|
||||
const CArchiverInfo &archiverInfo =
|
||||
archiverInfoList[archiverIndex];
|
||||
prevFormat = archiverIndex;
|
||||
|
||||
if (archiverInfo.KeepName)
|
||||
archiveName = archiveNameSrc;
|
||||
else
|
||||
{
|
||||
int dotPos = archiveName.ReverseFind('.');
|
||||
int slashPos = MyMax(archiveName.ReverseFind('\\'), archiveName.ReverseFind('/'));
|
||||
if (dotPos > slashPos)
|
||||
archiveName = archiveName.Left(dotPos);
|
||||
}
|
||||
archiveName += L'.';
|
||||
archiveName += archiverInfo.GetMainExtension();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (askCode != kOkButtonIndex)
|
||||
return E_ABORT;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
const CArchiverInfo &archiverInfoFinal = archiverInfoList[archiverIndex];
|
||||
compressionInfo.ArchiveType = archiverInfoFinal.Name;
|
||||
SaveCompressionInfo(compressionInfo);
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
ReadWorkDirInfo(workDirInfo);
|
||||
|
||||
UString fullArchiveName;
|
||||
if (!MyGetFullPathName(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;
|
||||
|
||||
|
||||
CScreenRestorer screenRestorer;
|
||||
CProgressBox progressBox;
|
||||
CProgressBox *progressBoxPointer = NULL;
|
||||
|
||||
screenRestorer.Save();
|
||||
|
||||
progressBoxPointer = &progressBox;
|
||||
progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 1 << 16);
|
||||
|
||||
|
||||
// std::auto_ptr<CProxyHandler> proxyHandler;
|
||||
NFind::CFileInfoW fileInfo;
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
|
||||
CMyComPtr<IInFolderArchive> archiveHandler;
|
||||
if(NFind::FindFile(fullArchiveName, fileInfo))
|
||||
{
|
||||
if (fileInfo.IsDirectory())
|
||||
throw "There is Directory with such name";
|
||||
|
||||
CAgent *agentSpec = new CAgent;
|
||||
archiveHandler = agentSpec;
|
||||
// CLSID realClassID;
|
||||
CMyComBSTR archiveType;
|
||||
RINOK(agentSpec->Open(
|
||||
GetUnicodeString(fullArchiveName, CP_OEMCP),
|
||||
// &realClassID,
|
||||
&archiveType,
|
||||
NULL));
|
||||
|
||||
if (archiverInfoFinal.Name.CollateNoCase((const wchar_t *)archiveType) != 0)
|
||||
throw "Type of existing archive differs from specified type";
|
||||
HRESULT result = archiveHandler.QueryInterface(
|
||||
IID_IOutFolderArchive, &outArchive);
|
||||
if(result != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// HRESULT result = outArchive.CoCreateInstance(classID);
|
||||
CAgent *agentSpec = new CAgent;
|
||||
outArchive = agentSpec;
|
||||
|
||||
/*
|
||||
HRESULT result = outArchive.CoCreateInstance(CLSID_CAgentArchiveHandler);
|
||||
if (result != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return E_FAIL;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
CRecordVector<const wchar_t *> fileNamePointers;
|
||||
fileNamePointers.Reserve(fileNames.Size());
|
||||
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());
|
||||
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = actionSet->StateActions[i];
|
||||
|
||||
CUpdateCallBack100Imp *updateCallbackSpec = new CUpdateCallBack100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(archiveHandler, &progressBox);
|
||||
|
||||
|
||||
RINOK(SetOutProperties(outArchive, compressionInfo.Level));
|
||||
|
||||
HRESULT result = outArchive->DoOperation(
|
||||
GetUnicodeString(archiverInfoFinal.FilePath, CP_OEMCP),
|
||||
&archiverInfoFinal.ClassID,
|
||||
tempFileName, actionSetByte,
|
||||
NULL, updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if(archiveHandler)
|
||||
{
|
||||
archiveHandler->Close();
|
||||
if (!DeleteFileAlways(fullArchiveName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
}
|
||||
tempFile.DisableDeleting();
|
||||
if (!MyMoveFile(tempFileName, fullArchiveName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
3
7zip/UI/Far/StdAfx.cpp
Executable file
3
7zip/UI/Far/StdAfx.cpp
Executable file
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
28
7zip/UI/Far/StdAfx.h
Executable file
28
7zip/UI/Far/StdAfx.h
Executable file
@@ -0,0 +1,28 @@
|
||||
// stdafx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/*
|
||||
#define _ATL_APARTMENT_THREADED
|
||||
|
||||
#define _ATL_NO_UUIDOF
|
||||
|
||||
#include <atlbase.h>
|
||||
|
||||
extern CComModule _Module;
|
||||
|
||||
#include <atlcom.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlguid.h>
|
||||
#include <regstr.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <memory>
|
||||
// #include <algorithm>
|
||||
*/
|
||||
#include <vector>
|
||||
|
||||
#endif
|
||||
44
7zip/UI/Far/UpdateCallback100.cpp
Executable file
44
7zip/UI/Far/UpdateCallback100.cpp
Executable file
@@ -0,0 +1,44 @@
|
||||
// UpdateCallback.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Far/FarUtils.h"
|
||||
|
||||
using namespace NFar;
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::SetTotal(UINT64 aSize)
|
||||
{
|
||||
if (m_ProgressBox != 0)
|
||||
{
|
||||
m_ProgressBox->SetTotal(aSize);
|
||||
m_ProgressBox->PrintCompeteValue(0);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::SetCompleted(const UINT64 *aCompleteValue)
|
||||
{
|
||||
if(WasEscPressed())
|
||||
return E_ABORT;
|
||||
if (m_ProgressBox != 0 && aCompleteValue != NULL)
|
||||
m_ProgressBox->PrintCompeteValue(*aCompleteValue);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::CompressOperation(const wchar_t *aName)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::DeleteOperation(const wchar_t *aName)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::OperationResult(INT32 aOperationResult)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
46
7zip/UI/Far/UpdateCallback100.h
Executable file
46
7zip/UI/Far/UpdateCallback100.h
Executable file
@@ -0,0 +1,46 @@
|
||||
// UpdateCallback.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __UPDATECALLBACK100_H
|
||||
#define __UPDATECALLBACK100_H
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
#include "Far/ProgressBox.h"
|
||||
|
||||
class CUpdateCallBack100Imp:
|
||||
public IFolderArchiveUpdateCallback,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
// IProfress
|
||||
|
||||
STDMETHOD(SetTotal)(UINT64 aSize);
|
||||
STDMETHOD(SetCompleted)(const UINT64 *aCompleteValue);
|
||||
|
||||
// IUpdateCallBack
|
||||
STDMETHOD(CompressOperation)(const wchar_t *aName);
|
||||
STDMETHOD(DeleteOperation)(const wchar_t *aName);
|
||||
STDMETHOD(OperationResult)(INT32 aOperationResult);
|
||||
|
||||
private:
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
CProgressBox *m_ProgressBox;
|
||||
public:
|
||||
void Init(IInFolderArchive *anArchiveHandler,
|
||||
CProgressBox *aProgressBox)
|
||||
{
|
||||
m_ArchiveHandler = anArchiveHandler;
|
||||
m_ProgressBox = aProgressBox;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
15
7zip/UI/Far/resource.h
Executable file
15
7zip/UI/Far/resource.h
Executable file
@@ -0,0 +1,15 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Far.rc
|
||||
//
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user