mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 19:14:56 -06:00
4.44 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
804edc5756
commit
d9666cf046
8
CPP/7zip/UI/Far/CLSIDConst.cpp
Executable file
8
CPP/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"
|
||||
168
CPP/7zip/UI/Far/ExtractEngine.cpp
Executable file
168
CPP/7zip/UI/Far/ExtractEngine.cpp
Executable file
@@ -0,0 +1,168 @@
|
||||
// ExtractEngine.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ExtractEngine.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;
|
||||
|
||||
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;
|
||||
oldFileInfo.SizeIsDefined = (existSize != NULL);
|
||||
if (oldFileInfo.SizeIsDefined)
|
||||
oldFileInfo.Size = *existSize;
|
||||
oldFileInfo.Name = GetSystemString(existName, m_CodePage);
|
||||
|
||||
|
||||
newFileInfo.Time = *aNewTime;
|
||||
|
||||
newFileInfo.SizeIsDefined = (newSize != NULL);
|
||||
if (newFileInfo.SizeIsDefined)
|
||||
newFileInfo.Size = *newSize;
|
||||
newFileInfo.Name = GetSystemString(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 */, const UINT64 * /* position */)
|
||||
{
|
||||
m_CurrentFilePath = name;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::MessageError(const wchar_t *message)
|
||||
{
|
||||
AString s = UnicodeStringToMultiByte(message, CP_OEMCP);
|
||||
if (g_StartupInfo.ShowMessage((const char *)s) == -1)
|
||||
return E_ABORT;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::SetOperationResult(INT32 operationResult, bool encrypted)
|
||||
{
|
||||
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;
|
||||
}
|
||||
68
CPP/7zip/UI/Far/ExtractEngine.h
Executable file
68
CPP/7zip/UI/Far/ExtractEngine.h
Executable file
@@ -0,0 +1,68 @@
|
||||
// ExtractEngine.h
|
||||
|
||||
#ifndef __EXTRACTENGINE_H
|
||||
#define __EXTRACTENGINE_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Common/String.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
#include "ProgressBox.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, const UINT64 *position);
|
||||
|
||||
STDMETHOD(MessageError)(const wchar_t *message);
|
||||
STDMETHOD(SetOperationResult)(INT32 resultEOperationResult, bool encrypted);
|
||||
// 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
CPP/7zip/UI/Far/Far.def
Executable file
20
CPP/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
|
||||
561
CPP/7zip/UI/Far/Far.dsp
Executable file
561
CPP/7zip/UI/Far/Far.dsp
Executable file
@@ -0,0 +1,561 @@
|
||||
# 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=.\resource.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\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
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.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=.\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=.\FarPlugin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FarUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FarUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ProgressBox.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\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
|
||||
# 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
|
||||
|
||||
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\ExtractMode.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\UpdateCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdatePair.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdatePair.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateProduce.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateProduce.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\WorkDir.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\WorkDir.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ZipRegistry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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\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"
|
||||
|
||||
# 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
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
CPP/7zip/UI/Far/Far.dsw
Executable file
29
CPP/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>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
577
CPP/7zip/UI/Far/FarPlugin.h
Executable file
577
CPP/7zip/UI/Far/FarPlugin.h
Executable file
@@ -0,0 +1,577 @@
|
||||
// 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;
|
||||
union
|
||||
{
|
||||
int Selected;
|
||||
const char *History;
|
||||
const char *Mask;
|
||||
struct FarList *ListItems;
|
||||
int ListPos;
|
||||
CHAR_INFO *VBuf;
|
||||
};
|
||||
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
|
||||
416
CPP/7zip/UI/Far/FarUtils.cpp
Executable file
416
CPP/7zip/UI/Far/FarUtils.cpp
Executable file
@@ -0,0 +1,416 @@
|
||||
// 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.History = srcItem.HistoryName;
|
||||
else
|
||||
destItem.Selected = GetBOOLValue(srcItem.Selected);
|
||||
destItem.Flags = srcItem.Flags;
|
||||
destItem.DefaultButton = GetBOOLValue(srcItem.DefaultButton);
|
||||
|
||||
if(srcItem.DataMessageId < 0)
|
||||
MyStringCopy(destItem.Data, srcItem.DataString);
|
||||
else
|
||||
MyStringCopy(destItem.Data, GetMsgString(srcItem.DataMessageId));
|
||||
|
||||
/*
|
||||
if ((unsigned int)Init[i].Data < 0xFFF)
|
||||
MyStringCopy(destItem.Data, GetMsg((unsigned int)srcItem.Data));
|
||||
else
|
||||
MyStringCopy(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);
|
||||
AString reducedString = items[i].Left(sizeof(item.Text) / sizeof(item.Text[0]) - 1);
|
||||
MyStringCopy(item.Text, (const char *)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 AString 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);
|
||||
for (;;)
|
||||
{
|
||||
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)
|
||||
{
|
||||
AString message;
|
||||
NError::MyFormatMessage(errorCode, message);
|
||||
message.Replace("\x0D", "");
|
||||
message.Replace("\x0A", " ");
|
||||
g_StartupInfo.ShowMessage(SystemStringToOemString(message));
|
||||
|
||||
}
|
||||
|
||||
void ShowLastErrorMessage()
|
||||
{
|
||||
ShowErrorMessage(::GetLastError());
|
||||
}
|
||||
|
||||
}
|
||||
185
CPP/7zip/UI/Far/FarUtils.h
Executable file
185
CPP/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
|
||||
622
CPP/7zip/UI/Far/Main.cpp
Executable file
622
CPP/7zip/UI/Far/Main.cpp
Executable file
@@ -0,0 +1,622 @@
|
||||
// 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 "../../IPassword.h"
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "../Common/DefaultName.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
#include "ProgressBox.h"
|
||||
#include "FarUtils.h"
|
||||
#include "Messages.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;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
*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)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
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");
|
||||
|
||||
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)
|
||||
{
|
||||
if (result == E_ABORT)
|
||||
return (HANDLE)-2;
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
// ::OutputDebugString("after OpenArchive\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
CPP/7zip/UI/Far/Messages.h
Executable file
152
CPP/7zip/UI/Far/Messages.h
Executable file
@@ -0,0 +1,152 @@
|
||||
// SevenZip/ Messages.h
|
||||
|
||||
#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,
|
||||
kPosition,
|
||||
|
||||
kGetPasswordTitle,
|
||||
kEnterPasswordForFile,
|
||||
|
||||
kExtractTitle,
|
||||
kExtractTo,
|
||||
|
||||
kExtractPathMode,
|
||||
kExtractPathFull,
|
||||
kExtractPathCurrent,
|
||||
kExtractPathNo,
|
||||
|
||||
kExtractOwerwriteMode,
|
||||
kExtractOwerwriteAsk,
|
||||
kExtractOwerwritePrompt,
|
||||
kExtractOwerwriteSkip,
|
||||
kExtractOwerwriteAutoRename,
|
||||
kExtractOwerwriteAutoRenameExisting,
|
||||
|
||||
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
|
||||
109
CPP/7zip/UI/Far/OverwriteDialog.cpp
Executable file
109
CPP/7zip/UI/Far/OverwriteDialog.cpp
Executable file
@@ -0,0 +1,109 @@
|
||||
// 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 "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 = ConvertFileTimeToString(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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
33
CPP/7zip/UI/Far/OverwriteDialog.h
Executable file
33
CPP/7zip/UI/Far/OverwriteDialog.h
Executable file
@@ -0,0 +1,33 @@
|
||||
// OverwriteDialog.h
|
||||
|
||||
#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
|
||||
693
CPP/7zip/UI/Far/Plugin.cpp
Executable file
693
CPP/7zip/UI/Far/Plugin.cpp
Executable file
@@ -0,0 +1,693 @@
|
||||
// Plugin.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/Wildcard.h"
|
||||
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "../Common/PropIDUtils.h"
|
||||
|
||||
#include "Messages.h"
|
||||
#include "FarUtils.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(UINT32 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 path = MultiByteToUnicodeString(aszDir, CP_OEMCP);
|
||||
if (path == L"\\")
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
}
|
||||
else if (path == L"..")
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToParentFolder(&newFolder);
|
||||
if (newFolder == NULL)
|
||||
throw 40312;
|
||||
_folder = newFolder;
|
||||
}
|
||||
else if (path.IsEmpty())
|
||||
EnterToDirectory(path);
|
||||
else
|
||||
{
|
||||
if (path[0] == L'\\')
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
path = path.Mid(1);
|
||||
}
|
||||
UStringVector pathParts;
|
||||
SplitPathToParts(path, pathParts);
|
||||
for(int i = 0; i < pathParts.Size(); i++)
|
||||
EnterToDirectory(pathParts[i]);
|
||||
}
|
||||
GetCurrentDir();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPlugin::GetPathParts(UStringVector &pathParts)
|
||||
{
|
||||
pathParts.Clear();
|
||||
CMyComPtr<IFolderFolder> folderItem = _folder;
|
||||
for (;;)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
folderItem->BindToParentFolder(&newFolder);
|
||||
if (newFolder == NULL)
|
||||
break;
|
||||
CMyComBSTR name;
|
||||
folderItem->GetName(&name);
|
||||
pathParts.Insert(0, (const wchar_t *)name);
|
||||
folderItem = newFolder;
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
|
||||
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 },
|
||||
{ kpidPosition, NMessageID::kPosition }
|
||||
|
||||
};
|
||||
|
||||
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 < (int)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;
|
||||
}
|
||||
99
CPP/7zip/UI/Far/Plugin.h
Executable file
99
CPP/7zip/UI/Far/Plugin.h
Executable file
@@ -0,0 +1,99 @@
|
||||
// 7zip/Far/Plugin.h
|
||||
|
||||
#ifndef __7ZIP_FAR_PLUGIN_H
|
||||
#define __7ZIP_FAR_PLUGIN_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "Windows/COM.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/ArchiverInfo.h"
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
#include "FarUtils.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);
|
||||
void GetCurrentDir();
|
||||
public:
|
||||
UString m_FileName;
|
||||
// UString m_DefaultName;
|
||||
NWindows::NFile::NFind::CFileInfoW m_FileInfo;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
HRESULT ExtractFiles(
|
||||
bool decompressAllItems,
|
||||
const UINT32 *indices,
|
||||
UINT32 numIndices,
|
||||
bool silent,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::EEnum overwriteMode,
|
||||
const UString &destPath,
|
||||
bool passwordIsDefined, 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
|
||||
50
CPP/7zip/UI/Far/PluginCommon.cpp
Executable file
50
CPP/7zip/UI/Far/PluginCommon.cpp
Executable file
@@ -0,0 +1,50 @@
|
||||
// SevenZip/Plugin.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
/*
|
||||
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
CPP/7zip/UI/Far/PluginDelete.cpp
Executable file
169
CPP/7zip/UI/Far/PluginDelete.cpp
Executable file
@@ -0,0 +1,169 @@
|
||||
// PluginDelete.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.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"
|
||||
|
||||
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;
|
||||
}
|
||||
GetCurrentDir();
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
278
CPP/7zip/UI/Far/PluginRead.cpp
Executable file
278
CPP/7zip/UI/Far/PluginRead.cpp
Executable file
@@ -0,0 +1,278 @@
|
||||
// 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 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,
|
||||
NExtract::NPathMode::EEnum pathMode,
|
||||
NExtract::NOverwriteMode::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;
|
||||
|
||||
NExtract::CInfo extractionInfo;
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kCurrentPathnames;
|
||||
extractionInfo.OverwriteMode = NExtract::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 kNumOverwriteOptions = 6;
|
||||
const int kFilesModeIndex = kOverwriteModeRadioIndex + kNumOverwriteOptions;
|
||||
const int kXSize = 76;
|
||||
const int kYSize = 19;
|
||||
const int kPasswordYPos = 12;
|
||||
|
||||
const int kXMid = kXSize / 2;
|
||||
|
||||
AString oemPassword = UnicodeStringToMultiByte(password, CP_OEMCP);
|
||||
|
||||
struct CInitDialogItem initItems[]={
|
||||
{ DI_DOUBLEBOX, 3, 1, kXSize - 4, 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, kXSize - 6, 3, true, false, DIF_HISTORY, false, -1, destPath, kExractPathHistoryName},
|
||||
// { DI_EDIT, 5, 3, kXSize - 6, 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 == NExtract::NPathMode::kFullPathnames,
|
||||
DIF_GROUP, false, NMessageID::kExtractPathFull, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 7, 0, 0, false,
|
||||
extractionInfo.PathMode == NExtract::NPathMode::kCurrentPathnames,
|
||||
0, false, NMessageID::kExtractPathCurrent, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 8, 0, 0, false,
|
||||
extractionInfo.PathMode == NExtract::NPathMode::kNoPathnames,
|
||||
false, 0, NMessageID::kExtractPathNo, NULL, NULL },
|
||||
|
||||
{ DI_SINGLEBOX, kXMid, 5, kXSize - 6, 5 + kNumOverwriteOptions, false, false, 0, false, NMessageID::kExtractOwerwriteMode, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAskBefore,
|
||||
DIF_GROUP, false, NMessageID::kExtractOwerwriteAsk, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kWithoutPrompt,
|
||||
0, false, NMessageID::kExtractOwerwritePrompt, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kSkipExisting,
|
||||
0, false, NMessageID::kExtractOwerwriteSkip, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 9, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRename,
|
||||
0, false, NMessageID::kExtractOwerwriteAutoRename, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 10, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting,
|
||||
0, false, NMessageID::kExtractOwerwriteAutoRenameExisting, 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, kPasswordYPos, kXSize - 6, kPasswordYPos + 2, false, false, 0, false, NMessageID::kExtractPassword, NULL, NULL },
|
||||
{ DI_PSWEDIT, kXMid + 2, kPasswordYPos + 1, kXSize - 8, 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);
|
||||
for (;;)
|
||||
{
|
||||
int askCode = g_StartupInfo.ShowDialog(kXSize, 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 = NExtract::NPathMode::kFullPathnames;
|
||||
else if (dialogItems[kPathModeRadioIndex + 1].Selected)
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kCurrentPathnames;
|
||||
else if (dialogItems[kPathModeRadioIndex + 2].Selected)
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kNoPathnames;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
if (dialogItems[kOverwriteModeRadioIndex].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 1].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 2].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kSkipExisting;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 3].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kAutoRename;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 4].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kAutoRenameExisting;
|
||||
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);
|
||||
|
||||
HRESULT result = ExtractFiles(decompressAllItems, &indices.Front(), itemsNumber,
|
||||
!showBox, extractionInfo.PathMode, extractionInfo.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;
|
||||
}
|
||||
696
CPP/7zip/UI/Far/PluginWrite.cpp
Executable file
696
CPP/7zip/UI/Far/PluginWrite.cpp
Executable file
@@ -0,0 +1,696 @@
|
||||
// PluginWrite.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
#include "../Common/WorkDir.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
#include "ProgressBox.h"
|
||||
#include "Messages.h"
|
||||
#include "UpdateCallback100.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> setProperties;
|
||||
if (outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties) == S_OK)
|
||||
{
|
||||
UStringVector realNames;
|
||||
realNames.Add(UString(L"x"));
|
||||
NCOM::CPropVariant value = (UInt32)method;
|
||||
CRecordVector<const wchar_t *> names;
|
||||
for(int i = 0; i < realNames.Size(); i++)
|
||||
names.Add(realNames[i]);
|
||||
RINOK(setProperties->SetProperties(&names.Front(), &value, 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.CompareNoCase(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;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
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.CompareNoCase((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;
|
||||
}
|
||||
|
||||
103
CPP/7zip/UI/Far/ProgressBox.cpp
Executable file
103
CPP/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
CPP/7zip/UI/Far/ProgressBox.h
Executable file
35
CPP/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
|
||||
3
CPP/7zip/UI/Far/StdAfx.cpp
Executable file
3
CPP/7zip/UI/Far/StdAfx.cpp
Executable file
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
12
CPP/7zip/UI/Far/StdAfx.h
Executable file
12
CPP/7zip/UI/Far/StdAfx.h
Executable file
@@ -0,0 +1,12 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
|
||||
54
CPP/7zip/UI/Far/UpdateCallback100.cpp
Executable file
54
CPP/7zip/UI/Far/UpdateCallback100.cpp
Executable file
@@ -0,0 +1,54 @@
|
||||
// UpdateCallback.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
45
CPP/7zip/UI/Far/UpdateCallback100.h
Executable file
45
CPP/7zip/UI/Far/UpdateCallback100.h
Executable file
@@ -0,0 +1,45 @@
|
||||
// UpdateCallback.h
|
||||
|
||||
#ifndef __UPDATECALLBACK100_H
|
||||
#define __UPDATECALLBACK100_H
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
#include "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);
|
||||
STDMETHOD(UpdateErrorMessage)(const wchar_t *message);
|
||||
|
||||
private:
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
CProgressBox *m_ProgressBox;
|
||||
public:
|
||||
void Init(IInFolderArchive *anArchiveHandler,
|
||||
CProgressBox *aProgressBox)
|
||||
{
|
||||
m_ArchiveHandler = anArchiveHandler;
|
||||
m_ProgressBox = aProgressBox;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
102
CPP/7zip/UI/Far/makefile
Executable file
102
CPP/7zip/UI/Far/makefile
Executable file
@@ -0,0 +1,102 @@
|
||||
PROG = 7-ZipFar.dll
|
||||
DEF_FILE = Far.def
|
||||
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib ole32.lib
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -DWIN_LONG_PATH
|
||||
|
||||
FAR_OBJS = \
|
||||
$O\CLSIDConst.obj \
|
||||
$O\ExtractEngine.obj \
|
||||
$O\FarUtils.obj \
|
||||
$O\Main.obj \
|
||||
$O\OverwriteDialog.obj \
|
||||
$O\Plugin.obj \
|
||||
$O\PluginCommon.obj \
|
||||
$O\PluginDelete.obj \
|
||||
$O\PluginRead.obj \
|
||||
$O\PluginWrite.obj \
|
||||
$O\ProgressBox.obj \
|
||||
$O\UpdateCallback100.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
$O\Vector.obj \
|
||||
$O\Wildcard.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\Error.obj \
|
||||
$O\FileDir.obj \
|
||||
$O\FileFind.obj \
|
||||
$O\FileIO.obj \
|
||||
$O\FileName.obj \
|
||||
$O\PropVariant.obj \
|
||||
$O\PropVariantConversions.obj \
|
||||
$O\Registry.obj \
|
||||
$O\Synchronization.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\FilePathAutoRename.obj \
|
||||
$O\FileStreams.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
UI_COMMON_OBJS = \
|
||||
$O\ArchiveExtractCallback.obj \
|
||||
$O\ArchiveOpenCallback.obj \
|
||||
$O\ArchiverInfo.obj \
|
||||
$O\DefaultName.obj \
|
||||
$O\EnumDirItems.obj \
|
||||
$O\ExtractingFilePath.obj \
|
||||
$O\OpenArchive.obj \
|
||||
$O\PropIDUtils.obj \
|
||||
$O\SortUtils.obj \
|
||||
$O\UpdateAction.obj \
|
||||
$O\UpdateCallback.obj \
|
||||
$O\UpdatePair.obj \
|
||||
$O\UpdateProduce.obj \
|
||||
$O\WorkDir.obj \
|
||||
$O\ZipRegistry.obj \
|
||||
|
||||
AGENT_OBJS = \
|
||||
$O\Agent.obj \
|
||||
$O\AgentOut.obj \
|
||||
$O\AgentProxy.obj \
|
||||
$O\UpdateCallbackAgent.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Sort.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(FAR_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(UI_COMMON_OBJS) \
|
||||
$(AGENT_OBJS) \
|
||||
$(C_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(FAR_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(UI_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AGENT_OBJS): ../Agent/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(C_OBJS): ../../../../C/$(*B).c
|
||||
$(COMPL_O2)
|
||||
3
CPP/7zip/UI/Far/resource.rc
Executable file
3
CPP/7zip/UI/Far/resource.rc
Executable file
@@ -0,0 +1,3 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("7-Zip Plugin for FAR Manager", "7-ZipFar")
|
||||
Reference in New Issue
Block a user