mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 04:07:12 -06:00
Initialer Commit
This commit is contained in:
276
CPP/7zip/UI/Far/ExtractEngine.cpp
Normal file
276
CPP/7zip/UI/Far/ExtractEngine.cpp
Normal file
@@ -0,0 +1,276 @@
|
||||
// ExtractEngine.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
#endif
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#include "ExtractEngine.h"
|
||||
#include "FarUtils.h"
|
||||
#include "Messages.h"
|
||||
#include "OverwriteDialogFar.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
|
||||
#else
|
||||
#define MT_LOCK
|
||||
#endif
|
||||
|
||||
|
||||
static HRESULT CheckBreak2()
|
||||
{
|
||||
return WasEscPressed() ? E_ABORT : S_OK;
|
||||
}
|
||||
|
||||
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;
|
||||
_percent = progressBox;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 size)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
_percent->Total = size;
|
||||
_percent->Print();
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *completeValue)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
if (completeValue)
|
||||
_percent->Completed = *completeValue;
|
||||
_percent->Print();
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::AskOverwrite(
|
||||
const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
|
||||
Int32 *answer)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
NOverwriteDialog::CFileInfo oldFileInfo, newFileInfo;
|
||||
oldFileInfo.TimeIsDefined = (existTime != 0);
|
||||
if (oldFileInfo.TimeIsDefined)
|
||||
oldFileInfo.Time = *existTime;
|
||||
oldFileInfo.SizeIsDefined = (existSize != NULL);
|
||||
if (oldFileInfo.SizeIsDefined)
|
||||
oldFileInfo.Size = *existSize;
|
||||
oldFileInfo.Name = existName;
|
||||
|
||||
newFileInfo.TimeIsDefined = (newTime != 0);
|
||||
if (newFileInfo.TimeIsDefined)
|
||||
newFileInfo.Time = *newTime;
|
||||
newFileInfo.SizeIsDefined = (newSize != NULL);
|
||||
if (newFileInfo.SizeIsDefined)
|
||||
newFileInfo.Size = *newSize;
|
||||
newFileInfo.Name = newName;
|
||||
|
||||
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:
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
static const char *kTestString = "Testing";
|
||||
static const char *kExtractString = "Extracting";
|
||||
static const char *kSkipString = "Skipping";
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 /* isFolder */, Int32 askExtractMode, const UInt64 * /* position */)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
m_CurrentFilePath = name;
|
||||
const char *s;
|
||||
|
||||
switch (askExtractMode)
|
||||
{
|
||||
case NArchive::NExtract::NAskMode::kExtract: s = kExtractString; break;
|
||||
case NArchive::NExtract::NAskMode::kTest: s = kTestString; break;
|
||||
case NArchive::NExtract::NAskMode::kSkip: s = kSkipString; break;
|
||||
default: s = "???"; // return E_FAIL;
|
||||
};
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
_percent->Command = s;
|
||||
_percent->FileName = name;
|
||||
_percent->Print();
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
AString s = UnicodeStringToMultiByte(message, CP_OEMCP);
|
||||
if (g_StartupInfo.ShowErrorMessage((const char *)s) == -1)
|
||||
return E_ABORT;
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &s)
|
||||
{
|
||||
s.Empty();
|
||||
|
||||
switch (opRes)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kOK:
|
||||
return;
|
||||
default:
|
||||
{
|
||||
UINT messageID = 0;
|
||||
switch (opRes)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kUnsupportedMethod:
|
||||
messageID = NMessageID::kExtractUnsupportedMethod;
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kCRCError:
|
||||
messageID = encrypted ?
|
||||
NMessageID::kExtractCRCFailedEncrypted :
|
||||
NMessageID::kExtractCRCFailed;
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kDataError:
|
||||
messageID = encrypted ?
|
||||
NMessageID::kExtractDataErrorEncrypted :
|
||||
NMessageID::kExtractDataError;
|
||||
break;
|
||||
}
|
||||
if (messageID != 0)
|
||||
{
|
||||
s = g_StartupInfo.GetMsgString(messageID);
|
||||
s.Replace(" '%s'", "");
|
||||
}
|
||||
else if (opRes == NArchive::NExtract::NOperationResult::kUnavailable)
|
||||
s = "Unavailable data";
|
||||
else if (opRes == NArchive::NExtract::NOperationResult::kUnexpectedEnd)
|
||||
s = "Unexpected end of data";
|
||||
else if (opRes == NArchive::NExtract::NOperationResult::kDataAfterEnd)
|
||||
s = "There are some data after the end of the payload data";
|
||||
else if (opRes == NArchive::NExtract::NOperationResult::kIsNotArc)
|
||||
s = "Is not archive";
|
||||
else if (opRes == NArchive::NExtract::NOperationResult::kHeadersError)
|
||||
s = "kHeaders Error";
|
||||
else
|
||||
{
|
||||
char temp[16];
|
||||
ConvertUInt32ToString(opRes, temp);
|
||||
s = "Error #";
|
||||
s += temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 opRes, Int32 encrypted)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (opRes == NArchive::NExtract::NOperationResult::kOK)
|
||||
{
|
||||
if (_percent)
|
||||
{
|
||||
_percent->Command.Empty();
|
||||
_percent->FileName.Empty();
|
||||
_percent->Files++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AString s;
|
||||
SetExtractErrorMessage(opRes, encrypted, s);
|
||||
if (PrintErrorMessage(s, m_CurrentFilePath) == -1)
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::ReportExtractResult(Int32 opRes, Int32 encrypted, const wchar_t *name)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (opRes != NArchive::NExtract::NOperationResult::kOK)
|
||||
{
|
||||
AString s;
|
||||
SetExtractErrorMessage(opRes, encrypted, s);
|
||||
if (PrintErrorMessage(s, name) == -1)
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
extern HRESULT GetPassword(UString &password);
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (!m_PasswordIsDefined)
|
||||
{
|
||||
RINOK(GetPassword(m_Password));
|
||||
m_PasswordIsDefined = true;
|
||||
}
|
||||
return StringToBstr(m_Password, password);
|
||||
}
|
||||
57
CPP/7zip/UI/Far/ExtractEngine.h
Normal file
57
CPP/7zip/UI/Far/ExtractEngine.h
Normal file
@@ -0,0 +1,57 @@
|
||||
// ExtractEngine.h
|
||||
|
||||
#ifndef __EXTRACT_ENGINE_H
|
||||
#define __EXTRACT_ENGINE_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
#include "ProgressBox.h"
|
||||
|
||||
class CExtractCallbackImp:
|
||||
public IFolderArchiveExtractCallback,
|
||||
public IFolderArchiveExtractCallback2,
|
||||
public ICryptoGetTextPassword,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP2(ICryptoGetTextPassword, IFolderArchiveExtractCallback2)
|
||||
|
||||
// IProgress
|
||||
STDMETHOD(SetTotal)(UInt64 size);
|
||||
STDMETHOD(SetCompleted)(const UInt64 *completeValue);
|
||||
|
||||
INTERFACE_IFolderArchiveExtractCallback(;)
|
||||
INTERFACE_IFolderArchiveExtractCallback2(;)
|
||||
|
||||
// ICryptoGetTextPassword
|
||||
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
|
||||
|
||||
private:
|
||||
UString m_CurrentFilePath;
|
||||
|
||||
CProgressBox *_percent;
|
||||
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() {}
|
||||
~CExtractCallbackImp();
|
||||
void Init(UINT codePage,
|
||||
CProgressBox *progressBox,
|
||||
bool passwordIsDefined, const UString &password);
|
||||
};
|
||||
|
||||
#endif
|
||||
631
CPP/7zip/UI/Far/Far.cpp
Normal file
631
CPP/7zip/UI/Far/Far.cpp
Normal file
@@ -0,0 +1,631 @@
|
||||
// Far.cpp
|
||||
// Test Align for updating !!!!!!!!!!!!!!!!!!
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include "../../../Common/MyInitGuid.h"
|
||||
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#include "../../../Windows/FileDir.h"
|
||||
#include "../../../Windows/NtCheck.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "Messages.h"
|
||||
#include "Plugin.h"
|
||||
#include "ProgressBox.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
using namespace NFar;
|
||||
|
||||
static const DWORD kShowProgressTime_ms = 100;
|
||||
|
||||
static const char *kCommandPrefix = "7-zip";
|
||||
static const TCHAR *kRegisrtryMainKeyName = TEXT("");
|
||||
static const TCHAR *kRegisrtryValueNameEnabled = TEXT("UsedByDefault3");
|
||||
static const char *kHelpTopicConfig = "Config";
|
||||
static bool kPluginEnabledDefault = true;
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
|
||||
namespace NFar {
|
||||
|
||||
const char *g_PluginName_for_Error = "7-Zip";
|
||||
|
||||
}
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION return FALSE;
|
||||
|
||||
BOOL WINAPI DllMain(
|
||||
#ifdef UNDER_CE
|
||||
HANDLE
|
||||
#else
|
||||
HINSTANCE
|
||||
#endif
|
||||
hInstance, DWORD dwReason, LPVOID)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
// OutputDebugStringA("7-Zip FAR DLL_PROCESS_ATTACH");
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
NT_CHECK
|
||||
}
|
||||
if (dwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
// OutputDebugStringA("7-Zip FAR DLL_PROCESS_DETACH");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct COptions
|
||||
{
|
||||
bool Enabled;
|
||||
} g_Options;
|
||||
|
||||
static const TCHAR *kPliginNameForRegestry = TEXT("7-ZIP");
|
||||
|
||||
EXTERN_C void WINAPI ExitFAR()
|
||||
{
|
||||
/* WIN32:
|
||||
it's not allowed to call FreeLibrary() from FreeLibrary().
|
||||
So we try to free all DLLs before destructors */
|
||||
// OutputDebugStringA("-- ExitFAR --- START");
|
||||
|
||||
FreeGlobalCodecs();
|
||||
|
||||
// OutputDebugStringA("-- ExitFAR --- END");
|
||||
}
|
||||
|
||||
EXTERN_C void WINAPI SetStartupInfo(const PluginStartupInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
g_StartupInfo.Init(*info, kPliginNameForRegestry);
|
||||
g_Options.Enabled = g_StartupInfo.QueryRegKeyValue(
|
||||
HKEY_CURRENT_USER, kRegisrtryMainKeyName,
|
||||
kRegisrtryValueNameEnabled, kPluginEnabledDefault);
|
||||
|
||||
// OutputDebugStringA("SetStartupInfo");
|
||||
// LoadGlobalCodecs();
|
||||
|
||||
MY_TRY_END1("SetStartupInfo");
|
||||
}
|
||||
|
||||
class COpenArchiveCallback:
|
||||
public IArchiveOpenCallback,
|
||||
public IArchiveOpenVolumeCallback,
|
||||
public IArchiveOpenSetSubArchiveName,
|
||||
public IProgress,
|
||||
public ICryptoGetTextPassword,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
DWORD m_StartTickValue;
|
||||
bool m_MessageBoxIsShown;
|
||||
|
||||
CProgressBox _progressBox;
|
||||
|
||||
bool _numFilesTotalDefined;
|
||||
bool _numBytesTotalDefined;
|
||||
|
||||
NFind::CFileInfo _fileInfo;
|
||||
bool _subArchiveMode;
|
||||
UString _subArchiveName;
|
||||
public:
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
FString _folderPrefix;
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP4(
|
||||
IArchiveOpenVolumeCallback,
|
||||
IArchiveOpenSetSubArchiveName,
|
||||
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);
|
||||
|
||||
STDMETHOD(SetSubArchiveName(const wchar_t *name))
|
||||
{
|
||||
_subArchiveMode = true;
|
||||
_subArchiveName = name;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// ICryptoGetTextPassword
|
||||
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
|
||||
|
||||
COpenArchiveCallback(): _subArchiveMode(false) {}
|
||||
|
||||
void Init()
|
||||
{
|
||||
PasswordIsDefined = false;
|
||||
|
||||
_subArchiveMode = false;
|
||||
|
||||
_numFilesTotalDefined = false;
|
||||
_numBytesTotalDefined = false;
|
||||
|
||||
m_MessageBoxIsShown = false;
|
||||
|
||||
_progressBox.Init(
|
||||
// g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kReading));
|
||||
}
|
||||
void ShowMessage();
|
||||
|
||||
void LoadFileInfo(const FString &folderPrefix, const FString &fileName)
|
||||
{
|
||||
_folderPrefix = folderPrefix;
|
||||
if (!_fileInfo.Find(_folderPrefix + fileName))
|
||||
throw 1;
|
||||
}
|
||||
};
|
||||
|
||||
static HRESULT CheckBreak2()
|
||||
{
|
||||
return WasEscPressed() ? E_ABORT : S_OK;
|
||||
}
|
||||
|
||||
void COpenArchiveCallback::ShowMessage()
|
||||
{
|
||||
if (!m_MessageBoxIsShown)
|
||||
{
|
||||
DWORD currentTime = GetTickCount();
|
||||
if (currentTime - _progressBox.StartTick < kShowProgressTime_ms)
|
||||
return;
|
||||
m_MessageBoxIsShown = true;
|
||||
}
|
||||
|
||||
_progressBox.UseBytesForPercents = !_numFilesTotalDefined;
|
||||
_progressBox.Print();
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes)
|
||||
{
|
||||
_numFilesTotalDefined = (numFiles != NULL);
|
||||
if (_numFilesTotalDefined)
|
||||
_progressBox.FilesTotal = *numFiles;
|
||||
|
||||
_numBytesTotalDefined = (numBytes != NULL);
|
||||
if (_numBytesTotalDefined)
|
||||
_progressBox.Total = *numBytes;
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes)
|
||||
{
|
||||
if (numFiles)
|
||||
_progressBox.Files = *numFiles;
|
||||
|
||||
if (numBytes)
|
||||
_progressBox.Completed = *numBytes;
|
||||
|
||||
ShowMessage();
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 /* total */)
|
||||
{
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 * /* completed */)
|
||||
{
|
||||
ShowMessage();
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream)
|
||||
{
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
if (_subArchiveMode)
|
||||
return S_FALSE;
|
||||
*inStream = NULL;
|
||||
FString fullPath = _folderPrefix + us2fs(name);
|
||||
if (!_fileInfo.Find(fullPath))
|
||||
return S_FALSE;
|
||||
if (_fileInfo.IsDir())
|
||||
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)
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
if (_subArchiveMode)
|
||||
{
|
||||
switch (propID)
|
||||
{
|
||||
case kpidName: prop = _subArchiveName; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
switch (propID)
|
||||
{
|
||||
case kpidName: prop = GetUnicodeString(_fileInfo.Name, CP_OEMCP); break;
|
||||
case kpidIsDir: prop = _fileInfo.IsDir(); break;
|
||||
case kpidSize: prop = _fileInfo.Size; break;
|
||||
case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
|
||||
case kpidCTime: prop = _fileInfo.CTime; break;
|
||||
case kpidATime: prop = _fileInfo.ATime; break;
|
||||
case kpidMTime: prop = _fileInfo.MTime; break;
|
||||
}
|
||||
prop.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 = ARRAY_SIZE(initItems);
|
||||
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;
|
||||
}
|
||||
return StringToBstr(Password, password);
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT OpenArchive(const CSysString &fileName,
|
||||
IInFolderArchive **archiveHandlerResult,
|
||||
CArchiverInfo &archiverInfoResult,
|
||||
UString &defaultName,
|
||||
IArchiveOpenCallback *openArchiveCallback)
|
||||
{
|
||||
HRESULT OpenArchive(const CSysString &fileName,
|
||||
IInArchive **archive,
|
||||
CArchiverInfo &archiverInfoResult,
|
||||
IArchiveOpenCallback *openArchiveCallback);
|
||||
}
|
||||
*/
|
||||
|
||||
static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
||||
{
|
||||
FString normalizedName = us2fs(name);
|
||||
normalizedName.Trim();
|
||||
FString fullName;
|
||||
MyGetFullPathName(normalizedName, fullName);
|
||||
NFind::CFileInfo fileInfo;
|
||||
if (!fileInfo.Find(fullName))
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileInfo.IsDir())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
|
||||
CMyComPtr<IInFolderArchive> archiveHandler;
|
||||
|
||||
// CArchiverInfo archiverInfoResult;
|
||||
// ::OutputDebugStringA("before OpenArchive\n");
|
||||
|
||||
CScreenRestorer screenRestorer;
|
||||
{
|
||||
screenRestorer.Save();
|
||||
}
|
||||
|
||||
COpenArchiveCallback *openArchiveCallbackSpec = new COpenArchiveCallback;
|
||||
CMyComPtr<IArchiveOpenCallback> openArchiveCallback = openArchiveCallbackSpec;
|
||||
|
||||
// if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
|
||||
openArchiveCallbackSpec->Init();
|
||||
{
|
||||
FString dirPrefix, fileName;
|
||||
GetFullPathAndSplit(fullName, dirPrefix, fileName);
|
||||
openArchiveCallbackSpec->LoadFileInfo(dirPrefix, fileName);
|
||||
}
|
||||
|
||||
// ::OutputDebugStringA("before OpenArchive\n");
|
||||
|
||||
CAgent *agent = new CAgent;
|
||||
archiveHandler = agent;
|
||||
CMyComBSTR archiveType;
|
||||
HRESULT result = archiveHandler->Open(NULL,
|
||||
GetUnicodeString(fullName, CP_OEMCP), UString(), &archiveType, openArchiveCallback);
|
||||
/*
|
||||
HRESULT result = ::OpenArchive(fullName, &archiveHandler,
|
||||
archiverInfoResult, defaultName, openArchiveCallback);
|
||||
*/
|
||||
if (result == E_ABORT)
|
||||
return (HANDLE)-2;
|
||||
|
||||
UString errorMessage = agent->GetErrorMessage();
|
||||
if (!errorMessage.IsEmpty())
|
||||
g_StartupInfo.ShowErrorMessage(UnicodeStringToMultiByte(errorMessage, CP_OEMCP));
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
if (result == S_FALSE)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
ShowSysErrorMessage(result);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
// ::OutputDebugStringA("after OpenArchive\n");
|
||||
|
||||
CPlugin *plugin = new CPlugin(
|
||||
fullName,
|
||||
// defaultName,
|
||||
agent,
|
||||
(const wchar_t *)archiveType
|
||||
);
|
||||
if (!plugin)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
plugin->PasswordIsDefined = openArchiveCallbackSpec->PasswordIsDefined;
|
||||
plugin->Password = openArchiveCallbackSpec->Password;
|
||||
|
||||
// OutputDebugStringA("--- OpenFilePlugin ---- END");
|
||||
return (HANDLE)(plugin);
|
||||
}
|
||||
|
||||
static HANDLE MyOpenFilePlugin(const char *name)
|
||||
{
|
||||
UINT codePage =
|
||||
#ifdef UNDER_CE
|
||||
CP_OEMCP;
|
||||
#else
|
||||
::AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
#endif
|
||||
return MyOpenFilePluginW(GetUnicodeString(name, codePage));
|
||||
}
|
||||
|
||||
EXTERN_C HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char * /* data */, int /* dataSize */)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
// OutputDebugStringA("--- OpenFilePlugin");
|
||||
if (name == NULL || (!g_Options.Enabled))
|
||||
{
|
||||
// if (!Opt.ProcessShiftF1)
|
||||
return(INVALID_HANDLE_VALUE);
|
||||
}
|
||||
return MyOpenFilePlugin(name);
|
||||
MY_TRY_END2("OpenFilePlugin", INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
EXTERN_C HANDLE WINAPI OpenFilePluginW(const wchar_t *name,const unsigned char *Data,int DataSize,int OpMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
if (name == NULL || (!g_Options.Enabled))
|
||||
{
|
||||
// if (!Opt.ProcessShiftF1)
|
||||
return(INVALID_HANDLE_VALUE);
|
||||
}
|
||||
return MyOpenFilePluginW(name);
|
||||
::OutputDebugStringA("OpenFilePluginW\n");
|
||||
MY_TRY_END2("OpenFilePluginW", INVALID_HANDLE_VALUE);
|
||||
}
|
||||
*/
|
||||
|
||||
EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, INT_PTR item)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
|
||||
if (openFrom == OPEN_COMMANDLINE)
|
||||
{
|
||||
AString fileName = (const char *)item;
|
||||
if (fileName.IsEmpty())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileName.Len() >= 2
|
||||
&& fileName[0] == '\"'
|
||||
&& fileName.Back() == '\"')
|
||||
{
|
||||
fileName.DeleteBack();
|
||||
fileName.DeleteFrontal(1);
|
||||
}
|
||||
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;
|
||||
HRESULT res = CompressFiles(pluginPanelItem);
|
||||
if (res != S_OK && res != E_ABORT)
|
||||
{
|
||||
ShowSysErrorMessage(res);
|
||||
}
|
||||
// if (res == 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);
|
||||
}
|
||||
|
||||
EXTERN_C void WINAPI ClosePlugin(HANDLE plugin)
|
||||
{
|
||||
// OutputDebugStringA("-- ClosePlugin --- START");
|
||||
// MY_TRY_BEGIN;
|
||||
delete (CPlugin *)plugin;
|
||||
// OutputDebugStringA("-- ClosePlugin --- END");
|
||||
// MY_TRY_END1("ClosePlugin");
|
||||
}
|
||||
|
||||
EXTERN_C 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);
|
||||
}
|
||||
|
||||
EXTERN_C void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
((CPlugin *)plugin)->FreeFindData(panelItems, itemsNumber);
|
||||
MY_TRY_END1("FreeFindData");
|
||||
}
|
||||
|
||||
EXTERN_C 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);
|
||||
}
|
||||
|
||||
EXTERN_C int WINAPI SetDirectory(HANDLE plugin, const char *dir, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->SetDirectory(dir, opMode));
|
||||
MY_TRY_END2("SetDirectory", FALSE);
|
||||
}
|
||||
|
||||
EXTERN_C 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 = ARRAY_SIZE(pluginCfgStrings);
|
||||
info->CommandPrefix = (char *)kCommandPrefix;
|
||||
MY_TRY_END1("GetPluginInfo");
|
||||
}
|
||||
|
||||
EXTERN_C 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 = ARRAY_SIZE(initItems);
|
||||
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);
|
||||
}
|
||||
|
||||
EXTERN_C void WINAPI GetOpenPluginInfo(HANDLE plugin,struct OpenPluginInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
((CPlugin *)plugin)->GetOpenPluginInfo(info);
|
||||
MY_TRY_END1("GetOpenPluginInfo");
|
||||
}
|
||||
|
||||
EXTERN_C 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);
|
||||
}
|
||||
|
||||
EXTERN_C 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);
|
||||
}
|
||||
|
||||
EXTERN_C int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return (((CPlugin *)plugin)->ProcessKey(key, controlState));
|
||||
MY_TRY_END2("ProcessKey", FALSE);
|
||||
}
|
||||
35
CPP/7zip/UI/Far/Far.def
Normal file
35
CPP/7zip/UI/Far/Far.def
Normal file
@@ -0,0 +1,35 @@
|
||||
; 7-ZipFar.def : Declares the module parameters for the DLL.
|
||||
|
||||
LIBRARY "7-ZipFar"
|
||||
|
||||
EXPORTS
|
||||
ExitFAR
|
||||
SetStartupInfo
|
||||
OpenPlugin
|
||||
OpenFilePlugin
|
||||
ClosePlugin
|
||||
GetFindData
|
||||
FreeFindData
|
||||
SetDirectory
|
||||
GetPluginInfo
|
||||
Configure
|
||||
GetOpenPluginInfo
|
||||
GetFiles
|
||||
PutFiles
|
||||
DeleteFiles
|
||||
ProcessKey
|
||||
|
||||
;SetStartupInfoW
|
||||
;OpenPluginW
|
||||
;OpenFilePluginW
|
||||
;ClosePluginW
|
||||
;GetFindDataW
|
||||
;FreeFindDataW
|
||||
;SetDirectoryW
|
||||
;GetPluginInfoW
|
||||
;ConfigureW
|
||||
;GetOpenPluginInfoW
|
||||
;GetFilesW
|
||||
;PutFilesW
|
||||
;DeleteFilesW
|
||||
;ProcessKeyW
|
||||
759
CPP/7zip/UI/Far/Far.dsp
Normal file
759
CPP/7zip/UI/Far/Far.dsp
Normal file
@@ -0,0 +1,759 @@
|
||||
# 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 /W4 /WX /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /D "EXTERNAL_CODECS" /D "NEW_FOLDER_INTERFACE" /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 /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /D "EXTERNAL_CODECS" /D "NEW_FOLDER_INTERFACE" /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=.\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\CRC.cpp
|
||||
# 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\MyString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyVector.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyVector.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\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\UTFConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\UTFConvert.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=.\Far.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Messages.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OverwriteDialogFar.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OverwriteDialogFar.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=.\UpdateCallbackFar.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\UpdateCallbackFar.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\ErrorMsg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\ErrorMsg.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\FileLink.cpp
|
||||
# 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\PropVariantConv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariantConv.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\ResourceString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\ResourceString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\TimeUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\TimeUtils.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\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\LoadCodecs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\LoadCodecs.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\SetProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\SetProperties.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\ArchiveFolder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\ArchiveFolderOpen.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Agent\ArchiveFolderOut.cpp
|
||||
# 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\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7-zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CreateCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CreateCoder.h
|
||||
# End Source File
|
||||
# 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\FilterCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilterCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\PropId.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamObjects.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamObjects.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\UniqBlocks.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\UniqBlocks.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "C"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrcOpt.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\CpuArch.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sort.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sort.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Arc Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Interface"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\IArchive.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\ICoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\IDecl.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\IFileExtractCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\FileManager\IFolder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\IPassword.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\IProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\PropID.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
CPP/7zip/UI/Far/Far.dsw
Normal file
29
CPP/7zip/UI/Far/Far.dsw
Normal 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>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
529
CPP/7zip/UI/Far/FarPlugin.h
Normal file
529
CPP/7zip/UI/Far/FarPlugin.h
Normal file
@@ -0,0 +1,529 @@
|
||||
// FarPlugin.h
|
||||
|
||||
// #include "plugin.hpp"
|
||||
|
||||
const int kInfoPanelLineSize = 80;
|
||||
|
||||
// #define __FAR_PLUGIN_H
|
||||
|
||||
#ifdef UNDER_CE
|
||||
typedef struct _CHAR_INFO {
|
||||
union {
|
||||
WCHAR UnicodeChar;
|
||||
CHAR AsciiChar;
|
||||
} Char;
|
||||
WORD Attributes;
|
||||
} CHAR_INFO, *PCHAR_INFO;
|
||||
#endif
|
||||
|
||||
#ifndef __FAR_PLUGIN_H
|
||||
#define __FAR_PLUGIN_H
|
||||
|
||||
#ifndef _WIN64
|
||||
#if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
|
||||
#pragma option -a1
|
||||
#elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
|
||||
#pragma pack(1)
|
||||
#else
|
||||
#pragma pack(push,1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if _MSC_VER
|
||||
#define _export
|
||||
#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_PTR UserData;
|
||||
DWORD CRC32;
|
||||
DWORD_PTR Reserved[2];
|
||||
};
|
||||
|
||||
#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_PTR 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_PTR PluginNumber,
|
||||
int X1,
|
||||
int Y1,
|
||||
int X2,
|
||||
int Y2,
|
||||
char *HelpTopic,
|
||||
struct FarDialogItem *Item,
|
||||
int ItemsNumber
|
||||
);
|
||||
|
||||
enum {
|
||||
FMSG_WARNING = 0x00000001,
|
||||
FMSG_ERRORTYPE = 0x00000002,
|
||||
FMSG_KEEPBACKGROUND = 0x00000004,
|
||||
FMSG_DOWN = 0x00000008,
|
||||
FMSG_LEFTALIGN = 0x00000010,
|
||||
|
||||
FMSG_ALLINONE = 0x00000020,
|
||||
|
||||
FMSG_MB_OK = 0x00010000,
|
||||
FMSG_MB_OKCANCEL = 0x00020000,
|
||||
FMSG_MB_ABORTRETRYIGNORE = 0x00030000,
|
||||
FMSG_MB_YESNO = 0x00040000,
|
||||
FMSG_MB_YESNOCANCEL = 0x00050000,
|
||||
FMSG_MB_RETRYCANCEL = 0x00060000
|
||||
};
|
||||
|
||||
typedef int (WINAPI *FARAPIMESSAGE)(
|
||||
INT_PTR PluginNumber,
|
||||
unsigned int Flags,
|
||||
const char *HelpTopic,
|
||||
const char * const *Items,
|
||||
int ItemsNumber,
|
||||
int ButtonsNumber
|
||||
);
|
||||
|
||||
typedef char* (WINAPI *FARAPIGETMSG)(
|
||||
INT_PTR 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 Flags;
|
||||
DWORD Reserved;
|
||||
};
|
||||
|
||||
|
||||
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_PTR 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
|
||||
);
|
||||
|
||||
struct PluginStartupInfo
|
||||
{
|
||||
int StructSize;
|
||||
char ModuleName[NM];
|
||||
INT_PTR 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[kInfoPanelLineSize];
|
||||
char Data[kInfoPanelLineSize];
|
||||
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;
|
||||
const char *HostFile;
|
||||
const char *CurDir;
|
||||
const char *Format;
|
||||
const char *PanelTitle;
|
||||
const struct InfoPanelLine *InfoLines;
|
||||
int InfoLinesNumber;
|
||||
const char * const *DescrFiles;
|
||||
int DescrFilesNumber;
|
||||
const struct PanelMode *PanelModesArray;
|
||||
int PanelModesNumber;
|
||||
int StartPanelMode;
|
||||
int StartSortMode;
|
||||
int StartSortOrder;
|
||||
const struct KeyBarTitles *KeyBar;
|
||||
const char *ShortcutData;
|
||||
// long Reserverd;
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
#ifndef _WIN64
|
||||
#if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
|
||||
#pragma option -a.
|
||||
#elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
|
||||
#pragma pack()
|
||||
#else
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
void WINAPI _export ClosePluginW(HANDLE hPlugin);
|
||||
int WINAPI _export CompareW(HANDLE hPlugin,const struct PluginPanelItem *Item1,const struct PluginPanelItem *Item2,unsigned int Mode);
|
||||
int WINAPI _export ConfigureW(int ItemNumber);
|
||||
int WINAPI _export DeleteFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int OpMode);
|
||||
void WINAPI _export ExitFARW(void);
|
||||
void WINAPI _export FreeFindDataW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber);
|
||||
void WINAPI _export FreeVirtualFindDataW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber);
|
||||
int WINAPI _export GetFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int Move,const wchar_t **DestPath,int OpMode);
|
||||
int WINAPI _export GetFindDataW(HANDLE hPlugin,struct PluginPanelItem **pPanelItem,int *pItemsNumber,int OpMode);
|
||||
int WINAPI _export GetMinFarVersionW(void);
|
||||
void WINAPI _export GetOpenPluginInfoW(HANDLE hPlugin,struct OpenPluginInfo *Info);
|
||||
void WINAPI _export GetPluginInfoW(struct PluginInfo *Info);
|
||||
int WINAPI _export GetVirtualFindDataW(HANDLE hPlugin,struct PluginPanelItem **pPanelItem,int *pItemsNumber,const wchar_t *Path);
|
||||
int WINAPI _export MakeDirectoryW(HANDLE hPlugin,const wchar_t **Name,int OpMode);
|
||||
HANDLE WINAPI _export OpenFilePluginW(const wchar_t *Name,const unsigned char *Data,int DataSize,int OpMode);
|
||||
HANDLE WINAPI _export OpenPluginW(int OpenFrom,INT_PTR Item);
|
||||
int WINAPI _export ProcessDialogEventW(int Event,void *Param);
|
||||
int WINAPI _export ProcessEditorEventW(int Event,void *Param);
|
||||
int WINAPI _export ProcessEditorInputW(const INPUT_RECORD *Rec);
|
||||
int WINAPI _export ProcessEventW(HANDLE hPlugin,int Event,void *Param);
|
||||
int WINAPI _export ProcessHostFileW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int OpMode);
|
||||
int WINAPI _export ProcessKeyW(HANDLE hPlugin,int Key,unsigned int ControlState);
|
||||
int WINAPI _export ProcessSynchroEventW(int Event,void *Param);
|
||||
int WINAPI _export ProcessViewerEventW(int Event,void *Param);
|
||||
int WINAPI _export PutFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int Move,const wchar_t *SrcPath,int OpMode);
|
||||
int WINAPI _export SetDirectoryW(HANDLE hPlugin,const wchar_t *Dir,int OpMode);
|
||||
int WINAPI _export SetFindListW(HANDLE hPlugin,const struct PluginPanelItem *PanelItem,int ItemsNumber);
|
||||
void WINAPI _export SetStartupInfoW(const struct PluginStartupInfo *Info);
|
||||
|
||||
EXTERN_C_END
|
||||
*/
|
||||
|
||||
#endif
|
||||
518
CPP/7zip/UI/Far/FarUtils.cpp
Normal file
518
CPP/7zip/UI/Far/FarUtils.cpp
Normal file
@@ -0,0 +1,518 @@
|
||||
// FarUtils.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#ifndef UNDER_CE
|
||||
#include "../../../Windows/Console.h"
|
||||
#endif
|
||||
#include "../../../Windows/Defs.h"
|
||||
#include "../../../Windows/ErrorMsg.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NFar {
|
||||
|
||||
CStartupInfo g_StartupInfo;
|
||||
|
||||
void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo,
|
||||
const CSysString &pluginNameForRegestry)
|
||||
{
|
||||
m_Data = pluginStartupInfo;
|
||||
m_RegistryPath = GetSystemString(pluginStartupInfo.RootKey);
|
||||
m_RegistryPath += TEXT('\\');
|
||||
m_RegistryPath += pluginNameForRegestry;
|
||||
}
|
||||
|
||||
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, helpTopic,
|
||||
items, numItems, numButtons);
|
||||
}
|
||||
|
||||
namespace NMessageID
|
||||
{
|
||||
enum
|
||||
{
|
||||
kOk,
|
||||
kCancel,
|
||||
kWarning,
|
||||
kError
|
||||
};
|
||||
}
|
||||
|
||||
int CStartupInfo::ShowWarningWithOk(const char **items, int numItems)
|
||||
{
|
||||
return ShowMessage(FMSG_WARNING | FMSG_MB_OK, NULL, items, numItems, 0);
|
||||
}
|
||||
|
||||
extern const char *g_PluginName_for_Error;
|
||||
|
||||
void CStartupInfo::SetErrorTitle(AString &s)
|
||||
{
|
||||
if (g_PluginName_for_Error)
|
||||
{
|
||||
s += g_PluginName_for_Error;
|
||||
s += ": ";
|
||||
}
|
||||
s += GetMsgString(NMessageID::kError);
|
||||
}
|
||||
|
||||
/*
|
||||
int CStartupInfo::ShowErrorMessage(const char *message)
|
||||
{
|
||||
AString s;
|
||||
SetErrorTitle(s);
|
||||
const char *items[]= { s, message };
|
||||
return ShowWarningWithOk(items, ARRAY_SIZE(items));
|
||||
}
|
||||
*/
|
||||
|
||||
int CStartupInfo::ShowErrorMessage2(const char *m1, const char *m2)
|
||||
{
|
||||
AString s;
|
||||
SetErrorTitle(s);
|
||||
const char *items[]= { s, m1, m2 };
|
||||
return ShowWarningWithOk(items, ARRAY_SIZE(items));
|
||||
}
|
||||
|
||||
static void SplitString(const AString &src, AStringVector &destStrings)
|
||||
{
|
||||
destStrings.Clear();
|
||||
AString s;
|
||||
unsigned len = src.Len();
|
||||
if (len == 0)
|
||||
return;
|
||||
for (unsigned i = 0; i < len; i++)
|
||||
{
|
||||
char c = src[i];
|
||||
if (c == '\n')
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
{
|
||||
destStrings.Add(s);
|
||||
s.Empty();
|
||||
}
|
||||
}
|
||||
else
|
||||
s += c;
|
||||
}
|
||||
if (!s.IsEmpty())
|
||||
destStrings.Add(s);
|
||||
}
|
||||
|
||||
int CStartupInfo::ShowErrorMessage(const char *message)
|
||||
{
|
||||
AStringVector strings;
|
||||
SplitString(message, strings);
|
||||
const unsigned kNumStringsMax = 20;
|
||||
const char *items[kNumStringsMax + 1];
|
||||
unsigned pos = 0;
|
||||
items[pos++] = GetMsgString(NMessageID::kError);
|
||||
for (unsigned i = 0; i < strings.Size() && pos < kNumStringsMax; i++)
|
||||
items[pos++] = strings[i];
|
||||
items[pos++] = GetMsgString(NMessageID::kOk);
|
||||
|
||||
return ShowMessage(FMSG_WARNING, NULL, items, pos, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
int CStartupInfo::ShowMessageLines(const char *message)
|
||||
{
|
||||
AString s = GetMsgString(NMessageID::kError);
|
||||
s.Add_LF();
|
||||
s += message;
|
||||
return ShowMessage(FMSG_WARNING | FMSG_MB_OK | FMSG_ALLINONE, NULL,
|
||||
(const char **)(const char *)s, 1, 0);
|
||||
}
|
||||
*/
|
||||
|
||||
int CStartupInfo::ShowMessage(int messageId)
|
||||
{
|
||||
return ShowErrorMessage(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 TCHAR kRegestryKeyDelimiter = TEXT('\'');
|
||||
|
||||
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_VECTOR (i, items)
|
||||
{
|
||||
FarMenuItem item;
|
||||
item.Checked = 0;
|
||||
item.Separator = 0;
|
||||
item.Selected = ((int)i == selectedItem);
|
||||
CSysString reducedString = items[i].Left(ARRAY_SIZE(item.Text) - 1);
|
||||
MyStringCopy(item.Text, (const char *)GetOemString(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;
|
||||
}
|
||||
};
|
||||
|
||||
int PrintErrorMessage(const char *message, unsigned code)
|
||||
{
|
||||
AString s = message;
|
||||
s += " #";
|
||||
char temp[16];
|
||||
ConvertUInt32ToString((UInt32)code, temp);
|
||||
s += temp;
|
||||
return g_StartupInfo.ShowErrorMessage(s);
|
||||
}
|
||||
|
||||
int PrintErrorMessage(const char *message, const char *text)
|
||||
{
|
||||
return g_StartupInfo.ShowErrorMessage2(message, text);
|
||||
}
|
||||
|
||||
|
||||
void ReduceString(UString &s, unsigned size)
|
||||
{
|
||||
if (s.Len() > size)
|
||||
{
|
||||
if (size > 5)
|
||||
size -= 5;
|
||||
s.Delete(size / 2, s.Len() - size);
|
||||
s.Insert(size / 2, L" ... ");
|
||||
}
|
||||
}
|
||||
|
||||
int PrintErrorMessage(const char *message, const wchar_t *name, unsigned maxLen)
|
||||
{
|
||||
UString s = name;
|
||||
ReduceString(s, maxLen);
|
||||
return PrintErrorMessage(message, UnicodeStringToMultiByte(s, CP_OEMCP));
|
||||
}
|
||||
|
||||
int ShowSysErrorMessage(DWORD errorCode)
|
||||
{
|
||||
UString message = NError::MyFormatMessage(errorCode);
|
||||
return g_StartupInfo.ShowErrorMessage(UnicodeStringToMultiByte(message, CP_OEMCP));
|
||||
}
|
||||
|
||||
int ShowLastErrorMessage()
|
||||
{
|
||||
return ShowSysErrorMessage(::GetLastError());
|
||||
}
|
||||
|
||||
int ShowSysErrorMessage(DWORD errorCode, const wchar_t *name)
|
||||
{
|
||||
UString s = NError::MyFormatMessage(errorCode);
|
||||
AString s1 = UnicodeStringToMultiByte(s, CP_OEMCP);
|
||||
AString s2 = UnicodeStringToMultiByte(name, CP_OEMCP);
|
||||
return g_StartupInfo.ShowErrorMessage2(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
bool WasEscPressed()
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
return false;
|
||||
#else
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
197
CPP/7zip/UI/Far/FarUtils.h
Normal file
197
CPP/7zip/UI/Far/FarUtils.h
Normal file
@@ -0,0 +1,197 @@
|
||||
// FarUtils.h
|
||||
|
||||
#ifndef __FAR_UTILS_H
|
||||
#define __FAR_UTILS_H
|
||||
|
||||
#include "FarPlugin.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 &pluginNameForRegestry);
|
||||
const char *GetMsgString(int messageId);
|
||||
|
||||
int ShowMessage(unsigned int flags, const char *helpTopic,
|
||||
const char **items, int numItems, int numButtons);
|
||||
int ShowWarningWithOk(const char **items, int numItems);
|
||||
|
||||
void SetErrorTitle(AString &s);
|
||||
int ShowErrorMessage(const char *message);
|
||||
int ShowErrorMessage2(const char *m1, const char *m2);
|
||||
// int ShowMessageLines(const char *messageLines);
|
||||
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;
|
||||
|
||||
|
||||
int PrintErrorMessage(const char *message, unsigned code);
|
||||
int PrintErrorMessage(const char *message, const char *text);
|
||||
int PrintErrorMessage(const char *message, const wchar_t *name, unsigned maxLen = 70);
|
||||
|
||||
#define MY_TRY_BEGIN try {
|
||||
|
||||
#define MY_TRY_END1(x) }\
|
||||
catch(unsigned n) { PrintErrorMessage(x, n); return; }\
|
||||
catch(const CSysString &s) { PrintErrorMessage(x, s); return; }\
|
||||
catch(const char *s) { PrintErrorMessage(x, s); return; }\
|
||||
catch(...) { g_StartupInfo.ShowErrorMessage(x); return; }
|
||||
|
||||
#define MY_TRY_END2(x, y) }\
|
||||
catch(unsigned n) { PrintErrorMessage(x, n); return y; }\
|
||||
catch(const AString &s) { PrintErrorMessage(x, s); return y; }\
|
||||
catch(const char *s) { PrintErrorMessage(x, s); return y; }\
|
||||
catch(const UString &s) { PrintErrorMessage(x, s); return y; }\
|
||||
catch(const wchar_t *s) { PrintErrorMessage(x, s); return y; }\
|
||||
catch(...) { g_StartupInfo.ShowErrorMessage(x); return y; }
|
||||
|
||||
int ShowSysErrorMessage(DWORD errorCode);
|
||||
int ShowSysErrorMessage(DWORD errorCode, const wchar_t *name);
|
||||
int ShowLastErrorMessage();
|
||||
|
||||
bool WasEscPressed();
|
||||
|
||||
void ReduceString(UString &s, unsigned size);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
136
CPP/7zip/UI/Far/Messages.h
Normal file
136
CPP/7zip/UI/Far/Messages.h
Normal file
@@ -0,0 +1,136 @@
|
||||
// Far/Messages.h
|
||||
|
||||
#ifndef __7ZIP_FAR_MESSAGES_H
|
||||
#define __7ZIP_FAR_MESSAGES_H
|
||||
|
||||
#include "../../PropID.h"
|
||||
|
||||
namespace NMessageID {
|
||||
|
||||
const unsigned k_Last_PropId_supported_by_plugin = kpidStreamId;
|
||||
|
||||
enum EEnum
|
||||
{
|
||||
kOk,
|
||||
kCancel,
|
||||
|
||||
kWarning,
|
||||
kError,
|
||||
|
||||
kArchiveType,
|
||||
|
||||
kProperties,
|
||||
|
||||
kYes,
|
||||
kNo,
|
||||
|
||||
kGetPasswordTitle,
|
||||
kEnterPasswordForFile,
|
||||
|
||||
kExtractTitle,
|
||||
kExtractTo,
|
||||
|
||||
kExtractPathMode,
|
||||
kExtractPathFull,
|
||||
kExtractPathCurrent,
|
||||
kExtractPathNo,
|
||||
|
||||
kExtractOwerwriteMode,
|
||||
kExtractOwerwriteAsk,
|
||||
kExtractOwerwritePrompt,
|
||||
kExtractOwerwriteSkip,
|
||||
kExtractOwerwriteAutoRename,
|
||||
kExtractOwerwriteAutoRenameExisting,
|
||||
|
||||
kExtractFilesMode,
|
||||
kExtractFilesSelected,
|
||||
kExtractFilesAll,
|
||||
|
||||
kExtractPassword,
|
||||
|
||||
kExtractExtract,
|
||||
kExtractCancel,
|
||||
|
||||
kExtractCanNotOpenOutputFile,
|
||||
|
||||
kExtractUnsupportedMethod,
|
||||
kExtractCRCFailed,
|
||||
kExtractDataError,
|
||||
kExtractCRCFailedEncrypted,
|
||||
kExtractDataErrorEncrypted,
|
||||
|
||||
kOverwriteTitle,
|
||||
kOverwriteMessage1,
|
||||
kOverwriteMessageWouldYouLike,
|
||||
kOverwriteMessageWithtTisOne,
|
||||
|
||||
kOverwriteBytes,
|
||||
kOverwriteModifiedOn,
|
||||
|
||||
kOverwriteYes,
|
||||
kOverwriteYesToAll,
|
||||
kOverwriteNo,
|
||||
kOverwriteNoToAll,
|
||||
kOverwriteAutoRename,
|
||||
kOverwriteCancel,
|
||||
|
||||
kUpdateNotSupportedForThisArchive,
|
||||
|
||||
kDeleteTitle,
|
||||
kDeleteFile,
|
||||
kDeleteFiles,
|
||||
kDeleteNumberOfFiles,
|
||||
kDeleteDelete,
|
||||
kDeleteCancel,
|
||||
|
||||
kUpdateTitle,
|
||||
kUpdateAddToArchive,
|
||||
|
||||
kUpdateMethod,
|
||||
kUpdateMethod_Store,
|
||||
kUpdateMethod_Fastest,
|
||||
kUpdateMethod_Fast,
|
||||
kUpdateMethod_Normal,
|
||||
kUpdateMethod_Maximum,
|
||||
kUpdateMethod_Ultra,
|
||||
|
||||
kUpdateMode,
|
||||
kUpdateMode_Add,
|
||||
kUpdateMode_Update,
|
||||
kUpdateMode_Fresh,
|
||||
kUpdateMode_Sync,
|
||||
|
||||
kUpdateAdd,
|
||||
kUpdateSelectArchiver,
|
||||
|
||||
kUpdateSelectArchiverMenuTitle,
|
||||
|
||||
// kArcReadFiles,
|
||||
|
||||
kWaitTitle,
|
||||
|
||||
kReading,
|
||||
kExtracting,
|
||||
kDeleting,
|
||||
kUpdating,
|
||||
|
||||
// kReadingList,
|
||||
|
||||
kMoveIsNotSupported,
|
||||
|
||||
kOpenArchiveMenuString,
|
||||
kCreateArchiveMenuString,
|
||||
|
||||
kConfigTitle,
|
||||
|
||||
kConfigPluginEnabled,
|
||||
|
||||
// ---------- IDs for Properies (kpid*) ----------
|
||||
kNoProperty,
|
||||
k_Last_MessageID_for_Property = kNoProperty + k_Last_PropId_supported_by_plugin
|
||||
// ----------
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
122
CPP/7zip/UI/Far/OverwriteDialogFar.cpp
Normal file
122
CPP/7zip/UI/Far/OverwriteDialogFar.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
// OverwriteDialogFar.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/IntToString.h"
|
||||
|
||||
#include "../../../Windows/FileName.h"
|
||||
#include "../../../Windows/PropVariantConv.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
#include "Messages.h"
|
||||
|
||||
#include "OverwriteDialogFar.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
namespace NOverwriteDialog {
|
||||
|
||||
struct CFileInfoStrings
|
||||
{
|
||||
AString Size;
|
||||
AString Time;
|
||||
};
|
||||
|
||||
void SetFileInfoStrings(const CFileInfo &fileInfo,
|
||||
CFileInfoStrings &fileInfoStrings)
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
if (fileInfo.SizeIsDefined)
|
||||
{
|
||||
ConvertUInt64ToString(fileInfo.Size, buffer);
|
||||
fileInfoStrings.Size = buffer;
|
||||
fileInfoStrings.Size += ' ';
|
||||
fileInfoStrings.Size += g_StartupInfo.GetMsgString(NMessageID::kOverwriteBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileInfoStrings.Size = "";
|
||||
}
|
||||
|
||||
FILETIME localFileTime;
|
||||
fileInfoStrings.Time.Empty();
|
||||
if (fileInfo.TimeIsDefined)
|
||||
{
|
||||
if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
|
||||
throw 4190402;
|
||||
char timeString[32];
|
||||
ConvertFileTimeToString(localFileTime, timeString);
|
||||
fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn);
|
||||
fileInfoStrings.Time += ' ';
|
||||
fileInfoStrings.Time += timeString;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
UString oldName2 = oldFileInfo.Name;
|
||||
UString newName2 = newFileInfo.Name;
|
||||
|
||||
{
|
||||
const unsigned maxNameLen = kXSize - 9 - 2;
|
||||
ReduceString(oldName2, maxNameLen);
|
||||
ReduceString(newName2, maxNameLen);
|
||||
}
|
||||
|
||||
AString oldName = UnicodeStringToMultiByte(oldName2);
|
||||
AString newName = UnicodeStringToMultiByte(newName2);
|
||||
|
||||
struct CInitDialogItem initItems[]={
|
||||
{ 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, oldName, 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, newName, 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 = ARRAY_SIZE(initItems);
|
||||
FarDialogItem aDialogItems[kNumDialogItems];
|
||||
g_StartupInfo.InitDialogItems(initItems, 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;
|
||||
}
|
||||
|
||||
}
|
||||
37
CPP/7zip/UI/Far/OverwriteDialogFar.h
Normal file
37
CPP/7zip/UI/Far/OverwriteDialogFar.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// OverwriteDialogFar.h
|
||||
|
||||
#ifndef __OVERWRITE_DIALOG_FAR_H
|
||||
#define __OVERWRITE_DIALOG_FAR_H
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
#include "../../../Common/MyTypes.h"
|
||||
|
||||
namespace NOverwriteDialog {
|
||||
|
||||
struct CFileInfo
|
||||
{
|
||||
bool SizeIsDefined;
|
||||
bool TimeIsDefined;
|
||||
UInt64 Size;
|
||||
FILETIME Time;
|
||||
UString Name;
|
||||
};
|
||||
|
||||
namespace NResult
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kYes,
|
||||
kYesToAll,
|
||||
kNo,
|
||||
kNoToAll,
|
||||
kAutoRename,
|
||||
kCancel
|
||||
};
|
||||
}
|
||||
|
||||
NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInfo);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
924
CPP/7zip/UI/Far/Plugin.cpp
Normal file
924
CPP/7zip/UI/Far/Plugin.cpp
Normal file
@@ -0,0 +1,924 @@
|
||||
// Plugin.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/Wildcard.h"
|
||||
|
||||
#include "../../../Windows/FileDir.h"
|
||||
#include "../../../Windows/PropVariantConv.h"
|
||||
|
||||
#include "../Common/PropIDUtils.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
#include "Messages.h"
|
||||
#include "Plugin.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
using namespace NFar;
|
||||
|
||||
// This function is unused
|
||||
int CompareFileNames_ForFolderList(const wchar_t *s1, const wchar_t *s2)
|
||||
{
|
||||
return MyStringCompareNoCase(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
CPlugin::CPlugin(const FString &fileName, CAgent *agent, UString archiveTypeName):
|
||||
_agent(agent),
|
||||
m_FileName(fileName),
|
||||
_archiveTypeName(archiveTypeName)
|
||||
{
|
||||
m_ArchiveHandler = agent;
|
||||
if (!m_FileInfo.Find(m_FileName))
|
||||
throw "error";
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
}
|
||||
|
||||
CPlugin::~CPlugin() {}
|
||||
|
||||
static void MyGetFileTime(IFolderFolder *folder, UInt32 itemIndex,
|
||||
PROPID propID, FILETIME &fileTime)
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
if (folder->GetProperty(itemIndex, propID, &prop) != S_OK)
|
||||
throw 271932;
|
||||
if (prop.vt == VT_EMPTY)
|
||||
{
|
||||
fileTime.dwHighDateTime = 0;
|
||||
fileTime.dwLowDateTime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prop.vt != VT_FILETIME)
|
||||
throw 4191730;
|
||||
fileTime = prop.filetime;
|
||||
}
|
||||
}
|
||||
|
||||
#define kDotsReplaceString "[[..]]"
|
||||
#define kDotsReplaceStringU L"[[..]]"
|
||||
|
||||
static void CopyStrLimited(char *dest, const AString &src, unsigned len)
|
||||
{
|
||||
len--;
|
||||
if (src.Len() < len)
|
||||
len = src.Len();
|
||||
memcpy(dest, src, sizeof(dest[0]) * len);
|
||||
dest[len] = 0;
|
||||
}
|
||||
|
||||
#define COPY_STR_LIMITED(dest, src) CopyStrLimited(dest, src, ARRAY_SIZE(dest))
|
||||
|
||||
void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
if (_folder->GetProperty(itemIndex, kpidName, &prop) != S_OK)
|
||||
throw 271932;
|
||||
|
||||
if (prop.vt != VT_BSTR)
|
||||
throw 272340;
|
||||
|
||||
AString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
|
||||
if (oemString == "..")
|
||||
oemString = kDotsReplaceString;
|
||||
|
||||
COPY_STR_LIMITED(panelItem.FindData.cFileName, oemString);
|
||||
panelItem.FindData.cAlternateFileName[0] = 0;
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidAttrib, &prop) != S_OK)
|
||||
throw 271932;
|
||||
if (prop.vt == VT_UI4)
|
||||
panelItem.FindData.dwFileAttributes = prop.ulVal;
|
||||
else if (prop.vt == VT_EMPTY)
|
||||
panelItem.FindData.dwFileAttributes = m_FileInfo.Attrib;
|
||||
else
|
||||
throw 21631;
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidIsDir, &prop) != S_OK)
|
||||
throw 271932;
|
||||
if (prop.vt == VT_BOOL)
|
||||
{
|
||||
if (VARIANT_BOOLToBool(prop.boolVal))
|
||||
panelItem.FindData.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
}
|
||||
else if (prop.vt != VT_EMPTY)
|
||||
throw 21632;
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidSize, &prop) != S_OK)
|
||||
throw 271932;
|
||||
UInt64 length = 0;
|
||||
ConvertPropVariantToUInt64(prop, length);
|
||||
panelItem.FindData.nFileSizeLow = (UInt32)length;
|
||||
panelItem.FindData.nFileSizeHigh = (UInt32)(length >> 32);
|
||||
|
||||
MyGetFileTime(_folder, itemIndex, kpidCTime, panelItem.FindData.ftCreationTime);
|
||||
MyGetFileTime(_folder, itemIndex, kpidATime, panelItem.FindData.ftLastAccessTime);
|
||||
MyGetFileTime(_folder, itemIndex, kpidMTime, panelItem.FindData.ftLastWriteTime);
|
||||
|
||||
if (panelItem.FindData.ftLastWriteTime.dwHighDateTime == 0 &&
|
||||
panelItem.FindData.ftLastWriteTime.dwLowDateTime == 0)
|
||||
panelItem.FindData.ftLastWriteTime = m_FileInfo.MTime;
|
||||
|
||||
if (_folder->GetProperty(itemIndex, kpidPackSize, &prop) != S_OK)
|
||||
throw 271932;
|
||||
length = 0;
|
||||
ConvertPropVariantToUInt64(prop, length);
|
||||
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.CRC32 = 0;
|
||||
panelItem.Reserved[0] = 0;
|
||||
panelItem.Reserved[1] = 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 *msgItems[]=
|
||||
{
|
||||
g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kReadingList)
|
||||
};
|
||||
g_StartupInfo.ShowMessage(0, NULL, msgItems, ARRAY_SIZE(msgItems), 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 &dirName)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
UString s = dirName;
|
||||
if (dirName == kDotsReplaceStringU)
|
||||
s = L"..";
|
||||
_folder->BindToFolder(s, &newFolder);
|
||||
if (!newFolder)
|
||||
if (dirName.IsEmpty())
|
||||
return;
|
||||
else
|
||||
throw 40325;
|
||||
_folder = newFolder;
|
||||
}
|
||||
|
||||
int CPlugin::SetDirectory(const char *aszDir, int /* opMode */)
|
||||
{
|
||||
UString path = MultiByteToUnicodeString(aszDir, CP_OEMCP);
|
||||
if (path == WSTRING_PATH_SEPARATOR)
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
}
|
||||
else if (path == L"..")
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToParentFolder(&newFolder);
|
||||
if (!newFolder)
|
||||
throw 40312;
|
||||
_folder = newFolder;
|
||||
}
|
||||
else if (path.IsEmpty())
|
||||
EnterToDirectory(path);
|
||||
else
|
||||
{
|
||||
if (path[0] == WCHAR_PATH_SEPARATOR)
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
path.DeleteFrontal(1);
|
||||
}
|
||||
UStringVector pathParts;
|
||||
SplitPathToParts(path, pathParts);
|
||||
FOR_VECTOR (i, pathParts)
|
||||
EnterToDirectory(pathParts[i]);
|
||||
}
|
||||
SetCurrentDirVar();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPlugin::GetPathParts(UStringVector &pathParts)
|
||||
{
|
||||
pathParts.Clear();
|
||||
CMyComPtr<IFolderFolder> folderItem = _folder;
|
||||
for (;;)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
folderItem->BindToParentFolder(&newFolder);
|
||||
if (!newFolder)
|
||||
break;
|
||||
NCOM::CPropVariant prop;
|
||||
if (folderItem->GetFolderProperty(kpidName, &prop) == S_OK)
|
||||
if (prop.vt == VT_BSTR)
|
||||
pathParts.Insert(0, (const wchar_t *)prop.bstrVal);
|
||||
folderItem = newFolder;
|
||||
}
|
||||
}
|
||||
|
||||
void CPlugin::SetCurrentDirVar()
|
||||
{
|
||||
m_CurrentDir.Empty();
|
||||
|
||||
/*
|
||||
// kpidPath path has tail slash, but we don't need it for compatibility with default FAR style
|
||||
NCOM::CPropVariant prop;
|
||||
if (_folder->GetFolderProperty(kpidPath, &prop) == S_OK)
|
||||
if (prop.vt == VT_BSTR)
|
||||
{
|
||||
m_CurrentDir = (wchar_t *)prop.bstrVal;
|
||||
// if (!m_CurrentDir.IsEmpty())
|
||||
}
|
||||
m_CurrentDir.InsertAtFront(WCHAR_PATH_SEPARATOR);
|
||||
*/
|
||||
|
||||
UStringVector pathParts;
|
||||
GetPathParts(pathParts);
|
||||
FOR_VECTOR (i, pathParts)
|
||||
{
|
||||
m_CurrentDir.Add_PathSepar();
|
||||
m_CurrentDir += pathParts[i];
|
||||
}
|
||||
}
|
||||
|
||||
static const char *kPluginFormatName = "7-ZIP";
|
||||
|
||||
|
||||
static int FindPropNameID(PROPID propID)
|
||||
{
|
||||
if (propID > NMessageID::k_Last_PropId_supported_by_plugin)
|
||||
return -1;
|
||||
return NMessageID::kNoProperty + propID;
|
||||
}
|
||||
|
||||
/*
|
||||
struct CPropertyIDInfo
|
||||
{
|
||||
PROPID PropID;
|
||||
const char *FarID;
|
||||
int Width;
|
||||
// char CharID;
|
||||
};
|
||||
|
||||
static CPropertyIDInfo kPropertyIDInfos[] =
|
||||
{
|
||||
{ kpidName, "N", 0},
|
||||
{ kpidSize, "S", 8},
|
||||
{ kpidPackSize, "P", 8},
|
||||
{ kpidAttrib, "A", 0},
|
||||
{ kpidCTime, "DC", 14},
|
||||
{ kpidATime, "DA", 14},
|
||||
{ kpidMTime, "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 = ARRAY_SIZE(kPropertyIDInfos);
|
||||
|
||||
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 &destString, const char *srcString)
|
||||
{
|
||||
if (!destString.IsEmpty())
|
||||
destString += ',';
|
||||
destString += srcString;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
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 &propertyIDInfo = kPropertyIDInfos[index];
|
||||
SmartAddToString(PanelModeColumnTypes, propertyIDInfo.FarID);
|
||||
char tmp[32];
|
||||
itoa(propertyIDInfo.Width, tmp, 10);
|
||||
SmartAddToString(PanelModeColumnWidths, tmp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
static AString GetNameOfProp(PROPID propID, const wchar_t *name)
|
||||
{
|
||||
int farID = FindPropNameID(propID);
|
||||
if (farID >= 0)
|
||||
return g_StartupInfo.GetMsgString(farID);
|
||||
if (name)
|
||||
return UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP);
|
||||
char s[16];
|
||||
ConvertUInt32ToString(propID, s);
|
||||
return s;
|
||||
}
|
||||
|
||||
static AString GetNameOfProp2(PROPID propID, const wchar_t *name)
|
||||
{
|
||||
AString s = GetNameOfProp(propID, name);
|
||||
if (s.Len() > (kInfoPanelLineSize - 1))
|
||||
s.DeleteFrom(kInfoPanelLineSize - 1);
|
||||
return s;
|
||||
}
|
||||
|
||||
static AString ConvertSizeToString(UInt64 value)
|
||||
{
|
||||
char s[32];
|
||||
ConvertUInt64ToString(value, s);
|
||||
unsigned i = MyStringLen(s);
|
||||
unsigned pos = ARRAY_SIZE(s);
|
||||
s[--pos] = 0;
|
||||
while (i > 3)
|
||||
{
|
||||
s[--pos] = s[--i];
|
||||
s[--pos] = s[--i];
|
||||
s[--pos] = s[--i];
|
||||
s[--pos] = ' ';
|
||||
}
|
||||
while (i > 0)
|
||||
s[--pos] = s[--i];
|
||||
return s + pos;
|
||||
}
|
||||
|
||||
static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID)
|
||||
{
|
||||
if (prop.vt == VT_BSTR)
|
||||
{
|
||||
AString s = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
|
||||
s.Replace((char)0xA, ' ');
|
||||
s.Replace((char)0xD, ' ');
|
||||
return s;
|
||||
}
|
||||
if (prop.vt == VT_BOOL)
|
||||
{
|
||||
int messageID = VARIANT_BOOLToBool(prop.boolVal) ?
|
||||
NMessageID::kYes : NMessageID::kNo;
|
||||
return g_StartupInfo.GetMsgString(messageID);
|
||||
}
|
||||
if (prop.vt != VT_EMPTY)
|
||||
{
|
||||
if ((prop.vt == VT_UI8 || prop.vt == VT_UI4) && (
|
||||
propID == kpidSize ||
|
||||
propID == kpidPackSize ||
|
||||
propID == kpidNumSubDirs ||
|
||||
propID == kpidNumSubFiles ||
|
||||
propID == kpidNumBlocks ||
|
||||
propID == kpidPhySize ||
|
||||
propID == kpidHeadersSize ||
|
||||
propID == kpidClusterSize ||
|
||||
propID == kpidUnpackSize
|
||||
))
|
||||
{
|
||||
UInt64 v = 0;
|
||||
ConvertPropVariantToUInt64(prop, v);
|
||||
return ConvertSizeToString(v);
|
||||
}
|
||||
{
|
||||
char sz[64];
|
||||
ConvertPropertyToShortString(sz, prop, propID);
|
||||
return sz;
|
||||
}
|
||||
}
|
||||
return AString();
|
||||
}
|
||||
|
||||
static AString PropToString2(const NCOM::CPropVariant &prop, PROPID propID)
|
||||
{
|
||||
AString s = PropToString(prop, propID);
|
||||
if (s.Len() > (kInfoPanelLineSize - 1))
|
||||
s.DeleteFrom(kInfoPanelLineSize - 1);
|
||||
return s;
|
||||
}
|
||||
|
||||
static void AddPropertyString(InfoPanelLine *lines, int &numItems, PROPID propID, const wchar_t *name,
|
||||
const NCOM::CPropVariant &prop)
|
||||
{
|
||||
if (prop.vt != VT_EMPTY)
|
||||
{
|
||||
AString val = PropToString2(prop, propID);
|
||||
if (!val.IsEmpty())
|
||||
{
|
||||
InfoPanelLine &item = lines[numItems++];
|
||||
COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name));
|
||||
COPY_STR_LIMITED(item.Data, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void InsertSeparator(InfoPanelLine *lines, int &numItems)
|
||||
{
|
||||
if (numItems < kNumInfoLinesMax)
|
||||
{
|
||||
InfoPanelLine &item = lines[numItems++];
|
||||
*item.Text = 0;
|
||||
*item.Data = 0;
|
||||
item.Separator = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
{
|
||||
info->StructSize = sizeof(*info);
|
||||
info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS | OPIF_USEHIGHLIGHTING |
|
||||
OPIF_ADDDOTS | OPIF_COMPAREFATTIME;
|
||||
|
||||
COPY_STR_LIMITED(m_FileNameBuffer, UnicodeStringToMultiByte(fs2us(m_FileName), CP_OEMCP));
|
||||
info->HostFile = m_FileNameBuffer; // test it it is not static
|
||||
|
||||
COPY_STR_LIMITED(m_CurrentDirBuffer, UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP));
|
||||
info->CurDir = m_CurrentDirBuffer;
|
||||
|
||||
info->Format = kPluginFormatName;
|
||||
|
||||
{
|
||||
UString name;
|
||||
{
|
||||
FString dirPrefix, fileName;
|
||||
GetFullPathAndSplit(m_FileName, dirPrefix, fileName);
|
||||
name = fs2us(fileName);
|
||||
}
|
||||
|
||||
m_PannelTitle = L' ';
|
||||
m_PannelTitle += _archiveTypeName;
|
||||
m_PannelTitle += L':';
|
||||
m_PannelTitle += name;
|
||||
m_PannelTitle.Add_Space();
|
||||
if (!m_CurrentDir.IsEmpty())
|
||||
{
|
||||
// m_PannelTitle += '\\';
|
||||
m_PannelTitle += m_CurrentDir;
|
||||
}
|
||||
|
||||
COPY_STR_LIMITED(m_PannelTitleBuffer, UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP));
|
||||
info->PanelTitle = m_PannelTitleBuffer;
|
||||
|
||||
}
|
||||
|
||||
memset(m_InfoLines, 0, sizeof(m_InfoLines));
|
||||
m_InfoLines[0].Text[0] = 0;
|
||||
m_InfoLines[0].Separator = TRUE;
|
||||
|
||||
MyStringCopy(m_InfoLines[1].Text, g_StartupInfo.GetMsgString(NMessageID::kArchiveType));
|
||||
MyStringCopy(m_InfoLines[1].Data, (const char *)UnicodeStringToMultiByte(_archiveTypeName, CP_OEMCP));
|
||||
|
||||
int numItems = 2;
|
||||
|
||||
{
|
||||
CMyComPtr<IFolderProperties> folderProperties;
|
||||
_folder.QueryInterface(IID_IFolderProperties, &folderProperties);
|
||||
if (folderProperties)
|
||||
{
|
||||
UInt32 numProps;
|
||||
if (folderProperties->GetNumberOfFolderProperties(&numProps) == S_OK)
|
||||
{
|
||||
for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
if (folderProperties->GetFolderPropertyInfo(i, &name, &propID, &vt) != S_OK)
|
||||
continue;
|
||||
NCOM::CPropVariant prop;
|
||||
if (_folder->GetFolderProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY)
|
||||
continue;
|
||||
|
||||
InfoPanelLine &item = m_InfoLines[numItems++];
|
||||
COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name));
|
||||
COPY_STR_LIMITED(item.Data, PropToString2(prop, propID));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (numItems < kNumInfoLinesMax)
|
||||
{
|
||||
InsertSeparator(m_InfoLines, numItems);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
CMyComPtr<IGetFolderArcProps> getFolderArcProps;
|
||||
_folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
|
||||
if (getFolderArcProps)
|
||||
{
|
||||
CMyComPtr<IFolderArcProps> getProps;
|
||||
getFolderArcProps->GetFolderArcProps(&getProps);
|
||||
if (getProps)
|
||||
{
|
||||
UInt32 numLevels;
|
||||
if (getProps->GetArcNumLevels(&numLevels) != S_OK)
|
||||
numLevels = 0;
|
||||
for (UInt32 level2 = 0; level2 < numLevels; level2++)
|
||||
{
|
||||
{
|
||||
UInt32 level = numLevels - 1 - level2;
|
||||
UInt32 numProps;
|
||||
if (getProps->GetArcNumProps(level, &numProps) == S_OK)
|
||||
{
|
||||
InsertSeparator(m_InfoLines, numItems);
|
||||
for (Int32 i = -3; i < (Int32)numProps && numItems < kNumInfoLinesMax; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
switch (i)
|
||||
{
|
||||
case -3: propID = kpidPath; break;
|
||||
case -2: propID = kpidType; break;
|
||||
case -1: propID = kpidError; break;
|
||||
default:
|
||||
if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK)
|
||||
continue;
|
||||
}
|
||||
NCOM::CPropVariant prop;
|
||||
if (getProps->GetArcProp(level, propID, &prop) != S_OK)
|
||||
continue;
|
||||
AddPropertyString(m_InfoLines, numItems, propID, name, prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (level2 != numLevels - 1)
|
||||
{
|
||||
UInt32 level = numLevels - 1 - level2;
|
||||
UInt32 numProps;
|
||||
if (getProps->GetArcNumProps2(level, &numProps) == S_OK)
|
||||
{
|
||||
InsertSeparator(m_InfoLines, numItems);
|
||||
for (Int32 i = 0; i < (Int32)numProps && numItems < kNumInfoLinesMax; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
if (getProps->GetArcPropInfo2(level, i, &name, &propID, &vt) != S_OK)
|
||||
continue;
|
||||
NCOM::CPropVariant prop;
|
||||
if (getProps->GetArcProp2(level, propID, &prop) != S_OK)
|
||||
continue;
|
||||
AddPropertyString(m_InfoLines, numItems, propID, name, prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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(kpidPackSize);
|
||||
AddColumn(kpidMTime);
|
||||
AddColumn(kpidCTime);
|
||||
AddColumn(kpidATime);
|
||||
AddColumn(kpidAttrib);
|
||||
|
||||
_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;
|
||||
};
|
||||
|
||||
static inline char GetHex(Byte value)
|
||||
{
|
||||
return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
|
||||
}
|
||||
|
||||
HRESULT CPlugin::ShowAttributesWindow()
|
||||
{
|
||||
PluginPanelItem pluginPanelItem;
|
||||
if (!g_StartupInfo.ControlGetActivePanelCurrentItemInfo(pluginPanelItem))
|
||||
return S_FALSE;
|
||||
if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 &&
|
||||
NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
|
||||
return S_FALSE;
|
||||
int itemIndex = (int)pluginPanelItem.UserData;
|
||||
|
||||
CObjectVector<CArchiveItemProperty> properties;
|
||||
UInt32 numProps;
|
||||
RINOK(_folder->GetNumberOfProperties(&numProps));
|
||||
unsigned i;
|
||||
for (i = 0; i < numProps; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
RINOK(_folder->GetPropertyInfo(i, &name, &propID, &vt));
|
||||
CArchiveItemProperty prop;
|
||||
prop.Type = vt;
|
||||
prop.ID = propID;
|
||||
if (prop.ID == kpidPath)
|
||||
prop.ID = kpidName;
|
||||
prop.Name = GetNameOfProp(propID, name);
|
||||
properties.Add(prop);
|
||||
}
|
||||
|
||||
int size = 2;
|
||||
CRecordVector<CInitDialogItem> initDialogItems;
|
||||
|
||||
int xSize = 70;
|
||||
{
|
||||
const CInitDialogItem idi =
|
||||
{ DI_DOUBLEBOX, 3, 1, xSize - 4, size - 2, false, false, 0, false, NMessageID::kProperties, NULL, NULL };
|
||||
initDialogItems.Add(idi);
|
||||
}
|
||||
|
||||
AStringVector values;
|
||||
|
||||
const int kStartY = 3;
|
||||
|
||||
for (i = 0; i < properties.Size(); i++)
|
||||
{
|
||||
const CArchiveItemProperty &property = properties[i];
|
||||
|
||||
int startY = kStartY + values.Size();
|
||||
|
||||
{
|
||||
CInitDialogItem idi =
|
||||
{ DI_TEXT, 5, startY, 0, 0, false, false, 0, false, 0, NULL, NULL };
|
||||
idi.DataMessageId = FindPropNameID(property.ID);
|
||||
if (idi.DataMessageId < 0)
|
||||
idi.DataString = property.Name;
|
||||
initDialogItems.Add(idi);
|
||||
}
|
||||
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(_folder->GetProperty(itemIndex, property.ID, &prop));
|
||||
AString s = PropToString(prop, property.ID);
|
||||
values.Add(s);
|
||||
|
||||
{
|
||||
const CInitDialogItem idi =
|
||||
{ DI_TEXT, 30, startY, 0, 0, false, false, 0, false, -1, NULL, NULL };
|
||||
initDialogItems.Add(idi);
|
||||
}
|
||||
}
|
||||
|
||||
CMyComPtr<IArchiveGetRawProps> _folderRawProps;
|
||||
_folder.QueryInterface(IID_IArchiveGetRawProps, &_folderRawProps);
|
||||
|
||||
CObjectVector<CArchiveItemProperty> properties2;
|
||||
|
||||
if (_folderRawProps)
|
||||
{
|
||||
_folderRawProps->GetNumRawProps(&numProps);
|
||||
|
||||
for (i = 0; i < numProps; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
if (_folderRawProps->GetRawPropInfo(i, &name, &propID) != S_OK)
|
||||
continue;
|
||||
CArchiveItemProperty prop;
|
||||
prop.Type = VT_EMPTY;
|
||||
prop.ID = propID;
|
||||
if (prop.ID == kpidPath)
|
||||
prop.ID = kpidName;
|
||||
prop.Name = GetNameOfProp(propID, name);
|
||||
properties2.Add(prop);
|
||||
}
|
||||
|
||||
for (i = 0; i < properties2.Size(); i++)
|
||||
{
|
||||
const CArchiveItemProperty &property = properties2[i];
|
||||
CMyComBSTR name;
|
||||
|
||||
const void *data;
|
||||
UInt32 dataSize;
|
||||
UInt32 propType;
|
||||
if (_folderRawProps->GetRawProp(itemIndex, property.ID, &data, &dataSize, &propType) != S_OK)
|
||||
continue;
|
||||
|
||||
if (dataSize != 0)
|
||||
{
|
||||
AString s;
|
||||
if (property.ID == kpidNtSecure)
|
||||
ConvertNtSecureToString((const Byte *)data, dataSize, s);
|
||||
else
|
||||
{
|
||||
const UInt32 kMaxDataSize = 64;
|
||||
if (dataSize > kMaxDataSize)
|
||||
{
|
||||
char temp[64];
|
||||
s += "data:";
|
||||
ConvertUInt32ToString(dataSize, temp);
|
||||
s += temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (UInt32 k = 0; k < dataSize; k++)
|
||||
{
|
||||
Byte b = ((const Byte *)data)[k];
|
||||
s += GetHex((Byte)((b >> 4) & 0xF));
|
||||
s += GetHex((Byte)(b & 0xF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int startY = kStartY + values.Size();
|
||||
|
||||
{
|
||||
CInitDialogItem idi =
|
||||
{ DI_TEXT, 5, startY, 0, 0, false, false, 0, false, 0, NULL, NULL };
|
||||
idi.DataMessageId = FindPropNameID(property.ID);
|
||||
if (idi.DataMessageId < 0)
|
||||
idi.DataString = property.Name;
|
||||
initDialogItems.Add(idi);
|
||||
}
|
||||
|
||||
values.Add(s);
|
||||
|
||||
{
|
||||
const CInitDialogItem idi =
|
||||
{ DI_TEXT, 30, startY, 0, 0, false, false, 0, false, -1, NULL, NULL };
|
||||
initDialogItems.Add(idi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned numLines = values.Size();
|
||||
for (i = 0; i < numLines; i++)
|
||||
{
|
||||
CInitDialogItem &idi = initDialogItems[1 + i * 2 + 1];
|
||||
idi.DataString = values[i];
|
||||
}
|
||||
|
||||
unsigned numDialogItems = initDialogItems.Size();
|
||||
|
||||
CObjArray<FarDialogItem> dialogItems(numDialogItems);
|
||||
g_StartupInfo.InitDialogItems(&initDialogItems.Front(), dialogItems, numDialogItems);
|
||||
|
||||
unsigned maxLen = 0;
|
||||
|
||||
for (i = 0; i < numLines; i++)
|
||||
{
|
||||
FarDialogItem &dialogItem = dialogItems[1 + i * 2];
|
||||
unsigned len = (unsigned)strlen(dialogItem.Data);
|
||||
if (len > maxLen)
|
||||
maxLen = len;
|
||||
}
|
||||
|
||||
unsigned maxLen2 = 0;
|
||||
const unsigned kSpace = 10;
|
||||
|
||||
for (i = 0; i < numLines; i++)
|
||||
{
|
||||
FarDialogItem &dialogItem = dialogItems[1 + i * 2 + 1];
|
||||
unsigned len = (int)strlen(dialogItem.Data);
|
||||
if (len > maxLen2)
|
||||
maxLen2 = len;
|
||||
dialogItem.X1 = maxLen + kSpace;
|
||||
}
|
||||
|
||||
size = numLines + 6;
|
||||
xSize = maxLen + kSpace + maxLen2 + 5;
|
||||
FarDialogItem &firstDialogItem = dialogItems[0];
|
||||
firstDialogItem.Y2 = size - 2;
|
||||
firstDialogItem.X2 = xSize - 4;
|
||||
|
||||
/* int askCode = */ g_StartupInfo.ShowDialog(xSize, size, NULL, dialogItems, numDialogItems);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int CPlugin::ProcessKey(int key, unsigned int controlState)
|
||||
{
|
||||
if (key == VK_F7 && controlState == 0)
|
||||
{
|
||||
CreateFolder();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (controlState == PKF_CONTROL && key == 'A')
|
||||
{
|
||||
HRESULT result = ShowAttributesWindow();
|
||||
if (result == S_OK)
|
||||
return TRUE;
|
||||
if (result == S_FALSE)
|
||||
return FALSE;
|
||||
throw "Error";
|
||||
}
|
||||
|
||||
if ((controlState & PKF_ALT) != 0 && key == VK_F6)
|
||||
{
|
||||
FString folderPath;
|
||||
if (!GetOnlyDirPrefix(m_FileName, folderPath))
|
||||
return FALSE;
|
||||
PanelInfo panelInfo;
|
||||
g_StartupInfo.ControlGetActivePanelInfo(panelInfo);
|
||||
GetFilesReal(panelInfo.SelectedItems,
|
||||
panelInfo.SelectedItemsNumber, FALSE,
|
||||
UnicodeStringToMultiByte(fs2us(folderPath), CP_OEMCP), OPM_SILENT, true);
|
||||
g_StartupInfo.Control(this, FCTL_UPDATEPANEL, NULL);
|
||||
g_StartupInfo.Control(this, FCTL_REDRAWPANEL, NULL);
|
||||
g_StartupInfo.Control(this, FCTL_UPDATEANOTHERPANEL, NULL);
|
||||
g_StartupInfo.Control(this, FCTL_REDRAWANOTHERPANEL, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
94
CPP/7zip/UI/Far/Plugin.h
Normal file
94
CPP/7zip/UI/Far/Plugin.h
Normal file
@@ -0,0 +1,94 @@
|
||||
// 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/WorkDir.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
|
||||
const UInt32 kNumInfoLinesMax = 64;
|
||||
|
||||
class CPlugin
|
||||
{
|
||||
CAgent *_agent;
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
CMyComPtr<IFolderFolder> _folder;
|
||||
|
||||
// NWindows::NCOM::CComInitializer m_ComInitializer;
|
||||
UString m_CurrentDir;
|
||||
|
||||
UString m_PannelTitle;
|
||||
FString m_FileName;
|
||||
NWindows::NFile::NFind::CFileInfo m_FileInfo;
|
||||
|
||||
UString _archiveTypeName;
|
||||
|
||||
InfoPanelLine m_InfoLines[kNumInfoLinesMax];
|
||||
|
||||
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 &dirName);
|
||||
void GetPathParts(UStringVector &pathParts);
|
||||
void SetCurrentDirVar();
|
||||
// HRESULT AfterUpdate(CWorkDirTempFile &tempFile, const UStringVector &pathVector);
|
||||
|
||||
public:
|
||||
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
CPlugin(const FString &fileName, CAgent *agent, UString archiveTypeName);
|
||||
~CPlugin();
|
||||
|
||||
void ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex);
|
||||
|
||||
int GetFindData(PluginPanelItem **panelItems,int *itemsNumber,int opMode);
|
||||
void FreeFindData(PluginPanelItem *panelItem,int ItemsNumber);
|
||||
int SetDirectory(const char *aszDir, int opMode);
|
||||
void GetOpenPluginInfo(struct OpenPluginInfo *info);
|
||||
int DeleteFiles(PluginPanelItem *panelItems, 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 *panelItem, int itemsNumber,
|
||||
int move, char *destPath, int opMode);
|
||||
|
||||
NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, const char *_aDestPath, int opMode, bool showBox);
|
||||
|
||||
NFar::NFileOperationReturnCode::EEnum PutFiles(struct PluginPanelItem *panelItems, int itemsNumber,
|
||||
int move, int opMode);
|
||||
HRESULT CreateFolder();
|
||||
|
||||
HRESULT ShowAttributesWindow();
|
||||
|
||||
int ProcessKey(int key, unsigned int controlState);
|
||||
};
|
||||
|
||||
HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems);
|
||||
|
||||
#endif
|
||||
50
CPP/7zip/UI/Far/PluginCommon.cpp
Normal file
50
CPP/7zip/UI/Far/PluginCommon.cpp
Normal 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());
|
||||
}
|
||||
|
||||
*/
|
||||
118
CPP/7zip/UI/Far/PluginDelete.cpp
Normal file
118
CPP/7zip/UI/Far/PluginDelete.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
// PluginDelete.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Messages.h"
|
||||
#include "Plugin.h"
|
||||
#include "UpdateCallbackFar.h"
|
||||
|
||||
using namespace NFar;
|
||||
|
||||
int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
{
|
||||
if (numItems == 0)
|
||||
return FALSE;
|
||||
if (_agent->IsThereReadOnlyArc())
|
||||
{
|
||||
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, ARRAY_SIZE(msgItems), 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));
|
||||
}
|
||||
|
||||
/*
|
||||
CWorkDirTempFile tempFile;
|
||||
if (tempFile.CreateTempFile(m_FileName) != S_OK)
|
||||
return FALSE;
|
||||
*/
|
||||
|
||||
CObjArray<UInt32> indices(numItems);
|
||||
int i;
|
||||
for (i = 0; i < numItems; i++)
|
||||
indices[i] = (UInt32)panelItems[i].UserData;
|
||||
|
||||
/*
|
||||
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;
|
||||
}
|
||||
*/
|
||||
|
||||
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
|
||||
|
||||
/*
|
||||
outArchive->SetFolder(_folder);
|
||||
result = outArchive->DeleteItems(tempFile.OutStream, indices, numItems, updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
result = AfterUpdate(tempFile, pathVector);
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT result;
|
||||
{
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
result = _folder.QueryInterface(IID_IFolderOperations, &folderOperations);
|
||||
if (folderOperations)
|
||||
result = folderOperations->Delete(indices, numItems, updateCallback);
|
||||
else if (result != S_OK)
|
||||
result = E_FAIL;
|
||||
}
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowSysErrorMessage(result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SetCurrentDirVar();
|
||||
return TRUE;
|
||||
}
|
||||
295
CPP/7zip/UI/Far/PluginRead.cpp
Normal file
295
CPP/7zip/UI/Far/PluginRead.cpp
Normal file
@@ -0,0 +1,295 @@
|
||||
// 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 "../Common/ZipRegistry.h"
|
||||
|
||||
#include "ExtractEngine.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
using namespace NFar;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
CExtractCallbackImp *extractCallbackSpec = new CExtractCallbackImp;
|
||||
CMyComPtr<IFolderArchiveExtractCallback> extractCallback(extractCallbackSpec);
|
||||
|
||||
extractCallbackSpec->Init(
|
||||
CP_OEMCP,
|
||||
progressBoxPointer,
|
||||
/*
|
||||
GetDefaultName(m_FileName, m_ArchiverInfo.Extension),
|
||||
m_FileInfo.MTime, 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,
|
||||
BoolToInt(true), // includeAltStreams
|
||||
BoolToInt(false), // replaceAltStreamChars
|
||||
pathMode, overwriteMode,
|
||||
destPath, BoolToInt(false), extractCallback);
|
||||
}
|
||||
}
|
||||
|
||||
NFileOperationReturnCode::EEnum CPlugin::GetFiles(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, char *destPath, int opMode)
|
||||
{
|
||||
return GetFilesReal(panelItems, itemsNumber, move,
|
||||
destPath, opMode, (opMode & OPM_SILENT) == 0);
|
||||
}
|
||||
|
||||
NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, const char *destPathLoc, int opMode, bool showBox)
|
||||
{
|
||||
if (move != 0)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
AString destPath = destPathLoc;
|
||||
UString destPathU = GetUnicodeString(destPath, CP_OEMCP);
|
||||
NName::NormalizeDirPathPrefix(destPathU);
|
||||
destPath = UnicodeStringToMultiByte(destPathU, CP_OEMCP);
|
||||
|
||||
// bool extractSelectedFiles = true;
|
||||
|
||||
NExtract::CInfo extractionInfo;
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kCurPaths;
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kOverwrite;
|
||||
|
||||
bool silent = (opMode & OPM_SILENT) != 0;
|
||||
bool decompressAllItems = false;
|
||||
UString password = Password;
|
||||
bool passwordIsDefined = PasswordIsDefined;
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
const int kPathIndex = 2;
|
||||
|
||||
extractionInfo.Load();
|
||||
|
||||
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::kFullPaths,
|
||||
DIF_GROUP, false, NMessageID::kExtractPathFull, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 7, 0, 0, false,
|
||||
extractionInfo.PathMode == NExtract::NPathMode::kCurPaths,
|
||||
0, false, NMessageID::kExtractPathCurrent, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 8, 0, 0, false,
|
||||
extractionInfo.PathMode == NExtract::NPathMode::kNoPaths,
|
||||
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::kAsk,
|
||||
DIF_GROUP, false, NMessageID::kExtractOwerwriteAsk, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kOverwrite,
|
||||
0, false, NMessageID::kExtractOwerwritePrompt, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kSkip,
|
||||
0, false, NMessageID::kExtractOwerwriteSkip, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 9, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kRename,
|
||||
0, false, NMessageID::kExtractOwerwriteAutoRename, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 10, 0, 0, false,
|
||||
extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kRenameExisting,
|
||||
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 = ARRAY_SIZE(initItems);
|
||||
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;
|
||||
destPathU = GetUnicodeString(destPath, CP_OEMCP);
|
||||
destPathU.Trim();
|
||||
if (destPathU.IsEmpty())
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
destPathU = L"\\";
|
||||
#else
|
||||
FString destPathF = us2fs(destPathU);
|
||||
if (!GetCurrentDir(destPathF))
|
||||
throw 318016;
|
||||
NName::NormalizeDirPathPrefix(destPathF);
|
||||
destPathU = fs2us(destPathF);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (destPathU.Back() == kDirDelimiter)
|
||||
break;
|
||||
}
|
||||
g_StartupInfo.ShowErrorMessage("You must specify directory path");
|
||||
}
|
||||
|
||||
if (dialogItems[kPathModeRadioIndex].Selected)
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kFullPaths;
|
||||
else if (dialogItems[kPathModeRadioIndex + 1].Selected)
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kCurPaths;
|
||||
else if (dialogItems[kPathModeRadioIndex + 2].Selected)
|
||||
extractionInfo.PathMode = NExtract::NPathMode::kNoPaths;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
if (dialogItems[kOverwriteModeRadioIndex].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kAsk;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 1].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kOverwrite;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 2].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kSkip;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 3].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kRename;
|
||||
else if (dialogItems[kOverwriteModeRadioIndex + 4].Selected)
|
||||
extractionInfo.OverwriteMode = NExtract::NOverwriteMode::kRenameExisting;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
if (dialogItems[kFilesModeIndex].Selected)
|
||||
decompressAllItems = false;
|
||||
else if (dialogItems[kFilesModeIndex + 1].Selected)
|
||||
decompressAllItems = true;
|
||||
else
|
||||
throw 31806;
|
||||
|
||||
extractionInfo.Save();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
CreateComplexDir(us2fs(destPathU));
|
||||
|
||||
/*
|
||||
vector<int> realIndices;
|
||||
if (!decompressAllItems)
|
||||
GetRealIndexes(panelItems, itemsNumber, realIndices);
|
||||
*/
|
||||
CObjArray<UInt32> indices(itemsNumber);
|
||||
for (int i = 0; i < itemsNumber; i++)
|
||||
indices[i] = (UInt32)panelItems[i].UserData;
|
||||
|
||||
HRESULT result = ExtractFiles(decompressAllItems, indices, itemsNumber,
|
||||
!showBox, extractionInfo.PathMode, extractionInfo.OverwriteMode,
|
||||
destPathU,
|
||||
passwordIsDefined, password);
|
||||
// HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox,
|
||||
// extractionInfo, destPath, passwordIsDefined, password);
|
||||
if (result != S_OK)
|
||||
{
|
||||
if (result == E_ABORT)
|
||||
return NFileOperationReturnCode::kInterruptedByUser;
|
||||
ShowSysErrorMessage(result);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
// if (move != 0)
|
||||
// {
|
||||
// if (DeleteFiles(panelItems, itemsNumber, opMode) == FALSE)
|
||||
// return NFileOperationReturnCode::kError;
|
||||
// }
|
||||
return NFileOperationReturnCode::kSuccess;
|
||||
}
|
||||
818
CPP/7zip/UI/Far/PluginWrite.cpp
Normal file
818
CPP/7zip/UI/Far/PluginWrite.cpp
Normal file
@@ -0,0 +1,818 @@
|
||||
// PluginWrite.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/Wildcard.h"
|
||||
|
||||
#include "../../../Windows/FileName.h"
|
||||
#include "../../../Windows/FileFind.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
#include "ProgressBox.h"
|
||||
#include "Messages.h"
|
||||
#include "UpdateCallbackFar.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
using namespace NFar;
|
||||
|
||||
using namespace NUpdateArchive;
|
||||
|
||||
static const char *kHelpTopic = "Update";
|
||||
|
||||
static const char *kArchiveHistoryKeyName = "7-ZipArcName";
|
||||
|
||||
static const 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_VECTOR (i, realNames)
|
||||
names.Add(realNames[i]);
|
||||
RINOK(setProperties->SetProperties(&names.Front(), &value, names.Size()));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT CPlugin::AfterUpdate(CWorkDirTempFile &tempFile, const UStringVector &pathVector)
|
||||
{
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->Close();
|
||||
|
||||
RINOK(tempFile.MoveToOriginal(true));
|
||||
|
||||
RINOK(m_ArchiveHandler->ReOpen(NULL)); // check it
|
||||
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
FOR_VECTOR (i, pathVector)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(pathVector[i], &newFolder);
|
||||
if (!newFolder)
|
||||
break;
|
||||
_folder = newFolder;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
struct PluginPanelItem *panelItems, int numItems,
|
||||
int moveMode, int opMode)
|
||||
{
|
||||
/*
|
||||
if (moveMode != 0)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
*/
|
||||
|
||||
if (numItems == 0)
|
||||
return NFileOperationReturnCode::kError;
|
||||
|
||||
if (_agent->IsThereReadOnlyArc())
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
const int kYSize = 14;
|
||||
const int kXMid = 38;
|
||||
|
||||
NCompression::CInfo compressionInfo;
|
||||
compressionInfo.Load();
|
||||
|
||||
int methodIndex = 0;
|
||||
int i;
|
||||
for (i = ARRAY_SIZE(g_MethodMap) - 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::kUpdateMethod_Store, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 4, 0, 0, methodIndex == 1, methodIndex == 1, 0, false, NMessageID::kUpdateMethod_Fastest, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 5, 0, 0, methodIndex == 2, methodIndex == 2, 0, false, NMessageID::kUpdateMethod_Fast, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 6, 0, 0, methodIndex == 3, methodIndex == 3, 0, false, NMessageID::kUpdateMethod_Normal, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 7, 0, 0, methodIndex == 4, methodIndex == 4, 0, false, NMessageID::kUpdateMethod_Maximum, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 8, 0, 0, methodIndex == 5, methodIndex == 5, 0, false, NMessageID::kUpdateMethod_Ultra, 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::kUpdateMode_Add, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 4, 0, 0, false, false, 0, false, NMessageID::kUpdateMode_Update, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false, false, 0, false, NMessageID::kUpdateMode_Fresh, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, false, 0, false, NMessageID::kUpdateMode_Sync, 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 = ARRAY_SIZE(initItems);
|
||||
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 < ARRAY_SIZE(g_MethodMap); i++)
|
||||
if (dialogItems[kMethodRadioIndex + i].Selected)
|
||||
compressionInfo.Level = g_MethodMap[i];
|
||||
|
||||
const CActionSet *actionSet;
|
||||
|
||||
if (dialogItems[kModeRadioIndex ].Selected) actionSet = &k_ActionSet_Add;
|
||||
else if (dialogItems[kModeRadioIndex + 1].Selected) actionSet = &k_ActionSet_Update;
|
||||
else if (dialogItems[kModeRadioIndex + 2].Selected) actionSet = &k_ActionSet_Fresh;
|
||||
else if (dialogItems[kModeRadioIndex + 3].Selected) actionSet = &k_ActionSet_Sync;
|
||||
else throw 51751;
|
||||
|
||||
compressionInfo.Save();
|
||||
|
||||
CWorkDirTempFile tempFile;;
|
||||
if (tempFile.CreateTempFile(m_FileName) != S_OK)
|
||||
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));
|
||||
}
|
||||
|
||||
UStringVector pathVector;
|
||||
GetPathParts(pathVector);
|
||||
|
||||
UStringVector fileNames;
|
||||
fileNames.ClearAndReserve(numItems);
|
||||
for (i = 0; i < numItems; i++)
|
||||
fileNames.AddInReserved(MultiByteToUnicodeString(panelItems[i].FindData.cFileName, CP_OEMCP));
|
||||
CObjArray<const wchar_t *> fileNamePointers(numItems);
|
||||
for (i = 0; i < numItems; i++)
|
||||
fileNamePointers[i] = 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;
|
||||
}
|
||||
|
||||
/*
|
||||
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
|
||||
*/
|
||||
|
||||
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
|
||||
|
||||
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
|
||||
/*
|
||||
outArchive->SetFolder(_folder);
|
||||
outArchive->SetFiles(L"", fileNamePointers, numItems);
|
||||
// FStringVector requestedPaths;
|
||||
// FStringVector processedPaths;
|
||||
result = outArchive->DoOperation2(
|
||||
// &requestedPaths, &processedPaths,
|
||||
NULL, NULL,
|
||||
tempFile.OutStream, actionSetByte, NULL, updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
result = AfterUpdate(tempFile, pathVector);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
result = _agent->SetFiles(L"", fileNamePointers, numItems);
|
||||
if (result == S_OK)
|
||||
{
|
||||
CAgentFolder *agentFolder = NULL;
|
||||
{
|
||||
CMyComPtr<IArchiveFolderInternal> afi;
|
||||
_folder.QueryInterface(IID_IArchiveFolderInternal, &afi);
|
||||
if (afi)
|
||||
afi->GetAgentFolder(&agentFolder);
|
||||
}
|
||||
if (agentFolder)
|
||||
result = agentFolder->CommonUpdateOperation(AGENT_OP_Uni,
|
||||
(moveMode != 0), NULL, actionSet, NULL, 0, updateCallback);
|
||||
else
|
||||
result = E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowSysErrorMessage(result);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
return NFileOperationReturnCode::kSuccess;
|
||||
}
|
||||
|
||||
namespace NPathType
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kLocal,
|
||||
kUNC
|
||||
};
|
||||
EEnum GetPathType(const UString &path);
|
||||
}
|
||||
|
||||
struct CParsedPath
|
||||
{
|
||||
UString Prefix; // Disk or UNC with slash
|
||||
UStringVector PathParts;
|
||||
void ParsePath(const UString &path);
|
||||
UString MergePath() const;
|
||||
};
|
||||
|
||||
static const wchar_t kDirDelimiter = WCHAR_PATH_SEPARATOR;
|
||||
static const wchar_t kDiskDelimiter = L':';
|
||||
|
||||
namespace NPathType
|
||||
{
|
||||
EEnum GetPathType(const UString &path)
|
||||
{
|
||||
if (path.Len() <= 2)
|
||||
return kLocal;
|
||||
if (path[0] == kDirDelimiter && path[1] == kDirDelimiter)
|
||||
return kUNC;
|
||||
return kLocal;
|
||||
}
|
||||
}
|
||||
|
||||
void CParsedPath::ParsePath(const UString &path)
|
||||
{
|
||||
int curPos = 0;
|
||||
switch (NPathType::GetPathType(path))
|
||||
{
|
||||
case NPathType::kLocal:
|
||||
{
|
||||
int posDiskDelimiter = path.Find(kDiskDelimiter);
|
||||
if (posDiskDelimiter >= 0)
|
||||
{
|
||||
curPos = posDiskDelimiter + 1;
|
||||
if ((int)path.Len() > curPos)
|
||||
if (path[curPos] == kDirDelimiter)
|
||||
curPos++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NPathType::kUNC:
|
||||
{
|
||||
// the bug was fixed:
|
||||
curPos = path.Find(kDirDelimiter, 2);
|
||||
if (curPos < 0)
|
||||
curPos = path.Len();
|
||||
else
|
||||
curPos++;
|
||||
}
|
||||
}
|
||||
Prefix = path.Left(curPos);
|
||||
SplitPathToParts(path.Ptr(curPos), PathParts);
|
||||
}
|
||||
|
||||
UString CParsedPath::MergePath() const
|
||||
{
|
||||
UString result = Prefix;
|
||||
FOR_VECTOR (i, PathParts)
|
||||
{
|
||||
if (i != 0)
|
||||
result += kDirDelimiter;
|
||||
result += PathParts[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void SetArcName(UString &arcName, const CArcInfoEx &arcInfo)
|
||||
{
|
||||
if (!arcInfo.Flags_KeepName())
|
||||
{
|
||||
int dotPos = arcName.ReverseFind_Dot();
|
||||
int slashPos = arcName.ReverseFind_PathSepar();
|
||||
if (dotPos > slashPos + 1)
|
||||
arcName.DeleteFrom(dotPos);
|
||||
}
|
||||
arcName += L'.';
|
||||
arcName += arcInfo.GetMainExt();
|
||||
}
|
||||
|
||||
HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
{
|
||||
if (pluginPanelItems.Size() == 0)
|
||||
return E_FAIL;
|
||||
|
||||
UStringVector fileNames;
|
||||
{
|
||||
FOR_VECTOR (i, pluginPanelItems)
|
||||
{
|
||||
const PluginPanelItem &panelItem = pluginPanelItems[i];
|
||||
if (strcmp(panelItem.FindData.cFileName, "..") == 0 &&
|
||||
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
|
||||
return E_FAIL;
|
||||
if (strcmp(panelItem.FindData.cFileName, ".") == 0 &&
|
||||
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
|
||||
return E_FAIL;
|
||||
FString fullPath;
|
||||
FString fileNameUnicode = us2fs(MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP));
|
||||
if (!MyGetFullPathName(fileNameUnicode, fullPath))
|
||||
return E_FAIL;
|
||||
fileNames.Add(fs2us(fullPath));
|
||||
}
|
||||
}
|
||||
|
||||
NCompression::CInfo compressionInfo;
|
||||
compressionInfo.Load();
|
||||
|
||||
int archiverIndex = -1;
|
||||
|
||||
/*
|
||||
CCodecs *codecs = new CCodecs;
|
||||
CMyComPtr<ICompressCodecsInfo> compressCodecsInfo = codecs;
|
||||
if (codecs->Load() != S_OK)
|
||||
throw "Can't load 7-Zip codecs";
|
||||
*/
|
||||
|
||||
if (LoadGlobalCodecs() != S_OK)
|
||||
throw "Can't load 7-Zip codecs";
|
||||
|
||||
CCodecs *codecs = g_CodecsObj;
|
||||
|
||||
{
|
||||
FOR_VECTOR (i, codecs->Formats)
|
||||
{
|
||||
const CArcInfoEx &arcInfo = codecs->Formats[i];
|
||||
if (arcInfo.UpdateEnabled)
|
||||
{
|
||||
if (archiverIndex == -1)
|
||||
archiverIndex = i;
|
||||
if (MyStringCompareNoCase(arcInfo.Name, compressionInfo.ArcType) == 0)
|
||||
archiverIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (archiverIndex < 0)
|
||||
throw "there is no output handler";
|
||||
|
||||
UString resultPath;
|
||||
{
|
||||
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 arcName = archiveNameSrc;
|
||||
|
||||
int prevFormat = archiverIndex;
|
||||
SetArcName(arcName, codecs->Formats[archiverIndex]);
|
||||
|
||||
const CActionSet *actionSet = &k_ActionSet_Add;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
AString archiveNameA = UnicodeStringToMultiByte(arcName, CP_OEMCP);
|
||||
const int kYSize = 16;
|
||||
const int kXMid = 38;
|
||||
|
||||
const int kArchiveNameIndex = 2;
|
||||
const int kMethodRadioIndex = kArchiveNameIndex + 2;
|
||||
const int kModeRadioIndex = kMethodRadioIndex + 7;
|
||||
|
||||
|
||||
char updateAddToArchiveString[512];
|
||||
{
|
||||
const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
|
||||
const AString s = UnicodeStringToMultiByte(arcInfo.Name, CP_OEMCP);
|
||||
sprintf(updateAddToArchiveString,
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s);
|
||||
}
|
||||
|
||||
int methodIndex = 0;
|
||||
int i;
|
||||
for (i = ARRAY_SIZE(g_MethodMap) - 1; i >= 0; i--)
|
||||
if (compressionInfo.Level >= g_MethodMap[i])
|
||||
{
|
||||
methodIndex = i;
|
||||
break;
|
||||
}
|
||||
|
||||
const 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, arcName, 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::kUpdateMethod_Store, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 6, 0, 0, false, methodIndex == 1, 0, false, NMessageID::kUpdateMethod_Fastest, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 7, 0, 0, false, methodIndex == 2, 0, false, NMessageID::kUpdateMethod_Fast, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 8, 0, 0, false, methodIndex == 3, 0, false, NMessageID::kUpdateMethod_Normal, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6, 9, 0, 0, false, methodIndex == 4, 0, false, NMessageID::kUpdateMethod_Maximum, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, 6,10, 0, 0, false, methodIndex == 5, 0, false, NMessageID::kUpdateMethod_Ultra, 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 == &k_ActionSet_Add, DIF_GROUP, false, NMessageID::kUpdateMode_Add, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, actionSet == &k_ActionSet_Update, 0, false, NMessageID::kUpdateMode_Update, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false, actionSet == &k_ActionSet_Fresh, 0, false, NMessageID::kUpdateMode_Fresh, NULL, NULL },
|
||||
{ DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false, actionSet == &k_ActionSet_Sync, 0, false, NMessageID::kUpdateMode_Sync, 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 = ARRAY_SIZE(initItems);
|
||||
|
||||
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();
|
||||
MultiByteToUnicodeString2(arcName, archiveNameA, CP_OEMCP);
|
||||
|
||||
compressionInfo.Level = g_MethodMap[0];
|
||||
for (i = 0; i < ARRAY_SIZE(g_MethodMap); i++)
|
||||
if (dialogItems[kMethodRadioIndex + i].Selected)
|
||||
compressionInfo.Level = g_MethodMap[i];
|
||||
|
||||
if (dialogItems[kModeRadioIndex ].Selected) actionSet = &k_ActionSet_Add;
|
||||
else if (dialogItems[kModeRadioIndex + 1].Selected) actionSet = &k_ActionSet_Update;
|
||||
else if (dialogItems[kModeRadioIndex + 2].Selected) actionSet = &k_ActionSet_Fresh;
|
||||
else if (dialogItems[kModeRadioIndex + 3].Selected) actionSet = &k_ActionSet_Sync;
|
||||
else throw 51751;
|
||||
|
||||
if (askCode == kSelectarchiverButtonIndex)
|
||||
{
|
||||
CIntVector indices;
|
||||
CSysStringVector archiverNames;
|
||||
FOR_VECTOR (k, codecs->Formats)
|
||||
{
|
||||
const CArcInfoEx &arc = codecs->Formats[k];
|
||||
if (arc.UpdateEnabled)
|
||||
{
|
||||
indices.Add(k);
|
||||
archiverNames.Add(GetSystemString(arc.Name, CP_OEMCP));
|
||||
}
|
||||
}
|
||||
|
||||
int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT,
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdateSelectArchiverMenuTitle),
|
||||
NULL, archiverNames, archiverIndex);
|
||||
if (index >= 0)
|
||||
{
|
||||
const CArcInfoEx &prevArchiverInfo = codecs->Formats[prevFormat];
|
||||
if (prevArchiverInfo.Flags_KeepName())
|
||||
{
|
||||
const UString &prevExtension = prevArchiverInfo.GetMainExt();
|
||||
const unsigned prevExtensionLen = prevExtension.Len();
|
||||
if (arcName.Len() >= prevExtensionLen &&
|
||||
MyStringCompareNoCase(arcName.RightPtr(prevExtensionLen), prevExtension) == 0)
|
||||
{
|
||||
int pos = arcName.Len() - prevExtensionLen;
|
||||
if (pos > 2)
|
||||
{
|
||||
if (arcName[pos - 1] == '.')
|
||||
arcName.DeleteFrom(pos - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
archiverIndex = indices[index];
|
||||
const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
|
||||
prevFormat = archiverIndex;
|
||||
|
||||
if (arcInfo.Flags_KeepName())
|
||||
arcName = archiveNameSrc;
|
||||
SetArcName(arcName, arcInfo);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (askCode != kOkButtonIndex)
|
||||
return E_ABORT;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
const CArcInfoEx &archiverInfoFinal = codecs->Formats[archiverIndex];
|
||||
compressionInfo.ArcType = archiverInfoFinal.Name;
|
||||
compressionInfo.Save();
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
workDirInfo.Load();
|
||||
|
||||
FString fullArcName;
|
||||
if (!MyGetFullPathName(us2fs(arcName), fullArcName))
|
||||
return E_FAIL;
|
||||
|
||||
CWorkDirTempFile tempFile;
|
||||
RINOK(tempFile.CreateTempFile(fullArcName));
|
||||
|
||||
CScreenRestorer screenRestorer;
|
||||
CProgressBox progressBox;
|
||||
CProgressBox *progressBoxPointer = NULL;
|
||||
|
||||
screenRestorer.Save();
|
||||
|
||||
progressBoxPointer = &progressBox;
|
||||
progressBox.Init(
|
||||
// g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdating));
|
||||
|
||||
|
||||
NFind::CFileInfo fileInfo;
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
|
||||
CMyComPtr<IInFolderArchive> archiveHandler;
|
||||
if (fileInfo.Find(fullArcName))
|
||||
{
|
||||
if (fileInfo.IsDir())
|
||||
throw "There is Directory with such name";
|
||||
|
||||
CAgent *agentSpec = new CAgent;
|
||||
archiveHandler = agentSpec;
|
||||
// CLSID realClassID;
|
||||
CMyComBSTR archiveType;
|
||||
RINOK(agentSpec->Open(NULL,
|
||||
GetUnicodeString(fullArcName, CP_OEMCP), UString(),
|
||||
// &realClassID,
|
||||
&archiveType,
|
||||
NULL));
|
||||
|
||||
if (MyStringCompareNoCase(archiverInfoFinal.Name, (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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
CObjArray<const wchar_t *> fileNamePointers(fileNames.Size());
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < fileNames.Size(); i++)
|
||||
fileNamePointers[i] = fileNames[i];
|
||||
|
||||
outArchive->SetFolder(NULL);
|
||||
outArchive->SetFiles(L"", fileNamePointers, fileNames.Size());
|
||||
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
|
||||
|
||||
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(/* archiveHandler, */ progressBoxPointer);
|
||||
|
||||
|
||||
RINOK(SetOutProperties(outArchive, compressionInfo.Level));
|
||||
|
||||
// FStringVector requestedPaths;
|
||||
// FStringVector processedPaths;
|
||||
HRESULT result = outArchive->DoOperation(
|
||||
// &requestedPaths, &processedPaths,
|
||||
NULL, NULL,
|
||||
codecs, archiverIndex,
|
||||
tempFile.OutStream, actionSetByte,
|
||||
NULL, updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowSysErrorMessage(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (archiveHandler)
|
||||
{
|
||||
archiveHandler->Close();
|
||||
}
|
||||
|
||||
result = tempFile.MoveToOriginal(archiveHandler != NULL);
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowSysErrorMessage(result);
|
||||
return result;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static const char *k_CreateFolder_History = "NewFolder"; // we use default FAR folder name
|
||||
|
||||
HRESULT CPlugin::CreateFolder()
|
||||
{
|
||||
if (_agent->IsThereReadOnlyArc())
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
UString destPathU;
|
||||
{
|
||||
const int kXSize = 60;
|
||||
const int kYSize = 8;
|
||||
const int kPathIndex = 2;
|
||||
|
||||
AString destPath = "New Folder";
|
||||
|
||||
const struct CInitDialogItem initItems[]={
|
||||
{ DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false,
|
||||
-1, "Create Folder", NULL },
|
||||
|
||||
{ DI_TEXT, 5, 2, 0, 0, false, false, 0, false, -1, "Folder name:", NULL },
|
||||
|
||||
{ DI_EDIT, 5, 3, kXSize - 6, 3, true, false, DIF_HISTORY, false, -1, destPath, k_CreateFolder_History },
|
||||
|
||||
{ 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 = ARRAY_SIZE(initItems);
|
||||
const int kOkButtonIndex = kNumDialogItems - 2;
|
||||
|
||||
FarDialogItem dialogItems[kNumDialogItems];
|
||||
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems);
|
||||
for (;;)
|
||||
{
|
||||
int askCode = g_StartupInfo.ShowDialog(kXSize, kYSize,
|
||||
NULL, // kHelpTopic
|
||||
dialogItems, kNumDialogItems);
|
||||
if (askCode != kOkButtonIndex)
|
||||
return E_ABORT;
|
||||
destPath = dialogItems[kPathIndex].Data;
|
||||
destPathU = GetUnicodeString(destPath, CP_OEMCP);
|
||||
destPathU.Trim();
|
||||
if (!destPathU.IsEmpty())
|
||||
break;
|
||||
g_StartupInfo.ShowErrorMessage("You must specify folder name");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
|
||||
|
||||
HRESULT result;
|
||||
{
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
result = _folder.QueryInterface(IID_IFolderOperations, &folderOperations);
|
||||
if (folderOperations)
|
||||
result = folderOperations->CreateFolder(destPathU, updateCallback);
|
||||
else if (result != S_OK)
|
||||
result = E_FAIL;
|
||||
}
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowSysErrorMessage(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
g_StartupInfo.Control(this, FCTL_UPDATEPANEL, (void *)1);
|
||||
g_StartupInfo.Control(this, FCTL_REDRAWPANEL, NULL);
|
||||
|
||||
PanelInfo panelInfo;
|
||||
|
||||
if (g_StartupInfo.ControlGetActivePanelInfo(panelInfo))
|
||||
{
|
||||
AString destPath = GetOemString(destPathU);
|
||||
|
||||
for (int i = 0; i < panelInfo.ItemsNumber; i++)
|
||||
{
|
||||
const PluginPanelItem &pi = panelInfo.PanelItems[i];
|
||||
if (strcmp(destPath, pi.FindData.cFileName) == 0)
|
||||
{
|
||||
PanelRedrawInfo panelRedrawInfo;
|
||||
panelRedrawInfo.CurrentItem = i;
|
||||
panelRedrawInfo.TopPanelItem = 0;
|
||||
g_StartupInfo.Control(this, FCTL_REDRAWPANEL, &panelRedrawInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetCurrentDirVar();
|
||||
return S_OK;
|
||||
}
|
||||
306
CPP/7zip/UI/Far/ProgressBox.cpp
Normal file
306
CPP/7zip/UI/Far/ProgressBox.cpp
Normal file
@@ -0,0 +1,306 @@
|
||||
// ProgressBox.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
#include "ProgressBox.h"
|
||||
|
||||
void CPercentPrinterState::ClearCurState()
|
||||
{
|
||||
Completed = 0;
|
||||
Total = ((UInt64)(Int64)-1);
|
||||
Files = 0;
|
||||
FilesTotal = 0;
|
||||
Command.Empty();
|
||||
FileName.Empty();
|
||||
}
|
||||
|
||||
void CProgressBox::Init(const AString &title)
|
||||
{
|
||||
_title = title;
|
||||
_wasPrinted = false;
|
||||
StartTick = GetTickCount();
|
||||
_prevTick = StartTick;
|
||||
_prevElapsedSec = 0;
|
||||
}
|
||||
|
||||
static unsigned GetPower32(UInt32 val)
|
||||
{
|
||||
const unsigned kStart = 32;
|
||||
UInt32 mask = ((UInt32)1 << (kStart - 1));
|
||||
for (unsigned i = kStart;; i--)
|
||||
{
|
||||
if (i == 0 || (val & mask) != 0)
|
||||
return i;
|
||||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned GetPower64(UInt64 val)
|
||||
{
|
||||
UInt32 high = (UInt32)(val >> 32);
|
||||
if (high == 0)
|
||||
return GetPower32((UInt32)val);
|
||||
return GetPower32(high) + 32;
|
||||
}
|
||||
|
||||
static UInt64 MyMultAndDiv(UInt64 mult1, UInt64 mult2, UInt64 divider)
|
||||
{
|
||||
unsigned pow1 = GetPower64(mult1);
|
||||
unsigned pow2 = GetPower64(mult2);
|
||||
while (pow1 + pow2 > 64)
|
||||
{
|
||||
if (pow1 > pow2) { pow1--; mult1 >>= 1; }
|
||||
else { pow2--; mult2 >>= 1; }
|
||||
divider >>= 1;
|
||||
}
|
||||
UInt64 res = mult1 * mult2;
|
||||
if (divider != 0)
|
||||
res /= divider;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define UINT_TO_STR_2(val) { s[0] = (char)('0' + (val) / 10); s[1] = (char)('0' + (val) % 10); s += 2; }
|
||||
|
||||
static void GetTimeString(UInt64 timeValue, char *s)
|
||||
{
|
||||
UInt64 hours = timeValue / 3600;
|
||||
UInt32 seconds = (UInt32)(timeValue - hours * 3600);
|
||||
UInt32 minutes = seconds / 60;
|
||||
seconds %= 60;
|
||||
if (hours > 99)
|
||||
{
|
||||
ConvertUInt64ToString(hours, s);
|
||||
for (; *s != 0; s++);
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt32 hours32 = (UInt32)hours;
|
||||
UINT_TO_STR_2(hours32);
|
||||
}
|
||||
*s++ = ':'; UINT_TO_STR_2(minutes);
|
||||
*s++ = ':'; UINT_TO_STR_2(seconds);
|
||||
*s = 0;
|
||||
}
|
||||
|
||||
void CProgressBox::ReduceString(const UString &src, AString &dest)
|
||||
{
|
||||
UnicodeStringToMultiByte2(dest, src, CP_OEMCP);
|
||||
|
||||
if (dest.Len() <= MaxLen)
|
||||
return;
|
||||
unsigned len = FileName.Len();
|
||||
for (; len != 0;)
|
||||
{
|
||||
unsigned delta = len / 8;
|
||||
if (delta == 0)
|
||||
delta = 1;
|
||||
len -= delta;
|
||||
_tempU = FileName;
|
||||
_tempU.Delete(len / 2, FileName.Len() - len);
|
||||
_tempU.Insert(len / 2, L" . ");
|
||||
UnicodeStringToMultiByte2(dest, _tempU, CP_OEMCP);
|
||||
if (dest.Len() <= MaxLen)
|
||||
return;
|
||||
}
|
||||
dest.Empty();
|
||||
}
|
||||
|
||||
static void Print_UInt64_and_String(AString &s, UInt64 val, const char *name)
|
||||
{
|
||||
char temp[32];
|
||||
ConvertUInt64ToString(val, temp);
|
||||
s += temp;
|
||||
s.Add_Space();
|
||||
s += name;
|
||||
}
|
||||
|
||||
|
||||
static void PrintSize_bytes_Smart(AString &s, UInt64 val)
|
||||
{
|
||||
// Print_UInt64_and_String(s, val, "bytes");
|
||||
{
|
||||
char temp[32];
|
||||
ConvertUInt64ToString(val, temp);
|
||||
s += temp;
|
||||
}
|
||||
|
||||
if (val == 0)
|
||||
return;
|
||||
|
||||
unsigned numBits = 10;
|
||||
char c = 'K';
|
||||
char temp[4] = { 'K', 'i', 'B', 0 };
|
||||
if (val >= ((UInt64)10 << 30)) { numBits = 30; c = 'G'; }
|
||||
else if (val >= ((UInt64)10 << 20)) { numBits = 20; c = 'M'; }
|
||||
temp[0] = c;
|
||||
s += " (";
|
||||
Print_UInt64_and_String(s, ((val + ((UInt64)1 << numBits) - 1) >> numBits), temp);
|
||||
s += ')';
|
||||
}
|
||||
|
||||
|
||||
static const unsigned kPercentsSize = 4;
|
||||
|
||||
void CProgressBox::Print()
|
||||
{
|
||||
DWORD tick = GetTickCount();
|
||||
DWORD elapsedTicks = tick - StartTick;
|
||||
DWORD elapsedSec = elapsedTicks / 1000;
|
||||
|
||||
if (_wasPrinted)
|
||||
{
|
||||
if (elapsedSec == _prevElapsedSec)
|
||||
{
|
||||
if ((UInt32)(tick - _prevTick) < _tickStep)
|
||||
return;
|
||||
if (_printedState.IsEqualTo((const CPercentPrinterState &)*this))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UInt64 cur = Completed;
|
||||
UInt64 total = Total;
|
||||
|
||||
if (!UseBytesForPercents)
|
||||
{
|
||||
cur = Files;
|
||||
total = FilesTotal;
|
||||
}
|
||||
|
||||
{
|
||||
_timeStr.Empty();
|
||||
_timeStr = "Elapsed time: ";
|
||||
char s[40];
|
||||
GetTimeString(elapsedSec, s);
|
||||
_timeStr += s;
|
||||
|
||||
if (cur != 0)
|
||||
{
|
||||
UInt64 remainingTime = 0;
|
||||
if (cur < total)
|
||||
remainingTime = MyMultAndDiv(elapsedTicks, total - cur, cur);
|
||||
UInt64 remainingSec = remainingTime / 1000;
|
||||
_timeStr += " Remaining time: ";
|
||||
|
||||
GetTimeString(remainingSec, s);
|
||||
_timeStr += s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
_perc.Empty();
|
||||
char s[32];
|
||||
unsigned size;
|
||||
{
|
||||
UInt64 val = 0;
|
||||
if (total != (UInt64)(Int64)-1 && total != 0)
|
||||
val = cur * 100 / Total;
|
||||
|
||||
ConvertUInt64ToString(val, s);
|
||||
size = (unsigned)strlen(s);
|
||||
s[size++] = '%';
|
||||
s[size] = 0;
|
||||
}
|
||||
|
||||
unsigned len = size;
|
||||
while (len < kPercentsSize)
|
||||
len = kPercentsSize;
|
||||
len++;
|
||||
|
||||
if (len < MaxLen)
|
||||
{
|
||||
unsigned numChars = MaxLen - len;
|
||||
unsigned filled = 0;
|
||||
if (total != (UInt64)(Int64)-1 && total != 0)
|
||||
filled = (unsigned)(cur * numChars / total);
|
||||
unsigned i = 0;
|
||||
if (filled < numChars)
|
||||
{
|
||||
for (i = 0; i < filled; i++)
|
||||
_perc += '=';
|
||||
}
|
||||
for (; i < numChars; i++)
|
||||
_perc += '.';
|
||||
}
|
||||
|
||||
_perc.Add_Space();
|
||||
while (size < kPercentsSize)
|
||||
{
|
||||
_perc.Add_Space();
|
||||
size++;
|
||||
}
|
||||
_perc += s;
|
||||
}
|
||||
|
||||
_files.Empty();
|
||||
if (Files != 0 || FilesTotal != 0)
|
||||
{
|
||||
_files += "Files: ";
|
||||
char s[32];
|
||||
// if (Files != 0)
|
||||
{
|
||||
ConvertUInt64ToString(Files, s);
|
||||
_files += s;
|
||||
}
|
||||
if (FilesTotal != 0)
|
||||
{
|
||||
_files += " / ";
|
||||
ConvertUInt64ToString(FilesTotal, s);
|
||||
_files += s;
|
||||
}
|
||||
}
|
||||
|
||||
_sizesStr.Empty();
|
||||
if (Total != 0)
|
||||
{
|
||||
_sizesStr += "Size: ";
|
||||
PrintSize_bytes_Smart(_sizesStr, Completed);
|
||||
if (Total != 0 && Total != (UInt64)(Int64)-1)
|
||||
{
|
||||
_sizesStr += " / ";
|
||||
PrintSize_bytes_Smart(_sizesStr, Total);
|
||||
}
|
||||
}
|
||||
|
||||
_name1.Empty();
|
||||
_name2.Empty();
|
||||
|
||||
if (!FileName.IsEmpty())
|
||||
{
|
||||
_name1U.Empty();
|
||||
_name2U.Empty();
|
||||
|
||||
/*
|
||||
if (_isDir)
|
||||
s1 = _filePath;
|
||||
else
|
||||
*/
|
||||
{
|
||||
int slashPos = FileName.ReverseFind_PathSepar();
|
||||
if (slashPos >= 0)
|
||||
{
|
||||
_name1U.SetFrom(FileName, slashPos + 1);
|
||||
_name2U = FileName.Ptr(slashPos + 1);
|
||||
}
|
||||
else
|
||||
_name2U = FileName;
|
||||
}
|
||||
ReduceString(_name1U, _name1);
|
||||
ReduceString(_name2U, _name2);
|
||||
}
|
||||
|
||||
{
|
||||
const char *strings[] = { _title, _timeStr, _files, _sizesStr, Command, _name1, _name2, _perc };
|
||||
NFar::g_StartupInfo.ShowMessage(FMSG_LEFTALIGN, NULL, strings, ARRAY_SIZE(strings), 0);
|
||||
}
|
||||
|
||||
_wasPrinted = true;
|
||||
_printedState = *this;
|
||||
_prevTick = tick;
|
||||
_prevElapsedSec = elapsedSec;
|
||||
}
|
||||
83
CPP/7zip/UI/Far/ProgressBox.h
Normal file
83
CPP/7zip/UI/Far/ProgressBox.h
Normal file
@@ -0,0 +1,83 @@
|
||||
// ProgressBox.h
|
||||
|
||||
#ifndef __PROGRESS_BOX_H
|
||||
#define __PROGRESS_BOX_H
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
#include "../../../Common/MyTypes.h"
|
||||
|
||||
struct CPercentPrinterState
|
||||
{
|
||||
UInt64 Completed;
|
||||
UInt64 Total;
|
||||
|
||||
UInt64 Files;
|
||||
UInt64 FilesTotal;
|
||||
|
||||
AString Command;
|
||||
UString FileName;
|
||||
|
||||
void ClearCurState();
|
||||
|
||||
bool IsEqualTo(const CPercentPrinterState &s) const
|
||||
{
|
||||
return
|
||||
Completed == s.Completed
|
||||
&& Total == s.Total
|
||||
&& Files == s.Files
|
||||
&& FilesTotal == s.FilesTotal
|
||||
&& Command == s.Command
|
||||
&& FileName == s.FileName;
|
||||
}
|
||||
|
||||
CPercentPrinterState():
|
||||
Completed(0),
|
||||
Total((UInt64)(Int64)-1),
|
||||
Files(0),
|
||||
FilesTotal(0)
|
||||
{}
|
||||
};
|
||||
|
||||
class CProgressBox: public CPercentPrinterState
|
||||
{
|
||||
UInt32 _tickStep;
|
||||
DWORD _prevTick;
|
||||
DWORD _prevElapsedSec;
|
||||
|
||||
bool _wasPrinted;
|
||||
|
||||
UString _tempU;
|
||||
UString _name1U;
|
||||
UString _name2U;
|
||||
|
||||
CPercentPrinterState _printedState;
|
||||
|
||||
AString _title;
|
||||
|
||||
AString _timeStr;
|
||||
AString _files;
|
||||
AString _sizesStr;
|
||||
AString _name1;
|
||||
AString _name2;
|
||||
AString _perc;
|
||||
|
||||
void ReduceString(const UString &src, AString &dest);
|
||||
|
||||
public:
|
||||
DWORD StartTick;
|
||||
bool UseBytesForPercents;
|
||||
unsigned MaxLen;
|
||||
|
||||
CProgressBox(UInt32 tickStep = 200):
|
||||
_tickStep(tickStep),
|
||||
_prevTick(0),
|
||||
StartTick(0),
|
||||
UseBytesForPercents(true),
|
||||
MaxLen(60)
|
||||
{}
|
||||
|
||||
void Init(const AString &title);
|
||||
void Print();
|
||||
};
|
||||
|
||||
#endif
|
||||
3
CPP/7zip/UI/Far/StdAfx.cpp
Normal file
3
CPP/7zip/UI/Far/StdAfx.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
8
CPP/7zip/UI/Far/StdAfx.h
Normal file
8
CPP/7zip/UI/Far/StdAfx.h
Normal file
@@ -0,0 +1,8 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#endif
|
||||
212
CPP/7zip/UI/Far/UpdateCallbackFar.cpp
Normal file
212
CPP/7zip/UI/Far/UpdateCallbackFar.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
// UpdateCallbackFar.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
#endif
|
||||
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
#include "UpdateCallbackFar.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
|
||||
#else
|
||||
#define MT_LOCK
|
||||
#endif
|
||||
|
||||
static HRESULT CheckBreak2()
|
||||
{
|
||||
return WasEscPressed() ? E_ABORT : S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::ScanProgress(UInt64 numFolders, UInt64 numFiles, UInt64 totalSize, const wchar_t *path, Int32 /* isDir */)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
_percent->FilesTotal = numFolders + numFiles;
|
||||
_percent->Total = totalSize;
|
||||
_percent->Command = "Scanning";
|
||||
_percent->FileName = path;
|
||||
_percent->Print();
|
||||
_percent->Print();
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::ScanError(const wchar_t *path, HRESULT errorCode)
|
||||
{
|
||||
if (ShowSysErrorMessage(errorCode, path) == -1)
|
||||
return E_ABORT;
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
_percent->FilesTotal = numFiles;
|
||||
_percent->Print();
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
_percent->Total = size;
|
||||
_percent->Print();
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
if (completeValue)
|
||||
_percent->Completed = *completeValue;
|
||||
_percent->Print();
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *name)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
_percent->Command = "Adding";
|
||||
_percent->FileName = name;
|
||||
_percent->Print();
|
||||
}
|
||||
return CheckBreak2();;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *name)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
_percent->Command = "Deleting";
|
||||
_percent->FileName = name;
|
||||
_percent->Print();
|
||||
}
|
||||
return CheckBreak2();;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* opRes */)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
_percent->Files++;
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (g_StartupInfo.ShowErrorMessage(UnicodeStringToMultiByte(message, CP_OEMCP)) == -1)
|
||||
return E_ABORT;
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallback100Imp::OpenFileError(const wchar_t *path, HRESULT errorCode)
|
||||
{
|
||||
if (ShowSysErrorMessage(errorCode, path) == -1)
|
||||
return E_ABORT;
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::ReadingFileError(const wchar_t *path, HRESULT errorCode)
|
||||
{
|
||||
if (ShowSysErrorMessage(errorCode, path) == -1)
|
||||
return E_ABORT;
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &s);
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (opRes != NArchive::NExtract::NOperationResult::kOK)
|
||||
{
|
||||
AString s;
|
||||
SetExtractErrorMessage(opRes, isEncrypted, s);
|
||||
if (PrintErrorMessage(s, name) == -1)
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::ReportUpdateOperation(UInt32 op, const wchar_t *name, Int32 /* isDir */)
|
||||
{
|
||||
const char *s;
|
||||
switch (op)
|
||||
{
|
||||
case NUpdateNotifyOp::kAdd: s = "Adding"; break;
|
||||
case NUpdateNotifyOp::kUpdate: s = "Updating"; break;
|
||||
case NUpdateNotifyOp::kAnalyze: s = "Analyzing"; break;
|
||||
case NUpdateNotifyOp::kReplicate: s = "Replicating"; break;
|
||||
case NUpdateNotifyOp::kRepack: s = "Repacking"; break;
|
||||
case NUpdateNotifyOp::kSkip: s = "Skipping"; break;
|
||||
case NUpdateNotifyOp::kHeader: s = "Header creating"; break;
|
||||
case NUpdateNotifyOp::kDelete: s = "Deleting"; break;
|
||||
default: s = "Unknown operation";
|
||||
}
|
||||
|
||||
MT_LOCK
|
||||
|
||||
if (_percent)
|
||||
{
|
||||
_percent->Command = s;
|
||||
_percent->FileName.Empty();
|
||||
if (name)
|
||||
_percent->FileName = name;
|
||||
_percent->Print();
|
||||
}
|
||||
|
||||
return CheckBreak2();;
|
||||
}
|
||||
|
||||
|
||||
extern HRESULT GetPassword(UString &password);
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
*password = NULL;
|
||||
if (!m_PasswordIsDefined)
|
||||
{
|
||||
RINOK(GetPassword(m_Password));
|
||||
m_PasswordIsDefined = true;
|
||||
}
|
||||
return StringToBstr(m_Password, password);
|
||||
}
|
||||
50
CPP/7zip/UI/Far/UpdateCallbackFar.h
Normal file
50
CPP/7zip/UI/Far/UpdateCallbackFar.h
Normal file
@@ -0,0 +1,50 @@
|
||||
// UpdateCallbackFar.h
|
||||
|
||||
#ifndef __UPDATE_CALLBACK_FAR_H
|
||||
#define __UPDATE_CALLBACK_FAR_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
#include "ProgressBox.h"
|
||||
|
||||
class CUpdateCallback100Imp:
|
||||
public IFolderArchiveUpdateCallback,
|
||||
public IFolderArchiveUpdateCallback2,
|
||||
public IFolderScanProgress,
|
||||
public ICryptoGetTextPassword,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
// CMyComPtr<IInFolderArchive> _archiveHandler;
|
||||
CProgressBox *_percent;
|
||||
UInt64 _total;
|
||||
bool m_PasswordIsDefined;
|
||||
UString m_Password;
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP4(
|
||||
IFolderArchiveUpdateCallback,
|
||||
IFolderArchiveUpdateCallback2,
|
||||
IFolderScanProgress,
|
||||
ICryptoGetTextPassword)
|
||||
|
||||
INTERFACE_IProgress(;)
|
||||
INTERFACE_IFolderArchiveUpdateCallback(;)
|
||||
INTERFACE_IFolderArchiveUpdateCallback2(;)
|
||||
INTERFACE_IFolderScanProgress(;)
|
||||
|
||||
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
|
||||
|
||||
CUpdateCallback100Imp(): _total(0) {}
|
||||
void Init(/* IInFolderArchive *archiveHandler, */ CProgressBox *progressBox)
|
||||
{
|
||||
// _archiveHandler = archiveHandler;
|
||||
_percent = progressBox;
|
||||
m_PasswordIsDefined = false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
102
CPP/7zip/UI/Far/makefile
Normal file
102
CPP/7zip/UI/Far/makefile
Normal file
@@ -0,0 +1,102 @@
|
||||
PROG = 7-ZipFar.dll
|
||||
DEF_FILE = Far.def
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-DEXTERNAL_CODECS \
|
||||
-DNEW_FOLDER_INTERFACE
|
||||
|
||||
!IFNDEF UNDER_CE
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH
|
||||
!ENDIF
|
||||
|
||||
CURRENT_OBJS = \
|
||||
$O\ExtractEngine.obj \
|
||||
$O\FarUtils.obj \
|
||||
$O\Far.obj \
|
||||
$O\OverwriteDialogFar.obj \
|
||||
$O\Plugin.obj \
|
||||
$O\PluginCommon.obj \
|
||||
$O\PluginDelete.obj \
|
||||
$O\PluginRead.obj \
|
||||
$O\PluginWrite.obj \
|
||||
$O\ProgressBox.obj \
|
||||
$O\UpdateCallbackFar.obj \
|
||||
$O\UTFConvert.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\MyString.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
$O\MyVector.obj \
|
||||
$O\Wildcard.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\ErrorMsg.obj \
|
||||
$O\FileDir.obj \
|
||||
$O\FileFind.obj \
|
||||
$O\FileIO.obj \
|
||||
$O\FileLink.obj \
|
||||
$O\FileName.obj \
|
||||
$O\PropVariant.obj \
|
||||
$O\PropVariantConv.obj \
|
||||
$O\Registry.obj \
|
||||
$O\ResourceString.obj \
|
||||
$O\Synchronization.obj \
|
||||
$O\TimeUtils.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\CreateCoder.obj \
|
||||
$O\FilePathAutoRename.obj \
|
||||
$O\FileStreams.obj \
|
||||
$O\FilterCoder.obj \
|
||||
$O\LimitedStreams.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\PropId.obj \
|
||||
$O\StreamObjects.obj \
|
||||
$O\StreamUtils.obj \
|
||||
$O\UniqBlocks.obj \
|
||||
|
||||
UI_COMMON_OBJS = \
|
||||
$O\ArchiveExtractCallback.obj \
|
||||
$O\ArchiveOpenCallback.obj \
|
||||
$O\DefaultName.obj \
|
||||
$O\EnumDirItems.obj \
|
||||
$O\ExtractingFilePath.obj \
|
||||
$O\LoadCodecs.obj \
|
||||
$O\OpenArchive.obj \
|
||||
$O\PropIDUtils.obj \
|
||||
$O\SetProperties.obj \
|
||||
$O\SortUtils.obj \
|
||||
$O\UpdateAction.obj \
|
||||
$O\UpdateCallback.obj \
|
||||
$O\UpdatePair.obj \
|
||||
$O\UpdateProduce.obj \
|
||||
$O\WorkDir.obj \
|
||||
$O\ZipRegistry.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
|
||||
AGENT_OBJS = \
|
||||
$O\Agent.obj \
|
||||
$O\AgentOut.obj \
|
||||
$O\AgentProxy.obj \
|
||||
$O\ArchiveFolder.obj \
|
||||
$O\ArchiveFolderOpen.obj \
|
||||
$O\ArchiveFolderOut.obj \
|
||||
$O\UpdateCallbackAgent.obj \
|
||||
|
||||
COMPRESS_OBJS = \
|
||||
$O\CopyCoder.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\CpuArch.obj \
|
||||
$O\Sort.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
!include "../../Crc.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
3
CPP/7zip/UI/Far/resource.rc
Normal file
3
CPP/7zip/UI/Far/resource.rc
Normal 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