mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 16:07:09 -06:00
4.20
This commit is contained in:
committed by
Kornel Lesiński
parent
8c1b5c7b7e
commit
3c510ba80b
@@ -1,347 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// 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
|
||||
@@ -2,18 +2,19 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ExtractEngine.h"
|
||||
#include "Far/FarUtils.h"
|
||||
|
||||
#include "Messages.h"
|
||||
|
||||
#include "OverwriteDialog.h"
|
||||
|
||||
#include "Common/WildCard.h"
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
#include "Messages.h"
|
||||
#include "OverwriteDialog.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
@@ -102,7 +103,7 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, INT32 askExtractMode)
|
||||
STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, INT32 askExtractMode, const UINT64 *position)
|
||||
{
|
||||
m_CurrentFilePath = name;
|
||||
return S_OK;
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// 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"
|
||||
|
||||
#include "ProgressBox.h"
|
||||
|
||||
class CExtractCallBackImp:
|
||||
public IFolderArchiveExtractCallback,
|
||||
public ICryptoGetTextPassword,
|
||||
@@ -29,7 +28,7 @@ public:
|
||||
const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UINT64 *newSize,
|
||||
INT32 *result);
|
||||
STDMETHOD (PrepareOperation)(const wchar_t *name, INT32 askExtractMode);
|
||||
STDMETHOD (PrepareOperation)(const wchar_t *name, INT32 askExtractMode, const UINT64 *position);
|
||||
|
||||
STDMETHOD(MessageError)(const wchar_t *message);
|
||||
STDMETHOD(SetOperationResult)(INT32 resultEOperationResult);
|
||||
|
||||
@@ -118,6 +118,14 @@ SOURCE=.\StdAfx.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -194,10 +202,6 @@ 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
|
||||
@@ -226,23 +230,23 @@ SOURCE=.\UpdateCallback100.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\FarPlugin.h
|
||||
SOURCE=.\FarPlugin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\FarUtils.cpp
|
||||
SOURCE=.\FarUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\FarUtils.h
|
||||
SOURCE=.\FarUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\ProgressBox.cpp
|
||||
SOURCE=.\ProgressBox.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Far\ProgressBox.h
|
||||
SOURCE=.\ProgressBox.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
@@ -332,20 +336,28 @@ SOURCE=..\..\..\Windows\Synchronization.cpp
|
||||
|
||||
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\ArchiveExtractCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveExtractCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveOpenCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveOpenCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiverInfo.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -382,6 +394,10 @@ SOURCE=..\Common\ExtractingFilePath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ExtractMode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\HandlerLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -418,6 +434,14 @@ SOURCE=..\Common\UpdateAction.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdatePair.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -474,24 +498,16 @@ 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
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\UpdateCallbackAgent.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\UpdateCallbackAgent.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,13,0,0
|
||||
PRODUCTVERSION 3,13,0,0
|
||||
FILEVERSION 4,20,0,0
|
||||
PRODUCTVERSION 4,20,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -85,14 +85,14 @@ BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "Igor Pavlov\0"
|
||||
VALUE "FileDescription", "7-Zip FAR Plugin\0"
|
||||
VALUE "FileVersion", "3, 13, 0, 0\0"
|
||||
VALUE "FileVersion", "4, 20, 0, 0\0"
|
||||
VALUE "InternalName", "7-ZipFar\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2003 Igor Pavlov\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2005 Igor Pavlov\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "7-ZipFar.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "7-Zip\0"
|
||||
VALUE "ProductVersion", "3, 13, 0, 0\0"
|
||||
VALUE "ProductVersion", "4, 20, 0, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
|
||||
569
7zip/UI/Far/FarPlugin.h
Executable file
569
7zip/UI/Far/FarPlugin.h
Executable file
@@ -0,0 +1,569 @@
|
||||
// FarPlugin.h
|
||||
|
||||
#ifndef __FARPLUGIN_H
|
||||
#define __FARPLUGIN_H
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
|
||||
#pragma option -a1
|
||||
#elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
|
||||
#pragma pack(1)
|
||||
#else
|
||||
#pragma pack(push,1)
|
||||
#if _MSC_VER
|
||||
#define _export
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define NM 260
|
||||
|
||||
struct FarFindData
|
||||
{
|
||||
DWORD dwFileAttributes;
|
||||
FILETIME ftCreationTime;
|
||||
FILETIME ftLastAccessTime;
|
||||
FILETIME ftLastWriteTime;
|
||||
DWORD nFileSizeHigh;
|
||||
DWORD nFileSizeLow;
|
||||
DWORD dwReserved0;
|
||||
DWORD dwReserved1;
|
||||
char cFileName[ MAX_PATH ];
|
||||
char cAlternateFileName[ 14 ];
|
||||
};
|
||||
|
||||
struct PluginPanelItem
|
||||
{
|
||||
FarFindData FindData;
|
||||
DWORD PackSizeHigh;
|
||||
DWORD PackSize;
|
||||
DWORD Flags;
|
||||
DWORD NumberOfLinks;
|
||||
char *Description;
|
||||
char *Owner;
|
||||
char **CustomColumnData;
|
||||
int CustomColumnNumber;
|
||||
DWORD UserData;
|
||||
DWORD Reserved[3];
|
||||
};
|
||||
|
||||
#define PPIF_PROCESSDESCR 0x80000000
|
||||
#define PPIF_SELECTED 0x40000000
|
||||
#define PPIF_USERDATA 0x20000000
|
||||
|
||||
enum {
|
||||
FMENU_SHOWAMPERSAND=1,
|
||||
FMENU_WRAPMODE=2,
|
||||
FMENU_AUTOHIGHLIGHT=4,
|
||||
FMENU_REVERSEAUTOHIGHLIGHT=8
|
||||
};
|
||||
|
||||
|
||||
typedef int (WINAPI *FARAPIMENU)(
|
||||
int PluginNumber,
|
||||
int X,
|
||||
int Y,
|
||||
int MaxHeight,
|
||||
unsigned int Flags,
|
||||
char *Title,
|
||||
char *Bottom,
|
||||
char *HelpTopic,
|
||||
int *BreakKeys,
|
||||
int *BreakCode,
|
||||
struct FarMenuItem *Item,
|
||||
int ItemsNumber
|
||||
);
|
||||
|
||||
typedef int (WINAPI *FARAPIDIALOG)(
|
||||
int PluginNumber,
|
||||
int X1,
|
||||
int Y1,
|
||||
int X2,
|
||||
int Y2,
|
||||
char *HelpTopic,
|
||||
struct FarDialogItem *Item,
|
||||
int ItemsNumber
|
||||
);
|
||||
|
||||
enum {
|
||||
FMSG_WARNING=1,
|
||||
FMSG_ERRORTYPE=2,
|
||||
FMSG_KEEPBACKGROUND=4,
|
||||
FMSG_DOWN=8,
|
||||
FMSG_LEFTALIGN=16
|
||||
};
|
||||
|
||||
typedef int (WINAPI *FARAPIMESSAGE)(
|
||||
int PluginNumber,
|
||||
unsigned int Flags,
|
||||
char *HelpTopic,
|
||||
char **Items,
|
||||
int ItemsNumber,
|
||||
int ButtonsNumber
|
||||
);
|
||||
|
||||
typedef char* (WINAPI *FARAPIGETMSG)(
|
||||
int PluginNumber,
|
||||
int MsgId
|
||||
);
|
||||
|
||||
|
||||
enum DialogItemTypes {
|
||||
DI_TEXT,
|
||||
DI_VTEXT,
|
||||
DI_SINGLEBOX,
|
||||
DI_DOUBLEBOX,
|
||||
DI_EDIT,
|
||||
DI_PSWEDIT,
|
||||
DI_FIXEDIT,
|
||||
DI_BUTTON,
|
||||
DI_CHECKBOX,
|
||||
DI_RADIOBUTTON
|
||||
};
|
||||
|
||||
enum FarDialogItemFlags {
|
||||
DIF_COLORMASK = 0xff,
|
||||
DIF_SETCOLOR = 0x100,
|
||||
DIF_BOXCOLOR = 0x200,
|
||||
DIF_GROUP = 0x400,
|
||||
DIF_LEFTTEXT = 0x800,
|
||||
DIF_MOVESELECT = 0x1000,
|
||||
DIF_SHOWAMPERSAND = 0x2000,
|
||||
DIF_CENTERGROUP = 0x4000,
|
||||
DIF_NOBRACKETS = 0x8000,
|
||||
DIF_SEPARATOR = 0x10000,
|
||||
DIF_EDITOR = 0x20000,
|
||||
DIF_HISTORY = 0x40000
|
||||
};
|
||||
|
||||
struct FarDialogItem
|
||||
{
|
||||
int Type;
|
||||
int X1,Y1,X2,Y2;
|
||||
int Focus;
|
||||
int Selected;
|
||||
unsigned int Flags;
|
||||
int DefaultButton;
|
||||
char Data[512];
|
||||
};
|
||||
|
||||
|
||||
struct FarMenuItem
|
||||
{
|
||||
char Text[128];
|
||||
int Selected;
|
||||
int Checked;
|
||||
int Separator;
|
||||
};
|
||||
|
||||
|
||||
enum {FCTL_CLOSEPLUGIN,FCTL_GETPANELINFO,FCTL_GETANOTHERPANELINFO,
|
||||
FCTL_UPDATEPANEL,FCTL_UPDATEANOTHERPANEL,
|
||||
FCTL_REDRAWPANEL,FCTL_REDRAWANOTHERPANEL,
|
||||
FCTL_SETANOTHERPANELDIR,FCTL_GETCMDLINE,FCTL_SETCMDLINE,
|
||||
FCTL_SETSELECTION,FCTL_SETANOTHERSELECTION,
|
||||
FCTL_SETVIEWMODE,FCTL_SETANOTHERVIEWMODE,FCTL_INSERTCMDLINE,
|
||||
FCTL_SETUSERSCREEN,FCTL_SETPANELDIR,FCTL_SETCMDLINEPOS,
|
||||
FCTL_GETCMDLINEPOS
|
||||
};
|
||||
|
||||
enum {PTYPE_FILEPANEL,PTYPE_TREEPANEL,PTYPE_QVIEWPANEL,PTYPE_INFOPANEL};
|
||||
|
||||
struct PanelInfo
|
||||
{
|
||||
int PanelType;
|
||||
int Plugin;
|
||||
RECT PanelRect;
|
||||
struct PluginPanelItem *PanelItems;
|
||||
int ItemsNumber;
|
||||
struct PluginPanelItem *SelectedItems;
|
||||
int SelectedItemsNumber;
|
||||
int CurrentItem;
|
||||
int TopPanelItem;
|
||||
int Visible;
|
||||
int Focus;
|
||||
int ViewMode;
|
||||
char ColumnTypes[80];
|
||||
char ColumnWidths[80];
|
||||
char CurDir[NM];
|
||||
int ShortNames;
|
||||
int SortMode;
|
||||
DWORD Reserved[2];
|
||||
};
|
||||
|
||||
|
||||
struct PanelRedrawInfo
|
||||
{
|
||||
int CurrentItem;
|
||||
int TopPanelItem;
|
||||
};
|
||||
|
||||
|
||||
typedef int (WINAPI *FARAPICONTROL)(
|
||||
HANDLE hPlugin,
|
||||
int Command,
|
||||
void *Param
|
||||
);
|
||||
|
||||
typedef HANDLE (WINAPI *FARAPISAVESCREEN)(int X1,int Y1,int X2,int Y2);
|
||||
|
||||
typedef void (WINAPI *FARAPIRESTORESCREEN)(HANDLE hScreen);
|
||||
|
||||
typedef int (WINAPI *FARAPIGETDIRLIST)(
|
||||
char *Dir,
|
||||
struct PluginPanelItem **pPanelItem,
|
||||
int *pItemsNumber
|
||||
);
|
||||
|
||||
typedef int (WINAPI *FARAPIGETPLUGINDIRLIST)(
|
||||
int PluginNumber,
|
||||
HANDLE hPlugin,
|
||||
char *Dir,
|
||||
struct PluginPanelItem **pPanelItem,
|
||||
int *pItemsNumber
|
||||
);
|
||||
|
||||
typedef void (WINAPI *FARAPIFREEDIRLIST)(struct PluginPanelItem *PanelItem);
|
||||
|
||||
enum VIEWER_FLAGS {
|
||||
VF_NONMODAL=1,VF_DELETEONCLOSE=2
|
||||
};
|
||||
|
||||
typedef int (WINAPI *FARAPIVIEWER)(
|
||||
char *FileName,
|
||||
char *Title,
|
||||
int X1,
|
||||
int Y1,
|
||||
int X2,
|
||||
int Y2,
|
||||
DWORD Flags
|
||||
);
|
||||
|
||||
typedef int (WINAPI *FARAPIEDITOR)(
|
||||
char *FileName,
|
||||
char *Title,
|
||||
int X1,
|
||||
int Y1,
|
||||
int X2,
|
||||
int Y2,
|
||||
DWORD Flags,
|
||||
int StartLine,
|
||||
int StartChar
|
||||
);
|
||||
|
||||
typedef int (WINAPI *FARAPICMPNAME)(
|
||||
char *Pattern,
|
||||
char *String,
|
||||
int SkipPath
|
||||
);
|
||||
|
||||
|
||||
#define FCT_DETECT 0x40000000
|
||||
|
||||
struct CharTableSet
|
||||
{
|
||||
char DecodeTable[256];
|
||||
char EncodeTable[256];
|
||||
char UpperTable[256];
|
||||
char LowerTable[256];
|
||||
char TableName[128];
|
||||
};
|
||||
|
||||
typedef int (WINAPI *FARAPICHARTABLE)(
|
||||
int Command,
|
||||
char *Buffer,
|
||||
int BufferSize
|
||||
);
|
||||
|
||||
typedef void (WINAPI *FARAPITEXT)(
|
||||
int X,
|
||||
int Y,
|
||||
int Color,
|
||||
char *Str
|
||||
);
|
||||
|
||||
|
||||
typedef int (WINAPI *FARAPIEDITORCONTROL)(
|
||||
int Command,
|
||||
void *Param
|
||||
);
|
||||
|
||||
|
||||
enum EDITOR_EVENTS {
|
||||
EE_READ,EE_SAVE,EE_REDRAW,EE_CLOSE
|
||||
};
|
||||
|
||||
enum EDITOR_CONTROL_COMMANDS {
|
||||
ECTL_GETSTRING,ECTL_SETSTRING,ECTL_INSERTSTRING,ECTL_DELETESTRING,
|
||||
ECTL_DELETECHAR,ECTL_INSERTTEXT,ECTL_GETINFO,ECTL_SETPOSITION,
|
||||
ECTL_SELECT,ECTL_REDRAW,ECTL_EDITORTOOEM,ECTL_OEMTOEDITOR,
|
||||
ECTL_TABTOREAL,ECTL_REALTOTAB,ECTL_EXPANDTABS,ECTL_SETTITLE,
|
||||
ECTL_READINPUT,ECTL_PROCESSINPUT,ECTL_ADDCOLOR,ECTL_GETCOLOR
|
||||
};
|
||||
|
||||
|
||||
struct EditorGetString
|
||||
{
|
||||
int StringNumber;
|
||||
char *StringText;
|
||||
char *StringEOL;
|
||||
int StringLength;
|
||||
int SelStart;
|
||||
int SelEnd;
|
||||
};
|
||||
|
||||
|
||||
struct EditorSetString
|
||||
{
|
||||
int StringNumber;
|
||||
char *StringText;
|
||||
char *StringEOL;
|
||||
int StringLength;
|
||||
};
|
||||
|
||||
|
||||
enum EDITOR_OPTIONS {
|
||||
EOPT_EXPANDTABS=1,EOPT_PERSISTENTBLOCKS=2,EOPT_DELREMOVESBLOCKS=4,
|
||||
EOPT_AUTOINDENT=8,EOPT_SAVEFILEPOSITION=16,EOPT_AUTODETECTTABLE=32,
|
||||
EOPT_CURSORBEYONDEOL=64
|
||||
};
|
||||
|
||||
|
||||
enum EDITOR_BLOCK_TYPES {
|
||||
BTYPE_NONE,BTYPE_STREAM,BTYPE_COLUMN
|
||||
};
|
||||
|
||||
|
||||
struct EditorInfo
|
||||
{
|
||||
int EditorID;
|
||||
char *FileName;
|
||||
int WindowSizeX;
|
||||
int WindowSizeY;
|
||||
int TotalLines;
|
||||
int CurLine;
|
||||
int CurPos;
|
||||
int CurTabPos;
|
||||
int TopScreenLine;
|
||||
int LeftPos;
|
||||
int Overtype;
|
||||
int BlockType;
|
||||
int BlockStartLine;
|
||||
int AnsiMode;
|
||||
int TableNum;
|
||||
DWORD Options;
|
||||
int TabSize;
|
||||
DWORD Reserved[8];
|
||||
};
|
||||
|
||||
|
||||
struct EditorSetPosition
|
||||
{
|
||||
int CurLine;
|
||||
int CurPos;
|
||||
int CurTabPos;
|
||||
int TopScreenLine;
|
||||
int LeftPos;
|
||||
int Overtype;
|
||||
};
|
||||
|
||||
|
||||
struct EditorSelect
|
||||
{
|
||||
int BlockType;
|
||||
int BlockStartLine;
|
||||
int BlockStartPos;
|
||||
int BlockWidth;
|
||||
int BlockHeight;
|
||||
};
|
||||
|
||||
|
||||
struct EditorConvertText
|
||||
{
|
||||
char *Text;
|
||||
int TextLength;
|
||||
};
|
||||
|
||||
|
||||
struct EditorConvertPos
|
||||
{
|
||||
int StringNumber;
|
||||
int SrcPos;
|
||||
int DestPos;
|
||||
};
|
||||
|
||||
|
||||
struct EditorColor
|
||||
{
|
||||
int StringNumber;
|
||||
int ColorItem;
|
||||
int StartPos;
|
||||
int EndPos;
|
||||
int Color;
|
||||
};
|
||||
|
||||
|
||||
struct PluginStartupInfo
|
||||
{
|
||||
int StructSize;
|
||||
char ModuleName[NM];
|
||||
int ModuleNumber;
|
||||
char *RootKey;
|
||||
FARAPIMENU Menu;
|
||||
FARAPIDIALOG Dialog;
|
||||
FARAPIMESSAGE Message;
|
||||
FARAPIGETMSG GetMsg;
|
||||
FARAPICONTROL Control;
|
||||
FARAPISAVESCREEN SaveScreen;
|
||||
FARAPIRESTORESCREEN RestoreScreen;
|
||||
FARAPIGETDIRLIST GetDirList;
|
||||
FARAPIGETPLUGINDIRLIST GetPluginDirList;
|
||||
FARAPIFREEDIRLIST FreeDirList;
|
||||
FARAPIVIEWER Viewer;
|
||||
FARAPIEDITOR Editor;
|
||||
FARAPICMPNAME CmpName;
|
||||
FARAPICHARTABLE CharTable;
|
||||
FARAPITEXT Text;
|
||||
FARAPIEDITORCONTROL EditorControl;
|
||||
};
|
||||
|
||||
|
||||
enum PLUGIN_FLAGS {
|
||||
PF_PRELOAD = 0x0001,
|
||||
PF_DISABLEPANELS = 0x0002,
|
||||
PF_EDITOR = 0x0004,
|
||||
PF_VIEWER = 0x0008
|
||||
};
|
||||
|
||||
|
||||
struct PluginInfo
|
||||
{
|
||||
int StructSize;
|
||||
DWORD Flags;
|
||||
char **DiskMenuStrings;
|
||||
int *DiskMenuNumbers;
|
||||
int DiskMenuStringsNumber;
|
||||
char **PluginMenuStrings;
|
||||
int PluginMenuStringsNumber;
|
||||
char **PluginConfigStrings;
|
||||
int PluginConfigStringsNumber;
|
||||
char *CommandPrefix;
|
||||
};
|
||||
|
||||
|
||||
struct InfoPanelLine
|
||||
{
|
||||
char Text[80];
|
||||
char Data[80];
|
||||
int Separator;
|
||||
};
|
||||
|
||||
|
||||
struct PanelMode
|
||||
{
|
||||
char *ColumnTypes;
|
||||
char *ColumnWidths;
|
||||
char **ColumnTitles;
|
||||
int FullScreen;
|
||||
int DetailedStatus;
|
||||
int AlignExtensions;
|
||||
int CaseConversion;
|
||||
char *StatusColumnTypes;
|
||||
char *StatusColumnWidths;
|
||||
DWORD Reserved[2];
|
||||
};
|
||||
|
||||
|
||||
enum OPENPLUGININFO_FLAGS {
|
||||
OPIF_USEFILTER = 0x0001,
|
||||
OPIF_USESORTGROUPS = 0x0002,
|
||||
OPIF_USEHIGHLIGHTING = 0x0004,
|
||||
OPIF_ADDDOTS = 0x0008,
|
||||
OPIF_RAWSELECTION = 0x0010,
|
||||
OPIF_REALNAMES = 0x0020,
|
||||
OPIF_SHOWNAMESONLY = 0x0040,
|
||||
OPIF_SHOWRIGHTALIGNNAMES = 0x0080,
|
||||
OPIF_SHOWPRESERVECASE = 0x0100,
|
||||
OPIF_FINDFOLDERS = 0x0200,
|
||||
OPIF_COMPAREFATTIME = 0x0400,
|
||||
OPIF_EXTERNALGET = 0x0800,
|
||||
OPIF_EXTERNALPUT = 0x1000,
|
||||
OPIF_EXTERNALDELETE = 0x2000,
|
||||
OPIF_EXTERNALMKDIR = 0x4000,
|
||||
OPIF_USEATTRHIGHLIGHTING = 0x8000
|
||||
};
|
||||
|
||||
|
||||
enum OPENPLUGININFO_SORTMODES {
|
||||
SM_DEFAULT,SM_UNSORTED,SM_NAME,SM_EXT,SM_MTIME,SM_CTIME,
|
||||
SM_ATIME,SM_SIZE,SM_DESCR,SM_OWNER,SM_COMPRESSEDSIZE,SM_NUMLINKS
|
||||
};
|
||||
|
||||
|
||||
struct KeyBarTitles
|
||||
{
|
||||
char *Titles[12];
|
||||
char *CtrlTitles[12];
|
||||
char *AltTitles[12];
|
||||
char *ShiftTitles[12];
|
||||
};
|
||||
|
||||
|
||||
struct OpenPluginInfo
|
||||
{
|
||||
int StructSize;
|
||||
DWORD Flags;
|
||||
char *HostFile;
|
||||
char *CurDir;
|
||||
char *Format;
|
||||
char *PanelTitle;
|
||||
struct InfoPanelLine *InfoLines;
|
||||
int InfoLinesNumber;
|
||||
char **DescrFiles;
|
||||
int DescrFilesNumber;
|
||||
struct PanelMode *PanelModesArray;
|
||||
int PanelModesNumber;
|
||||
int StartPanelMode;
|
||||
int StartSortMode;
|
||||
int StartSortOrder;
|
||||
struct KeyBarTitles *KeyBar;
|
||||
char *ShortcutData;
|
||||
};
|
||||
|
||||
enum {
|
||||
OPEN_DISKMENU,
|
||||
OPEN_PLUGINSMENU,
|
||||
OPEN_FINDLIST,
|
||||
OPEN_SHORTCUT,
|
||||
OPEN_COMMANDLINE,
|
||||
OPEN_EDITOR,
|
||||
OPEN_VIEWER
|
||||
};
|
||||
|
||||
enum {PKF_CONTROL=1,PKF_ALT=2,PKF_SHIFT=4};
|
||||
|
||||
enum FAR_EVENTS {
|
||||
FE_CHANGEVIEWMODE,
|
||||
FE_REDRAW,
|
||||
FE_IDLE,
|
||||
FE_CLOSE,
|
||||
FE_BREAK,
|
||||
FE_COMMAND
|
||||
};
|
||||
|
||||
enum OPERATION_MODES {
|
||||
OPM_SILENT=1,
|
||||
OPM_FIND=2,
|
||||
OPM_VIEW=4,
|
||||
OPM_EDIT=8,
|
||||
OPM_TOPLEVEL=16,
|
||||
OPM_DESCR=32
|
||||
};
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
|
||||
#pragma option -a.
|
||||
#elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
|
||||
#pragma pack()
|
||||
#else
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
415
7zip/UI/Far/FarUtils.cpp
Executable file
415
7zip/UI/Far/FarUtils.cpp
Executable file
@@ -0,0 +1,415 @@
|
||||
// FarUtils.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
#include "Common/DynamicBuffer.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/Console.h"
|
||||
#include "Windows/Error.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NFar {
|
||||
|
||||
CStartupInfo g_StartupInfo;
|
||||
|
||||
void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo,
|
||||
const CSysString &pliginNameForRegestry)
|
||||
{
|
||||
m_Data = pluginStartupInfo;
|
||||
m_RegistryPath = pluginStartupInfo.RootKey;
|
||||
m_RegistryPath += '\\';
|
||||
m_RegistryPath += pliginNameForRegestry;
|
||||
}
|
||||
|
||||
const char *CStartupInfo::GetMsgString(int messageId)
|
||||
{
|
||||
return (const char*)m_Data.GetMsg(m_Data.ModuleNumber, messageId);
|
||||
}
|
||||
|
||||
int CStartupInfo::ShowMessage(unsigned int flags,
|
||||
const char *helpTopic, const char **items, int numItems, int numButtons)
|
||||
{
|
||||
return m_Data.Message(m_Data.ModuleNumber, flags, (char *)helpTopic,
|
||||
(char **)items, numItems, numButtons);
|
||||
}
|
||||
|
||||
namespace NMessageID
|
||||
{
|
||||
enum
|
||||
{
|
||||
kOk,
|
||||
kCancel,
|
||||
kWarning,
|
||||
kError
|
||||
};
|
||||
}
|
||||
|
||||
int CStartupInfo::ShowMessage(const char *message)
|
||||
{
|
||||
const char *messagesItems[]= { GetMsgString(NMessageID::kError), message,
|
||||
GetMsgString(NMessageID::kOk) };
|
||||
return ShowMessage(FMSG_WARNING, NULL, messagesItems,
|
||||
sizeof(messagesItems) / sizeof(messagesItems[0]), 1);
|
||||
}
|
||||
|
||||
int CStartupInfo::ShowMessage(int messageId)
|
||||
{
|
||||
return ShowMessage(GetMsgString(messageId));
|
||||
}
|
||||
|
||||
int CStartupInfo::ShowDialog(int X1, int Y1, int X2, int Y2,
|
||||
const char *helpTopic, struct FarDialogItem *items, int numItems)
|
||||
{
|
||||
return m_Data.Dialog(m_Data.ModuleNumber, X1, Y1, X2, Y2, (char *)helpTopic,
|
||||
items, numItems);
|
||||
}
|
||||
|
||||
int CStartupInfo::ShowDialog(int sizeX, int sizeY,
|
||||
const char *helpTopic, struct FarDialogItem *items, int numItems)
|
||||
{
|
||||
return ShowDialog(-1, -1, sizeX, sizeY, helpTopic, items, numItems);
|
||||
}
|
||||
|
||||
inline static BOOL GetBOOLValue(bool v) { return (v? TRUE: FALSE); }
|
||||
|
||||
void CStartupInfo::InitDialogItems(const CInitDialogItem *srcItems,
|
||||
FarDialogItem *destItems, int numItems)
|
||||
{
|
||||
for (int i = 0; i < numItems; i++)
|
||||
{
|
||||
const CInitDialogItem &srcItem = srcItems[i];
|
||||
FarDialogItem &destItem = destItems[i];
|
||||
|
||||
destItem.Type = srcItem.Type;
|
||||
destItem.X1 = srcItem.X1;
|
||||
destItem.Y1 = srcItem.Y1;
|
||||
destItem.X2 = srcItem.X2;
|
||||
destItem.Y2 = srcItem.Y2;
|
||||
destItem.Focus = GetBOOLValue(srcItem.Focus);
|
||||
if(srcItem.HistoryName != NULL)
|
||||
destItem.Selected = int(srcItem.HistoryName);
|
||||
else
|
||||
destItem.Selected = GetBOOLValue(srcItem.Selected);
|
||||
destItem.Flags = srcItem.Flags;
|
||||
destItem.DefaultButton = GetBOOLValue(srcItem.DefaultButton);
|
||||
|
||||
if(srcItem.DataMessageId < 0)
|
||||
strcpy(destItem.Data, srcItem.DataString);
|
||||
else
|
||||
strcpy(destItem.Data, GetMsgString(srcItem.DataMessageId));
|
||||
|
||||
/*
|
||||
if ((unsigned int)Init[i].Data < 0xFFF)
|
||||
strcpy(destItem.Data, GetMsg((unsigned int)srcItem.Data));
|
||||
else
|
||||
strcpy(destItem.Data,srcItem.Data);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------
|
||||
|
||||
HANDLE CStartupInfo::SaveScreen(int X1, int Y1, int X2, int Y2)
|
||||
{
|
||||
return m_Data.SaveScreen(X1, Y1, X2, Y2);
|
||||
}
|
||||
|
||||
HANDLE CStartupInfo::SaveScreen()
|
||||
{
|
||||
return SaveScreen(0, 0, -1, -1);
|
||||
}
|
||||
|
||||
void CStartupInfo::RestoreScreen(HANDLE handle)
|
||||
{
|
||||
m_Data.RestoreScreen(handle);
|
||||
}
|
||||
|
||||
const char kRegestryKeyDelimiter = '\'';
|
||||
|
||||
CSysString CStartupInfo::GetFullKeyName(const CSysString &keyName) const
|
||||
{
|
||||
return (keyName.IsEmpty()) ? m_RegistryPath:
|
||||
(m_RegistryPath + kRegestryKeyDelimiter + keyName);
|
||||
}
|
||||
|
||||
|
||||
LONG CStartupInfo::CreateRegKey(HKEY parentKey,
|
||||
const CSysString &keyName, NRegistry::CKey &destKey) const
|
||||
{
|
||||
return destKey.Create(parentKey, GetFullKeyName(keyName));
|
||||
}
|
||||
|
||||
LONG CStartupInfo::OpenRegKey(HKEY parentKey,
|
||||
const CSysString &keyName, NRegistry::CKey &destKey) const
|
||||
{
|
||||
return destKey.Open(parentKey, GetFullKeyName(keyName));
|
||||
}
|
||||
|
||||
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
LPCTSTR valueName, LPCTSTR value) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
CreateRegKey(parentKey, keyName, regKey);
|
||||
regKey.SetValue(valueName, value);
|
||||
}
|
||||
|
||||
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
LPCTSTR valueName, UINT32 value) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
CreateRegKey(parentKey, keyName, regKey);
|
||||
regKey.SetValue(valueName, value);
|
||||
}
|
||||
|
||||
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
LPCTSTR valueName, bool value) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
CreateRegKey(parentKey, keyName, regKey);
|
||||
regKey.SetValue(valueName, value);
|
||||
}
|
||||
|
||||
CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
LPCTSTR valueName, const CSysString &valueDefault) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
if (OpenRegKey(parentKey, keyName, regKey) != ERROR_SUCCESS)
|
||||
return valueDefault;
|
||||
|
||||
CSysString value;
|
||||
if(regKey.QueryValue(valueName, value) != ERROR_SUCCESS)
|
||||
return valueDefault;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
UINT32 CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
LPCTSTR valueName, UINT32 valueDefault) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
if (OpenRegKey(parentKey, keyName, regKey) != ERROR_SUCCESS)
|
||||
return valueDefault;
|
||||
|
||||
UINT32 value;
|
||||
if(regKey.QueryValue(valueName, value) != ERROR_SUCCESS)
|
||||
return valueDefault;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
LPCTSTR valueName, bool valueDefault) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
if (OpenRegKey(parentKey, keyName, regKey) != ERROR_SUCCESS)
|
||||
return valueDefault;
|
||||
|
||||
bool value;
|
||||
if(regKey.QueryValue(valueName, value) != ERROR_SUCCESS)
|
||||
return valueDefault;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool CStartupInfo::Control(HANDLE pluginHandle, int command, void *param)
|
||||
{
|
||||
return BOOLToBool(m_Data.Control(pluginHandle, command, param));
|
||||
}
|
||||
|
||||
bool CStartupInfo::ControlRequestActivePanel(int command, void *param)
|
||||
{
|
||||
return Control(INVALID_HANDLE_VALUE, command, param);
|
||||
}
|
||||
|
||||
bool CStartupInfo::ControlGetActivePanelInfo(PanelInfo &panelInfo)
|
||||
{
|
||||
return ControlRequestActivePanel(FCTL_GETPANELINFO, &panelInfo);
|
||||
}
|
||||
|
||||
bool CStartupInfo::ControlSetSelection(const PanelInfo &panelInfo)
|
||||
{
|
||||
return ControlRequestActivePanel(FCTL_SETSELECTION, (void *)&panelInfo);
|
||||
}
|
||||
|
||||
bool CStartupInfo::ControlGetActivePanelCurrentItemInfo(
|
||||
PluginPanelItem &pluginPanelItem)
|
||||
{
|
||||
PanelInfo panelInfo;
|
||||
if(!ControlGetActivePanelInfo(panelInfo))
|
||||
return false;
|
||||
if(panelInfo.ItemsNumber <= 0)
|
||||
throw "There are no items";
|
||||
pluginPanelItem = panelInfo.PanelItems[panelInfo.CurrentItem];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStartupInfo::ControlGetActivePanelSelectedOrCurrentItems(
|
||||
CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
{
|
||||
pluginPanelItems.Clear();
|
||||
PanelInfo panelInfo;
|
||||
if(!ControlGetActivePanelInfo(panelInfo))
|
||||
return false;
|
||||
if(panelInfo.ItemsNumber <= 0)
|
||||
throw "There are no items";
|
||||
if (panelInfo.SelectedItemsNumber == 0)
|
||||
pluginPanelItems.Add(panelInfo.PanelItems[panelInfo.CurrentItem]);
|
||||
else
|
||||
for (int i = 0; i < panelInfo.SelectedItemsNumber; i++)
|
||||
pluginPanelItems.Add(panelInfo.SelectedItems[i]);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStartupInfo::ControlClearPanelSelection()
|
||||
{
|
||||
PanelInfo panelInfo;
|
||||
if(!ControlGetActivePanelInfo(panelInfo))
|
||||
return false;
|
||||
for (int i = 0; i < panelInfo.ItemsNumber; i++)
|
||||
panelInfo.PanelItems[i].Flags &= ~PPIF_SELECTED;
|
||||
return ControlSetSelection(panelInfo);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// menu function
|
||||
|
||||
int CStartupInfo::Menu(
|
||||
int x,
|
||||
int y,
|
||||
int maxHeight,
|
||||
unsigned int flags,
|
||||
const char *title,
|
||||
const char *aBottom,
|
||||
const char *helpTopic,
|
||||
int *breakKeys,
|
||||
int *breakCode,
|
||||
struct FarMenuItem *items,
|
||||
int numItems)
|
||||
{
|
||||
return m_Data.Menu(m_Data.ModuleNumber, x, y, maxHeight, flags, (char *)title,
|
||||
(char *)aBottom, (char *)helpTopic, breakKeys, breakCode, items, numItems);
|
||||
}
|
||||
|
||||
int CStartupInfo::Menu(
|
||||
unsigned int flags,
|
||||
const char *title,
|
||||
const char *helpTopic,
|
||||
struct FarMenuItem *items,
|
||||
int numItems)
|
||||
{
|
||||
return Menu(-1, -1, 0, flags, title, NULL, helpTopic, NULL,
|
||||
NULL, items, numItems);
|
||||
}
|
||||
|
||||
int CStartupInfo::Menu(
|
||||
unsigned int flags,
|
||||
const char *title,
|
||||
const char *helpTopic,
|
||||
const CSysStringVector &items,
|
||||
int selectedItem)
|
||||
{
|
||||
CRecordVector<FarMenuItem> farMenuItems;
|
||||
for(int i = 0; i < items.Size(); i++)
|
||||
{
|
||||
FarMenuItem item;
|
||||
item.Checked = 0;
|
||||
item.Separator = 0;
|
||||
item.Selected = (i == selectedItem);
|
||||
CSysString reducedString =
|
||||
items[i].Left(sizeof(item.Text) / sizeof(item.Text[0]) - 1);
|
||||
strcpy(item.Text, reducedString);
|
||||
farMenuItems.Add(item);
|
||||
}
|
||||
return Menu(flags, title, helpTopic, &farMenuItems.Front(), farMenuItems.Size());
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
// CScreenRestorer
|
||||
|
||||
CScreenRestorer::~CScreenRestorer()
|
||||
{
|
||||
Restore();
|
||||
}
|
||||
void CScreenRestorer::Save()
|
||||
{
|
||||
if(m_Saved)
|
||||
return;
|
||||
m_HANDLE = g_StartupInfo.SaveScreen();
|
||||
m_Saved = true;
|
||||
}
|
||||
|
||||
void CScreenRestorer::Restore()
|
||||
{
|
||||
if(m_Saved)
|
||||
{
|
||||
g_StartupInfo.RestoreScreen(m_HANDLE);
|
||||
m_Saved = false;
|
||||
}
|
||||
};
|
||||
|
||||
static CSysString DWORDToString(DWORD number)
|
||||
{
|
||||
char buffer[32];
|
||||
ultoa(number, buffer, 10);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void PrintErrorMessage(const char *message, int code)
|
||||
{
|
||||
CSysString tmp = message;
|
||||
tmp += " #";
|
||||
tmp += DWORDToString(code);
|
||||
g_StartupInfo.ShowMessage(tmp);
|
||||
}
|
||||
|
||||
void PrintErrorMessage(const char *message, const char *text)
|
||||
{
|
||||
CSysString tmp = message;
|
||||
tmp += ": ";
|
||||
tmp += text;
|
||||
g_StartupInfo.ShowMessage(tmp);
|
||||
}
|
||||
|
||||
bool WasEscPressed()
|
||||
{
|
||||
NConsole::CIn inConsole;
|
||||
HANDLE handle = ::GetStdHandle(STD_INPUT_HANDLE);
|
||||
if(handle == INVALID_HANDLE_VALUE)
|
||||
return true;
|
||||
inConsole.Attach(handle);
|
||||
while (true)
|
||||
{
|
||||
DWORD numEvents;
|
||||
if(!inConsole.GetNumberOfEvents(numEvents))
|
||||
return true;
|
||||
if(numEvents == 0)
|
||||
return false;
|
||||
|
||||
INPUT_RECORD event;
|
||||
if(!inConsole.ReadEvent(event, numEvents))
|
||||
return true;
|
||||
if (event.EventType == KEY_EVENT &&
|
||||
event.Event.KeyEvent.bKeyDown &&
|
||||
event.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void ShowErrorMessage(DWORD errorCode)
|
||||
{
|
||||
CSysString message;
|
||||
NError::MyFormatMessage(errorCode, message);
|
||||
g_StartupInfo.ShowMessage(SystemStringToOemString(message));
|
||||
|
||||
}
|
||||
|
||||
void ShowLastErrorMessage()
|
||||
{
|
||||
ShowErrorMessage(::GetLastError());
|
||||
}
|
||||
|
||||
}
|
||||
185
7zip/UI/Far/FarUtils.h
Executable file
185
7zip/UI/Far/FarUtils.h
Executable file
@@ -0,0 +1,185 @@
|
||||
// FarUtils.h
|
||||
|
||||
#ifndef __FARUTILS_H
|
||||
#define __FARUTILS_H
|
||||
|
||||
#include "FarPlugin.h"
|
||||
#include "Common/String.h"
|
||||
#include "Common/Vector.h"
|
||||
#include "Windows/Registry.h"
|
||||
|
||||
namespace NFar {
|
||||
|
||||
namespace NFileOperationReturnCode
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kInterruptedByUser = -1,
|
||||
kError = 0,
|
||||
kSuccess = 1
|
||||
};
|
||||
}
|
||||
|
||||
namespace NEditorReturnCode
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kOpenError = 0,
|
||||
kFileWasChanged = 1,
|
||||
kFileWasNotChanged = 2,
|
||||
kInterruptedByUser = 3
|
||||
};
|
||||
}
|
||||
|
||||
struct CInitDialogItem
|
||||
{
|
||||
DialogItemTypes Type;
|
||||
int X1,Y1,X2,Y2;
|
||||
bool Focus;
|
||||
bool Selected;
|
||||
unsigned int Flags; //FarDialogItemFlags Flags;
|
||||
bool DefaultButton;
|
||||
int DataMessageId;
|
||||
const char *DataString;
|
||||
const char *HistoryName;
|
||||
// void InitToFarDialogItem(struct FarDialogItem &anItemDest);
|
||||
};
|
||||
|
||||
class CStartupInfo
|
||||
{
|
||||
PluginStartupInfo m_Data;
|
||||
CSysString m_RegistryPath;
|
||||
|
||||
CSysString GetFullKeyName(const CSysString &keyName) const;
|
||||
LONG CreateRegKey(HKEY parentKey,
|
||||
const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const;
|
||||
LONG OpenRegKey(HKEY parentKey,
|
||||
const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const;
|
||||
|
||||
public:
|
||||
void Init(const PluginStartupInfo &pluginStartupInfo,
|
||||
const CSysString &pliginNameForRegestry);
|
||||
const char *GetMsgString(int messageId);
|
||||
int ShowMessage(unsigned int flags, const char *helpTopic,
|
||||
const char **items, int numItems, int numButtons);
|
||||
int ShowMessage(const char *message);
|
||||
int ShowMessage(int messageId);
|
||||
|
||||
int ShowDialog(int X1, int Y1, int X2, int Y2,
|
||||
const char *helpTopic, struct FarDialogItem *items, int numItems);
|
||||
int ShowDialog(int sizeX, int sizeY,
|
||||
const char *helpTopic, struct FarDialogItem *items, int numItems);
|
||||
|
||||
void InitDialogItems(const CInitDialogItem *srcItems,
|
||||
FarDialogItem *destItems, int numItems);
|
||||
|
||||
HANDLE SaveScreen(int X1, int Y1, int X2, int Y2);
|
||||
HANDLE SaveScreen();
|
||||
void RestoreScreen(HANDLE handle);
|
||||
|
||||
void SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
const LPCTSTR valueName, LPCTSTR value) const;
|
||||
void SetRegKeyValue(HKEY hRoot, const CSysString &keyName,
|
||||
const LPCTSTR valueName, UINT32 value) const;
|
||||
void SetRegKeyValue(HKEY hRoot, const CSysString &keyName,
|
||||
const LPCTSTR valueName, bool value) const;
|
||||
|
||||
CSysString QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
LPCTSTR valueName, const CSysString &valueDefault) const;
|
||||
|
||||
UINT32 QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
LPCTSTR valueName, UINT32 valueDefault) const;
|
||||
|
||||
bool QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
LPCTSTR valueName, bool valueDefault) const;
|
||||
|
||||
bool Control(HANDLE plugin, int command, void *param);
|
||||
bool ControlRequestActivePanel(int command, void *param);
|
||||
bool ControlGetActivePanelInfo(PanelInfo &panelInfo);
|
||||
bool ControlSetSelection(const PanelInfo &panelInfo);
|
||||
bool ControlGetActivePanelCurrentItemInfo(PluginPanelItem &pluginPanelItem);
|
||||
bool ControlGetActivePanelSelectedOrCurrentItems(
|
||||
CObjectVector<PluginPanelItem> &pluginPanelItems);
|
||||
|
||||
bool ControlClearPanelSelection();
|
||||
|
||||
int Menu(
|
||||
int x,
|
||||
int y,
|
||||
int maxHeight,
|
||||
unsigned int flags,
|
||||
const char *title,
|
||||
const char *aBottom,
|
||||
const char *helpTopic,
|
||||
int *breakKeys,
|
||||
int *breakCode,
|
||||
FarMenuItem *items,
|
||||
int numItems);
|
||||
int Menu(
|
||||
unsigned int flags,
|
||||
const char *title,
|
||||
const char *helpTopic,
|
||||
FarMenuItem *items,
|
||||
int numItems);
|
||||
|
||||
int Menu(
|
||||
unsigned int flags,
|
||||
const char *title,
|
||||
const char *helpTopic,
|
||||
const CSysStringVector &items,
|
||||
int selectedItem);
|
||||
|
||||
int Editor(const char *fileName, const char *title,
|
||||
int X1, int Y1, int X2, int Y2, DWORD flags, int startLine, int startChar)
|
||||
{ return m_Data.Editor((char *)fileName, (char *)title, X1, Y1, X2, Y2,
|
||||
flags, startLine, startChar); }
|
||||
int Editor(const char *fileName)
|
||||
{ return Editor(fileName, NULL, 0, 0, -1, -1, 0, -1, -1); }
|
||||
|
||||
int Viewer(const char *fileName, const char *title,
|
||||
int X1, int Y1, int X2, int Y2, DWORD flags)
|
||||
{ return m_Data.Viewer((char *)fileName, (char *)title, X1, Y1, X2, Y2, flags); }
|
||||
int Viewer(const char *fileName)
|
||||
{ return Viewer(fileName, NULL, 0, 0, -1, -1, VF_NONMODAL); }
|
||||
|
||||
};
|
||||
|
||||
class CScreenRestorer
|
||||
{
|
||||
bool m_Saved;
|
||||
HANDLE m_HANDLE;
|
||||
public:
|
||||
CScreenRestorer(): m_Saved(false){};
|
||||
~CScreenRestorer();
|
||||
void Save();
|
||||
void Restore();
|
||||
};
|
||||
|
||||
|
||||
extern CStartupInfo g_StartupInfo;
|
||||
|
||||
void PrintErrorMessage(const char *message, int code);
|
||||
void PrintErrorMessage(const char *message, const char *aText);
|
||||
|
||||
#define MY_TRY_BEGIN try\
|
||||
{
|
||||
|
||||
#define MY_TRY_END1(x) }\
|
||||
catch(int n) { PrintErrorMessage(x, n); return; }\
|
||||
catch(const CSysString &s) { PrintErrorMessage(x, s); return; }\
|
||||
catch(const char *s) { PrintErrorMessage(x, s); return; }\
|
||||
catch(...) { g_StartupInfo.ShowMessage(x); return; }
|
||||
|
||||
#define MY_TRY_END2(x, y) }\
|
||||
catch(int n) { PrintErrorMessage(x, n); return y; }\
|
||||
catch(const CSysString &s) { PrintErrorMessage(x, s); return y; }\
|
||||
catch(const char *s) { PrintErrorMessage(x, s); return y; }\
|
||||
catch(...) { g_StartupInfo.ShowMessage(x); return y; }
|
||||
|
||||
bool WasEscPressed();
|
||||
void ShowErrorMessage(DWORD errorCode);
|
||||
void ShowLastErrorMessage();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Common/WildCard.h"
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/DynamicBuffer.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Defs.h"
|
||||
@@ -17,18 +17,16 @@
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "Far/FarUtils.h"
|
||||
#include "Far/ProgressBox.h"
|
||||
|
||||
#include "Messages.h"
|
||||
|
||||
#include "../../IPassword.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"
|
||||
|
||||
#include "ProgressBox.h"
|
||||
#include "FarUtils.h"
|
||||
#include "Messages.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
@@ -249,6 +247,8 @@ STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 *completed)
|
||||
STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
|
||||
IInStream **inStream)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
*inStream = NULL;
|
||||
UString fullPath = _folderPrefix + name;
|
||||
if (!NWindows::NFile::NFind::FindFile(fullPath, _fileInfo))
|
||||
@@ -297,6 +297,8 @@ STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value
|
||||
|
||||
HRESULT GetPassword(UString &password)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
password.Empty();
|
||||
CInitDialogItem initItems[]=
|
||||
{
|
||||
@@ -396,7 +398,11 @@ static HANDLE MyOpenFilePlugin(const char *name)
|
||||
archiverInfoResult, defaultName, openArchiveCallback);
|
||||
*/
|
||||
if (result != S_OK)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
{
|
||||
if (result == E_ABORT)
|
||||
return (HANDLE)-2;
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
// ::OutputDebugString("after OpenArchive\n");
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// SevenZip/ Messages.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __SEVENZIP_MESSAGES_H
|
||||
#define __SEVENZIP_MESSAGES_H
|
||||
|
||||
@@ -47,6 +45,7 @@ enum EEnum
|
||||
kGroup,
|
||||
kBlock,
|
||||
kComment,
|
||||
kPosition,
|
||||
|
||||
kGetPasswordTitle,
|
||||
kEnterPasswordForFile,
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
// OverwriteDialog.cpp : implementation file
|
||||
// OverwriteDialog.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "OverwriteDialog.h"
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/StringConvert.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 "FarUtils.h"
|
||||
#include "Messages.h"
|
||||
|
||||
using namespace NWindows;
|
||||
@@ -45,7 +48,7 @@ void SetFileInfoStrings(const CFileInfo &fileInfo,
|
||||
FILETIME localFileTime;
|
||||
if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
|
||||
throw 4190402;
|
||||
UString timeString = ConvertFileTimeToString2(localFileTime);
|
||||
UString timeString = ConvertFileTimeToString(localFileTime);
|
||||
|
||||
fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn);
|
||||
fileInfoStrings.Time += " ";
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// OverwriteDialog.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef OVERWRITEDIALOG_H
|
||||
#define OVERWRITEDIALOG_H
|
||||
|
||||
|
||||
@@ -4,21 +4,17 @@
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
// #include "Windows/Time.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Wildcard.h"
|
||||
|
||||
#include "Windows/PropVariantConversions.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"
|
||||
#include "FarUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
@@ -111,7 +107,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UINT32 itemIndex)
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
length = 0;
|
||||
else
|
||||
length = ::ConvertPropVariantToUINT64(propVariant);
|
||||
length = ::ConvertPropVariantToUInt64(propVariant);
|
||||
panelItem.FindData.nFileSizeLow = UINT32(length);
|
||||
panelItem.FindData.nFileSizeHigh = UINT32(length >> 32);
|
||||
|
||||
@@ -128,7 +124,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UINT32 itemIndex)
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
length = 0;
|
||||
else
|
||||
length = ::ConvertPropVariantToUINT64(propVariant);
|
||||
length = ::ConvertPropVariantToUInt64(propVariant);
|
||||
panelItem.PackSize = UINT32(length);
|
||||
panelItem.PackSizeHigh = UINT32(length >> 32);
|
||||
|
||||
@@ -170,7 +166,7 @@ int CPlugin::GetFindData(PluginPanelItem **panelItems,
|
||||
*panelItems = new PluginPanelItem[numItems];
|
||||
try
|
||||
{
|
||||
for(int i = 0; i < numItems; i++)
|
||||
for(UINT32 i = 0; i < numItems; i++)
|
||||
{
|
||||
PluginPanelItem &panelItem = (*panelItems)[i];
|
||||
ReadPluginPanelItem(panelItem, i);
|
||||
@@ -210,13 +206,13 @@ void CPlugin::EnterToDirectory(const UString &aDirName)
|
||||
|
||||
int CPlugin::SetDirectory(const char *aszDir, int opMode)
|
||||
{
|
||||
UString aDir = MultiByteToUnicodeString(aszDir, CP_OEMCP);
|
||||
if (aDir == L"\\")
|
||||
UString path = MultiByteToUnicodeString(aszDir, CP_OEMCP);
|
||||
if (path == L"\\")
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
}
|
||||
else if (aDir == L"..")
|
||||
else if (path == L"..")
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToParentFolder(&newFolder);
|
||||
@@ -224,29 +220,22 @@ int CPlugin::SetDirectory(const char *aszDir, int opMode)
|
||||
throw 40312;
|
||||
_folder = newFolder;
|
||||
}
|
||||
else if (aDir.IsEmpty())
|
||||
EnterToDirectory(aDir);
|
||||
else if (path.IsEmpty())
|
||||
EnterToDirectory(path);
|
||||
else
|
||||
{
|
||||
if (aDir[0] == L'\\')
|
||||
if (path[0] == L'\\')
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
aDir = aDir.Mid(1);
|
||||
path = path.Mid(1);
|
||||
}
|
||||
UStringVector pathParts;
|
||||
SplitPathToParts(aDir, pathParts);
|
||||
SplitPathToParts(path, 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];
|
||||
}
|
||||
GetCurrentDir();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -267,6 +256,18 @@ void CPlugin::GetPathParts(UStringVector &pathParts)
|
||||
}
|
||||
}
|
||||
|
||||
void CPlugin::GetCurrentDir()
|
||||
{
|
||||
m_CurrentDir.Empty();
|
||||
UStringVector pathParts;
|
||||
GetPathParts(pathParts);
|
||||
for (int i = 0; i < pathParts.Size(); i++)
|
||||
{
|
||||
m_CurrentDir += L'\\';
|
||||
m_CurrentDir += pathParts[i];
|
||||
}
|
||||
}
|
||||
|
||||
static char *kPluginFormatName = "7-ZIP";
|
||||
|
||||
|
||||
@@ -302,7 +303,9 @@ static CPROPIDToName kPROPIDToName[] =
|
||||
{ kpidUser, NMessageID::kUser },
|
||||
{ kpidGroup, NMessageID::kGroup },
|
||||
{ kpidBlock, NMessageID::kBlock },
|
||||
{ kpidComment, NMessageID::kComment }
|
||||
{ kpidComment, NMessageID::kComment },
|
||||
{ kpidPosition, NMessageID::kPosition }
|
||||
|
||||
};
|
||||
|
||||
static const int kNumPROPIDToName = sizeof(kPROPIDToName) / sizeof(kPROPIDToName[0]);
|
||||
@@ -537,7 +540,7 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
UINT32 numProps;
|
||||
RINOK(m_ArchiveHandler->GetNumberOfProperties(&numProps));
|
||||
int i;
|
||||
for (i = 0; i < numProps; i++)
|
||||
for (i = 0; i < (int)numProps; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
// Far/Plugin.h
|
||||
// 7zip/Far/Plugin.h
|
||||
|
||||
#pragma once
|
||||
#ifndef __7ZIP_FAR_PLUGIN_H
|
||||
#define __7ZIP_FAR_PLUGIN_H
|
||||
|
||||
#ifndef __FAR_PLUGIN_H
|
||||
#define __FAR_PLUGIN_H
|
||||
#include "Common/MyCom.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"
|
||||
|
||||
#include "FarUtils.h"
|
||||
|
||||
class CPlugin
|
||||
{
|
||||
NWindows::NCOM::CComInitializer m_ComInitializer;
|
||||
@@ -36,6 +36,7 @@ class CPlugin
|
||||
void EnterToDirectory(const UString &aDirName);
|
||||
|
||||
void GetPathParts(UStringVector &aPathParts);
|
||||
void GetCurrentDir();
|
||||
public:
|
||||
UString m_FileName;
|
||||
// UString m_DefaultName;
|
||||
@@ -80,14 +81,14 @@ public:
|
||||
*/
|
||||
|
||||
HRESULT ExtractFiles(
|
||||
bool aDecompressAllItems,
|
||||
const UINT32 *anIndexes,
|
||||
bool decompressAllItems,
|
||||
const UINT32 *indices,
|
||||
UINT32 numIndices,
|
||||
bool aSilent,
|
||||
NExtractionMode::NPath::EEnum aPathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
bool silent,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const UString &destPath,
|
||||
bool aPasswordIsDefined, const UString &password);
|
||||
bool passwordIsDefined, const UString &password);
|
||||
|
||||
NFar::NFileOperationReturnCode::EEnum GetFiles(struct PluginPanelItem *aPanelItem, int itemsNumber,
|
||||
int move, char *destPath, int opMode);
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
/*
|
||||
using namespace NWindows;
|
||||
using namespace std;
|
||||
using namespace NFar;
|
||||
*/
|
||||
|
||||
/*
|
||||
void CPlugin::AddRealIndexOfFile(const CArchiveFolderItem &aFolder,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Plugin.h"
|
||||
#include "Messages.h"
|
||||
#include "UpdateCallback100.h"
|
||||
@@ -14,10 +16,7 @@
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
#include "../Common/WorkDir.h"
|
||||
// #include "../Common/OpenEngine2.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace NFar;
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
@@ -109,7 +108,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
|
||||
}
|
||||
outArchive->SetFolder(_folder);
|
||||
|
||||
CUpdateCallBack100Imp *updateCallbackSpec = new CUpdateCallBack100Imp;
|
||||
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(m_ArchiveHandler, &progressBox);
|
||||
@@ -164,6 +163,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
|
||||
break;
|
||||
_folder = newFolder;
|
||||
}
|
||||
GetCurrentDir();
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
#include "ExtractEngine.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace NFar;
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -33,8 +31,8 @@ HRESULT CPlugin::ExtractFiles(
|
||||
const UINT32 *indices,
|
||||
UINT32 numIndices,
|
||||
bool silent,
|
||||
NExtractionMode::NPath::EEnum pathMode,
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const UString &destPath,
|
||||
bool passwordIsDefined, const UString &password)
|
||||
{
|
||||
@@ -96,9 +94,10 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
NFile::NName::NormalizeDirPathPrefix(destPath);
|
||||
|
||||
bool extractSelectedFiles = true;
|
||||
NExtraction::CInfo extractionInfo;
|
||||
extractionInfo.PathMode = NExtraction::NPathMode::kCurrentPathnames;
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kWithoutPrompt;
|
||||
|
||||
NExtract::CInfo extractionInfo;
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kCurrentPathnames;
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
|
||||
|
||||
bool silent = (opMode & OPM_SILENT) != 0;
|
||||
bool decompressAllItems = false;
|
||||
@@ -129,27 +128,27 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
|
||||
{ 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,
|
||||
extractionInfo.PathMode == NExtract::NPathMode::kFullPathnames,
|
||||
DIF_GROUP, false, NMessageID::kExtractPathFull, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 7, 0, 0, false,
|
||||
extractionInfo.PathMode == NExtraction::NPathMode::kCurrentPathnames,
|
||||
extractionInfo.PathMode == NExtract::NPathMode::kCurrentPathnames,
|
||||
0, false, NMessageID::kExtractPathCurrent, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 8, 0, 0, false,
|
||||
extractionInfo.PathMode == NExtraction::NPathMode::kNoPathnames,
|
||||
extractionInfo.PathMode == NExtract::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,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAskBefore,
|
||||
DIF_GROUP, false, NMessageID::kExtractOwerwriteAsk, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtraction::NOverwriteMode::kWithoutPrompt,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kWithoutPrompt,
|
||||
0, false, NMessageID::kExtractOwerwritePrompt, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtraction::NOverwriteMode::kSkipExisting,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kSkipExisting,
|
||||
0, false, NMessageID::kExtractOwerwriteSkip, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 9, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtraction::NOverwriteMode::kAutoRename,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRename,
|
||||
0, false, NMessageID::kExtractOwerwriteAutoRename, NULL, NULL },
|
||||
|
||||
{ DI_SINGLEBOX, 4, 10, kXMid- 2, 10 + 3, false, false, 0, false, NMessageID::kExtractFilesMode, NULL, NULL },
|
||||
@@ -196,22 +195,22 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
}
|
||||
|
||||
if (dialogItems[kPathModeRadioIndex].Selected)
|
||||
extractionInfo.PathMode = NExtraction::NPathMode::kFullPathnames;
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kFullPathnames;
|
||||
else if (dialogItems[kPathModeRadioIndex + 1].Selected)
|
||||
extractionInfo.PathMode = NExtraction::NPathMode::kCurrentPathnames;
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kCurrentPathnames;
|
||||
else if (dialogItems[kPathModeRadioIndex + 2].Selected)
|
||||
extractionInfo.PathMode = NExtraction::NPathMode::kNoPathnames;
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kNoPathnames;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
if (dialogItems[kOverwriteModeRadioIndex].Selected)
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kAskBefore;
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 1].Selected)
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kWithoutPrompt;
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 2].Selected)
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kSkipExisting;
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kSkipExisting;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 3].Selected)
|
||||
extractionInfo.OverwriteMode = NExtraction::NOverwriteMode::kAutoRename;
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kAutoRename;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
@@ -248,35 +247,35 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
for (int i = 0; i < itemsNumber; i++)
|
||||
indices.Add(panelItems[i].UserData);
|
||||
|
||||
NExtractionMode::NPath::EEnum pathMode;
|
||||
NExtractionMode::NOverwrite::EEnum overwriteMode;
|
||||
NExtract::NPathMode::EEnum pathMode;
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode;
|
||||
switch (extractionInfo.OverwriteMode)
|
||||
{
|
||||
case NExtraction::NOverwriteMode::kAskBefore:
|
||||
overwriteMode = NExtractionMode::NOverwrite::kAskBefore;
|
||||
case NExtract::NOverwriteMode::kAskBefore:
|
||||
overwriteMode = NExtract::NOverwriteMode::kAskBefore;
|
||||
break;
|
||||
case NExtraction::NOverwriteMode::kWithoutPrompt:
|
||||
overwriteMode = NExtractionMode::NOverwrite::kWithoutPrompt;
|
||||
case NExtract::NOverwriteMode::kWithoutPrompt:
|
||||
overwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
|
||||
break;
|
||||
case NExtraction::NOverwriteMode::kSkipExisting:
|
||||
overwriteMode = NExtractionMode::NOverwrite::kSkipExisting;
|
||||
case NExtract::NOverwriteMode::kSkipExisting:
|
||||
overwriteMode = NExtract::NOverwriteMode::kSkipExisting;
|
||||
break;
|
||||
case NExtraction::NOverwriteMode::kAutoRename:
|
||||
overwriteMode = NExtractionMode::NOverwrite::kAutoRename;
|
||||
case NExtract::NOverwriteMode::kAutoRename:
|
||||
overwriteMode = NExtract::NOverwriteMode::kAutoRename;
|
||||
break;
|
||||
default:
|
||||
throw 12334454;
|
||||
}
|
||||
switch (extractionInfo.PathMode)
|
||||
{
|
||||
case NExtraction::NPathMode::kFullPathnames:
|
||||
pathMode = NExtractionMode::NPath::kFullPathnames;
|
||||
case NExtract::NPathMode::kFullPathnames:
|
||||
pathMode = NExtract::NPathMode::kFullPathnames;
|
||||
break;
|
||||
case NExtraction::NPathMode::kCurrentPathnames:
|
||||
pathMode = NExtractionMode::NPath::kCurrentPathnames;
|
||||
case NExtract::NPathMode::kCurrentPathnames:
|
||||
pathMode = NExtract::NPathMode::kCurrentPathnames;
|
||||
break;
|
||||
case NExtraction::NPathMode::kNoPathnames:
|
||||
pathMode = NExtractionMode::NPath::kNoPathnames;
|
||||
case NExtract::NPathMode::kNoPathnames:
|
||||
pathMode = NExtract::NPathMode::kNoPathnames;
|
||||
break;
|
||||
default:
|
||||
throw 12334455;
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Messages.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
@@ -15,23 +13,14 @@
|
||||
#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"
|
||||
#include "ProgressBox.h"
|
||||
#include "Messages.h"
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
@@ -50,20 +39,19 @@ 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)
|
||||
CMyComPtr<ISetProperties> setProperties;
|
||||
if (outArchive->QueryInterface(&setProperties) == S_OK)
|
||||
{
|
||||
CMyComBSTR comBSTR = L"x";
|
||||
CObjectVector<CMyComBSTR> realNames;
|
||||
UStringVector realNames;
|
||||
realNames.Add(UString(L"x"));
|
||||
std::vector<NCOM::CPropVariant> values;
|
||||
realNames.Add(comBSTR);
|
||||
values.push_back(NCOM::CPropVariant((UINT32)method));
|
||||
|
||||
std::vector<BSTR> names;
|
||||
CRecordVector<const wchar_t *> names;
|
||||
for(int i = 0; i < realNames.Size(); i++)
|
||||
names.push_back(realNames[i]);
|
||||
RINOK(aSetProperties->SetProperties(&names.front(),
|
||||
&values.front(), names.size()));
|
||||
names.Add(realNames[i]);
|
||||
RINOK(setProperties->SetProperties(&names.Front(),
|
||||
&values.front(), names.Size()));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -243,7 +231,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = actionSet->StateActions[i];
|
||||
|
||||
CUpdateCallBack100Imp *updateCallbackSpec = new CUpdateCallBack100Imp;
|
||||
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(m_ArchiveHandler, &progressBox);
|
||||
@@ -669,7 +657,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = actionSet->StateActions[i];
|
||||
|
||||
CUpdateCallBack100Imp *updateCallbackSpec = new CUpdateCallBack100Imp;
|
||||
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(archiveHandler, &progressBox);
|
||||
|
||||
103
7zip/UI/Far/ProgressBox.cpp
Executable file
103
7zip/UI/Far/ProgressBox.cpp
Executable file
@@ -0,0 +1,103 @@
|
||||
// ProgressBox.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ProgressBox.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
|
||||
using namespace NFar;
|
||||
|
||||
static void CopySpaces(char *destString, int numSpaces)
|
||||
{
|
||||
for(int i = 0; i < numSpaces; i++)
|
||||
destString[i] = ' ';
|
||||
destString[i] = '\0';
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// CMessageBox
|
||||
|
||||
const int kNumStringsMax = 10;
|
||||
|
||||
void CMessageBox::Init(const CSysString &title, const CSysString &message,
|
||||
int numStrings, int width)
|
||||
{
|
||||
if (numStrings > kNumStringsMax)
|
||||
throw 120620;
|
||||
m_NumStrings = numStrings;
|
||||
m_Width = width;
|
||||
|
||||
m_Title = title;
|
||||
m_Message = message;
|
||||
}
|
||||
|
||||
const int kNumStaticStrings = 2;
|
||||
|
||||
void CMessageBox::ShowProcessMessages(const char *messages[])
|
||||
{
|
||||
const char *msgItems[kNumStaticStrings + kNumStringsMax];
|
||||
msgItems[0] = m_Title;
|
||||
msgItems[1] = m_Message;
|
||||
|
||||
char formattedMessages[kNumStringsMax][256];
|
||||
|
||||
for (int i = 0; i < m_NumStrings; i++)
|
||||
{
|
||||
char *formattedMessage = formattedMessages[i];
|
||||
int len = strlen(messages[i]);
|
||||
int size = MyMax(m_Width, len);
|
||||
int startPos = (size - len) / 2;
|
||||
CopySpaces(formattedMessage, startPos);
|
||||
strcpy(formattedMessage + startPos, messages[i]);
|
||||
CopySpaces(formattedMessage + startPos + len, size - startPos - len);
|
||||
msgItems[kNumStaticStrings + i] = formattedMessage;
|
||||
}
|
||||
|
||||
g_StartupInfo.ShowMessage(0, NULL, msgItems, kNumStaticStrings + m_NumStrings, 0);
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// CProgressBox
|
||||
|
||||
void CProgressBox::Init(const CSysString &title, const CSysString &message,
|
||||
UInt64 step)
|
||||
{
|
||||
CMessageBox::Init(title, message, 1, 22);
|
||||
m_Step = step;
|
||||
m_CompletedPrev = 0;
|
||||
m_Total = 0;
|
||||
}
|
||||
|
||||
|
||||
void CProgressBox::ShowProcessMessage(const char *message)
|
||||
{
|
||||
CMessageBox::ShowProcessMessages(&message);
|
||||
}
|
||||
|
||||
void CProgressBox::PrintPercent(UInt64 percent)
|
||||
{
|
||||
char valueBuffer[32];
|
||||
sprintf(valueBuffer, "%I64u%%", percent);
|
||||
ShowProcessMessage(valueBuffer);
|
||||
}
|
||||
|
||||
void CProgressBox::SetTotal(UInt64 total)
|
||||
{
|
||||
m_Total = total;
|
||||
}
|
||||
|
||||
void CProgressBox::PrintCompeteValue(UInt64 completed)
|
||||
{
|
||||
if (completed >= m_CompletedPrev + m_Step || completed < m_CompletedPrev ||
|
||||
completed == 0)
|
||||
{
|
||||
if (m_Total == 0)
|
||||
PrintPercent(0);
|
||||
else
|
||||
PrintPercent(completed * 100 / m_Total);
|
||||
m_CompletedPrev = completed;
|
||||
}
|
||||
}
|
||||
35
7zip/UI/Far/ProgressBox.h
Executable file
35
7zip/UI/Far/ProgressBox.h
Executable file
@@ -0,0 +1,35 @@
|
||||
// ProgressBox.h
|
||||
|
||||
#ifndef __PROGRESSBOX_H
|
||||
#define __PROGRESSBOX_H
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/Types.h"
|
||||
|
||||
class CMessageBox
|
||||
{
|
||||
CSysString m_Title;
|
||||
CSysString m_Message;
|
||||
int m_NumStrings;
|
||||
int m_Width;
|
||||
public:
|
||||
void Init(const CSysString &title,
|
||||
const CSysString &message, int numStrings, int width);
|
||||
void ShowProcessMessages(const char *messages[]);
|
||||
};
|
||||
|
||||
class CProgressBox: public CMessageBox
|
||||
{
|
||||
UInt64 m_Total;
|
||||
UInt64 m_CompletedPrev;
|
||||
UInt64 m_Step;
|
||||
public:
|
||||
void Init(const CSysString &title,
|
||||
const CSysString &message, UInt64 step);
|
||||
void ShowProcessMessage(const char *message);
|
||||
void PrintPercent(UInt64 percent);
|
||||
void PrintCompeteValue(UInt64 completed);
|
||||
void SetTotal(UInt64 total);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,28 +1,8 @@
|
||||
// stdafx.h
|
||||
// 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
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Far/FarUtils.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "FarUtils.h"
|
||||
|
||||
using namespace NFar;
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::SetTotal(UINT64 aSize)
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetTotal(UINT64 aSize)
|
||||
{
|
||||
if (m_ProgressBox != 0)
|
||||
{
|
||||
@@ -19,7 +20,7 @@ STDMETHODIMP CUpdateCallBack100Imp::SetTotal(UINT64 aSize)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::SetCompleted(const UINT64 *aCompleteValue)
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UINT64 *aCompleteValue)
|
||||
{
|
||||
if(WasEscPressed())
|
||||
return E_ABORT;
|
||||
@@ -28,17 +29,26 @@ STDMETHODIMP CUpdateCallBack100Imp::SetCompleted(const UINT64 *aCompleteValue)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::CompressOperation(const wchar_t *aName)
|
||||
STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *aName)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::DeleteOperation(const wchar_t *aName)
|
||||
STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *aName)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallBack100Imp::OperationResult(INT32 aOperationResult)
|
||||
STDMETHODIMP CUpdateCallback100Imp::OperationResult(INT32 aOperationResult)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message)
|
||||
{
|
||||
CSysString s = UnicodeStringToMultiByte(message, CP_OEMCP);
|
||||
if (g_StartupInfo.ShowMessage(s) == -1)
|
||||
return E_ABORT;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// UpdateCallback.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __UPDATECALLBACK100_H
|
||||
#define __UPDATECALLBACK100_H
|
||||
|
||||
@@ -10,9 +8,9 @@
|
||||
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
#include "Far/ProgressBox.h"
|
||||
#include "ProgressBox.h"
|
||||
|
||||
class CUpdateCallBack100Imp:
|
||||
class CUpdateCallback100Imp:
|
||||
public IFolderArchiveUpdateCallback,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
@@ -28,6 +26,7 @@ public:
|
||||
STDMETHOD(CompressOperation)(const wchar_t *aName);
|
||||
STDMETHOD(DeleteOperation)(const wchar_t *aName);
|
||||
STDMETHOD(OperationResult)(INT32 aOperationResult);
|
||||
STDMETHOD(UpdateErrorMessage)(const wchar_t *message);
|
||||
|
||||
private:
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
|
||||
Reference in New Issue
Block a user