mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 23:14:54 -06:00
9.21
This commit is contained in:
committed by
Kornel Lesiński
parent
de4f8c22fe
commit
35596517f2
@@ -449,8 +449,7 @@ bool WasEscPressed()
|
||||
|
||||
void ShowErrorMessage(DWORD errorCode)
|
||||
{
|
||||
UString message;
|
||||
NError::MyFormatMessage(errorCode, message);
|
||||
UString message = NError::MyFormatMessageW(errorCode);
|
||||
message.Replace(L"\x0D", L"");
|
||||
message.Replace(L"\x0A", L" ");
|
||||
g_StartupInfo.ShowMessage(UnicodeStringToMultiByte(message, CP_OEMCP));
|
||||
|
||||
@@ -87,12 +87,12 @@ class COpenArchiveCallback:
|
||||
|
||||
DWORD m_PrevTickCount;
|
||||
|
||||
NWindows::NFile::NFind::CFileInfoW _fileInfo;
|
||||
NWindows::NFile::NFind::CFileInfo _fileInfo;
|
||||
public:
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
UString _folderPrefix;
|
||||
FString _folderPrefix;
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP3(
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
}
|
||||
void ShowMessage();
|
||||
|
||||
void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
|
||||
void LoadFileInfo(const FString &folderPrefix, const FString &fileName)
|
||||
{
|
||||
_folderPrefix = folderPrefix;
|
||||
if (!_fileInfo.Find(_folderPrefix + fileName))
|
||||
@@ -251,7 +251,7 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **in
|
||||
if (WasEscPressed())
|
||||
return E_ABORT;
|
||||
*inStream = NULL;
|
||||
UString fullPath = _folderPrefix + name;
|
||||
FString fullPath = _folderPrefix + us2fs(name);
|
||||
if (!_fileInfo.Find(fullPath))
|
||||
return S_FALSE;
|
||||
if (_fileInfo.IsDir())
|
||||
@@ -333,16 +333,15 @@ HRESULT OpenArchive(const CSysString &fileName,
|
||||
|
||||
static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
||||
{
|
||||
UString normalizedName = name;
|
||||
FString normalizedName = us2fs(name);
|
||||
normalizedName.Trim();
|
||||
UString fullName;
|
||||
int fileNamePartStartIndex;
|
||||
NFile::NDirectory::MyGetFullPathName(normalizedName, fullName, fileNamePartStartIndex);
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
FString fullName;
|
||||
NFile::NDirectory::MyGetFullPathName(normalizedName, fullName);
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
if (!fileInfo.Find(fullName))
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileInfo.IsDir())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
|
||||
CMyComPtr<IInFolderArchive> archiveHandler;
|
||||
@@ -360,9 +359,11 @@ static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
||||
|
||||
// if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
|
||||
openArchiveCallbackSpec->Init();
|
||||
openArchiveCallbackSpec->LoadFileInfo(
|
||||
fullName.Left(fileNamePartStartIndex),
|
||||
fullName.Mid(fileNamePartStartIndex));
|
||||
{
|
||||
FString dirPrefix, fileName;
|
||||
NFile::NDirectory::GetFullPathAndSplit(fullName, dirPrefix, fileName);
|
||||
openArchiveCallbackSpec->LoadFileInfo(dirPrefix, fileName);
|
||||
}
|
||||
|
||||
// ::OutputDebugStringA("before OpenArchive\n");
|
||||
|
||||
@@ -449,7 +450,7 @@ EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, INT_PTR item)
|
||||
if(fileName.IsEmpty())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileName.Length() >= 2 &&
|
||||
fileName[0] == '\"' && fileName[fileName.Length() - 1] == '\"')
|
||||
fileName[0] == '\"' && fileName.Back() == '\"')
|
||||
fileName = fileName.Mid(1, fileName.Length() - 2);
|
||||
|
||||
return MyOpenFilePlugin(fileName);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
CPlugin::CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName):
|
||||
CPlugin::CPlugin(const FString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName):
|
||||
m_ArchiveHandler(archiveHandler),
|
||||
m_FileName(fileName),
|
||||
_archiveTypeName(archiveTypeName)
|
||||
@@ -532,10 +532,10 @@ static void InsertSeparator(InfoPanelLine *lines, int &numItems)
|
||||
void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
{
|
||||
info->StructSize = sizeof(*info);
|
||||
info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS| OPIF_USEHIGHLIGHTING|
|
||||
info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS | OPIF_USEHIGHLIGHTING |
|
||||
OPIF_ADDDOTS | OPIF_COMPAREFATTIME;
|
||||
|
||||
COPY_STR_LIMITED(m_FileNameBuffer, UnicodeStringToMultiByte(m_FileName, CP_OEMCP));
|
||||
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));
|
||||
@@ -545,10 +545,9 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
|
||||
UString name;
|
||||
{
|
||||
UString fullName;
|
||||
int index;
|
||||
NFile::NDirectory::MyGetFullPathName(m_FileName, fullName, index);
|
||||
name = fullName.Mid(index);
|
||||
FString dirPrefix, fileName;
|
||||
NFile::NDirectory::GetFullPathAndSplit(m_FileName, dirPrefix, fileName);
|
||||
name = fs2us(fileName);
|
||||
}
|
||||
|
||||
m_PannelTitle =
|
||||
@@ -852,14 +851,14 @@ int CPlugin::ProcessKey(int key, unsigned int controlState)
|
||||
}
|
||||
if ((controlState & PKF_ALT) != 0 && key == VK_F6)
|
||||
{
|
||||
UString folderPath;
|
||||
FString folderPath;
|
||||
if (!NFile::NDirectory::GetOnlyDirPrefix(m_FileName, folderPath))
|
||||
return FALSE;
|
||||
PanelInfo panelInfo;
|
||||
g_StartupInfo.ControlGetActivePanelInfo(panelInfo);
|
||||
GetFilesReal(panelInfo.SelectedItems,
|
||||
panelInfo.SelectedItemsNumber, FALSE,
|
||||
UnicodeStringToMultiByte(folderPath, CP_OEMCP), OPM_SILENT, true);
|
||||
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);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/WorkDir.h"
|
||||
|
||||
#include "../Agent/IFolderArchive.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
@@ -36,9 +38,10 @@ class CPlugin
|
||||
void EnterToDirectory(const UString &dirName);
|
||||
void GetPathParts(UStringVector &pathParts);
|
||||
void GetCurrentDir();
|
||||
HRESULT AfterUpdate(CWorkDirTempFile &tempFile, const UStringVector &pathVector);
|
||||
public:
|
||||
UString m_FileName;
|
||||
NWindows::NFile::NFind::CFileInfoW m_FileInfo;
|
||||
FString m_FileName;
|
||||
NWindows::NFile::NFind::CFileInfo m_FileInfo;
|
||||
|
||||
CMyComPtr<IInFolderArchive> m_ArchiveHandler;
|
||||
CMyComPtr<IFolderFolder> _folder;
|
||||
@@ -48,7 +51,7 @@ public:
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName);
|
||||
CPlugin(const FString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName);
|
||||
~CPlugin();
|
||||
|
||||
void ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex);
|
||||
|
||||
@@ -2,20 +2,11 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "../Common/WorkDir.h"
|
||||
|
||||
#include "Messages.h"
|
||||
#include "Plugin.h"
|
||||
#include "UpdateCallback100.h"
|
||||
|
||||
using namespace NFar;
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDirectory;
|
||||
|
||||
static LPCWSTR kTempArchivePrefix = L"7zA";
|
||||
|
||||
int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
{
|
||||
@@ -67,18 +58,10 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
g_StartupInfo.GetMsgString(NMessageID::kDeleting), 48);
|
||||
}
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
workDirInfo.Load();
|
||||
|
||||
UString workDir = GetWorkDir(workDirInfo, m_FileName);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
CTempFileW tempFile;
|
||||
UString tempFileName;
|
||||
if (tempFile.Create(workDir, kTempArchivePrefix, tempFileName) == 0)
|
||||
CWorkDirTempFile tempFile;
|
||||
if (tempFile.CreateTempFile(m_FileName) != S_OK)
|
||||
return FALSE;
|
||||
|
||||
|
||||
CRecordVector<UINT32> indices;
|
||||
indices.Reserve(numItems);
|
||||
int i;
|
||||
@@ -101,61 +84,23 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
outArchive->SetFolder(_folder);
|
||||
|
||||
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
|
||||
|
||||
|
||||
result = outArchive->DeleteItems(
|
||||
tempFileName,
|
||||
&indices.Front(), indices.Size(),
|
||||
updateCallback);
|
||||
result = outArchive->DeleteItems(tempFile.OutStream, &indices.Front(), indices.Size(), updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
result = AfterUpdate(tempFile, pathVector);
|
||||
}
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->Close();
|
||||
|
||||
if (!DeleteFileAlways(m_FileName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
tempFile.DisableDeleting();
|
||||
if (!MyMoveFile(tempFileName, m_FileName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
result = m_ArchiveHandler->ReOpen(NULL);
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Restore _folder;
|
||||
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
for (i = 0; i < pathVector.Size(); i++)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(pathVector[i], &newFolder);
|
||||
if (!newFolder)
|
||||
break;
|
||||
_folder = newFolder;
|
||||
}
|
||||
GetCurrentDir();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -194,9 +194,11 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
#ifdef UNDER_CE
|
||||
destPathU = L"\\";
|
||||
#else
|
||||
if (!NFile::NDirectory::MyGetCurrentDirectory(destPathU))
|
||||
FString destPathF = us2fs(destPathU);
|
||||
if (!NFile::NDirectory::MyGetCurrentDirectory(destPathF))
|
||||
throw 318016;
|
||||
NFile::NName::NormalizeDirPathPrefix(destPathU);
|
||||
NFile::NName::NormalizeDirPathPrefix(destPathF);
|
||||
destPathU = fs2us(destPathF);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -251,7 +253,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
passwordIsDefined = !password.IsEmpty();
|
||||
}
|
||||
|
||||
NFile::NDirectory::CreateComplexDirectory(destPathU);
|
||||
NFile::NDirectory::CreateComplexDirectory(us2fs(destPathU));
|
||||
|
||||
/*
|
||||
vector<int> realIndices;
|
||||
|
||||
@@ -7,15 +7,10 @@
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/ZipRegistry.h"
|
||||
#include "../Common/WorkDir.h"
|
||||
#include "../Common/OpenArchive.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
|
||||
@@ -30,13 +25,11 @@ using namespace NFar;
|
||||
|
||||
using namespace NUpdateArchive;
|
||||
|
||||
static const char *kHelpTopic = "Update";
|
||||
|
||||
static LPCWSTR kTempArcivePrefix = L"7zA";
|
||||
static const char *kHelpTopic = "Update";
|
||||
|
||||
static const char *kArchiveHistoryKeyName = "7-ZipArcName";
|
||||
|
||||
static UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
|
||||
static const UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
|
||||
|
||||
static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
|
||||
{
|
||||
@@ -47,18 +40,39 @@ static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
|
||||
realNames.Add(UString(L"x"));
|
||||
NCOM::CPropVariant value = (UInt32)method;
|
||||
CRecordVector<const wchar_t *> names;
|
||||
for(int i = 0; i < realNames.Size(); i++)
|
||||
for (int i = 0; i < realNames.Size(); i++)
|
||||
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 (int i = 0; i < pathVector.Size(); i++)
|
||||
{
|
||||
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)
|
||||
if (moveMode != 0)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported);
|
||||
return NFileOperationReturnCode::kError;
|
||||
@@ -153,20 +167,14 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
|
||||
compressionInfo.Save();
|
||||
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
workDirInfo.Load();
|
||||
UString workDir = GetWorkDir(workDirInfo, m_FileName);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
CTempFileW tempFile;
|
||||
UString tempFileName;
|
||||
if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
|
||||
CWorkDirTempFile tempFile;;
|
||||
if (tempFile.CreateTempFile(m_FileName) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
|
||||
|
||||
/*
|
||||
CSysStringVector fileNames;
|
||||
for(int i = 0; i < numItems; i++)
|
||||
for (int i = 0; i < numItems; i++)
|
||||
{
|
||||
const PluginPanelItem &panelItem = panelItems[i];
|
||||
CSysString fullName;
|
||||
@@ -189,44 +197,28 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// Save FolderItem;
|
||||
UStringVector aPathVector;
|
||||
GetPathParts(aPathVector);
|
||||
UStringVector pathVector;
|
||||
GetPathParts(pathVector);
|
||||
|
||||
/*
|
||||
UString anArchivePrefix;
|
||||
for(i = aPathVector.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
anArchivePrefix += aPathVector[i];
|
||||
anArchivePrefix += wchar_t(NName::kDirDelimiter);
|
||||
}
|
||||
/////////////////////////////////
|
||||
*/
|
||||
|
||||
UStringVector fileNames;
|
||||
fileNames.Reserve(numItems);
|
||||
for(i = 0; i < numItems; i++)
|
||||
for (i = 0; i < numItems; i++)
|
||||
fileNames.Add(MultiByteToUnicodeString(panelItems[i].FindData.cFileName, CP_OEMCP));
|
||||
CRecordVector<const wchar_t *> fileNamePointers;
|
||||
fileNamePointers.Reserve(numItems);
|
||||
for(i = 0; i < numItems; i++)
|
||||
for (i = 0; i < numItems; i++)
|
||||
fileNamePointers.Add(fileNames[i]);
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive);
|
||||
if(result != S_OK)
|
||||
if (result != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
outArchive->SetFolder(_folder);
|
||||
|
||||
// CSysString aCurrentFolder;
|
||||
// MyGetCurrentDirectory(aCurrentFolder);
|
||||
// outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
|
||||
outArchive->SetFiles(L"",
|
||||
&fileNamePointers.Front(), fileNamePointers.Size());
|
||||
outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size());
|
||||
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
|
||||
@@ -239,42 +231,14 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
|
||||
result = outArchive->DoOperation2(tempFileName, actionSetByte, NULL, updateCallback);
|
||||
result = outArchive->DoOperation2(tempFile.OutStream, actionSetByte, NULL, updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
|
||||
/*
|
||||
HRESULT result = Compress(fileNames, anArchivePrefix, *actionSet,
|
||||
m_ProxyHandler.get(),
|
||||
m_ArchiverInfo.ClassID, compressionInfo.Method == 0,
|
||||
compressionInfo.Method == 2, tempFileName, progressBoxPointer);
|
||||
*/
|
||||
|
||||
if (result != S_OK)
|
||||
if (result == S_OK)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
return NFileOperationReturnCode::kError;
|
||||
result = AfterUpdate(tempFile, pathVector);
|
||||
}
|
||||
|
||||
_folder.Release();
|
||||
m_ArchiveHandler->Close();
|
||||
|
||||
// m_FolderItem = NULL;
|
||||
|
||||
if (!DeleteFileAlways(m_FileName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
tempFile.DisableDeleting();
|
||||
if (!MyMoveFile(tempFileName, m_FileName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
m_ArchiveHandler->ReOpen(NULL);
|
||||
if (result != S_OK)
|
||||
{
|
||||
ShowErrorMessage(result);
|
||||
@@ -282,37 +246,17 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
}
|
||||
|
||||
/*
|
||||
if(m_ProxyHandler->ReInit(NULL) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
*/
|
||||
|
||||
////////////////////////////
|
||||
// Restore FolderItem;
|
||||
|
||||
m_ArchiveHandler->BindToRootFolder(&_folder);
|
||||
for (i = 0; i < aPathVector.Size(); i++)
|
||||
if (moveMode != 0)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(aPathVector[i], &newFolder);
|
||||
if(!newFolder )
|
||||
break;
|
||||
_folder = newFolder;
|
||||
}
|
||||
|
||||
/*
|
||||
if(moveMode != 0)
|
||||
{
|
||||
for(int i = 0; i < numItems; i++)
|
||||
for (int i = 0; i < numItems; i++)
|
||||
{
|
||||
const PluginPanelItem &aPluginPanelItem = panelItems[i];
|
||||
const PluginPanelItem &pluginPanelItem = panelItems[i];
|
||||
bool result;
|
||||
if(NFile::NFind::NAttributes::IsDir(aPluginPanelItem.FindData.dwFileAttributes))
|
||||
result = NFile::NDirectory::RemoveDirectoryWithSubItems(
|
||||
aPluginPanelItem.FindData.cFileName);
|
||||
if (NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
|
||||
result = NFile::NDirectory::RemoveDirectoryWithSubItems(pluginPanelItem.FindData.cFileName);
|
||||
else
|
||||
result = NFile::NDirectory::DeleteFileAlways(
|
||||
aPluginPanelItem.FindData.cFileName);
|
||||
if(!result)
|
||||
result = NFile::NDirectory::DeleteFileAlways(pluginPanelItem.FindData.cFileName);
|
||||
if (!result)
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
}
|
||||
@@ -361,11 +305,11 @@ void CParsedPath::ParsePath(const UString &path)
|
||||
case NPathType::kLocal:
|
||||
{
|
||||
int posDiskDelimiter = path.Find(kDiskDelimiter);
|
||||
if(posDiskDelimiter >= 0)
|
||||
if (posDiskDelimiter >= 0)
|
||||
{
|
||||
curPos = posDiskDelimiter + 1;
|
||||
if (path.Length() > curPos)
|
||||
if(path[curPos] == kDirDelimiter)
|
||||
if (path[curPos] == kDirDelimiter)
|
||||
curPos++;
|
||||
}
|
||||
break;
|
||||
@@ -373,7 +317,7 @@ void CParsedPath::ParsePath(const UString &path)
|
||||
case NPathType::kUNC:
|
||||
{
|
||||
int curPos = path.Find(kDirDelimiter, 2);
|
||||
if(curPos < 0)
|
||||
if (curPos < 0)
|
||||
curPos = path.Length();
|
||||
else
|
||||
curPos++;
|
||||
@@ -386,7 +330,7 @@ void CParsedPath::ParsePath(const UString &path)
|
||||
UString CParsedPath::MergePath() const
|
||||
{
|
||||
UString result = Prefix;
|
||||
for(int i = 0; i < PathParts.Size(); i++)
|
||||
for (int i = 0; i < PathParts.Size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
result += kDirDelimiter;
|
||||
@@ -409,20 +353,20 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
|
||||
UStringVector fileNames;
|
||||
int i;
|
||||
for(i = 0; i < pluginPanelItems.Size(); i++)
|
||||
for (i = 0; i < pluginPanelItems.Size(); i++)
|
||||
{
|
||||
const PluginPanelItem &panelItem = pluginPanelItems[i];
|
||||
UString fullName;
|
||||
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;
|
||||
UString fileNameUnicode = MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP);
|
||||
if (!MyGetFullPathName(fileNameUnicode, fullName))
|
||||
FString fullPath;
|
||||
FString fileNameUnicode = us2fs(MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP));
|
||||
if (!MyGetFullPathName(fileNameUnicode, fullPath))
|
||||
return E_FAIL;
|
||||
fileNames.Add(fullName);
|
||||
fileNames.Add(fs2us(fullPath));
|
||||
}
|
||||
|
||||
NCompression::CInfo compressionInfo;
|
||||
@@ -453,7 +397,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
{
|
||||
CParsedPath parsedPath;
|
||||
parsedPath.ParsePath(fileNames.Front());
|
||||
if(parsedPath.PathParts.Size() == 0)
|
||||
if (parsedPath.PathParts.Size() == 0)
|
||||
return E_FAIL;
|
||||
if (fileNames.Size() == 1 || parsedPath.PathParts.Size() == 1)
|
||||
{
|
||||
@@ -589,7 +533,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
{
|
||||
CIntVector indices;
|
||||
CSysStringVector archiverNames;
|
||||
for(int i = 0; i < codecs->Formats.Size(); i++)
|
||||
for (int i = 0; i < codecs->Formats.Size(); i++)
|
||||
{
|
||||
const CArcInfoEx &arc = codecs->Formats[i];
|
||||
if (arc.UpdateEnabled)
|
||||
@@ -602,7 +546,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT,
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdateSelectArchiverMenuTitle),
|
||||
NULL, archiverNames, archiverIndex);
|
||||
if(index >= 0)
|
||||
if (index >= 0)
|
||||
{
|
||||
const CArcInfoEx &prevArchiverInfo = codecs->Formats[prevFormat];
|
||||
if (prevArchiverInfo.KeepName)
|
||||
@@ -653,18 +597,12 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
NWorkDir::CInfo workDirInfo;
|
||||
workDirInfo.Load();
|
||||
|
||||
UString fullArchiveName;
|
||||
if (!MyGetFullPathName(archiveName, fullArchiveName))
|
||||
FString fullArchiveName;
|
||||
if (!MyGetFullPathName(us2fs(archiveName), fullArchiveName))
|
||||
return E_FAIL;
|
||||
|
||||
UString workDir = GetWorkDir(workDirInfo, fullArchiveName);
|
||||
CreateComplexDirectory(workDir);
|
||||
|
||||
CTempFileW tempFile;
|
||||
UString tempFileName;
|
||||
if (tempFile.Create(workDir, kTempArcivePrefix, tempFileName) == 0)
|
||||
return E_FAIL;
|
||||
|
||||
CWorkDirTempFile tempFile;
|
||||
RINOK(tempFile.CreateTempFile(fullArchiveName));
|
||||
|
||||
CScreenRestorer screenRestorer;
|
||||
CProgressBox progressBox;
|
||||
@@ -678,12 +616,12 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
|
||||
|
||||
|
||||
NFind::CFileInfoW fileInfo;
|
||||
NFind::CFileInfo fileInfo;
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
|
||||
CMyComPtr<IInFolderArchive> archiveHandler;
|
||||
if(fileInfo.Find(fullArchiveName))
|
||||
if (fileInfo.Find(fullArchiveName))
|
||||
{
|
||||
if (fileInfo.IsDir())
|
||||
throw "There is Directory with such name";
|
||||
@@ -702,7 +640,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
throw "Type of existing archive differs from specified type";
|
||||
HRESULT result = archiveHandler.QueryInterface(
|
||||
IID_IOutFolderArchive, &outArchive);
|
||||
if(result != S_OK)
|
||||
if (result != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return E_FAIL;
|
||||
@@ -726,15 +664,11 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
|
||||
CRecordVector<const wchar_t *> fileNamePointers;
|
||||
fileNamePointers.Reserve(fileNames.Size());
|
||||
for(i = 0; i < fileNames.Size(); i++)
|
||||
for (i = 0; i < fileNames.Size(); i++)
|
||||
fileNamePointers.Add(fileNames[i]);
|
||||
|
||||
outArchive->SetFolder(NULL);
|
||||
// CSysString aCurrentFolder;
|
||||
// MyGetCurrentDirectory(aCurrentFolder);
|
||||
// outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
|
||||
outArchive->SetFiles(L"",
|
||||
&fileNamePointers.Front(), fileNamePointers.Size());
|
||||
outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size());
|
||||
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
|
||||
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
|
||||
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
|
||||
@@ -749,7 +683,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
|
||||
HRESULT result = outArchive->DoOperation(
|
||||
codecs, archiverIndex,
|
||||
tempFileName, actionSetByte,
|
||||
tempFile.OutStream, actionSetByte,
|
||||
NULL, updateCallback);
|
||||
updateCallback.Release();
|
||||
outArchive.Release();
|
||||
@@ -760,21 +694,14 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
return result;
|
||||
}
|
||||
|
||||
if(archiveHandler)
|
||||
if (archiveHandler)
|
||||
{
|
||||
archiveHandler->Close();
|
||||
if (!DeleteFileAlways(fullArchiveName))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
}
|
||||
tempFile.DisableDeleting();
|
||||
if (!MyMoveFile(tempFileName, fullArchiveName))
|
||||
if (!tempFile.MoveToOriginal(archiveHandler != NULL))
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user