chore: initial commit (extracted from Launchers monorepo)

Plugin: ns7zip v2.0.0
Architectures: x86-ansi, x86-unicode, amd64-unicode
License: LGPL-2.1-or-later
This commit is contained in:
Simone
2026-04-29 14:07:51 +02:00
commit d074cc7c07
3848 changed files with 1076682 additions and 0 deletions
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="7-Zip.7-Zip.7zFM" type="win32"/>
<description>7-Zip File Manager.</description>
<dependency>
<dependentAssembly><assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/></dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"><application>
<!-- Vista --> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Win 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Win 8 --> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Win 8.1 --> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Win 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application></compatibility>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware></windowsSettings></application>
</assembly>
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

@@ -0,0 +1,81 @@
// AboutDialog.cpp
#include "StdAfx.h"
#include "../../../../C/CpuArch.h"
#include "../../MyVersion.h"
#include "../Common/LoadCodecs.h"
#include "AboutDialog.h"
#include "PropertyNameRes.h"
#include "HelpUtils.h"
#include "LangUtils.h"
#ifdef Z7_LANG
static const UInt32 kLangIDs[] =
{
IDT_ABOUT_INFO
};
#endif
#define kHomePageURL TEXT("https://www.7-zip.org/")
#define kHelpTopic "start.htm"
#define LLL_(quote) L##quote
#define LLL(quote) LLL_(quote)
extern CCodecs *g_CodecsObj;
bool CAboutDialog::OnInit()
{
#ifdef Z7_EXTERNAL_CODECS
if (g_CodecsObj)
{
UString s;
g_CodecsObj->GetCodecsErrorMessage(s);
if (!s.IsEmpty())
MessageBoxW(GetParent(), s, L"7-Zip", MB_ICONERROR);
}
#endif
#ifdef Z7_LANG
LangSetWindowText(*this, IDD_ABOUT);
LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
#endif
SetItemText(IDT_ABOUT_VERSION, UString("7-Zip " MY_VERSION_CPU));
SetItemText(IDT_ABOUT_DATE, LLL(MY_DATE));
NormalizePosition();
return CModalDialog::OnInit();
}
void CAboutDialog::OnHelp()
{
ShowHelpWindow(kHelpTopic);
}
bool CAboutDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
LPCTSTR url;
switch (buttonID)
{
case IDB_ABOUT_HOMEPAGE: url = kHomePageURL; break;
default:
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
#ifdef UNDER_CE
SHELLEXECUTEINFO s;
memset(&s, 0, sizeof(s));
s.cbSize = sizeof(s);
s.lpFile = url;
::ShellExecuteEx(&s);
#else
::ShellExecute(NULL, NULL, url, NULL, NULL, SW_SHOWNORMAL);
#endif
return true;
}
@@ -0,0 +1,19 @@
// AboutDialog.h
#ifndef ZIP7_INC_ABOUT_DIALOG_H
#define ZIP7_INC_ABOUT_DIALOG_H
#include "../../../Windows/Control/Dialog.h"
#include "AboutDialogRes.h"
class CAboutDialog: public NWindows::NControl::CModalDialog
{
public:
virtual bool OnInit() Z7_override;
virtual void OnHelp() Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
INT_PTR Create(HWND wndParent = NULL) { return CModalDialog::Create(IDD_ABOUT, wndParent); }
};
#endif
@@ -0,0 +1,26 @@
#include "AboutDialogRes.h"
#include "../../GuiCommon.rc"
#include "../../MyVersion.h"
#define xc 144
#define yc 144
#define y 93
IDI_LOGO ICON "../../UI/FileManager/7zipLogo.ico"
#ifndef SS_REALSIZEIMAGE
#define SS_REALSIZEIMAGE 0x800
#endif
IDD_ABOUT DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT
CAPTION "About 7-Zip"
{
DEFPUSHBUTTON "OK", IDOK, bx1, by, bxs, bys
PUSHBUTTON "www.7-zip.org", IDB_ABOUT_HOMEPAGE, bx2, by, bxs, bys
ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE
LTEXT "", IDT_ABOUT_VERSION, m, 54, xc, 8
LTEXT "", IDT_ABOUT_DATE, m, 67, xc, 8
LTEXT MY_COPYRIGHT, -1, m, 80, xc, 8
LTEXT "7-Zip is free software", IDT_ABOUT_INFO, m, y, xc, (by - y - 1)
}
@@ -0,0 +1,8 @@
#define IDD_ABOUT 2900
#define IDT_ABOUT_INFO 2901
#define IDI_LOGO 100
#define IDT_ABOUT_VERSION 101
#define IDT_ABOUT_DATE 102
#define IDB_ABOUT_HOMEPAGE 110
Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

@@ -0,0 +1,946 @@
// AltStreamsFolder.cpp
#include "StdAfx.h"
#ifdef __MINGW32_VERSION
// #if !defined(_MSC_VER) && (__GNUC__) && (__GNUC__ < 10)
// for old mingw
#include <ddk/ntddk.h>
#else
#ifndef Z7_OLD_WIN_SDK
#if !defined(_M_IA64)
#include <winternl.h>
#endif
#else
typedef LONG NTSTATUS;
typedef struct _IO_STATUS_BLOCK {
union {
NTSTATUS Status;
PVOID Pointer;
};
ULONG_PTR Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
#endif
#endif
#include "../../../Common/ComTry.h"
#include "../../../Common/StringConvert.h"
#include "../../../Common/Wildcard.h"
#include "../../../Windows/DLL.h"
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileIO.h"
#include "../../../Windows/FileName.h"
#include "../../../Windows/PropVariant.h"
#include "../Common/ExtractingFilePath.h"
#include "../Agent/IFolderArchive.h"
#include "AltStreamsFolder.h"
#include "FSDrives.h"
#include "FSFolder.h"
#include "SysIconUtils.h"
using namespace NWindows;
using namespace NFile;
using namespace NFind;
using namespace NDir;
using namespace NName;
#ifndef USE_UNICODE_FSTRING
int CompareFileNames_ForFolderList(const FChar *s1, const FChar *s2);
#endif
#ifndef UNDER_CE
namespace NFsFolder
{
bool MyGetCompressedFileSizeW(CFSTR path, UInt64 &size);
}
#endif
namespace NAltStreamsFolder {
static const Byte kProps[] =
{
kpidName,
kpidSize,
kpidPackSize
};
static unsigned GetFsParentPrefixSize(const FString &path)
{
if (IsNetworkShareRootPath(path))
return 0;
const unsigned prefixSize = GetRootPrefixSize(path);
if (prefixSize == 0 || prefixSize >= path.Len())
return 0;
FString parentPath = path;
int pos = parentPath.ReverseFind_PathSepar();
if (pos < 0)
return 0;
if (pos == (int)parentPath.Len() - 1)
{
parentPath.DeleteBack();
pos = parentPath.ReverseFind_PathSepar();
if (pos < 0)
return 0;
}
if ((unsigned)pos + 1 < prefixSize)
return 0;
return (unsigned)pos + 1;
}
HRESULT CAltStreamsFolder::Init(const FString &path /* , IFolderFolder *parentFolder */)
{
// _parentFolder = parentFolder;
if (path.Back() != ':')
return E_FAIL;
_pathPrefix = path;
_pathBaseFile = path;
_pathBaseFile.DeleteBack();
{
CFileInfo fi;
if (!fi.Find(_pathBaseFile))
return GetLastError_noZero_HRESULT();
}
unsigned prefixSize = GetFsParentPrefixSize(_pathBaseFile);
if (prefixSize == 0)
return S_OK;
FString parentPath = _pathBaseFile;
parentPath.DeleteFrom(prefixSize);
_findChangeNotification.FindFirst(parentPath, false,
FILE_NOTIFY_CHANGE_FILE_NAME
| FILE_NOTIFY_CHANGE_DIR_NAME
| FILE_NOTIFY_CHANGE_ATTRIBUTES
| FILE_NOTIFY_CHANGE_SIZE
| FILE_NOTIFY_CHANGE_LAST_WRITE
/*
| FILE_NOTIFY_CHANGE_LAST_ACCESS
| FILE_NOTIFY_CHANGE_CREATION
| FILE_NOTIFY_CHANGE_SECURITY
*/
);
/*
if (_findChangeNotification.IsHandleAllocated())
return S_OK;
return GetLastError();
*/
return S_OK;
}
Z7_COM7F_IMF(CAltStreamsFolder::LoadItems())
{
Int32 dummy;
WasChanged(&dummy);
Clear();
CStreamEnumerator enumerator(_pathBaseFile);
CStreamInfo si;
for (;;)
{
bool found;
if (!enumerator.Next(si, found))
{
// if (GetLastError() == ERROR_ACCESS_DENIED)
// break;
// return E_FAIL;
break;
}
if (!found)
break;
if (si.IsMainStream())
continue;
CAltStream ss;
ss.Name = si.GetReducedName();
if (!ss.Name.IsEmpty() && ss.Name[0] == ':')
ss.Name.Delete(0);
ss.Size = si.Size;
ss.PackSize_Defined = false;
ss.PackSize = si.Size;
Streams.Add(ss);
}
return S_OK;
}
Z7_COM7F_IMF(CAltStreamsFolder::GetNumberOfItems(UInt32 *numItems))
{
*numItems = Streams.Size();
return S_OK;
}
#ifdef USE_UNICODE_FSTRING
Z7_COM7F_IMF(CAltStreamsFolder::GetItemPrefix(UInt32 /* index */, const wchar_t **name, unsigned *len))
{
*name = NULL;
*len = 0;
return S_OK;
}
Z7_COM7F_IMF(CAltStreamsFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len))
{
*name = NULL;
*len = 0;
{
const CAltStream &ss = Streams[index];
*name = ss.Name;
*len = ss.Name.Len();
}
return S_OK;
}
Z7_COM7F_IMF2(UInt64, CAltStreamsFolder::GetItemSize(UInt32 index))
{
return Streams[index].Size;
}
#endif
Z7_COM7F_IMF(CAltStreamsFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
{
NCOM::CPropVariant prop;
{
CAltStream &ss = Streams[index];
switch (propID)
{
case kpidIsDir: prop = false; break;
case kpidIsAltStream: prop = true; break;
case kpidName: prop = ss.Name; break;
case kpidSize: prop = ss.Size; break;
case kpidPackSize:
#ifdef UNDER_CE
prop = ss.Size;
#else
if (!ss.PackSize_Defined)
{
ss.PackSize_Defined = true;
if (!NFsFolder::MyGetCompressedFileSizeW(_pathPrefix + us2fs(ss.Name), ss.PackSize))
ss.PackSize = ss.Size;
}
prop = ss.PackSize;
#endif
break;
}
}
prop.Detach(value);
return S_OK;
}
// returns Position of extension including '.'
static inline const wchar_t *GetExtensionPtr(const UString &name)
{
const int dotPos = name.ReverseFind_Dot();
return name.Ptr(dotPos < 0 ? name.Len() : (unsigned)dotPos);
}
Z7_COM7F_IMF2(Int32, CAltStreamsFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 /* propIsRaw */))
{
const CAltStream &ss1 = Streams[index1];
const CAltStream &ss2 = Streams[index2];
switch (propID)
{
case kpidName:
{
return CompareFileNames_ForFolderList(ss1.Name, ss2.Name);
// return MyStringCompareNoCase(ss1.Name, ss2.Name);
}
case kpidSize:
return MyCompare(ss1.Size, ss2.Size);
case kpidPackSize:
{
#ifdef UNDER_CE
return MyCompare(ss1.Size, ss2.Size);
#else
// PackSize can be undefined here
return MyCompare(
ss1.PackSize,
ss2.PackSize);
#endif
}
case kpidExtension:
return CompareFileNames_ForFolderList(
GetExtensionPtr(ss1.Name),
GetExtensionPtr(ss2.Name));
}
return 0;
}
Z7_COM7F_IMF(CAltStreamsFolder::BindToFolder(UInt32 /* index */, IFolderFolder **resultFolder))
{
*resultFolder = NULL;
return E_INVALIDARG;
}
Z7_COM7F_IMF(CAltStreamsFolder::BindToFolder(const wchar_t * /* name */, IFolderFolder **resultFolder))
{
*resultFolder = NULL;
return E_INVALIDARG;
}
// static CFSTR const kSuperPrefix = FTEXT("\\\\?\\");
Z7_COM7F_IMF(CAltStreamsFolder::BindToParentFolder(IFolderFolder **resultFolder))
{
*resultFolder = NULL;
/*
if (_parentFolder)
{
CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
*resultFolder = parentFolder.Detach();
return S_OK;
}
*/
if (IsDriveRootPath_SuperAllowed(_pathBaseFile))
{
CFSDrives *drivesFolderSpec = new CFSDrives;
CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
drivesFolderSpec->Init();
*resultFolder = drivesFolder.Detach();
return S_OK;
}
/*
parentPath.DeleteFrom(pos + 1);
if (parentPath == kSuperPrefix)
{
#ifdef UNDER_CE
*resultFolder = 0;
#else
CFSDrives *drivesFolderSpec = new CFSDrives;
CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
drivesFolderSpec->Init(false, true);
*resultFolder = drivesFolder.Detach();
#endif
return S_OK;
}
FString parentPathReduced = parentPath.Left(pos);
#ifndef UNDER_CE
pos = parentPathReduced.ReverseFind_PathSepar();
if (pos == 1)
{
if (!IS_PATH_SEPAR_CHAR(parentPath[0]))
return E_FAIL;
CNetFolder *netFolderSpec = new CNetFolder;
CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
netFolderSpec->Init(fs2us(parentPath));
*resultFolder = netFolder.Detach();
return S_OK;
}
#endif
CFSFolder *parentFolderSpec = new CFSFolder;
CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
RINOK(parentFolderSpec->Init(parentPath, 0));
*resultFolder = parentFolder.Detach();
*/
return S_OK;
}
IMP_IFolderFolder_Props(CAltStreamsFolder)
Z7_COM7F_IMF(CAltStreamsFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value))
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant prop;
switch (propID)
{
case kpidType: prop = "AltStreamsFolder"; break;
case kpidPath: prop = fs2us(_pathPrefix); break;
}
prop.Detach(value);
return S_OK;
COM_TRY_END
}
Z7_COM7F_IMF(CAltStreamsFolder::WasChanged(Int32 *wasChanged))
{
bool wasChangedMain = false;
for (;;)
{
if (!_findChangeNotification.IsHandleAllocated())
{
*wasChanged = BoolToInt(false);
return S_OK;
}
const DWORD waitResult = ::WaitForSingleObject(_findChangeNotification, 0);
const bool wasChangedLoc = (waitResult == WAIT_OBJECT_0);
if (wasChangedLoc)
{
_findChangeNotification.FindNext();
wasChangedMain = true;
}
else
break;
}
*wasChanged = BoolToInt(wasChangedMain);
return S_OK;
}
Z7_COM7F_IMF(CAltStreamsFolder::Clone(IFolderFolder **resultFolder))
{
CAltStreamsFolder *folderSpec = new CAltStreamsFolder;
CMyComPtr<IFolderFolder> folderNew = folderSpec;
folderSpec->Init(_pathPrefix);
*resultFolder = folderNew.Detach();
return S_OK;
}
void CAltStreamsFolder::GetAbsPath(const wchar_t *name, FString &absPath)
{
absPath.Empty();
if (!IsAbsolutePath(name))
absPath += _pathPrefix;
absPath += us2fs(name);
}
static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
const wchar_t *message, const FString &fileName)
{
UString s = message;
s += " : ";
s += fs2us(fileName);
return callback->ShowMessage(s);
}
static HRESULT SendMessageError(IFolderArchiveUpdateCallback *callback,
const wchar_t *message, const FString &fileName)
{
UString s = message;
s += " : ";
s += fs2us(fileName);
return callback->UpdateErrorMessage(s);
}
static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
const char *message, const FString &fileName)
{
return SendMessageError(callback, MultiByteToUnicodeString(message), fileName);
}
/*
static HRESULT SendMessageError(IFolderArchiveUpdateCallback *callback,
const char *message, const FString &fileName)
{
return SendMessageError(callback, MultiByteToUnicodeString(message), fileName);
}
*/
Z7_COM7F_IMF(CAltStreamsFolder::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
Z7_COM7F_IMF(CAltStreamsFolder::CreateFile(const wchar_t *name, IProgress * /* progress */))
{
FString absPath;
GetAbsPath(name, absPath);
NIO::COutFile outFile;
if (!outFile.Create_NEW(absPath))
return GetLastError_noZero_HRESULT();
return S_OK;
}
static UString GetLastErrorMessage()
{
return NError::MyFormatMessage(GetLastError_noZero_HRESULT());
}
static HRESULT UpdateFile(NFsFolder::CCopyStateIO &state, CFSTR inPath, CFSTR outPath, IFolderArchiveUpdateCallback *callback)
{
if (NFind::DoesFileOrDirExist(outPath))
{
RINOK(SendMessageError(callback, NError::MyFormatMessage(ERROR_ALREADY_EXISTS), FString(outPath)))
CFileInfo fi;
if (fi.Find(inPath))
{
if (state.TotalSize >= fi.Size)
state.TotalSize -= fi.Size;
}
return S_OK;
}
{
if (callback)
RINOK(callback->CompressOperation(fs2us(inPath)))
RINOK(state.MyCopyFile(inPath, outPath))
if (state.ErrorFileIndex >= 0)
{
if (state.ErrorMessage.IsEmpty())
state.ErrorMessage = GetLastErrorMessage();
FString errorName;
if (state.ErrorFileIndex == 0)
errorName = inPath;
else
errorName = outPath;
if (callback)
RINOK(SendMessageError(callback, state.ErrorMessage, errorName))
}
if (callback)
RINOK(callback->OperationResult(0))
}
return S_OK;
}
EXTERN_C_BEGIN
typedef enum
{
Z7_WIN_FileRenameInformation = 10
}
Z7_WIN_FILE_INFORMATION_CLASS;
typedef struct
{
// #if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS1)
union
{
BOOLEAN ReplaceIfExists; // FileRenameInformation
ULONG Flags; // FileRenameInformationEx
} DUMMYUNIONNAME;
// #else
// BOOLEAN ReplaceIfExists;
// #endif
HANDLE RootDirectory;
ULONG FileNameLength;
WCHAR FileName[1];
} Z7_WIN_FILE_RENAME_INFORMATION;
#if (_WIN32_WINNT >= 0x0500) && !defined(_M_IA64)
#define Z7_WIN_NTSTATUS NTSTATUS
#define Z7_WIN_IO_STATUS_BLOCK IO_STATUS_BLOCK
#else
typedef LONG Z7_WIN_NTSTATUS;
typedef struct
{
union
{
Z7_WIN_NTSTATUS Status;
PVOID Pointer;
} DUMMYUNIONNAME;
ULONG_PTR Information;
} Z7_WIN_IO_STATUS_BLOCK;
#endif
typedef Z7_WIN_NTSTATUS (WINAPI *Func_NtSetInformationFile)(
HANDLE FileHandle,
Z7_WIN_IO_STATUS_BLOCK *IoStatusBlock,
PVOID FileInformation,
ULONG Length,
Z7_WIN_FILE_INFORMATION_CLASS FileInformationClass);
// NTAPI
typedef ULONG (WINAPI *Func_RtlNtStatusToDosError)(Z7_WIN_NTSTATUS Status);
#define MY_STATUS_SUCCESS 0
EXTERN_C_END
// static Func_NtSetInformationFile f_NtSetInformationFile;
// static bool g_NtSetInformationFile_WasRequested = false;
Z7_DIAGNOSTIC_IGNORE_CAST_FUNCTION
Z7_COM7F_IMF(CAltStreamsFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress))
{
const CAltStream &ss = Streams[index];
const FString srcPath = _pathPrefix + us2fs(ss.Name);
const HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll");
// if (!g_NtSetInformationFile_WasRequested) {
// g_NtSetInformationFile_WasRequested = true;
const
Func_NtSetInformationFile
f_NtSetInformationFile = Z7_GET_PROC_ADDRESS(
Func_NtSetInformationFile, ntdll,
"NtSetInformationFile");
if (f_NtSetInformationFile)
{
NIO::CInFile inFile;
if (inFile.Open_for_FileRenameInformation(srcPath))
{
UString destPath (':');
destPath += newName;
const ULONG len = (ULONG)sizeof(wchar_t) * destPath.Len();
CByteBuffer buffer(sizeof(Z7_WIN_FILE_RENAME_INFORMATION) + len);
// buffer is 4 bytes larger than required.
Z7_WIN_FILE_RENAME_INFORMATION *fri = (Z7_WIN_FILE_RENAME_INFORMATION *)(void *)(Byte *)buffer;
memset(fri, 0, sizeof(Z7_WIN_FILE_RENAME_INFORMATION));
/* DOCS: If ReplaceIfExists is set to TRUE, the rename operation will succeed only
if a stream with the same name does not exist or is a zero-length data stream. */
fri->ReplaceIfExists = FALSE;
fri->RootDirectory = NULL;
fri->FileNameLength = len;
memcpy(fri->FileName, destPath.Ptr(), len);
Z7_WIN_IO_STATUS_BLOCK iosb;
const Z7_WIN_NTSTATUS status = f_NtSetInformationFile (inFile.GetHandle(),
&iosb, fri, (ULONG)buffer.Size(), Z7_WIN_FileRenameInformation);
if (status != MY_STATUS_SUCCESS)
{
const
Func_RtlNtStatusToDosError
f_RtlNtStatusToDosError = Z7_GET_PROC_ADDRESS(
Func_RtlNtStatusToDosError, ntdll,
"RtlNtStatusToDosError");
if (f_RtlNtStatusToDosError)
{
const ULONG res = f_RtlNtStatusToDosError(status);
if (res != ERROR_MR_MID_NOT_FOUND)
return HRESULT_FROM_WIN32(res);
}
}
return status;
}
}
CMyComPtr<IFolderArchiveUpdateCallback> callback;
if (progress)
{
RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&callback))
}
if (callback)
{
RINOK(callback->SetNumFiles(1))
RINOK(callback->SetTotal(ss.Size))
}
NFsFolder::CCopyStateIO state;
state.Progress = progress;
state.TotalSize = 0;
state.DeleteSrcFile = true;
const FString destPath = _pathPrefix + us2fs(newName);
return UpdateFile(state, srcPath, destPath, callback);
}
Z7_COM7F_IMF(CAltStreamsFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress))
{
RINOK(progress->SetTotal(numItems))
for (UInt32 i = 0; i < numItems; i++)
{
const CAltStream &ss = Streams[indices[i]];
const FString fullPath = _pathPrefix + us2fs(ss.Name);
const bool result = DeleteFileAlways(fullPath);
if (!result)
return GetLastError_noZero_HRESULT();
const UInt64 completed = i;
RINOK(progress->SetCompleted(&completed))
}
return S_OK;
}
Z7_COM7F_IMF(CAltStreamsFolder::SetProperty(UInt32 /* index */, PROPID /* propID */,
const PROPVARIANT * /* value */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
Z7_COM7F_IMF(CAltStreamsFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex))
{
const CAltStream &ss = Streams[index];
return Shell_GetFileInfo_SysIconIndex_for_Path_return_HRESULT(
_pathPrefix + us2fs(ss.Name),
FILE_ATTRIBUTE_ARCHIVE,
iconIndex);
}
/*
Z7_CLASS_IMP_COM_1(
CGetProp
, IGetProp
)
public:
// const CArc *Arc;
// UInt32 IndexInArc;
UString Name; // relative path
UInt64 Size;
};
Z7_COM7F_IMF(CGetProp::GetProp(PROPID propID, PROPVARIANT *value))
{
if (propID == kpidName)
{
COM_TRY_BEGIN
NCOM::CPropVariant prop;
prop = Name;
prop.Detach(value);
return S_OK;
COM_TRY_END
}
if (propID == kpidSize)
{
NCOM::CPropVariant prop = Size;
prop.Detach(value);
return S_OK;
}
NCOM::CPropVariant prop;
prop.Detach(value);
return S_OK;
}
*/
static HRESULT CopyStream(
NFsFolder::CCopyStateIO &state,
const FString &srcPath,
const CFileInfo &srcFileInfo,
const CAltStream &srcAltStream,
const FString &destPathSpec,
IFolderOperationsExtractCallback *callback)
{
FString destPath = destPathSpec;
if (CompareFileNames(destPath, srcPath) == 0)
{
RINOK(SendMessageError(callback, "Cannot copy file onto itself", destPath))
return E_ABORT;
}
Int32 writeAskResult;
CMyComBSTR destPathResult;
RINOK(callback->AskWrite(
fs2us(srcPath),
BoolToInt(false),
&srcFileInfo.MTime, &srcAltStream.Size,
fs2us(destPath),
&destPathResult,
&writeAskResult))
if (IntToBool(writeAskResult))
{
RINOK(callback->SetCurrentFilePath(fs2us(srcPath)))
FString destPathNew (us2fs((LPCOLESTR)destPathResult));
RINOK(state.MyCopyFile(srcPath, destPathNew))
if (state.ErrorFileIndex >= 0)
{
if (state.ErrorMessage.IsEmpty())
state.ErrorMessage = GetLastErrorMessage();
FString errorName;
if (state.ErrorFileIndex == 0)
errorName = srcPath;
else
errorName = destPathNew;
RINOK(SendMessageError(callback, state.ErrorMessage, errorName))
return E_ABORT;
}
state.StartPos += state.CurrentSize;
}
else
{
if (state.TotalSize >= srcAltStream.Size)
{
state.TotalSize -= srcAltStream.Size;
RINOK(state.Progress->SetTotal(state.TotalSize))
}
}
return S_OK;
}
Z7_COM7F_IMF(CAltStreamsFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems,
Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */,
const wchar_t *path, IFolderOperationsExtractCallback *callback))
{
if (numItems == 0)
return S_OK;
/*
Z7_DECL_CMyComPtr_QI_FROM(
IFolderExtractToStreamCallback,
ExtractToStreamCallback, callback)
if (ExtractToStreamCallback)
{
Int32 useStreams = 0;
if (ExtractToStreamCallback->UseExtractToStream(&useStreams) != S_OK)
useStreams = 0;
if (useStreams == 0)
ExtractToStreamCallback.Release();
}
*/
UInt64 totalSize = 0;
{
UInt32 i;
for (i = 0; i < numItems; i++)
{
totalSize += Streams[indices[i]].Size;
}
RINOK(callback->SetTotal(totalSize))
RINOK(callback->SetNumFiles(numItems))
}
/*
if (ExtractToStreamCallback)
{
CGetProp *GetProp_Spec = new CGetProp;
CMyComPtr<IGetProp> GetProp= GetProp_Spec;
for (UInt32 i = 0; i < numItems; i++)
{
UInt32 index = indices[i];
const CAltStream &ss = Streams[index];
GetProp_Spec->Name = ss.Name;
GetProp_Spec->Size = ss.Size;
CMyComPtr<ISequentialOutStream> outStream;
RINOK(ExtractToStreamCallback->GetStream7(GetProp_Spec->Name, BoolToInt(false), &outStream,
NArchive::NExtract::NAskMode::kExtract, GetProp)); // isDir
FString srcPath;
GetFullPath(ss, srcPath);
RINOK(ExtractToStreamCallback->PrepareOperation7(NArchive::NExtract::NAskMode::kExtract));
RINOK(ExtractToStreamCallback->SetOperationResult7(NArchive::NExtract::NOperationResult::kOK, BoolToInt(false))); // _encrypted
// RINOK(CopyStream(state, srcPath, fi, ss, destPath2, callback, completedSize));
}
return S_OK;
}
*/
FString destPath (us2fs(path));
if (destPath.IsEmpty() /* && !ExtractToStreamCallback */)
return E_INVALIDARG;
const bool isAltDest = NName::IsAltPathPrefix(destPath);
const bool isDirectPath = (!isAltDest && !IsPathSepar(destPath.Back()));
if (isDirectPath)
{
if (numItems > 1)
return E_INVALIDARG;
}
CFileInfo fi;
if (!fi.Find(_pathBaseFile))
return GetLastError_noZero_HRESULT();
NFsFolder::CCopyStateIO state;
state.Progress = callback;
state.DeleteSrcFile = IntToBool(moveMode);
state.TotalSize = totalSize;
for (UInt32 i = 0; i < numItems; i++)
{
const UInt32 index = indices[i];
const CAltStream &ss = Streams[index];
FString destPath2 = destPath;
if (!isDirectPath)
destPath2 += us2fs(Get_Correct_FsFile_Name(ss.Name));
FString srcPath;
GetFullPath(ss, srcPath);
RINOK(CopyStream(state, srcPath, fi, ss, destPath2, callback))
}
return S_OK;
}
Z7_COM7F_IMF(CAltStreamsFolder::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */,
const wchar_t * const * /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */))
{
/*
if (numItems == 0)
return S_OK;
CMyComPtr<IFolderArchiveUpdateCallback> callback;
if (progress)
{
RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&callback));
}
if (CompareFileNames(fromFolderPath, fs2us(_pathPrefix)) == 0)
{
RINOK(SendMessageError(callback, "Cannot copy file onto itself", _pathPrefix));
return E_ABORT;
}
if (callback)
RINOK(callback->SetNumFiles(numItems));
UInt64 totalSize = 0;
UInt32 i;
FString path;
for (i = 0; i < numItems; i++)
{
path = us2fs(fromFolderPath);
path += us2fs(itemsPaths[i]);
CFileInfo fi;
if (!fi.Find(path))
return ::GetLastError();
if (fi.IsDir())
return E_NOTIMPL;
totalSize += fi.Size;
}
RINOK(progress->SetTotal(totalSize));
// UInt64 completedSize = 0;
NFsFolder::CCopyStateIO state;
state.Progress = progress;
state.DeleteSrcFile = IntToBool(moveMode);
state.TotalSize = totalSize;
// we need to clear READ-ONLY of parent before creating alt stream
{
DWORD attrib = GetFileAttrib(_pathBaseFile);
if (attrib != INVALID_FILE_ATTRIBUTES
&& (attrib & FILE_ATTRIBUTE_READONLY) != 0)
{
if (!SetFileAttrib(_pathBaseFile, attrib & ~FILE_ATTRIBUTE_READONLY))
{
if (callback)
{
RINOK(SendMessageError(callback, GetLastErrorMessage(), _pathBaseFile));
return S_OK;
}
return Return_LastError_or_FAIL();
}
}
}
for (i = 0; i < numItems; i++)
{
path = us2fs(fromFolderPath);
path += us2fs(itemsPaths[i]);
FString destPath = _pathPrefix + us2fs(itemsPaths[i]);
RINOK(UpdateFile(state, path, destPath, callback));
}
return S_OK;
*/
return E_NOTIMPL;
}
Z7_COM7F_IMF(CAltStreamsFolder::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
}
@@ -0,0 +1,92 @@
// AltStreamsFolder.h
#ifndef ZIP7_INC_ALT_STREAMS_FOLDER_H
#define ZIP7_INC_ALT_STREAMS_FOLDER_H
#include "../../../Common/MyCom.h"
#include "../../../Windows/FileFind.h"
#include "../../Archive/IArchive.h"
#include "IFolder.h"
namespace NAltStreamsFolder {
class CAltStreamsFolder;
struct CAltStream
{
UInt64 Size;
UInt64 PackSize;
bool PackSize_Defined;
UString Name;
};
class CAltStreamsFolder Z7_final:
public IFolderFolder,
public IFolderCompare,
#ifdef USE_UNICODE_FSTRING
public IFolderGetItemName,
#endif
public IFolderWasChanged,
public IFolderOperations,
// public IFolderOperationsDeleteToRecycleBin,
public IFolderClone,
public IFolderGetSystemIconIndex,
public CMyUnknownImp
{
Z7_COM_QI_BEGIN2(IFolderFolder)
Z7_COM_QI_ENTRY(IFolderCompare)
#ifdef USE_UNICODE_FSTRING
Z7_COM_QI_ENTRY(IFolderGetItemName)
#endif
Z7_COM_QI_ENTRY(IFolderWasChanged)
// Z7_COM_QI_ENTRY(IFolderOperationsDeleteToRecycleBin)
Z7_COM_QI_ENTRY(IFolderOperations)
Z7_COM_QI_ENTRY(IFolderClone)
Z7_COM_QI_ENTRY(IFolderGetSystemIconIndex)
Z7_COM_QI_END
Z7_COM_ADDREF_RELEASE
Z7_IFACE_COM7_IMP(IFolderFolder)
Z7_IFACE_COM7_IMP(IFolderCompare)
#ifdef USE_UNICODE_FSTRING
Z7_IFACE_COM7_IMP(IFolderGetItemName)
#endif
Z7_IFACE_COM7_IMP(IFolderWasChanged)
Z7_IFACE_COM7_IMP(IFolderOperations)
Z7_IFACE_COM7_IMP(IFolderClone)
Z7_IFACE_COM7_IMP(IFolderGetSystemIconIndex)
FString _pathBaseFile; // folder
FString _pathPrefix; // folder:
CObjectVector<CAltStream> Streams;
// CMyComPtr<IFolderFolder> _parentFolder;
NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
HRESULT GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress);
void GetAbsPath(const wchar_t *name, FString &absPath);
public:
// path must be with ':' at tail
HRESULT Init(const FString &path /* , IFolderFolder *parentFolder */);
void GetFullPath(const CAltStream &item, FString &path) const
{
path = _pathPrefix;
path += us2fs(item.Name);
}
void Clear()
{
Streams.Clear();
}
};
}
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,314 @@
// App.h
#ifndef ZIP7_INC_APP_H
#define ZIP7_INC_APP_H
#include "../../../Windows/Control/CommandBar.h"
#include "../../../Windows/Control/ImageList.h"
#include "AppState.h"
#include "Panel.h"
class CApp;
extern CApp g_App;
extern HWND g_HWND;
const unsigned kNumPanelsMax = 2;
extern bool g_IsSmallScreen;
// must be larger than context menu IDs
const int kMenuCmdID_Toolbar_Start = 1070;
const int kMenuCmdID_Plugin_Start = 1100;
enum
{
kMenuCmdID_Toolbar_Add = kMenuCmdID_Toolbar_Start,
kMenuCmdID_Toolbar_Extract,
kMenuCmdID_Toolbar_Test,
kMenuCmdID_Toolbar_End
};
class CPanelCallbackImp Z7_final: public CPanelCallback
{
CApp *_app;
unsigned _index;
public:
void Init(CApp *app, unsigned index)
{
_app = app;
_index = index;
}
virtual void OnTab() Z7_override;
virtual void SetFocusToPath(unsigned index) Z7_override;
virtual void OnCopy(bool move, bool copyToSame) Z7_override;
virtual void OnSetSameFolder() Z7_override;
virtual void OnSetSubFolder() Z7_override;
virtual void PanelWasFocused() Z7_override;
virtual void DragBegin() Z7_override;
virtual void DragEnd() Z7_override;
virtual void RefreshTitle(bool always) Z7_override;
};
class CDropTarget;
class CApp
{
public:
NWindows::CWindow _window;
bool ShowSystemMenu;
bool AutoRefresh_Mode;
// bool ShowDeletedFiles;
unsigned NumPanels;
unsigned LastFocusedPanel;
bool ShowStandardToolbar;
bool ShowArchiveToolbar;
bool ShowButtonsLables;
bool LargeButtons;
CAppState AppState;
CPanelCallbackImp m_PanelCallbackImp[kNumPanelsMax];
CPanel Panels[kNumPanelsMax];
NWindows::NControl::CImageList _buttonsImageList;
#ifdef UNDER_CE
NWindows::NControl::CCommandBar _commandBar;
#endif
NWindows::NControl::CToolBar _toolBar;
CDropTarget *_dropTargetSpec;
CMyComPtr<IDropTarget> _dropTarget;
UString LangString_N_SELECTED_ITEMS;
void ReloadLangItems();
CApp():
_window(NULL),
AutoRefresh_Mode(true),
NumPanels(2),
LastFocusedPanel(0)
{
SetPanels_AutoRefresh_Mode();
}
void CreateDragTarget();
void SetFocusedPanel(unsigned index);
void DragBegin(unsigned panelIndex);
void DragEnd();
void OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex);
void OnSetSameFolder(unsigned srcPanelIndex);
void OnSetSubFolder(unsigned srcPanelIndex);
HRESULT CreateOnePanel(unsigned panelIndex, const UString &mainPath, const UString &arcFormat, bool needOpenArc, COpenResult &openRes);
HRESULT Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, COpenResult &openRes);
void Read();
void Save();
void ReleaseApp();
// void SetFocus(int panelIndex) { Panels[panelIndex].SetFocusToList(); }
void SetFocusToLastItem() { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); }
unsigned GetFocusedPanelIndex() const { return LastFocusedPanel; }
bool IsPanelVisible(unsigned index) const { return (NumPanels > 1 || index == LastFocusedPanel); }
CPanel &GetFocusedPanel() { return Panels[GetFocusedPanelIndex()]; }
// File Menu
void OpenItem() { GetFocusedPanel().OpenSelectedItems(true); }
void OpenItemInside(const wchar_t *type) { GetFocusedPanel().OpenFocusedItemAsInternal(type); }
void OpenItemOutside() { GetFocusedPanel().OpenSelectedItems(false); }
void EditItem(bool useEditor) { GetFocusedPanel().EditItem(useEditor); }
void Rename() { GetFocusedPanel().RenameFile(); }
void CopyTo() { OnCopy(false, false, GetFocusedPanelIndex()); }
void MoveTo() { OnCopy(true, false, GetFocusedPanelIndex()); }
void Delete(bool toRecycleBin) { GetFocusedPanel().DeleteItems(toRecycleBin); }
HRESULT CalculateCrc2(const UString &methodName);
void CalculateCrc(const char *methodName);
void DiffFiles(const UString &path1, const UString &path2);
void DiffFiles();
void VerCtrl(unsigned id);
void Split();
void Combine();
void Properties() { GetFocusedPanel().Properties(); }
void Comment() { GetFocusedPanel().ChangeComment(); }
#ifndef UNDER_CE
void Link();
void OpenAltStreams() { GetFocusedPanel().OpenAltStreams(); }
#endif
void CreateFolder() { GetFocusedPanel().CreateFolder(); }
void CreateFile() { GetFocusedPanel().CreateFile(); }
// Edit
void EditCut() { GetFocusedPanel().EditCut(); }
void EditCopy() { GetFocusedPanel().EditCopy(); }
void EditPaste() { GetFocusedPanel().EditPaste(); }
void SelectAll(bool selectMode) { GetFocusedPanel().SelectAll(selectMode); }
void InvertSelection() { GetFocusedPanel().InvertSelection(); }
void SelectSpec(bool selectMode) { GetFocusedPanel().SelectSpec(selectMode); }
void SelectByType(bool selectMode) { GetFocusedPanel().SelectByType(selectMode); }
void Refresh_StatusBar() { GetFocusedPanel().Refresh_StatusBar(); }
void SetListViewMode(UInt32 index) { GetFocusedPanel().SetListViewMode(index); }
UInt32 GetListViewMode() { return GetFocusedPanel().GetListViewMode(); }
PROPID GetSortID() { return GetFocusedPanel().GetSortID(); }
void SortItemsWithPropID(PROPID propID) { GetFocusedPanel().SortItemsWithPropID(propID); }
void OpenRootFolder() { GetFocusedPanel().OpenDrivesFolder(); }
void OpenParentFolder() { GetFocusedPanel().OpenParentFolder(); }
void FoldersHistory() { GetFocusedPanel().FoldersHistory(); }
void RefreshView() { GetFocusedPanel().OnReload(); }
void RefreshAllPanels()
{
for (unsigned i = 0; i < NumPanels; i++)
{
unsigned index = i;
if (NumPanels == 1)
index = LastFocusedPanel;
Panels[index].OnReload();
}
}
/*
void SysIconsWereChanged()
{
for (unsigned i = 0; i < NumPanels; i++)
{
unsigned index = i;
if (NumPanels == 1)
index = LastFocusedPanel;
Panels[index].SysIconsWereChanged();
}
}
*/
void SetListSettings();
HRESULT SwitchOnOffOnePanel();
CIntVector _timestampLevels;
bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); }
int GetTimestampLevel() const { return Panels[LastFocusedPanel]._timestampLevel; }
void SetTimestampLevel(int level)
{
for (unsigned i = 0; i < kNumPanelsMax; i++)
{
CPanel &panel = Panels[i];
panel._timestampLevel = level;
}
RedrawListItems_InPanels();
}
void RedrawListItems_InPanels()
{
for (unsigned i = 0; i < kNumPanelsMax; i++)
{
CPanel &panel = Panels[i];
if (panel.PanelCreated)
panel.RedrawListItems();
}
}
// bool Get_ShowNtfsStrems_Mode() { return Panels[LastFocusedPanel].Get_ShowNtfsStrems_Mode(); }
void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); }
// void Change_ShowNtfsStrems_Mode() { Panels[LastFocusedPanel].Change_ShowNtfsStrems_Mode(); }
// void Change_ShowDeleted() { ShowDeletedFiles = !ShowDeletedFiles; }
bool Get_AutoRefresh_Mode()
{
// return Panels[LastFocusedPanel].Get_ShowNtfsStrems_Mode();
return AutoRefresh_Mode;
}
void Change_AutoRefresh_Mode()
{
AutoRefresh_Mode = !AutoRefresh_Mode;
SetPanels_AutoRefresh_Mode();
}
void SetPanels_AutoRefresh_Mode()
{
for (unsigned i = 0; i < kNumPanelsMax; i++)
Panels[i].Set_AutoRefresh_Mode(AutoRefresh_Mode);
}
void OpenBookmark(unsigned index) { GetFocusedPanel().OpenBookmark(index); }
void SetBookmark(unsigned index) { GetFocusedPanel().SetBookmark(index); }
void ReloadToolbars();
void ReadToolbar()
{
const UInt32 mask = ReadToolbarsMask();
if (mask & ((UInt32)1 << 31))
{
ShowButtonsLables = !g_IsSmallScreen;
LargeButtons = false;
ShowStandardToolbar = ShowArchiveToolbar = true;
}
else
{
ShowButtonsLables = ((mask & 1) != 0);
LargeButtons = ((mask & 2) != 0);
ShowStandardToolbar = ((mask & 4) != 0);
ShowArchiveToolbar = ((mask & 8) != 0);
}
}
void SaveToolbar()
{
UInt32 mask = 0;
if (ShowButtonsLables) mask |= 1;
if (LargeButtons) mask |= 2;
if (ShowStandardToolbar) mask |= 4;
if (ShowArchiveToolbar) mask |= 8;
SaveToolbarsMask(mask);
}
void SaveToolbarChanges();
void SwitchStandardToolbar()
{
ShowStandardToolbar = !ShowStandardToolbar;
SaveToolbarChanges();
}
void SwitchArchiveToolbar()
{
ShowArchiveToolbar = !ShowArchiveToolbar;
SaveToolbarChanges();
}
void SwitchButtonsLables()
{
ShowButtonsLables = !ShowButtonsLables;
SaveToolbarChanges();
}
void SwitchLargeButtons()
{
LargeButtons = !LargeButtons;
SaveToolbarChanges();
}
void AddToArchive() { GetFocusedPanel().AddToArchive(); }
void ExtractArchives() { GetFocusedPanel().ExtractArchives(); }
void TestArchives() { GetFocusedPanel().TestArchives(); }
void OnNotify(int ctrlID, LPNMHDR pnmh);
UString PrevTitle;
void RefreshTitle(bool always = false);
void RefreshTitleAlways() { RefreshTitle(true); }
void RefreshTitlePanel(unsigned panelIndex, bool always = false);
void MoveSubWindows();
};
#endif
@@ -0,0 +1,95 @@
// AppState.h
#ifndef ZIP7_INC_APP_STATE_H
#define ZIP7_INC_APP_STATE_H
#include "../../../Windows/Synchronization.h"
#include "ViewSettings.h"
class CFastFolders
{
NWindows::NSynchronization::CCriticalSection _criticalSection;
public:
UStringVector Strings;
void SetString(unsigned index, const UString &s)
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
while (Strings.Size() <= index)
Strings.AddNew();
Strings[index] = s;
}
UString GetString(unsigned index)
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
if (index >= Strings.Size())
return UString();
return Strings[index];
}
void Save()
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
SaveFastFolders(Strings);
}
void Read()
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
ReadFastFolders(Strings);
}
};
class CFolderHistory
{
NWindows::NSynchronization::CCriticalSection _criticalSection;
UStringVector Strings;
void Normalize();
public:
void GetList(UStringVector &foldersHistory)
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
foldersHistory = Strings;
}
void AddString(const UString &s);
void RemoveAll()
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
Strings.Clear();
}
void Save()
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
SaveFolderHistory(Strings);
}
void Read()
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
ReadFolderHistory(Strings);
Normalize();
}
};
struct CAppState
{
CFastFolders FastFolders;
CFolderHistory FolderHistory;
void Save()
{
FastFolders.Save();
FolderHistory.Save();
}
void Read()
{
FastFolders.Read();
FolderHistory.Read();
}
};
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,32 @@
// BrowseDialog.h
#ifndef ZIP7_INC_BROWSE_DIALOG_H
#define ZIP7_INC_BROWSE_DIALOG_H
#include "../../../Windows/CommonDialog.h"
bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR path, UString &resultPath);
struct CBrowseFilterInfo
{
UStringVector Masks;
UString Description;
};
struct CBrowseInfo: public NWindows::CCommonDialogInfo
{
bool BrowseForFile(const CObjectVector<CBrowseFilterInfo> &filters);
};
/* CorrectFsPath removes undesirable characters in names (dots and spaces at the end of file)
But it doesn't change "bad" name in any of the following cases:
- path is Super Path (with \\?\ prefix)
- path is relative and relBase is Super Path
- there is file or dir in filesystem with specified "bad" name */
bool CorrectFsPath(const UString &relBase, const UString &path, UString &result);
bool Dlg_CreateFolder(HWND wnd, UString &destName);
#endif
@@ -0,0 +1,25 @@
#include "BrowseDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 256
#define yc 320
#define k_BROWSE_y_CtrlSize 14
#define k_BROWSE_y_List 24
IDD_BROWSE DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT
CAPTION "7-Zip: Browse"
{
EDITTEXT IDE_BROWSE_PATH, m, by - m - k_BROWSE_y_CtrlSize - k_BROWSE_y_CtrlSize - m, xc, k_BROWSE_y_CtrlSize, ES_AUTOHSCROLL
COMBOBOX IDC_BROWSE_FILTER, m, by - m - k_BROWSE_y_CtrlSize, xc, 30, MY_COMBO
PUSHBUTTON "OK", IDOK, bx2, by, bxs, bys
PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
PUSHBUTTON "<--", IDB_BROWSE_PARENT, m, m, 24, bys
PUSHBUTTON "+", IDB_BROWSE_CREATE_DIR, m + 32, m, 24, bys
LTEXT "", IDT_BROWSE_FOLDER, m + 64, m + 3, xc - 20, 8
CONTROL "List1", IDL_BROWSE, "SysListView32",
LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,
m, m + k_BROWSE_y_List, xc, yc - bys - m - k_BROWSE_y_List - k_BROWSE_y_CtrlSize - m - k_BROWSE_y_CtrlSize - m
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,10 @@
// BrowseDialog2.h
#ifndef ZIP7_INC_BROWSE_DIALOG2_H
#define ZIP7_INC_BROWSE_DIALOG2_H
#include "../../../Windows/Window.h"
void MyBrowseForTempFolder(HWND owner);
#endif
@@ -0,0 +1,32 @@
#include "BrowseDialog2Res.h"
#include "../../GuiCommon.rc"
// #include "resource.h"
#define xc 450
#define yc 328
#define k_BROWSE2_y_CtrlSize 14
#define k_BROWSE2_y_List 40
IDD_BROWSE2 DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT
CAPTION "7-Zip: Browse Temp Files"
{
// EDITTEXT IDE_BROWSE_PATH, m, by - m - k_BROWSE_y_CtrlSize - k_BROWSE_y_CtrlSize - m, xc, k_BROWSE_y_CtrlSize, ES_AUTOHSCROLL
COMBOBOX IDC_BROWSE2_FILTER, m, by - m - k_BROWSE2_y_CtrlSize, xc, 30, MY_COMBO
// DON'T USE DEFPUSHBUTTON here, because we use IDOK as default action for Enter key.
PUSHBUTTON "Close", IDCLOSE, bx2, by, bxs, bys, WS_GROUP
PUSHBUTTON "Help", IDHELP, bx1, by, bxs, bys
PUSHBUTTON "Delete", IDS_BUTTON_DELETE, m , m, 64, bys
PUSHBUTTON "Refresh", IDM_VIEW_REFRESH, m + 64 + 8, m, 64, bys
PUSHBUTTON "<--", IDB_BROWSE2_PARENT, m, m + 21, 24, bys
// LTEXT "", IDT_BROWSE_FOLDER, m + 30, m + 24, xc - 30, 8
EDITTEXT IDT_BROWSE2_FOLDER, m + 28, m + 22, xc - 28, 14, ES_AUTOHSCROLL | ES_READONLY
CONTROL "List1", IDL_BROWSE2, "SysListView32",
LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | WS_BORDER | WS_TABSTOP,
m, m + k_BROWSE2_y_List, xc, yc - bys - m - k_BROWSE2_y_List - k_BROWSE2_y_CtrlSize - m
}
@@ -0,0 +1,9 @@
#define IDD_BROWSE2 93
#define IDL_BROWSE2 100
#define IDT_BROWSE2_FOLDER 101
// #define IDE_BROWSE2_PATH 102
#define IDC_BROWSE2_FILTER 103
#define IDB_BROWSE2_PARENT 110
// #define IDB_BROWSE2_CREATE_DIR 112
@@ -0,0 +1,9 @@
#define IDD_BROWSE 95
#define IDL_BROWSE 100
#define IDT_BROWSE_FOLDER 101
#define IDE_BROWSE_PATH 102
#define IDC_BROWSE_FILTER 103
#define IDB_BROWSE_PARENT 110
#define IDB_BROWSE_CREATE_DIR 112
@@ -0,0 +1,12 @@
// ClassDefs.cpp
#include "StdAfx.h"
#include "../../../Common/MyWindows.h"
#include "../../../Common/MyInitGuid.h"
#include "../Agent/Agent.h"
#include "MyWindowsNew.h"
#include "../Explorer/MyExplorerCommand.h"
@@ -0,0 +1,64 @@
// ComboDialog.cpp
#include "StdAfx.h"
#include "ComboDialog.h"
#include "../../../Windows/Control/Static.h"
#ifdef Z7_LANG
#include "LangUtils.h"
#endif
using namespace NWindows;
bool CComboDialog::OnInit()
{
#ifdef Z7_LANG
LangSetDlgItems(*this, NULL, 0);
#endif
_comboBox.Attach(GetItem(IDC_COMBO));
/*
// why it doesn't work ?
DWORD style = _comboBox.GetStyle();
if (Sorted)
style |= CBS_SORT;
else
style &= ~CBS_SORT;
_comboBox.SetStyle(style);
*/
SetText(Title);
NControl::CStatic staticContol;
staticContol.Attach(GetItem(IDT_COMBO));
staticContol.SetText(Static);
_comboBox.SetText(Value);
FOR_VECTOR (i, Strings)
_comboBox.AddString(Strings[i]);
NormalizeSize();
return CModalDialog::OnInit();
}
bool CComboDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
{
int mx, my;
GetMargins(8, mx, my);
int bx1, bx2, by;
GetItemSizes(IDCANCEL, bx1, by);
GetItemSizes(IDOK, bx2, by);
int y = ySize - my - by;
int x = xSize - mx - bx1;
InvalidateRect(NULL);
MoveItem(IDCANCEL, x, y, bx1, by);
MoveItem(IDOK, x - mx - bx2, y, bx2, by);
ChangeSubWindowSizeX(_comboBox, xSize - mx * 2);
return false;
}
void CComboDialog::OnOK()
{
_comboBox.GetText(Value);
CModalDialog::OnOK();
}
@@ -0,0 +1,28 @@
// ComboDialog.h
#ifndef ZIP7_INC_COMBO_DIALOG_H
#define ZIP7_INC_COMBO_DIALOG_H
#include "../../../Windows/Control/ComboBox.h"
#include "../../../Windows/Control/Dialog.h"
#include "ComboDialogRes.h"
class CComboDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox _comboBox;
virtual void OnOK() Z7_override;
virtual bool OnInit() Z7_override;
virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
public:
// bool Sorted;
UString Title;
UString Static;
UString Value;
UStringVector Strings;
// CComboDialog(): Sorted(false) {};
INT_PTR Create(HWND parentWindow = NULL) { return CModalDialog::Create(IDD_COMBO, parentWindow); }
};
#endif
@@ -0,0 +1,16 @@
#include "ComboDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 240
#define yc 64
IDD_COMBO DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT
CAPTION "Combo"
{
LTEXT "", IDT_COMBO, m, m, xc, 8
COMBOBOX IDC_COMBO, m, 20, xc, 65, MY_COMBO_WITH_EDIT
OK_CANCEL
}
#undef xc
#undef yc
@@ -0,0 +1,4 @@
#define IDD_COMBO 98
#define IDT_COMBO 100
#define IDC_COMBO 101
Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

@@ -0,0 +1,103 @@
// CopyDialog.cpp
#include "StdAfx.h"
#include "../../../Windows/FileName.h"
#include "../../../Windows/Control/Static.h"
#include "BrowseDialog.h"
#include "CopyDialog.h"
#include "LangUtils.h"
using namespace NWindows;
bool CCopyDialog::OnInit()
{
#ifdef Z7_LANG
LangSetDlgItems(*this, NULL, 0);
#endif
_path.Attach(GetItem(IDC_COPY));
SetText(Title);
NControl::CStatic staticContol;
staticContol.Attach(GetItem(IDT_COPY));
staticContol.SetText(Static);
#ifdef UNDER_CE
// we do it, since WinCE selects Value\something instead of Value !!!!
_path.AddString(Value);
#endif
FOR_VECTOR (i, Strings)
_path.AddString(Strings[i]);
_path.SetText(Value);
SetItemText(IDT_COPY_INFO, Info);
NormalizeSize(true);
return CModalDialog::OnInit();
}
bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
{
int mx, my;
GetMargins(8, mx, my);
int bx1, bx2, by;
GetItemSizes(IDCANCEL, bx1, by);
GetItemSizes(IDOK, bx2, by);
const int y = ySize - my - by;
const int x = xSize - mx - bx1;
InvalidateRect(NULL);
{
RECT r;
GetClientRectOfItem(IDB_COPY_SET_PATH, r);
const int bx = RECT_SIZE_X(r);
MoveItem(IDB_COPY_SET_PATH, xSize - mx - bx, r.top, bx, RECT_SIZE_Y(r));
ChangeSubWindowSizeX(_path, xSize - mx - mx - bx - mx);
}
{
RECT r;
GetClientRectOfItem(IDT_COPY_INFO, r);
NControl::CStatic staticContol;
staticContol.Attach(GetItem(IDT_COPY_INFO));
const int yPos = r.top;
staticContol.Move(mx, yPos, xSize - mx * 2, y - 2 - yPos);
}
MoveItem(IDCANCEL, x, y, bx1, by);
MoveItem(IDOK, x - mx - bx2, y, bx2, by);
return false;
}
bool CCopyDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
switch (buttonID)
{
case IDB_COPY_SET_PATH:
OnButtonSetPath();
return true;
}
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
void CCopyDialog::OnButtonSetPath()
{
UString currentPath;
_path.GetText(currentPath);
const UString title = LangString(IDS_SET_FOLDER);
UString resultPath;
if (!MyBrowseForFolder(*this, title, currentPath, resultPath))
return;
NFile::NName::NormalizeDirPathPrefix(resultPath);
_path.SetCurSel(-1);
_path.SetText(resultPath);
}
void CCopyDialog::OnOK()
{
_path.GetText(Value);
CModalDialog::OnOK();
}
@@ -0,0 +1,31 @@
// CopyDialog.h
#ifndef ZIP7_INC_COPY_DIALOG_H
#define ZIP7_INC_COPY_DIALOG_H
#include "../../../Windows/Control/ComboBox.h"
#include "../../../Windows/Control/Dialog.h"
#include "CopyDialogRes.h"
const int kCopyDialog_NumInfoLines = 11;
class CCopyDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox _path;
virtual void OnOK() Z7_override;
virtual bool OnInit() Z7_override;
virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
void OnButtonSetPath();
public:
UString Title;
UString Static;
UString Value;
UString Info;
UStringVector Strings;
INT_PTR Create(HWND parentWindow = NULL) { return CModalDialog::Create(IDD_COPY, parentWindow); }
};
#endif
@@ -0,0 +1,20 @@
#include "CopyDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 320
#define yc 144
#define y 40
IDD_COPY DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT
CAPTION "Copy"
{
LTEXT "", IDT_COPY, m, m, xc, 8
COMBOBOX IDC_COPY, m, 20, xc - bxsDots - m, 65, MY_COMBO_WITH_EDIT
PUSHBUTTON "...", IDB_COPY_SET_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP
LTEXT "", IDT_COPY_INFO, m, y, xc, by - y - 1, SS_NOPREFIX | SS_LEFTNOWORDWRAP
OK_CANCEL
}
#undef xc
#undef yc
@@ -0,0 +1,8 @@
#define IDD_COPY 96
#define IDT_COPY 100
#define IDC_COPY 101
#define IDB_COPY_SET_PATH 102
#define IDT_COPY_INFO 103
#define IDS_SET_FOLDER 6007
Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

@@ -0,0 +1,16 @@
// DialogSize.h
#ifndef ZIP7_INC_DIALOG_SIZE_H
#define ZIP7_INC_DIALOG_SIZE_H
#include "../../../Windows/Control/Dialog.h"
#ifdef UNDER_CE
#define BIG_DIALOG_SIZE(x, y) bool isBig = NWindows::NControl::IsDialogSizeOK(x, y);
#define SIZED_DIALOG(big) (isBig ? big : big ## _2)
#else
#define BIG_DIALOG_SIZE(x, y)
#define SIZED_DIALOG(big) big
#endif
#endif
@@ -0,0 +1,57 @@
// EditDialog.cpp
#include "StdAfx.h"
#include "EditDialog.h"
#ifdef Z7_LANG
#include "LangUtils.h"
#endif
bool CEditDialog::OnInit()
{
#ifdef Z7_LANG
LangSetDlgItems(*this, NULL, 0);
#endif
_edit.Attach(GetItem(IDE_EDIT));
SetText(Title);
_edit.SetText(Text);
NormalizeSize();
return CModalDialog::OnInit();
}
// #define MY_CLOSE_BUTTON_ID IDCANCEL
#define MY_CLOSE_BUTTON_ID IDCLOSE
bool CEditDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
{
int mx, my;
GetMargins(8, mx, my);
int bx1, by;
GetItemSizes(MY_CLOSE_BUTTON_ID, bx1, by);
// int bx2;
// GetItemSizes(IDOK, bx2, by);
const int y = ySize - my - by;
const int x = xSize - mx - bx1;
/*
RECT rect;
GetClientRect(&rect);
rect.top = y - my;
InvalidateRect(&rect);
*/
InvalidateRect(NULL);
MoveItem(MY_CLOSE_BUTTON_ID, x, y, bx1, by);
// MoveItem(IDOK, x - mx - bx2, y, bx2, by);
/*
if (wParam == SIZE_MAXSHOW || wParam == SIZE_MAXIMIZED || wParam == SIZE_MAXHIDE)
mx = 0;
*/
_edit.Move(mx, my, xSize - mx * 2, y - my * 2);
return false;
}
@@ -0,0 +1,25 @@
// EditDialog.h
#ifndef ZIP7_INC_EDIT_DIALOG_H
#define ZIP7_INC_EDIT_DIALOG_H
#include "../../../Windows/Control/Dialog.h"
#include "../../../Windows/Control/Edit.h"
#include "EditDialogRes.h"
class CEditDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CEdit _edit;
virtual bool OnInit() Z7_override;
virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
public:
UString Title;
UString Text;
INT_PTR Create(HWND wndParent = NULL) { return CModalDialog::Create(IDD_EDIT_DLG, wndParent); }
CEditDialog() {}
};
#endif
@@ -0,0 +1,15 @@
#include "EditDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 320
#define yc 240
IDD_EDIT_DLG DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT
CAPTION "Edit"
{
// OK_CANCEL
MY_BUTTON__CLOSE
EDITTEXT IDE_EDIT, m, m, xc, yc - bys - m,
ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_HSCROLL | ES_WANTRETURN
}
@@ -0,0 +1,2 @@
#define IDD_EDIT_DLG 94
#define IDE_EDIT 100
@@ -0,0 +1,159 @@
// EditPage.cpp
#include "StdAfx.h"
#include "EditPage.h"
#include "EditPageRes.h"
#include "BrowseDialog.h"
#include "HelpUtils.h"
#include "LangUtils.h"
#include "RegistryUtils.h"
using namespace NWindows;
#ifdef Z7_LANG
static const UInt32 kLangIDs[] =
{
IDT_EDIT_EDITOR,
IDT_EDIT_DIFF
};
static const UInt32 kLangIDs_Colon[] =
{
IDT_EDIT_VIEWER
};
#endif
#define kEditTopic "FM/options.htm#editor"
bool CEditPage::OnInit()
{
_initMode = true;
#ifdef Z7_LANG
LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
LangSetDlgItems_Colon(*this, kLangIDs_Colon, Z7_ARRAY_SIZE(kLangIDs_Colon));
#endif
_ctrls[0].Ctrl = IDE_EDIT_VIEWER; _ctrls[0].Button = IDB_EDIT_VIEWER;
_ctrls[1].Ctrl = IDE_EDIT_EDITOR; _ctrls[1].Button = IDB_EDIT_EDITOR;
_ctrls[2].Ctrl = IDE_EDIT_DIFF; _ctrls[2].Button = IDB_EDIT_DIFF;
for (unsigned i = 0; i < 3; i++)
{
CEditPageCtrl &c = _ctrls[i];
c.WasChanged = false;
c.Edit.Attach(GetItem(c.Ctrl));
UString path;
if (i < 2)
ReadRegEditor(i > 0, path);
else
ReadRegDiff(path);
c.Edit.SetText(path);
}
_initMode = false;
return CPropertyPage::OnInit();
}
LONG CEditPage::OnApply()
{
for (unsigned i = 0; i < 3; i++)
{
CEditPageCtrl &c = _ctrls[i];
if (c.WasChanged)
{
UString path;
c.Edit.GetText(path);
if (i < 2)
SaveRegEditor(i > 0, path);
else
SaveRegDiff(path);
c.WasChanged = false;
}
}
return PSNRET_NOERROR;
}
void CEditPage::OnNotifyHelp()
{
ShowHelpWindow(kEditTopic);
}
void SplitCmdLineSmart(const UString &cmd, UString &prg, UString &params);
static void Edit_BrowseForFile(NWindows::NControl::CEdit &edit, HWND hwnd)
{
UString cmd;
edit.GetText(cmd);
UString param;
UString prg;
SplitCmdLineSmart(cmd, prg, param);
CObjectVector<CBrowseFilterInfo> filters;
CBrowseFilterInfo &bfi = filters.AddNew();
bfi.Description = "*.exe";
bfi.Masks.Add(UString("*.exe"));
CBrowseInfo bi;
bi.FilterIndex = 0;
bi.FilePath = prg;
bi.hwndOwner = hwnd;
if (bi.BrowseForFile(filters))
{
cmd = bi.FilePath;
cmd.Trim();
/*
if (!param.IsEmpty() && !resPath.IsEmpty())
{
cmd.InsertAtFront(L'\"');
cmd += L'\"';
cmd.Add_Space();
cmd += param;
}
*/
edit.SetText(cmd);
// Changed();
}
}
bool CEditPage::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
for (unsigned i = 0; i < 3; i++)
{
CEditPageCtrl &c = _ctrls[i];
if (buttonID == c.Button)
{
Edit_BrowseForFile(c.Edit, *this);
return true;
}
}
return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
}
bool CEditPage::OnCommand(unsigned code, unsigned itemID, LPARAM param)
{
if (!_initMode && code == EN_CHANGE)
{
for (unsigned i = 0; i < 3; i++)
{
CEditPageCtrl &c = _ctrls[i];
if (itemID == c.Ctrl)
{
c.WasChanged = true;
Changed();
return true;
}
}
}
return CPropertyPage::OnCommand(code, itemID, param);
}
@@ -0,0 +1,30 @@
// EditPage.h
#ifndef ZIP7_INC_EDIT_PAGE_H
#define ZIP7_INC_EDIT_PAGE_H
#include "../../../Windows/Control/PropertyPage.h"
#include "../../../Windows/Control/Edit.h"
struct CEditPageCtrl
{
NWindows::NControl::CEdit Edit;
bool WasChanged;
unsigned Ctrl;
unsigned Button;
};
class CEditPage: public NWindows::NControl::CPropertyPage
{
CEditPageCtrl _ctrls[3];
bool _initMode;
public:
virtual bool OnInit() Z7_override;
virtual void OnNotifyHelp() Z7_override;
virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM param) Z7_override;
virtual LONG OnApply() Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
};
#endif
@@ -0,0 +1,19 @@
#include "EditPageRes.h"
#include "../../GuiCommon.rc"
#define xc OPTIONS_PAGE_XC_SIZE
#define yc 100
IDD_EDIT MY_PAGE
#include "EditPage2.rc"
#ifdef UNDER_CE
#undef xc
#define xc SMALL_PAGE_SIZE_X
IDD_EDIT_2 MY_PAGE
#include "EditPage2.rc"
#endif
@@ -0,0 +1,14 @@
CAPTION "Editor"
{
LTEXT "&View:", IDT_EDIT_VIEWER, m, m, xc, 8
EDITTEXT IDE_EDIT_VIEWER, m, m + 12, xc - m - bxsDots, 14, ES_AUTOHSCROLL
PUSHBUTTON "...", IDB_EDIT_VIEWER, xs - m - bxsDots, m + 11, bxsDots, bys
LTEXT "&Editor:", IDT_EDIT_EDITOR, m, m + 32, xc, 8
EDITTEXT IDE_EDIT_EDITOR, m, m + 44, xc - m - bxsDots, 14, ES_AUTOHSCROLL
PUSHBUTTON "...", IDB_EDIT_EDITOR, xs - m - bxsDots, m + 43, bxsDots, bys
LTEXT "&Diff:", IDT_EDIT_DIFF, m, m + 64, xc, 8
EDITTEXT IDE_EDIT_DIFF, m, m + 76, xc - m - bxsDots, 14, ES_AUTOHSCROLL
PUSHBUTTON "...", IDB_EDIT_DIFF, xs - m - bxsDots, m + 75, bxsDots, bys
}
@@ -0,0 +1,15 @@
#define IDD_EDIT 2103
#define IDD_EDIT_2 12103
#define IDT_EDIT_VIEWER 543
#define IDT_EDIT_EDITOR 2104
#define IDT_EDIT_DIFF 2105
#define IDE_EDIT_VIEWER 100
#define IDB_EDIT_VIEWER 101
#define IDE_EDIT_EDITOR 102
#define IDB_EDIT_EDITOR 103
#define IDE_EDIT_DIFF 104
#define IDB_EDIT_DIFF 105
@@ -0,0 +1,107 @@
// EnumFormatEtc.cpp
#include "StdAfx.h"
#include "EnumFormatEtc.h"
#include "../../IDecl.h"
#include "MyCom2.h"
class CEnumFormatEtc Z7_final:
public IEnumFORMATETC,
public CMyUnknownImp
{
Z7_COM_UNKNOWN_IMP_1_MT(IEnumFORMATETC)
STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched) Z7_override;
STDMETHOD(Skip)(ULONG celt) Z7_override;
STDMETHOD(Reset)(void) Z7_override;
STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc) Z7_override;
LONG m_RefCount;
ULONG m_NumFormats;
FORMATETC *m_Formats;
ULONG m_Index;
public:
CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats);
~CEnumFormatEtc();
};
static void DeepCopyFormatEtc(FORMATETC *dest, const FORMATETC *src)
{
*dest = *src;
if (src->ptd)
{
dest->ptd = (DVTARGETDEVICE*)CoTaskMemAlloc(sizeof(DVTARGETDEVICE));
*(dest->ptd) = *(src->ptd);
}
}
CEnumFormatEtc::CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats)
{
m_RefCount = 1;
m_Index = 0;
m_NumFormats = 0;
m_Formats = new FORMATETC[numFormats];
// if (m_Formats)
{
m_NumFormats = numFormats;
for (ULONG i = 0; i < numFormats; i++)
DeepCopyFormatEtc(&m_Formats[i], &pFormatEtc[i]);
}
}
CEnumFormatEtc::~CEnumFormatEtc()
{
if (m_Formats)
{
for (ULONG i = 0; i < m_NumFormats; i++)
if (m_Formats[i].ptd)
CoTaskMemFree(m_Formats[i].ptd);
delete []m_Formats;
}
}
Z7_COMWF_B CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pceltFetched)
{
ULONG copied = 0;
if (celt == 0 || !pFormatEtc)
return E_INVALIDARG;
while (m_Index < m_NumFormats && copied < celt)
{
DeepCopyFormatEtc(&pFormatEtc[copied], &m_Formats[m_Index]);
copied++;
m_Index++;
}
if (pceltFetched)
*pceltFetched = copied;
return (copied == celt) ? S_OK : S_FALSE;
}
Z7_COMWF_B CEnumFormatEtc::Skip(ULONG celt)
{
m_Index += celt;
return (m_Index <= m_NumFormats) ? S_OK : S_FALSE;
}
Z7_COMWF_B CEnumFormatEtc::Reset(void)
{
m_Index = 0;
return S_OK;
}
Z7_COMWF_B CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc)
{
HRESULT hResult = CreateEnumFormatEtc(m_NumFormats, m_Formats, ppEnumFormatEtc);
if (hResult == S_OK)
((CEnumFormatEtc *)*ppEnumFormatEtc)->m_Index = m_Index;
return hResult;
}
// replacement for SHCreateStdEnumFmtEtc
HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat)
{
if (numFormats == 0 || !formats || !enumFormat)
return E_INVALIDARG;
*enumFormat = new CEnumFormatEtc(formats, numFormats);
return (*enumFormat) ? S_OK : E_OUTOFMEMORY;
}
@@ -0,0 +1,10 @@
// EnumFormatEtc.h
#ifndef ZIP7_INC_ENUMFORMATETC_H
#define ZIP7_INC_ENUMFORMATETC_H
#include "../../../Common/MyWindows.h"
HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat);
#endif
Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

File diff suppressed because it is too large Load Diff
@@ -0,0 +1,347 @@
// ExtractCallback.h
#ifndef ZIP7_INC_EXTRACT_CALLBACK_H
#define ZIP7_INC_EXTRACT_CALLBACK_H
#include "../../../../C/Alloc.h"
#include "../../../Common/MyCom.h"
#include "../../../Common/StringConvert.h"
#ifndef Z7_SFX
#include "../Agent/IFolderArchive.h"
#endif
#include "../Common/ArchiveExtractCallback.h"
#include "../Common/ArchiveOpenCallback.h"
#ifndef Z7_NO_CRYPTO
#include "../../IPassword.h"
#endif
#ifndef Z7_SFX
#include "IFolder.h"
#endif
#include "ProgressDialog2.h"
#ifndef Z7_SFX
class CGrowBuf
{
Byte *_items;
size_t _size;
Z7_CLASS_NO_COPY(CGrowBuf)
public:
void Free()
{
MyFree(_items);
_items = NULL;
_size = 0;
}
// newSize >= keepSize
bool ReAlloc_KeepData(size_t newSize, size_t keepSize)
{
void *buf = NULL;
if (newSize)
{
buf = MyAlloc(newSize);
if (!buf)
return false;
}
if (keepSize)
memcpy(buf, _items, keepSize);
MyFree(_items);
_items = (Byte *)buf;
_size = newSize;
return true;
}
CGrowBuf(): _items(NULL), _size(0) {}
~CGrowBuf() { MyFree(_items); }
operator Byte *() { return _items; }
operator const Byte *() const { return _items; }
size_t Size() const { return _size; }
};
struct CVirtFile
{
CGrowBuf Data;
UInt64 ExpectedSize; // size from props request. 0 if unknown
size_t WrittenSize; // size of written data in (Data) buffer
// use (WrittenSize) only if (CVirtFileSystem::_newVirtFileStream_IsReadyToWrite == false)
UString BaseName; // original name of file inside archive,
// It's not path. So any path separators
// should be treated as part of name (or as incorrect chars)
UString AltStreamName;
bool CTime_Defined;
bool ATime_Defined;
bool MTime_Defined;
bool Attrib_Defined;
// bool IsDir;
bool IsAltStream;
bool ColonWasUsed;
DWORD Attrib;
FILETIME CTime;
FILETIME ATime;
FILETIME MTime;
CVirtFile():
CTime_Defined(false),
ATime_Defined(false),
MTime_Defined(false),
Attrib_Defined(false),
// IsDir(false),
IsAltStream(false),
ColonWasUsed(false)
{}
};
/*
We use CVirtFileSystem only for single file extraction:
It supports the following cases and names:
- "fileName" : single file
- "fileName" item (main base file) and additional "fileName:altStream" items
- "altStream" : single item without "fileName:" prefix.
If file is flushed to disk, it uses Get_Correct_FsFile_Name(name).
*/
Z7_CLASS_IMP_NOQIB_1(
CVirtFileSystem,
ISequentialOutStream
)
unsigned _numFlushed;
public:
bool IsAltStreamFile; // in:
// = true, if extracting file is alt stream without "fileName:" prefix.
// = false, if extracting file is normal file, but additional
// alt streams "fileName:altStream" items are possible.
private:
bool _newVirtFileStream_IsReadyToWrite; // it can non real file (if can't open alt stream)
bool _needWriteToRealFile; // we need real writing to open file.
bool _wasSwitchedToFsMode;
bool _altStream_NeedRestore_Attrib_bool;
DWORD _altStream_NeedRestore_AttribVal;
CMyComPtr2<ISequentialOutStream, COutFileStream> _outFileStream;
public:
CObjectVector<CVirtFile> Files;
size_t MaxTotalAllocSize; // remain size, including Files.Back()
FString DirPrefix; // files will be flushed to this FS directory.
UString FileName; // name of file that will be extracted.
// it can be name of alt stream without "fileName:" prefix, if (IsAltStreamFile == trye).
// we use that name to detect altStream part in "FileName:altStream".
CByteBuffer ZoneBuf;
int Index_of_MainExtractedFile_in_Files; // out: index in Files. == -1, if expected file was not extracted
int Index_of_ZoneBuf_AltStream_in_Files; // out: index in Files. == -1, if no zonbuf alt stream
CVirtFileSystem()
{
_numFlushed = 0;
IsAltStreamFile = false;
_newVirtFileStream_IsReadyToWrite = false;
_needWriteToRealFile = false;
_wasSwitchedToFsMode = false;
_altStream_NeedRestore_Attrib_bool = false;
MaxTotalAllocSize = (size_t)0 - 1;
Index_of_MainExtractedFile_in_Files = -1;
Index_of_ZoneBuf_AltStream_in_Files = -1;
}
bool WasStreamFlushedToFS() const { return _wasSwitchedToFsMode; }
HRESULT CloseMemFile()
{
if (_wasSwitchedToFsMode)
return FlushToDisk(true); // closeLast
CVirtFile &file = Files.Back();
if (file.Data.Size() != file.WrittenSize)
file.Data.ReAlloc_KeepData(file.WrittenSize, file.WrittenSize);
return S_OK;
}
HRESULT FlushToDisk(bool closeLast);
};
#endif
class CExtractCallbackImp Z7_final:
public IFolderArchiveExtractCallback,
/* IExtractCallbackUI:
before v23.00 : it included IFolderArchiveExtractCallback
since v23.00 : it doesn't include IFolderArchiveExtractCallback
*/
public IExtractCallbackUI, // NON-COM interface since 23.00
public IOpenCallbackUI, // NON-COM interface
public IFolderArchiveExtractCallback2,
#ifndef Z7_SFX
public IFolderOperationsExtractCallback,
public IFolderExtractToStreamCallback,
public ICompressProgressInfo,
public IArchiveRequestMemoryUseCallback,
#endif
#ifndef Z7_NO_CRYPTO
public ICryptoGetTextPassword,
#endif
public CMyUnknownImp
{
Z7_COM_QI_BEGIN2(IFolderArchiveExtractCallback)
Z7_COM_QI_ENTRY(IFolderArchiveExtractCallback2)
#ifndef Z7_SFX
Z7_COM_QI_ENTRY(IFolderOperationsExtractCallback)
Z7_COM_QI_ENTRY(IFolderExtractToStreamCallback)
Z7_COM_QI_ENTRY(ICompressProgressInfo)
Z7_COM_QI_ENTRY(IArchiveRequestMemoryUseCallback)
#endif
#ifndef Z7_NO_CRYPTO
Z7_COM_QI_ENTRY(ICryptoGetTextPassword)
#endif
Z7_COM_QI_END
Z7_COM_ADDREF_RELEASE
Z7_IFACE_IMP(IExtractCallbackUI)
Z7_IFACE_IMP(IOpenCallbackUI)
Z7_IFACE_COM7_IMP(IProgress)
Z7_IFACE_COM7_IMP(IFolderArchiveExtractCallback)
Z7_IFACE_COM7_IMP(IFolderArchiveExtractCallback2)
#ifndef Z7_SFX
Z7_IFACE_COM7_IMP(IFolderOperationsExtractCallback)
Z7_IFACE_COM7_IMP(IFolderExtractToStreamCallback)
Z7_IFACE_COM7_IMP(ICompressProgressInfo)
Z7_IFACE_COM7_IMP(IArchiveRequestMemoryUseCallback)
#endif
#ifndef Z7_NO_CRYPTO
Z7_IFACE_COM7_IMP(ICryptoGetTextPassword)
#endif
bool _needWriteArchivePath;
bool _isFolder;
bool _totalFiles_Defined;
bool _totalBytes_Defined;
public:
bool MultiArcMode;
bool ProcessAltStreams;
bool StreamMode; // set to true, if you want the callee to call GetStream7()
bool ThereAreMessageErrors;
bool Src_Is_IO_FS_Folder;
#ifndef Z7_NO_CRYPTO
bool PasswordIsDefined;
bool PasswordWasAsked;
#endif
private:
#ifndef Z7_SFX
bool _needUpdateStat;
bool _newVirtFileWasAdded;
bool _isAltStream;
// bool _extractMode;
// bool _testMode;
bool _hashStream_WasUsed;
bool _curSize_Defined;
bool NeedAddFile;
bool _remember;
bool _skipArc;
#endif
public:
bool YesToAll;
bool TestMode;
UInt32 NumArchiveErrors;
NExtract::NOverwriteMode::EEnum OverwriteMode;
private:
UString _currentArchivePath;
UString _currentFilePath;
UString _filePath; // virtual path than will be sent via IFolderExtractToStreamCallback
#ifndef Z7_SFX
UInt64 _curSize;
CMyComPtr2<ISequentialOutStream, COutStreamWithHash> _hashStream;
IHashCalc *_hashCalc; // it's for stat in Test operation
#endif
public:
CProgressDialog *ProgressDialog;
#ifndef Z7_SFX
CVirtFileSystem *VirtFileSystemSpec;
CMyComPtr<ISequentialOutStream> VirtFileSystem;
UInt64 NumFolders;
UInt64 NumFiles;
#endif
#ifndef Z7_NO_CRYPTO
UString Password;
#endif
UString _lang_Extracting;
UString _lang_Testing;
UString _lang_Skipping;
UString _lang_Reading;
UString _lang_Empty;
CExtractCallbackImp():
_totalFiles_Defined(false)
, _totalBytes_Defined(false)
, MultiArcMode(false)
, ProcessAltStreams(true)
, StreamMode(false)
, ThereAreMessageErrors(false)
, Src_Is_IO_FS_Folder(false)
#ifndef Z7_NO_CRYPTO
, PasswordIsDefined(false)
, PasswordWasAsked(false)
#endif
#ifndef Z7_SFX
, _remember(false)
, _skipArc(false)
#endif
, YesToAll(false)
, TestMode(false)
, OverwriteMode(NExtract::NOverwriteMode::kAsk)
#ifndef Z7_SFX
, _hashCalc(NULL)
#endif
{}
~CExtractCallbackImp();
void Init();
HRESULT SetCurrentFilePath2(const wchar_t *filePath);
void AddError_Message(LPCWSTR message);
void AddError_Message_ShowArcPath(LPCWSTR message);
HRESULT MessageError(const char *message, const FString &path);
void Add_ArchiveName_Error();
#ifndef Z7_SFX
void SetHashCalc(IHashCalc *hashCalc) { _hashCalc = hashCalc; }
void SetHashMethods(IHashCalc *hash)
{
if (!hash)
return;
_hashStream.Create_if_Empty();
_hashStream->_hash = hash;
}
#endif
bool IsOK() const { return NumArchiveErrors == 0 && !ThereAreMessageErrors; }
};
#endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "FM"=.\FM.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

@@ -0,0 +1,103 @@
CFLAGS = $(CFLAGS) \
-DZ7_LANG \
!IFDEF UNDER_CE
LIBS = $(LIBS) ceshell.lib Commctrl.lib
!ELSE
LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
CFLAGS = $(CFLAGS) -DZ7_DEVICE_FILE
# -DZ7_LONG_PATH
LFLAGS = $(LFLAGS) /DELAYLOAD:mpr.dll
LIBS = $(LIBS) delayimp.lib
!ENDIF
FM_OBJS = \
$O\App.obj \
$O\BrowseDialog.obj \
$O\BrowseDialog2.obj \
$O\ClassDefs.obj \
$O\EnumFormatEtc.obj \
$O\ExtractCallback.obj \
$O\FileFolderPluginOpen.obj \
$O\FilePlugins.obj \
$O\FM.obj \
$O\FoldersPage.obj \
$O\FormatUtils.obj \
$O\FSFolder.obj \
$O\FSFolderCopy.obj \
$O\HelpUtils.obj \
$O\LangUtils.obj \
$O\MemDialog.obj \
$O\MenuPage.obj \
$O\MyLoadMenu.obj \
$O\OpenCallback.obj \
$O\OptionsDialog.obj \
$O\Panel.obj \
$O\PanelCopy.obj \
$O\PanelCrc.obj \
$O\PanelDrag.obj \
$O\PanelFolderChange.obj \
$O\PanelItemOpen.obj \
$O\PanelItems.obj \
$O\PanelKey.obj \
$O\PanelListNotify.obj \
$O\PanelMenu.obj \
$O\PanelOperations.obj \
$O\PanelSelect.obj \
$O\PanelSort.obj \
$O\PanelSplitFile.obj \
$O\ProgramLocation.obj \
$O\PropertyName.obj \
$O\RegistryAssociations.obj \
$O\RegistryUtils.obj \
$O\RootFolder.obj \
$O\SplitUtils.obj \
$O\StringUtils.obj \
$O\SysIconUtils.obj \
$O\TextPairs.obj \
$O\UpdateCallback100.obj \
$O\ViewSettings.obj \
$O\AboutDialog.obj \
$O\ComboDialog.obj \
$O\CopyDialog.obj \
$O\EditDialog.obj \
$O\EditPage.obj \
$O\LangPage.obj \
$O\ListViewDialog.obj \
$O\MessagesDialog.obj \
$O\OverwriteDialog.obj \
$O\PasswordDialog.obj \
$O\ProgressDialog2.obj \
$O\SettingsPage.obj \
$O\SplitDialog.obj \
$O\SystemPage.obj \
$O\VerCtrl.obj \
!IFNDEF UNDER_CE
FM_OBJS = $(FM_OBJS) \
$O\AltStreamsFolder.obj \
$O\FSDrives.obj \
$O\LinkDialog.obj \
$O\NetFolder.obj \
WIN_OBJS = $(WIN_OBJS) \
$O\FileSystem.obj \
$O\Net.obj \
$O\SecurityUtils.obj \
!ENDIF
C_OBJS = $(C_OBJS) \
$O\DllSecur.obj \
AGENT_OBJS = \
$O\Agent.obj \
$O\AgentOut.obj \
$O\AgentProxy.obj \
$O\ArchiveFolder.obj \
$O\ArchiveFolderOpen.obj \
$O\ArchiveFolderOut.obj \
$O\UpdateCallbackAgent.obj \
# we need empty line after last line above
@@ -0,0 +1,512 @@
// FSDrives.cpp
#include "StdAfx.h"
#include "../../../../C/Alloc.h"
#include "../../../Common/ComTry.h"
#include "../../../Common/Defs.h"
#include "../../../Common/IntToString.h"
#include "../../../Common/StringConvert.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileIO.h"
#include "../../../Windows/FileName.h"
#include "../../../Windows/FileSystem.h"
#include "../../../Windows/PropVariant.h"
#include "../../PropID.h"
#include "FSDrives.h"
#include "FSFolder.h"
#include "LangUtils.h"
#include "SysIconUtils.h"
#include "resource.h"
using namespace NWindows;
using namespace NFile;
using namespace NFind;
static const char * const kVolPrefix = "\\\\.\\";
static const char * const kSuperPrefix = "\\\\?\\";
FString CDriveInfo::GetDeviceFileIoName() const
{
FString f (kVolPrefix);
f += Name;
return f;
}
struct CPhysTempBuffer
{
void *buffer;
CPhysTempBuffer(): buffer(NULL) {}
~CPhysTempBuffer() { MidFree(buffer); }
};
static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath,
bool writeToDisk, UInt64 fileSize,
UInt32 bufferSize, UInt64 progressStart, IProgress *progress)
{
NIO::CInFile inFile;
if (!inFile.Open(fromPath))
return GetLastError_noZero_HRESULT();
if (fileSize == (UInt64)(Int64)-1)
{
if (!inFile.GetLength(fileSize))
return GetLastError_noZero_HRESULT();
}
NIO::COutFile outFile;
if (writeToDisk)
{
if (!outFile.Open(toPath, FILE_SHARE_WRITE, OPEN_EXISTING, 0))
return GetLastError_noZero_HRESULT();
}
else
if (!outFile.Create_ALWAYS(toPath))
return GetLastError_noZero_HRESULT();
CPhysTempBuffer tempBuffer;
tempBuffer.buffer = MidAlloc(bufferSize);
if (!tempBuffer.buffer)
return E_OUTOFMEMORY;
for (UInt64 pos = 0; pos < fileSize;)
{
{
const UInt64 progressCur = progressStart + pos;
RINOK(progress->SetCompleted(&progressCur))
}
const UInt64 rem = fileSize - pos;
UInt32 curSize = (UInt32)MyMin(rem, (UInt64)bufferSize);
UInt32 processedSize;
if (!inFile.Read(tempBuffer.buffer, curSize, processedSize))
return GetLastError_noZero_HRESULT();
if (processedSize == 0)
break;
curSize = processedSize;
if (writeToDisk)
{
const UInt32 kMask = 0x1FF;
curSize = (curSize + kMask) & ~kMask;
if (curSize > bufferSize)
return E_FAIL;
}
if (!outFile.Write(tempBuffer.buffer, curSize, processedSize))
return GetLastError_noZero_HRESULT();
if (curSize != processedSize)
return E_FAIL;
pos += curSize;
}
return S_OK;
}
static const Byte kProps[] =
{
kpidName,
// kpidOutName,
kpidTotalSize,
kpidFreeSpace,
kpidType,
kpidVolumeName,
kpidFileSystem,
kpidClusterSize
};
static const char * const kDriveTypes[] =
{
"Unknown"
, "No Root Dir"
, "Removable"
, "Fixed"
, "Remote"
, "CD-ROM"
, "RAM disk"
};
Z7_COM7F_IMF(CFSDrives::LoadItems())
{
_drives.Clear();
FStringVector driveStrings;
MyGetLogicalDriveStrings(driveStrings);
FOR_VECTOR (i, driveStrings)
{
CDriveInfo di;
const FString &driveName = driveStrings[i];
di.FullSystemName = driveName;
if (!driveName.IsEmpty())
di.Name.SetFrom(driveName, driveName.Len() - 1);
di.ClusterSize = 0;
di.DriveSize = 0;
di.FreeSpace = 0;
di.DriveType = NSystem::MyGetDriveType(driveName);
bool needRead = true;
if (di.DriveType == DRIVE_CDROM || di.DriveType == DRIVE_REMOVABLE)
{
/*
DWORD dwSerialNumber;`
if (!::GetVolumeInformation(di.FullSystemName,
NULL, 0, &dwSerialNumber, NULL, NULL, NULL, 0))
*/
{
needRead = false;
}
}
if (needRead)
{
DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
NSystem::MyGetVolumeInformation(driveName,
di.VolumeName,
&volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
di.FileSystemName);
NSystem::MyGetDiskFreeSpace(driveName,
di.ClusterSize, di.DriveSize, di.FreeSpace);
di.KnownSizes = true;
di.KnownSize = true;
}
_drives.Add(di);
}
if (_volumeMode)
{
// we must use IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
for (unsigned n = 0; n < 16; n++) // why 16 ?
{
FString name ("PhysicalDrive");
name.Add_UInt32(n);
FString fullPath (kVolPrefix);
fullPath += name;
CFileInfo fi;
if (!fi.Find(fullPath))
continue;
CDriveInfo di;
di.Name = name;
// if (_volumeMode == true) we use CDriveInfo::FullSystemName only in GetSystemIconIndex().
// And we need name without "\\\\.\\" prefix in GetSystemIconIndex().
// So we don't set di.FullSystemName = fullPath;
di.FullSystemName = name;
di.ClusterSize = 0;
di.DriveSize = fi.Size;
di.FreeSpace = 0;
di.DriveType = 0;
di.IsPhysicalDrive = true;
di.KnownSize = true;
_drives.Add(di);
}
}
return S_OK;
}
Z7_COM7F_IMF(CFSDrives::GetNumberOfItems(UInt32 *numItems))
{
*numItems = _drives.Size();
return S_OK;
}
Z7_COM7F_IMF(CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value))
{
if (itemIndex >= _drives.Size())
return E_INVALIDARG;
NCOM::CPropVariant prop;
const CDriveInfo &di = _drives[itemIndex];
switch (propID)
{
case kpidIsDir: prop = !_volumeMode; break;
case kpidName: prop = fs2us(di.Name); break;
case kpidOutName:
if (!di.Name.IsEmpty() && di.Name.Back() == ':')
{
FString s = di.Name;
s.DeleteBack();
AddExt(s, itemIndex);
prop = fs2us(s);
}
break;
case kpidTotalSize: if (di.KnownSize) prop = di.DriveSize; break;
case kpidFreeSpace: if (di.KnownSizes) prop = di.FreeSpace; break;
case kpidClusterSize: if (di.KnownSizes) prop = di.ClusterSize; break;
case kpidType:
if (di.DriveType < Z7_ARRAY_SIZE(kDriveTypes))
prop = kDriveTypes[di.DriveType];
break;
case kpidVolumeName: prop = di.VolumeName; break;
case kpidFileSystem: prop = di.FileSystemName; break;
}
prop.Detach(value);
return S_OK;
}
HRESULT CFSDrives::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
{
*resultFolder = NULL;
if (_volumeMode)
return S_OK;
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
FString path;
if (_superMode)
path = kSuperPrefix;
path += name;
RINOK(fsFolderSpec->Init(path))
*resultFolder = subFolder.Detach();
return S_OK;
}
Z7_COM7F_IMF(CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder))
{
*resultFolder = NULL;
if (index >= _drives.Size())
return E_INVALIDARG;
const CDriveInfo &di = _drives[index];
/*
if (_volumeMode)
{
*resultFolder = 0;
CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
CMyComPtr<IFolderFolder> subFolder = folderSpec;
RINOK(folderSpec->Init(di.Name));
*resultFolder = subFolder.Detach();
return S_OK;
}
*/
return BindToFolderSpec(di.FullSystemName, resultFolder);
}
Z7_COM7F_IMF(CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder))
{
return BindToFolderSpec(us2fs(name), resultFolder);
}
Z7_COM7F_IMF(CFSDrives::BindToParentFolder(IFolderFolder **resultFolder))
{
*resultFolder = NULL;
return S_OK;
}
IMP_IFolderFolder_Props(CFSDrives)
Z7_COM7F_IMF(CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value))
{
COM_TRY_BEGIN
NCOM::CPropVariant prop;
switch (propID)
{
case kpidType: prop = "FSDrives"; break;
case kpidPath:
if (_volumeMode)
prop = kVolPrefix;
else if (_superMode)
prop = kSuperPrefix;
else
prop = (UString)LangString(IDS_COMPUTER) + WCHAR_PATH_SEPARATOR;
break;
}
prop.Detach(value);
return S_OK;
COM_TRY_END
}
Z7_COM7F_IMF(CFSDrives::GetSystemIconIndex(UInt32 index, Int32 *iconIndex))
{
*iconIndex = -1;
const CDriveInfo &di = _drives[index];
return Shell_GetFileInfo_SysIconIndex_for_Path_return_HRESULT(
di.FullSystemName,
_volumeMode ?
FILE_ATTRIBUTE_ARCHIVE:
FILE_ATTRIBUTE_DIRECTORY,
iconIndex);
}
void CFSDrives::AddExt(FString &s, unsigned index) const
{
s.Add_Dot();
const CDriveInfo &di = _drives[index];
UString n = di.FileSystemName;
n.MakeLower_Ascii();
const char *ext;
if (di.DriveType == DRIVE_CDROM)
ext = "iso";
else
{
unsigned i;
for (i = 0; i < n.Len(); i++)
{
const wchar_t c = n[i];
if (c < 'a' || c > 'z')
break;
}
if (i != 0)
{
n.DeleteFrom(i);
s += us2fs(n);
return;
}
ext = "img";
}
/*
if (n.IsPrefixedBy_Ascii_NoCase("NTFS")) ext = "ntfs";
else if (n.IsPrefixedBy_Ascii_NoCase("UDF")) ext = "udf";
else if (n.IsPrefixedBy_Ascii_NoCase("exFAT")) ext = "exfat";
*/
s += ext;
}
HRESULT CFSDrives::GetFileSize(unsigned index, UInt64& fileSize) const
{
#ifdef Z7_DEVICE_FILE
NIO::CInFile inFile;
if (!inFile.Open(_drives[index].GetDeviceFileIoName()))
return GetLastError_noZero_HRESULT();
if (inFile.SizeDefined)
{
fileSize = inFile.Size;
return S_OK;
}
#else
UNUSED_VAR(index)
#endif
fileSize = 0;
return E_FAIL;
}
Z7_COM7F_IMF(CFSDrives::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems,
Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */,
const wchar_t *path, IFolderOperationsExtractCallback *callback))
{
if (numItems == 0)
return S_OK;
if (moveMode)
return E_NOTIMPL;
if (!_volumeMode)
return E_NOTIMPL;
UInt64 totalSize = 0;
UInt32 i;
for (i = 0; i < numItems; i++)
{
const CDriveInfo &di = _drives[indices[i]];
if (di.KnownSize)
totalSize += di.DriveSize;
}
RINOK(callback->SetTotal(totalSize))
RINOK(callback->SetNumFiles(numItems))
const FString destPath = us2fs(path);
if (destPath.IsEmpty())
return E_INVALIDARG;
const bool isAltDest = NName::IsAltPathPrefix(destPath);
const bool isDirectPath = (!isAltDest && !IsPathSepar(destPath.Back()));
if (isDirectPath)
{
if (numItems > 1)
return E_INVALIDARG;
}
UInt64 completedSize = 0;
RINOK(callback->SetCompleted(&completedSize))
for (i = 0; i < numItems; i++)
{
const unsigned index = indices[i];
const CDriveInfo &di = _drives[index];
FString destPath2 = destPath;
if (!isDirectPath)
{
FString destName = di.Name;
if (!destName.IsEmpty() && destName.Back() == ':')
{
destName.DeleteBack();
AddExt(destName, index);
}
destPath2 += destName;
}
const FString srcPath = di.GetDeviceFileIoName();
UInt64 fileSize = 0;
if (GetFileSize(index, fileSize) != S_OK)
{
return E_FAIL;
}
if (!di.KnownSize)
{
totalSize += fileSize;
RINOK(callback->SetTotal(totalSize))
}
Int32 writeAskResult;
CMyComBSTR destPathResult;
RINOK(callback->AskWrite(fs2us(srcPath), BoolToInt(false), NULL, &fileSize,
fs2us(destPath2), &destPathResult, &writeAskResult))
if (!IntToBool(writeAskResult))
{
if (totalSize >= fileSize)
totalSize -= fileSize;
RINOK(callback->SetTotal(totalSize))
continue;
}
RINOK(callback->SetCurrentFilePath(fs2us(srcPath)))
const UInt32 kBufferSize = (4 << 20);
const UInt32 bufferSize = (di.DriveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
RINOK(CopyFileSpec(srcPath, us2fs(destPathResult), false, fileSize, bufferSize, completedSize, callback))
completedSize += fileSize;
}
return S_OK;
}
Z7_COM7F_IMF(CFSDrives::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */,
const wchar_t * const * /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
Z7_COM7F_IMF(CFSDrives::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
Z7_COM7F_IMF(CFSDrives::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
Z7_COM7F_IMF(CFSDrives::CreateFile(const wchar_t * /* name */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
Z7_COM7F_IMF(CFSDrives::Rename(UInt32 /* index */, const wchar_t * /* newName */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
Z7_COM7F_IMF(CFSDrives::Delete(const UInt32 * /* indices */, UInt32 /* numItems */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
Z7_COM7F_IMF(CFSDrives::SetProperty(UInt32 /* index */, PROPID /* propID */,
const PROPVARIANT * /* value */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
@@ -0,0 +1,52 @@
// FSDrives.h
#ifndef ZIP7_INC_FS_DRIVES_H
#define ZIP7_INC_FS_DRIVES_H
#include "../../../Common/MyCom.h"
#include "../../../Common/MyString.h"
#include "IFolder.h"
struct CDriveInfo
{
FString Name;
FString FullSystemName;
UInt64 DriveSize;
UInt64 FreeSpace;
UInt64 ClusterSize;
// UString Type;
UString VolumeName;
UString FileSystemName;
UINT DriveType;
bool KnownSize;
bool KnownSizes;
bool IsPhysicalDrive;
FString GetDeviceFileIoName() const;
CDriveInfo(): KnownSize(false), KnownSizes(false), IsPhysicalDrive(false) {}
};
Z7_CLASS_IMP_NOQIB_3(
CFSDrives
, IFolderFolder
, IFolderOperations
, IFolderGetSystemIconIndex
)
CObjectVector<CDriveInfo> _drives;
bool _volumeMode;
bool _superMode;
HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
void AddExt(FString &s, unsigned index) const;
HRESULT GetFileSize(unsigned index, UInt64 &fileSize) const;
public:
void Init(bool volMode = false, bool superMode = false)
{
_volumeMode = volMode;
_superMode = superMode;
}
};
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,220 @@
// FSFolder.h
#ifndef ZIP7_INC_FS_FOLDER_H
#define ZIP7_INC_FS_FOLDER_H
#include "../../../Common/MyCom.h"
#include "../../../Common/MyBuffer.h"
#include "../../../Windows/FileFind.h"
#include "../../Archive/IArchive.h"
#include "IFolder.h"
#include "TextPairs.h"
namespace NFsFolder {
class CFSFolder;
#define FS_SHOW_LINKS_INFO
// #define FS_SHOW_CHANGE_TIME
struct CDirItem: public NWindows::NFile::NFind::CFileInfo
{
#ifndef UNDER_CE
UInt64 PackSize;
#endif
#ifdef FS_SHOW_LINKS_INFO
FILETIME ChangeTime;
UInt64 FileIndex;
UInt32 NumLinks;
bool FileInfo_Defined;
bool FileInfo_WasRequested;
bool ChangeTime_Defined;
bool ChangeTime_WasRequested;
#endif
#ifndef UNDER_CE
bool PackSize_Defined;
#endif
bool FolderStat_Defined;
int Parent;
#ifndef UNDER_CE
CByteBuffer Reparse;
#endif
UInt64 NumFolders;
UInt64 NumFiles;
};
/*
struct CAltStream
{
UInt64 Size;
UInt64 PackSize;
bool PackSize_Defined;
int Parent;
UString Name;
};
*/
struct CFsFolderStat
{
UInt64 NumFolders;
UInt64 NumFiles;
UInt64 Size;
IProgress *Progress;
FString Path;
CFsFolderStat(): NumFolders(0), NumFiles(0), Size(0), Progress(NULL) {}
CFsFolderStat(const FString &path, IProgress *progress = NULL):
NumFolders(0), NumFiles(0), Size(0), Progress(progress), Path(path) {}
HRESULT Enumerate();
};
class CFSFolder Z7_final:
public IFolderFolder,
public IArchiveGetRawProps,
public IFolderCompare,
#ifdef USE_UNICODE_FSTRING
public IFolderGetItemName,
#endif
public IFolderWasChanged,
public IFolderOperations,
// public IFolderOperationsDeleteToRecycleBin,
public IFolderCalcItemFullSize,
public IFolderClone,
public IFolderGetSystemIconIndex,
public IFolderSetFlatMode,
// public IFolderSetShowNtfsStreamsMode,
public CMyUnknownImp
{
Z7_COM_QI_BEGIN2(IFolderFolder)
Z7_COM_QI_ENTRY(IArchiveGetRawProps)
Z7_COM_QI_ENTRY(IFolderCompare)
#ifdef USE_UNICODE_FSTRING
Z7_COM_QI_ENTRY(IFolderGetItemName)
#endif
Z7_COM_QI_ENTRY(IFolderWasChanged)
// Z7_COM_QI_ENTRY(IFolderOperationsDeleteToRecycleBin)
Z7_COM_QI_ENTRY(IFolderOperations)
Z7_COM_QI_ENTRY(IFolderCalcItemFullSize)
Z7_COM_QI_ENTRY(IFolderClone)
Z7_COM_QI_ENTRY(IFolderGetSystemIconIndex)
Z7_COM_QI_ENTRY(IFolderSetFlatMode)
// Z7_COM_QI_ENTRY(IFolderSetShowNtfsStreamsMode)
Z7_COM_QI_END
Z7_COM_ADDREF_RELEASE
Z7_IFACE_COM7_IMP(IFolderFolder)
Z7_IFACE_COM7_IMP(IArchiveGetRawProps)
Z7_IFACE_COM7_IMP(IFolderCompare)
#ifdef USE_UNICODE_FSTRING
Z7_IFACE_COM7_IMP(IFolderGetItemName)
#endif
Z7_IFACE_COM7_IMP(IFolderWasChanged)
Z7_IFACE_COM7_IMP(IFolderOperations)
Z7_IFACE_COM7_IMP(IFolderCalcItemFullSize)
Z7_IFACE_COM7_IMP(IFolderClone)
Z7_IFACE_COM7_IMP(IFolderGetSystemIconIndex)
Z7_IFACE_COM7_IMP(IFolderSetFlatMode)
// Z7_IFACE_COM7_IMP(IFolderSetShowNtfsStreamsMode)
bool _flatMode;
bool _commentsAreLoaded;
// bool _scanAltStreams;
FString _path;
CObjectVector<CDirItem> Files;
FStringVector Folders;
// CObjectVector<CAltStream> Streams;
// CMyComPtr<IFolderFolder> _parentFolder;
CPairsStorage _comments;
#ifdef _WIN32
NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
#endif
// HRESULT GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress);
void GetAbsPath(const wchar_t *name, FString &absPath);
HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
bool LoadComments();
bool SaveComments();
HRESULT LoadSubItems(int dirItem, const FString &path);
#ifdef FS_SHOW_LINKS_INFO
bool ReadFileInfo(CDirItem &di);
void ReadChangeTime(CDirItem &di);
#endif
public:
HRESULT Init(const FString &path /* , IFolderFolder *parentFolder */);
#if !defined(_WIN32) || defined(UNDER_CE)
HRESULT InitToRoot() { return Init((FString) FSTRING_PATH_SEPARATOR /* , NULL */); }
#endif
CFSFolder():
_flatMode(false),
_commentsAreLoaded(false)
// , _scanAltStreams(false)
{}
void GetFullPath(const CDirItem &item, FString &path) const
{
// FString prefix;
// GetPrefix(item, prefix);
path = _path;
if (item.Parent >= 0)
path += Folders[item.Parent];
path += item.Name;
}
// void GetPrefix(const CDirItem &item, FString &prefix) const;
FString GetRelPath(const CDirItem &item) const;
void Clear()
{
Files.Clear();
Folders.Clear();
// Streams.Clear();
}
};
struct CCopyStateIO
{
IProgress *Progress;
UInt64 TotalSize;
UInt64 StartPos;
UInt64 CurrentSize;
bool DeleteSrcFile;
int ErrorFileIndex;
UString ErrorMessage;
CCopyStateIO(): TotalSize(0), StartPos(0), DeleteSrcFile(false) {}
HRESULT MyCopyFile(CFSTR inPath, CFSTR outPath, DWORD attrib = INVALID_FILE_ATTRIBUTES);
};
HRESULT SendLastErrorMessage(IFolderOperationsExtractCallback *callback, const FString &fileName);
/* destDirPrefix is allowed to be:
"full_path\" or "full_path:" for alt streams */
HRESULT CopyFileSystemItems(
const UStringVector &itemsPaths,
const FString &destDirPrefix,
bool moveMode,
IFolderOperationsExtractCallback *callback);
}
#endif
@@ -0,0 +1,871 @@
// FSFolderCopy.cpp
#include "StdAfx.h"
#include "../../../Common/MyWindows.h"
#include "../../../Common/Defs.h"
#include "../../../Common/StringConvert.h"
#include "../../../Common/Wildcard.h"
#include "../../../Windows/DLL.h"
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileName.h"
#include "../../Common/FilePathAutoRename.h"
#include "FSFolder.h"
using namespace NWindows;
using namespace NFile;
using namespace NDir;
using namespace NName;
using namespace NFind;
#ifndef _UNICODE
extern bool g_IsNT;
#endif
namespace NFsFolder {
static const char * const k_CannotCopyDirToAltStream = "Cannot copy folder as alternate stream";
HRESULT CCopyStateIO::MyCopyFile(CFSTR inPath, CFSTR outPath, DWORD attrib)
{
ErrorFileIndex = -1;
ErrorMessage.Empty();
CurrentSize = 0;
{
const size_t kBufSize = 1 << 16;
CByteArr buf(kBufSize);
NIO::CInFile inFile;
NIO::COutFile outFile;
if (!inFile.Open(inPath))
{
ErrorFileIndex = 0;
return S_OK;
}
if (!outFile.Create_ALWAYS(outPath))
{
ErrorFileIndex = 1;
return S_OK;
}
for (;;)
{
UInt32 num;
if (!inFile.Read(buf, kBufSize, num))
{
ErrorFileIndex = 0;
return S_OK;
}
if (num == 0)
break;
UInt32 written = 0;
if (!outFile.Write(buf, num, written))
{
ErrorFileIndex = 1;
return S_OK;
}
if (written != num)
{
ErrorMessage = "Write error";
return S_OK;
}
CurrentSize += num;
if (Progress)
{
UInt64 completed = StartPos + CurrentSize;
RINOK(Progress->SetCompleted(&completed))
}
}
}
/* SetFileAttrib("path:alt_stream_name") sets attributes for main file "path".
But we don't want to change attributes of main file, when we write alt stream.
So we need INVALID_FILE_ATTRIBUTES for alt stream here */
if (attrib != INVALID_FILE_ATTRIBUTES)
SetFileAttrib(outPath, attrib);
if (DeleteSrcFile)
{
if (!DeleteFileAlways(inPath))
{
ErrorFileIndex = 0;
return S_OK;
}
}
return S_OK;
}
/*
static bool IsItWindows2000orHigher()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
(versionInfo.dwMajorVersion >= 5);
}
*/
struct CProgressInfo
{
UInt64 TotalSize;
UInt64 StartPos;
UInt64 FileSize;
IProgress *Progress;
HRESULT ProgressResult;
void Init() { ProgressResult = S_OK; }
};
#ifndef PROGRESS_CONTINUE
#define PROGRESS_CONTINUE 0
#define PROGRESS_CANCEL 1
#define COPY_FILE_FAIL_IF_EXISTS 0x00000001
typedef
DWORD
(WINAPI* LPPROGRESS_ROUTINE)(
LARGE_INTEGER TotalFileSize,
LARGE_INTEGER TotalBytesTransferred,
LARGE_INTEGER StreamSize,
LARGE_INTEGER StreamBytesTransferred,
DWORD dwStreamNumber,
DWORD dwCallbackReason,
HANDLE hSourceFile,
HANDLE hDestinationFile,
LPVOID lpData
);
#endif
static DWORD CALLBACK CopyProgressRoutine(
LARGE_INTEGER TotalFileSize, // file size
LARGE_INTEGER TotalBytesTransferred, // bytes transferred
LARGE_INTEGER /* StreamSize */, // bytes in stream
LARGE_INTEGER /* StreamBytesTransferred */, // bytes transferred for stream
DWORD /* dwStreamNumber */, // current stream
DWORD /* dwCallbackReason */, // callback reason
HANDLE /* hSourceFile */, // handle to source file
HANDLE /* hDestinationFile */, // handle to destination file
LPVOID lpData // from CopyFileEx
)
{
// StreamSize = StreamSize;
// StreamBytesTransferred = StreamBytesTransferred;
// dwStreamNumber = dwStreamNumber;
// dwCallbackReason = dwCallbackReason;
CProgressInfo &pi = *(CProgressInfo *)lpData;
if ((UInt64)TotalFileSize.QuadPart > pi.FileSize)
{
pi.TotalSize += (UInt64)TotalFileSize.QuadPart - pi.FileSize;
pi.FileSize = (UInt64)TotalFileSize.QuadPart;
pi.ProgressResult = pi.Progress->SetTotal(pi.TotalSize);
}
const UInt64 completed = pi.StartPos + (UInt64)TotalBytesTransferred.QuadPart;
pi.ProgressResult = pi.Progress->SetCompleted(&completed);
return (pi.ProgressResult == S_OK ? PROGRESS_CONTINUE : PROGRESS_CANCEL);
}
#if !defined(Z7_WIN32_WINNT_MIN) || Z7_WIN32_WINNT_MIN < 0x0500 // win2000
#define Z7_USE_DYN_MoveFileWithProgressW
#endif
#ifdef Z7_USE_DYN_MoveFileWithProgressW
// nt4
typedef BOOL (WINAPI * Func_CopyFileExA)(
IN LPCSTR lpExistingFileName,
IN LPCSTR lpNewFileName,
IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
IN LPVOID lpData OPTIONAL,
IN LPBOOL pbCancel OPTIONAL,
IN DWORD dwCopyFlags
);
// nt4
typedef BOOL (WINAPI * Func_CopyFileExW)(
IN LPCWSTR lpExistingFileName,
IN LPCWSTR lpNewFileName,
IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
IN LPVOID lpData OPTIONAL,
IN LPBOOL pbCancel OPTIONAL,
IN DWORD dwCopyFlags
);
// win2000
typedef BOOL (WINAPI * Func_MoveFileWithProgressW)(
IN LPCWSTR lpExistingFileName,
IN LPCWSTR lpNewFileName,
IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
IN LPVOID lpData OPTIONAL,
IN DWORD dwFlags
);
#endif
struct CCopyState
{
CProgressInfo ProgressInfo;
IFolderOperationsExtractCallback *Callback;
bool MoveMode;
bool UseReadWriteMode;
bool IsAltStreamsDest;
#ifdef Z7_USE_DYN_MoveFileWithProgressW
private:
Func_CopyFileExW my_CopyFileExW;
#ifndef UNDER_CE
Func_MoveFileWithProgressW my_MoveFileWithProgressW;
#endif
#ifndef _UNICODE
Func_CopyFileExA my_CopyFileExA;
#endif
public:
CCopyState();
#endif
bool CopyFile_NT(const wchar_t *oldFile, const wchar_t *newFile);
bool CopyFile_Sys(CFSTR oldFile, CFSTR newFile);
bool MoveFile_Sys(CFSTR oldFile, CFSTR newFile);
HRESULT CallProgress();
bool IsCallbackProgressError() { return ProgressInfo.ProgressResult != S_OK; }
};
HRESULT CCopyState::CallProgress()
{
return ProgressInfo.Progress->SetCompleted(&ProgressInfo.StartPos);
}
#ifdef Z7_USE_DYN_MoveFileWithProgressW
CCopyState::CCopyState()
{
my_CopyFileExW = NULL;
#ifndef UNDER_CE
my_MoveFileWithProgressW = NULL;
#endif
#ifndef _UNICODE
my_CopyFileExA = NULL;
if (!g_IsNT)
{
my_CopyFileExA = Z7_GET_PROC_ADDRESS(
Func_CopyFileExA, ::GetModuleHandleA("kernel32.dll"),
"CopyFileExA");
}
else
#endif
{
const HMODULE module = ::GetModuleHandleW(
#ifdef UNDER_CE
L"coredll.dll"
#else
L"kernel32.dll"
#endif
);
my_CopyFileExW = Z7_GET_PROC_ADDRESS(
Func_CopyFileExW, module,
"CopyFileExW");
#ifndef UNDER_CE
my_MoveFileWithProgressW = Z7_GET_PROC_ADDRESS(
Func_MoveFileWithProgressW, module,
"MoveFileWithProgressW");
#endif
}
}
#endif
/* WinXP-64:
CopyFileW(fromFile, toFile:altStream)
OK - there are NO alt streams in fromFile
ERROR_INVALID_PARAMETER - there are alt streams in fromFile
*/
bool CCopyState::CopyFile_NT(const wchar_t *oldFile, const wchar_t *newFile)
{
BOOL cancelFlag = FALSE;
#ifdef Z7_USE_DYN_MoveFileWithProgressW
if (my_CopyFileExW)
#endif
return BOOLToBool(
#ifdef Z7_USE_DYN_MoveFileWithProgressW
my_CopyFileExW
#else
CopyFileExW
#endif
(oldFile, newFile, CopyProgressRoutine,
&ProgressInfo, &cancelFlag, COPY_FILE_FAIL_IF_EXISTS));
#ifdef Z7_USE_DYN_MoveFileWithProgressW
return BOOLToBool(::CopyFileW(oldFile, newFile, TRUE));
#endif
}
bool CCopyState::CopyFile_Sys(CFSTR oldFile, CFSTR newFile)
{
#ifndef _UNICODE
if (!g_IsNT)
{
#ifdef Z7_USE_DYN_MoveFileWithProgressW
if (my_CopyFileExA)
#endif
{
BOOL cancelFlag = FALSE;
if (
#ifdef Z7_USE_DYN_MoveFileWithProgressW
my_CopyFileExA
#else
CopyFileExA
#endif
(fs2fas(oldFile), fs2fas(newFile),
CopyProgressRoutine, &ProgressInfo, &cancelFlag, COPY_FILE_FAIL_IF_EXISTS))
return true;
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return false;
}
return BOOLToBool(::CopyFile(fs2fas(oldFile), fs2fas(newFile), TRUE));
}
else
#endif
{
IF_USE_MAIN_PATH_2(oldFile, newFile)
{
if (CopyFile_NT(fs2us(oldFile), fs2us(newFile)))
return true;
}
#ifdef Z7_LONG_PATH
if (USE_SUPER_PATH_2)
{
if (IsCallbackProgressError())
return false;
UString superPathOld, superPathNew;
if (!GetSuperPaths(oldFile, newFile, superPathOld, superPathNew, USE_MAIN_PATH_2))
return false;
if (CopyFile_NT(superPathOld, superPathNew))
return true;
}
#endif
return false;
}
}
bool CCopyState::MoveFile_Sys(CFSTR oldFile, CFSTR newFile)
{
#ifndef UNDER_CE
// if (IsItWindows2000orHigher())
// {
#ifdef Z7_USE_DYN_MoveFileWithProgressW
if (my_MoveFileWithProgressW)
#endif
{
IF_USE_MAIN_PATH_2(oldFile, newFile)
{
if (
#ifdef Z7_USE_DYN_MoveFileWithProgressW
my_MoveFileWithProgressW
#else
MoveFileWithProgressW
#endif
(fs2us(oldFile), fs2us(newFile), CopyProgressRoutine,
&ProgressInfo, MOVEFILE_COPY_ALLOWED))
return true;
}
#ifdef Z7_LONG_PATH
if ((!(USE_MAIN_PATH_2) || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) && USE_SUPER_PATH_2)
{
if (IsCallbackProgressError())
return false;
UString superPathOld, superPathNew;
if (!GetSuperPaths(oldFile, newFile, superPathOld, superPathNew, USE_MAIN_PATH_2))
return false;
if (
#ifdef Z7_USE_DYN_MoveFileWithProgressW
my_MoveFileWithProgressW
#else
MoveFileWithProgressW
#endif
(superPathOld, superPathNew, CopyProgressRoutine,
&ProgressInfo, MOVEFILE_COPY_ALLOWED))
return true;
}
#endif
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return false;
}
// }
// else
#endif
return MyMoveFile(oldFile, newFile);
}
static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
const wchar_t *message, const FString &fileName)
{
UString s = message;
s += " : ";
s += fs2us(fileName);
return callback->ShowMessage(s);
}
static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
const char *message, const FString &fileName)
{
return SendMessageError(callback, MultiByteToUnicodeString(message), fileName);
}
static DWORD Return_LastError_or_FAIL()
{
DWORD errorCode = GetLastError();
if (errorCode == 0)
errorCode = (DWORD)E_FAIL;
return errorCode;
}
static UString GetLastErrorMessage()
{
return NError::MyFormatMessage(Return_LastError_or_FAIL());
}
HRESULT SendLastErrorMessage(IFolderOperationsExtractCallback *callback, const FString &fileName)
{
return SendMessageError(callback, GetLastErrorMessage(), fileName);
}
static HRESULT CopyFile_Ask(
CCopyState &state,
const FString &srcPath,
const CFileInfo &srcFileInfo,
const FString &destPath)
{
if (CompareFileNames(destPath, srcPath) == 0)
{
RINOK(SendMessageError(state.Callback,
state.MoveMode ?
"Cannot move file onto itself" :
"Cannot copy file onto itself"
, destPath))
return E_ABORT;
}
Int32 writeAskResult;
CMyComBSTR destPathResult;
RINOK(state.Callback->AskWrite(
fs2us(srcPath),
BoolToInt(false),
&srcFileInfo.MTime, &srcFileInfo.Size,
fs2us(destPath),
&destPathResult,
&writeAskResult))
if (IntToBool(writeAskResult))
{
FString destPathNew = us2fs((LPCOLESTR)destPathResult);
RINOK(state.Callback->SetCurrentFilePath(fs2us(srcPath)))
if (state.UseReadWriteMode)
{
NFsFolder::CCopyStateIO state2;
state2.Progress = state.Callback;
state2.DeleteSrcFile = state.MoveMode;
state2.TotalSize = state.ProgressInfo.TotalSize;
state2.StartPos = state.ProgressInfo.StartPos;
RINOK(state2.MyCopyFile(srcPath, destPathNew,
state.IsAltStreamsDest ? INVALID_FILE_ATTRIBUTES: srcFileInfo.Attrib))
if (state2.ErrorFileIndex >= 0)
{
if (state2.ErrorMessage.IsEmpty())
state2.ErrorMessage = GetLastErrorMessage();
FString errorName;
if (state2.ErrorFileIndex == 0)
errorName = srcPath;
else
errorName = destPathNew;
RINOK(SendMessageError(state.Callback, state2.ErrorMessage, errorName))
return E_ABORT;
}
state.ProgressInfo.StartPos += state2.CurrentSize;
}
else
{
state.ProgressInfo.FileSize = srcFileInfo.Size;
bool res;
if (state.MoveMode)
res = state.MoveFile_Sys(srcPath, destPathNew);
else
res = state.CopyFile_Sys(srcPath, destPathNew);
RINOK(state.ProgressInfo.ProgressResult)
if (!res)
{
const DWORD errorCode = GetLastError();
UString errorMessage = NError::MyFormatMessage(Return_LastError_or_FAIL());
if (errorCode == ERROR_INVALID_PARAMETER)
{
NFind::CFileInfo fi;
if (fi.Find(srcPath) &&
fi.Size > (UInt32)(Int32)-1)
{
// bool isFsDetected = false;
// if (NSystem::Is_File_LimitedBy_4GB(destPathNew, isFsDetected) || !isFsDetected)
errorMessage += " File size exceeds 4 GB";
}
}
// GetLastError() is ERROR_REQUEST_ABORTED in case of PROGRESS_CANCEL.
RINOK(SendMessageError(state.Callback, errorMessage, destPathNew))
return E_ABORT;
}
state.ProgressInfo.StartPos += state.ProgressInfo.FileSize;
}
}
else
{
if (state.ProgressInfo.TotalSize >= srcFileInfo.Size)
{
state.ProgressInfo.TotalSize -= srcFileInfo.Size;
RINOK(state.ProgressInfo.Progress->SetTotal(state.ProgressInfo.TotalSize))
}
}
return state.CallProgress();
}
static FString CombinePath(const FString &folderPath, const FString &fileName)
{
FString s (folderPath);
s.Add_PathSepar(); // FCHAR_PATH_SEPARATOR
s += fileName;
return s;
}
static bool IsDestChild(const FString &src, const FString &dest)
{
unsigned len = src.Len();
if (dest.Len() < len)
return false;
if (dest.Len() != len && dest[len] != FCHAR_PATH_SEPARATOR)
return false;
return CompareFileNames(dest.Left(len), src) == 0;
}
static HRESULT CopyFolder(
CCopyState &state,
const FString &srcPath, // without TAIL separator
const FString &destPath) // without TAIL separator
{
RINOK(state.CallProgress())
if (IsDestChild(srcPath, destPath))
{
RINOK(SendMessageError(state.Callback,
state.MoveMode ?
"Cannot copy folder onto itself" :
"Cannot move folder onto itself"
, destPath))
return E_ABORT;
}
if (state.MoveMode)
{
if (state.MoveFile_Sys(srcPath, destPath))
return S_OK;
// MSDN: MoveFile() fails for dirs on different volumes.
}
if (!CreateComplexDir(destPath))
{
RINOK(SendMessageError(state.Callback, "Cannot create folder", destPath))
return E_ABORT;
}
CEnumerator enumerator;
enumerator.SetDirPrefix(CombinePath(srcPath, FString()));
for (;;)
{
NFind::CFileInfo fi;
bool found;
if (!enumerator.Next(fi, found))
{
SendLastErrorMessage(state.Callback, srcPath);
return S_OK;
}
if (!found)
break;
const FString srcPath2 = CombinePath(srcPath, fi.Name);
const FString destPath2 = CombinePath(destPath, fi.Name);
if (fi.IsDir())
{
RINOK(CopyFolder(state, srcPath2, destPath2))
}
else
{
RINOK(CopyFile_Ask(state, srcPath2, fi, destPath2))
}
}
if (state.MoveMode)
{
if (!RemoveDir(srcPath))
{
RINOK(SendMessageError(state.Callback, "Cannot remove folder", srcPath))
return E_ABORT;
}
}
return S_OK;
}
Z7_COM7F_IMF(CFSFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems,
Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */,
const wchar_t *path, IFolderOperationsExtractCallback *callback))
{
if (numItems == 0)
return S_OK;
const FString destPath = us2fs(path);
if (destPath.IsEmpty())
return E_INVALIDARG;
const bool isAltDest = NName::IsAltPathPrefix(destPath);
const bool isDirectPath = (!isAltDest && !IsPathSepar(destPath.Back()));
if (isDirectPath)
if (numItems > 1)
return E_INVALIDARG;
CFsFolderStat stat;
stat.Progress = callback;
UInt32 i;
for (i = 0; i < numItems; i++)
{
const UInt32 index = indices[i];
/*
if (index >= Files.Size())
{
size += Streams[index - Files.Size()].Size;
// numFiles++;
continue;
}
*/
const CDirItem &fi = Files[index];
if (fi.IsDir())
{
if (!isAltDest)
{
stat.Path = _path;
stat.Path += GetRelPath(fi);
RINOK(stat.Enumerate())
}
stat.NumFolders++;
}
else
{
stat.NumFiles++;
stat.Size += fi.Size;
}
}
/*
if (stat.NumFolders != 0 && isAltDest)
return E_NOTIMPL;
*/
RINOK(callback->SetTotal(stat.Size))
RINOK(callback->SetNumFiles(stat.NumFiles))
UInt64 completedSize = 0;
RINOK(callback->SetCompleted(&completedSize))
CCopyState state;
state.ProgressInfo.TotalSize = stat.Size;
state.ProgressInfo.StartPos = 0;
state.ProgressInfo.Progress = callback;
state.ProgressInfo.Init();
state.Callback = callback;
state.MoveMode = IntToBool(moveMode);
state.IsAltStreamsDest = isAltDest;
/* CopyFileW(fromFile, toFile:altStream) returns ERROR_INVALID_PARAMETER,
if there are alt streams in fromFile.
So we don't use CopyFileW() for alt Streams. */
state.UseReadWriteMode = isAltDest;
for (i = 0; i < numItems; i++)
{
const UInt32 index = indices[i];
if (index >= (UInt32)Files.Size())
continue;
const CDirItem &fi = Files[index];
FString destPath2 = destPath;
if (!isDirectPath)
destPath2 += fi.Name;
FString srcPath;
GetFullPath(fi, srcPath);
if (fi.IsDir())
{
if (isAltDest)
{
RINOK(SendMessageError(callback, k_CannotCopyDirToAltStream, srcPath))
}
else
{
RINOK(CopyFolder(state, srcPath, destPath2))
}
}
else
{
RINOK(CopyFile_Ask(state, srcPath, fi, destPath2))
}
}
return S_OK;
}
/* we can call CopyFileSystemItems() from CDropTarget::Drop() */
HRESULT CopyFileSystemItems(
const UStringVector &itemsPaths,
const FString &destDirPrefix,
bool moveMode,
IFolderOperationsExtractCallback *callback)
{
if (itemsPaths.IsEmpty())
return S_OK;
if (destDirPrefix.IsEmpty())
return E_INVALIDARG;
const bool isAltDest = NName::IsAltPathPrefix(destDirPrefix);
CFsFolderStat stat;
stat.Progress = callback;
{
FOR_VECTOR (i, itemsPaths)
{
const UString &path = itemsPaths[i];
CFileInfo fi;
if (!fi.Find(us2fs(path)))
continue;
if (fi.IsDir())
{
if (!isAltDest)
{
stat.Path = us2fs(path);
RINOK(stat.Enumerate())
}
stat.NumFolders++;
}
else
{
stat.NumFiles++;
stat.Size += fi.Size;
}
}
}
/*
if (stat.NumFolders != 0 && isAltDest)
return E_NOTIMPL;
*/
RINOK(callback->SetTotal(stat.Size))
// RINOK(progress->SetNumFiles(stat.NumFiles));
UInt64 completedSize = 0;
RINOK(callback->SetCompleted(&completedSize))
CCopyState state;
state.ProgressInfo.TotalSize = stat.Size;
state.ProgressInfo.StartPos = 0;
state.ProgressInfo.Progress = callback;
state.ProgressInfo.Init();
state.Callback = callback;
state.MoveMode = moveMode;
state.IsAltStreamsDest = isAltDest;
/* CopyFileW(fromFile, toFile:altStream) returns ERROR_INVALID_PARAMETER,
if there are alt streams in fromFile.
So we don't use CopyFileW() for alt Streams. */
state.UseReadWriteMode = isAltDest;
FOR_VECTOR (i, itemsPaths)
{
const UString path = itemsPaths[i];
CFileInfo fi;
if (!fi.Find(us2fs(path)))
{
RINOK(SendMessageError(callback, "Cannot find the file", us2fs(path)))
continue;
}
FString destPath = destDirPrefix;
destPath += fi.Name;
if (fi.IsDir())
{
if (isAltDest)
{
RINOK(SendMessageError(callback, k_CannotCopyDirToAltStream, us2fs(path)))
}
else
{
RINOK(CopyFolder(state, us2fs(path), destPath))
}
}
else
{
RINOK(CopyFile_Ask(state, us2fs(path), fi, destPath))
}
}
return S_OK;
}
/* we don't use CFSFolder::CopyFrom() because the caller of CopyFrom()
is optimized for IFolderArchiveUpdateCallback interface,
but we want to use IFolderOperationsExtractCallback interface instead */
Z7_COM7F_IMF(CFSFolder::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */,
const wchar_t * const * /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */))
{
/*
Z7_DECL_CMyComPtr_QI_FROM(
IFolderOperationsExtractCallback,
callback, progress)
if (!callback)
return E_NOTIMPL;
return CopyFileSystemItems(_path,
moveMode, fromDirPrefix,
itemsPaths, numItems, callback);
*/
return E_NOTIMPL;
}
Z7_COM7F_IMF(CFSFolder::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
}
@@ -0,0 +1,394 @@
// FileFolderPluginOpen.cpp
#include "StdAfx.h"
#include "resource.h"
#include "../../../Windows/FileName.h"
#include "../../../Windows/Thread.h"
#include "../Agent/Agent.h"
#include "../GUI/ExtractRes.h"
#include "FileFolderPluginOpen.h"
#include "FormatUtils.h"
#include "LangUtils.h"
#include "OpenCallback.h"
#include "PluginLoader.h"
#include "PropertyName.h"
#include "RegistryPlugins.h"
using namespace NWindows;
struct CThreadArchiveOpen
{
UString Path;
UString ArcFormat;
CMyComPtr<IInStream> InStream;
CMyComPtr<IFolderManager> FolderManager;
CMyComPtr<IProgress> OpenCallbackProgress;
COpenArchiveCallback *OpenCallbackSpec;
/*
CMyComPtr<IUnknown>
// CMyComPtr<IProgress>
// CMyComPtr<IArchiveOpenCallback>
OpenCallbackSpec_Ref;
*/
CMyComPtr<IFolderFolder> Folder;
HRESULT Result;
void Process()
{
try
{
CProgressCloser closer(OpenCallbackSpec->ProgressDialog);
Result = FolderManager->OpenFolderFile(InStream, Path, ArcFormat, &Folder, OpenCallbackProgress);
}
catch(...) { Result = E_FAIL; }
}
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
((CThreadArchiveOpen *)param)->Process();
return 0;
}
};
/*
static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &pluginName)
{
for (int i = 0; i < plugins.Size(); i++)
if (plugins[i].Name.CompareNoCase(pluginName) == 0)
return i;
return -1;
}
*/
static void SplitNameToPureNameAndExtension(const FString &fullName,
FString &pureName, FString &extensionDelimiter, FString &extension)
{
const int index = fullName.ReverseFind_Dot();
if (index < 0)
{
pureName = fullName;
extensionDelimiter.Empty();
extension.Empty();
}
else
{
pureName.SetFrom(fullName, (unsigned)index);
extensionDelimiter = '.';
extension = fullName.Ptr((unsigned)index + 1);
}
}
struct CArcLevelInfo
{
UString Error;
UString Path;
UString Type;
UString ErrorType;
UString ErrorFlags;
};
struct CArcLevelsInfo
{
CObjectVector<CArcLevelInfo> Levels; // LastLevel Is NON-OPEN
};
UString GetOpenArcErrorMessage(UInt32 errorFlags);
static void GetFolderLevels(CMyComPtr<IFolderFolder> &folder, CArcLevelsInfo &levels)
{
levels.Levels.Clear();
CMyComPtr<IGetFolderArcProps> getFolderArcProps;
folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
if (!getFolderArcProps)
return;
CMyComPtr<IFolderArcProps> arcProps;
getFolderArcProps->GetFolderArcProps(&arcProps);
if (!arcProps)
return;
UInt32 numLevels;
if (arcProps->GetArcNumLevels(&numLevels) != S_OK)
numLevels = 0;
for (UInt32 level = 0; level <= numLevels; level++)
{
const PROPID propIDs[] = { kpidError, kpidPath, kpidType, kpidErrorType };
CArcLevelInfo lev;
for (Int32 i = 0; i < 4; i++)
{
CMyComBSTR name;
NCOM::CPropVariant prop;
if (arcProps->GetArcProp(level, propIDs[i], &prop) != S_OK)
continue;
if (prop.vt != VT_EMPTY)
{
UString *s = NULL;
switch (propIDs[i])
{
case kpidError: s = &lev.Error; break;
case kpidPath: s = &lev.Path; break;
case kpidType: s = &lev.Type; break;
case kpidErrorType: s = &lev.ErrorType; break;
}
*s = (prop.vt == VT_BSTR) ? prop.bstrVal : L"?";
}
}
{
NCOM::CPropVariant prop;
if (arcProps->GetArcProp(level, kpidErrorFlags, &prop) == S_OK)
{
UInt32 flags = GetOpenArcErrorFlags(prop);
if (flags != 0)
lev.ErrorFlags = GetOpenArcErrorMessage(flags);
}
}
levels.Levels.Add(lev);
}
}
static UString GetBracedType(const wchar_t *type)
{
UString s ('[');
s += type;
s.Add_Char(']');
return s;
}
static void GetFolderError(CMyComPtr<IFolderFolder> &folder, UString &open_Errors, UString &nonOpen_Errors)
{
CArcLevelsInfo levs;
GetFolderLevels(folder, levs);
open_Errors.Empty();
nonOpen_Errors.Empty();
FOR_VECTOR (i, levs.Levels)
{
bool isNonOpenLevel = (i == 0);
const CArcLevelInfo &lev = levs.Levels[levs.Levels.Size() - 1 - i];
UString m;
if (!lev.ErrorType.IsEmpty())
{
m = MyFormatNew(IDS_CANT_OPEN_AS_TYPE, GetBracedType(lev.ErrorType));
if (!isNonOpenLevel)
{
m.Add_LF();
m += MyFormatNew(IDS_IS_OPEN_AS_TYPE, GetBracedType(lev.Type));
}
}
if (!lev.Error.IsEmpty())
{
if (!m.IsEmpty())
m.Add_LF();
m += GetBracedType(lev.Type);
m += " : ";
m += GetNameOfProperty(kpidError, L"Error");
m += " : ";
m += lev.Error;
}
if (!lev.ErrorFlags.IsEmpty())
{
if (!m.IsEmpty())
m.Add_LF();
m += GetNameOfProperty(kpidErrorFlags, L"Errors");
m += ": ";
m += lev.ErrorFlags;
}
if (!m.IsEmpty())
{
if (isNonOpenLevel)
{
UString &s = nonOpen_Errors;
s += lev.Path;
s.Add_LF();
s += m;
}
else
{
UString &s = open_Errors;
if (!s.IsEmpty())
s += "--------------------\n";
s += lev.Path;
s.Add_LF();
s += m;
}
}
}
}
#ifdef _MSC_VER
#pragma warning(error : 4702) // unreachable code
#endif
HRESULT CFfpOpen::OpenFileFolderPlugin(IInStream *inStream,
const FString &path, const UString &arcFormat, HWND parentWindow)
{
/*
CObjectVector<CPluginInfo> plugins;
ReadFileFolderPluginInfoList(plugins);
*/
FString extension, name, pureName, dot;
const int slashPos = path.ReverseFind_PathSepar();
FString dirPrefix;
FString fileName;
if (slashPos >= 0)
{
dirPrefix.SetFrom(path, (unsigned)(slashPos + 1));
fileName = path.Ptr((unsigned)(slashPos + 1));
}
else
fileName = path;
SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
/*
if (!extension.IsEmpty())
{
CExtInfo extInfo;
if (ReadInternalAssociation(extension, extInfo))
{
for (int i = extInfo.Plugins.Size() - 1; i >= 0; i--)
{
int pluginIndex = FindPlugin(plugins, extInfo.Plugins[i]);
if (pluginIndex >= 0)
{
const CPluginInfo plugin = plugins[pluginIndex];
plugins.Delete(pluginIndex);
plugins.Insert(0, plugin);
}
}
}
}
*/
ErrorMessage.Empty();
// FOR_VECTOR (i, plugins)
// {
/*
const CPluginInfo &plugin = plugins[i];
if (!plugin.ClassID_Defined && !plugin.FilePath.IsEmpty())
continue;
*/
CPluginLibrary library;
CThreadArchiveOpen t;
// if (plugin.FilePath.IsEmpty())
t.FolderManager = new CArchiveFolderManager;
/*
else if (library.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &t.FolderManager) != S_OK)
continue;
*/
COpenArchiveCallback OpenCallbackSpec_loc;
t.OpenCallbackSpec = &OpenCallbackSpec_loc;
/*
t.OpenCallbackSpec = new COpenArchiveCallback;
t.OpenCallbackSpec_Ref = t.OpenCallbackSpec;
*/
t.OpenCallbackSpec->PasswordIsDefined = Encrypted;
t.OpenCallbackSpec->Password = Password;
t.OpenCallbackSpec->ParentWindow = parentWindow;
/* COpenCallbackImp object will exist after Open stage for multivolume archives */
COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
t.OpenCallbackProgress = openCallbackSpec;
// openCallbackSpec->Callback_Ref = t.OpenCallbackSpec;
// we set pointer without reference counter:
openCallbackSpec->Callback =
// openCallbackSpec->ReOpenCallback =
t.OpenCallbackSpec;
if (inStream)
openCallbackSpec->SetSubArchiveName(fs2us(fileName));
else
{
RINOK(openCallbackSpec->Init2(dirPrefix, fileName))
}
t.InStream = inStream;
t.Path = fs2us(path);
t.ArcFormat = arcFormat;
const UString progressTitle = LangString(IDS_OPENNING);
{
CProgressDialog &pd = t.OpenCallbackSpec->ProgressDialog;
pd.MainWindow = parentWindow;
pd.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
pd.MainAddTitle = progressTitle + L' ';
pd.WaitMode = true;
}
{
NWindows::CThread thread;
const WRes wres = thread.Create(CThreadArchiveOpen::MyThreadFunction, &t);
if (wres != 0)
return HRESULT_FROM_WIN32(wres);
t.OpenCallbackSpec->StartProgressDialog(progressTitle, thread);
}
/*
if archive is multivolume:
COpenCallbackImp object will exist after Open stage.
COpenCallbackImp object will be deleted when last reference
from each volume object (CInFileStreamVol) will be closed (when archive will be closed).
*/
t.OpenCallbackProgress.Release();
if (t.Result != S_FALSE && t.Result != S_OK)
return t.Result;
if (t.Folder)
{
UString open_Errors, nonOpen_Errors;
GetFolderError(t.Folder, open_Errors, nonOpen_Errors);
if (!nonOpen_Errors.IsEmpty())
{
ErrorMessage = nonOpen_Errors;
// if (t.Result != S_OK) return t.Result;
/* if there are good open leves, and non0open level,
we could force error as critical error and return error here
but it's better to allow to open such rachives */
// return S_FALSE;
}
}
// if (openCallbackSpec->PasswordWasAsked)
{
Encrypted = t.OpenCallbackSpec->PasswordIsDefined;
Password = t.OpenCallbackSpec->Password;
}
if (t.Result == S_OK)
{
Library.Attach(library.Detach());
// Folder.Attach(t.Folder.Detach());
Folder = t.Folder;
}
return t.Result;
// }
}
@@ -0,0 +1,27 @@
// FileFolderPluginOpen.h
#ifndef ZIP7_INC_FILE_FOLDER_PLUGIN_OPEN_H
#define ZIP7_INC_FILE_FOLDER_PLUGIN_OPEN_H
#include "../../../Windows/DLL.h"
struct CFfpOpen
{
Z7_CLASS_NO_COPY(CFfpOpen)
public:
// out:
bool Encrypted;
UString Password;
NWindows::NDLL::CLibrary Library;
CMyComPtr<IFolderFolder> Folder;
UString ErrorMessage;
CFfpOpen(): Encrypted (false) {}
HRESULT OpenFileFolderPlugin(IInStream *inStream,
const FString &path, const UString &arcFormat, HWND parentWindow);
};
#endif
@@ -0,0 +1,78 @@
// FilePlugins.cpp
#include "StdAfx.h"
#include "../Agent/Agent.h"
#include "FilePlugins.h"
#include "PluginLoader.h"
#include "StringUtils.h"
int CExtDatabase::FindExt(const UString &ext) const
{
FOR_VECTOR (i, Exts)
if (Exts[i].Ext.IsEqualTo_NoCase(ext))
return (int)i;
return -1;
}
void CExtDatabase::Read()
{
/*
ReadFileFolderPluginInfoList(Plugins);
FOR_VECTOR (pluginIndex, Plugins)
*/
{
// const CPluginInfo &plugin = Plugins[pluginIndex];
CPluginLibrary pluginLib;
CMyComPtr<IFolderManager> folderManager;
// if (plugin.FilePath.IsEmpty())
folderManager = new CArchiveFolderManager;
/*
else
{
if (!plugin.ClassID_Defined)
continue;
if (pluginLib.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK)
continue;
}
*/
CMyComBSTR extBSTR;
if (folderManager->GetExtensions(&extBSTR) != S_OK)
return;
UStringVector exts;
SplitString((const wchar_t *)extBSTR, exts);
FOR_VECTOR (i, exts)
{
const UString &ext = exts[i];
#ifdef UNDER_CE
if (ext == L"cab")
continue;
#endif
Int32 iconIndex;
CMyComBSTR iconPath;
CPluginToIcon plugPair;
// plugPair.PluginIndex = pluginIndex;
if (folderManager->GetIconPath(ext, &iconPath, &iconIndex) == S_OK)
if (iconPath)
{
plugPair.IconPath = (const wchar_t *)iconPath;
plugPair.IconIndex = iconIndex;
}
const int index = FindExt(ext);
if (index >= 0)
Exts[index].Plugins.Add(plugPair);
else
{
CExtPlugins extInfo;
extInfo.Plugins.Add(plugPair);
extInfo.Ext = ext;
Exts.Add(extInfo);
}
}
}
}
@@ -0,0 +1,33 @@
// FilePlugins.h
#ifndef ZIP7_INC_FILE_PLUGINS_H
#define ZIP7_INC_FILE_PLUGINS_H
#include "RegistryPlugins.h"
struct CPluginToIcon
{
// unsigned PluginIndex;
int IconIndex;
UString IconPath;
CPluginToIcon(): IconIndex(-1) {}
};
struct CExtPlugins
{
UString Ext;
CObjectVector<CPluginToIcon> Plugins;
};
class CExtDatabase
{
int FindExt(const UString &ext) const;
public:
CObjectVector<CExtPlugins> Exts;
// CObjectVector<CPluginInfo> Plugins;
void Read();
};
#endif
@@ -0,0 +1,172 @@
// FoldersPage.cpp
#include "StdAfx.h"
#include "FoldersPageRes.h"
#include "FoldersPage.h"
#include "../FileManager/BrowseDialog.h"
#include "../FileManager/HelpUtils.h"
#include "../FileManager/LangUtils.h"
using namespace NWindows;
#ifdef Z7_LANG
static const UInt32 kLangIDs[] =
{
IDT_FOLDERS_WORKING_FOLDER,
IDR_FOLDERS_WORK_SYSTEM,
IDR_FOLDERS_WORK_CURRENT,
IDR_FOLDERS_WORK_SPECIFIED,
IDX_FOLDERS_WORK_FOR_REMOVABLE
};
#endif
static const unsigned kWorkModeButtons[] =
{
IDR_FOLDERS_WORK_SYSTEM,
IDR_FOLDERS_WORK_CURRENT,
IDR_FOLDERS_WORK_SPECIFIED
};
#define kFoldersTopic "fm/options.htm#folders"
static const unsigned kNumWorkModeButtons = Z7_ARRAY_SIZE(kWorkModeButtons);
bool CFoldersPage::OnInit()
{
_initMode = true;
_needSave = false;
#ifdef Z7_LANG
LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
#endif
m_WorkDirInfo.Load();
CheckButton(IDX_FOLDERS_WORK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly);
CheckRadioButton(
kWorkModeButtons[0],
kWorkModeButtons[kNumWorkModeButtons - 1],
kWorkModeButtons[m_WorkDirInfo.Mode]);
m_WorkPath.Init(*this, IDE_FOLDERS_WORK_PATH);
m_WorkPath.SetText(fs2us(m_WorkDirInfo.Path));
MyEnableControls();
_initMode = false;
return CPropertyPage::OnInit();
}
int CFoldersPage::GetWorkMode() const
{
for (unsigned i = 0; i < kNumWorkModeButtons; i++)
if (IsButtonCheckedBool(kWorkModeButtons[i]))
return (int)i;
throw 0;
}
void CFoldersPage::MyEnableControls()
{
bool enablePath = (GetWorkMode() == NWorkDir::NMode::kSpecified);
m_WorkPath.Enable(enablePath);
EnableItem(IDB_FOLDERS_WORK_PATH, enablePath);
}
void CFoldersPage::GetWorkDir(NWorkDir::CInfo &workDirInfo)
{
UString s;
m_WorkPath.GetText(s);
workDirInfo.Path = us2fs(s);
workDirInfo.ForRemovableOnly = IsButtonCheckedBool(IDX_FOLDERS_WORK_FOR_REMOVABLE);
workDirInfo.Mode = NWorkDir::NMode::EEnum(GetWorkMode());
}
/*
bool CFoldersPage::WasChanged()
{
NWorkDir::CInfo workDirInfo;
GetWorkDir(workDirInfo);
return (workDirInfo.Mode != m_WorkDirInfo.Mode ||
workDirInfo.ForRemovableOnly != m_WorkDirInfo.ForRemovableOnly ||
workDirInfo.Path.Compare(m_WorkDirInfo.Path) != 0);
}
*/
void CFoldersPage::ModifiedEvent()
{
if (!_initMode)
{
_needSave = true;
Changed();
}
/*
if (WasChanged())
Changed();
else
UnChanged();
*/
}
bool CFoldersPage::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
for (unsigned i = 0; i < kNumWorkModeButtons; i++)
if (buttonID == kWorkModeButtons[i])
{
MyEnableControls();
ModifiedEvent();
return true;
}
switch (buttonID)
{
case IDB_FOLDERS_WORK_PATH:
OnFoldersWorkButtonPath();
return true;
case IDX_FOLDERS_WORK_FOR_REMOVABLE:
break;
default:
return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
}
ModifiedEvent();
return true;
}
bool CFoldersPage::OnCommand(unsigned code, unsigned itemID, LPARAM lParam)
{
if (code == EN_CHANGE && itemID == IDE_FOLDERS_WORK_PATH)
{
ModifiedEvent();
return true;
}
return CPropertyPage::OnCommand(code, itemID, lParam);
}
void CFoldersPage::OnFoldersWorkButtonPath()
{
UString currentPath;
m_WorkPath.GetText(currentPath);
UString title = LangString(IDS_FOLDERS_SET_WORK_PATH_TITLE);
UString resultPath;
if (MyBrowseForFolder(*this, title, currentPath, resultPath))
m_WorkPath.SetText(resultPath);
}
LONG CFoldersPage::OnApply()
{
if (_needSave)
{
GetWorkDir(m_WorkDirInfo);
m_WorkDirInfo.Save();
_needSave = false;
}
return PSNRET_NOERROR;
}
void CFoldersPage::OnNotifyHelp()
{
ShowHelpWindow(kFoldersTopic);
}
@@ -0,0 +1,32 @@
// FoldersPage.h
#ifndef ZIP7_INC_FOLDERS_PAGE_H
#define ZIP7_INC_FOLDERS_PAGE_H
#include "../../../Windows/Control/PropertyPage.h"
#include "../Common/ZipRegistry.h"
class CFoldersPage : public NWindows::NControl::CPropertyPage
{
NWorkDir::CInfo m_WorkDirInfo;
NWindows::NControl::CDialogChildControl m_WorkPath;
bool _needSave;
bool _initMode;
void MyEnableControls();
void ModifiedEvent();
void OnFoldersWorkButtonPath();
int GetWorkMode() const;
void GetWorkDir(NWorkDir::CInfo &workDirInfo);
// bool WasChanged();
virtual bool OnInit() Z7_override;
virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam) Z7_override;
virtual void OnNotifyHelp() Z7_override;
virtual LONG OnApply() Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
};
#endif
@@ -0,0 +1,23 @@
#include "FoldersPageRes.h"
#include "../../GuiCommon.rc"
#define xc OPTIONS_PAGE_XC_SIZE
#define yc 100
IDD_FOLDERS MY_PAGE
#include "FoldersPage2.rc"
#ifdef UNDER_CE
#undef xc
#define xc SMALL_PAGE_SIZE_X
IDD_FOLDERS_2 MY_PAGE
#include "FoldersPage2.rc"
#endif
STRINGTABLE
BEGIN
IDS_FOLDERS_SET_WORK_PATH_TITLE "Specify a location for temporary archive files."
END
@@ -0,0 +1,11 @@
CAPTION "Folders"
BEGIN
// GROUPBOX "&Working folder", IDT_FOLDERS_WORKING_FOLDER, m, m, xc, 98
LTEXT "&Working folder", IDT_FOLDERS_WORKING_FOLDER, m, m, xc, 8
MY_CONTROL_AUTORADIOBUTTON_GROUP ( "&System temp folder", IDR_FOLDERS_WORK_SYSTEM, m, 20, xc)
MY_CONTROL_AUTORADIOBUTTON ( "&Current", IDR_FOLDERS_WORK_CURRENT, m, 34, xc)
MY_CONTROL_AUTORADIOBUTTON ( "Specified:", IDR_FOLDERS_WORK_SPECIFIED, m, 48, xc)
EDITTEXT IDE_FOLDERS_WORK_PATH, m + m, 62, xc - m - m - bxsDots, 14, ES_AUTOHSCROLL
PUSHBUTTON "...", IDB_FOLDERS_WORK_PATH, xs - m - bxsDots, 61, bxsDots, bys
MY_CONTROL_CHECKBOX ( "Use for removable drives only", IDX_FOLDERS_WORK_FOR_REMOVABLE, m, 86, xc)
END
@@ -0,0 +1,12 @@
#define IDD_FOLDERS 2400
#define IDD_FOLDERS_2 12400
#define IDT_FOLDERS_WORKING_FOLDER 2401
#define IDR_FOLDERS_WORK_SYSTEM 2402
#define IDR_FOLDERS_WORK_CURRENT 2403
#define IDR_FOLDERS_WORK_SPECIFIED 2404
#define IDX_FOLDERS_WORK_FOR_REMOVABLE 2405
#define IDS_FOLDERS_SET_WORK_PATH_TITLE 2406
#define IDE_FOLDERS_WORK_PATH 100
#define IDB_FOLDERS_WORK_PATH 101
@@ -0,0 +1,28 @@
// FormatUtils.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "FormatUtils.h"
#include "LangUtils.h"
UString NumberToString(UInt64 number)
{
wchar_t numberString[32];
ConvertUInt64ToString(number, numberString);
return numberString;
}
UString MyFormatNew(const UString &format, const UString &argument)
{
UString result = format;
result.Replace(L"{0}", argument);
return result;
}
UString MyFormatNew(UINT resourceID, const UString &argument)
{
return MyFormatNew(LangString(resourceID), argument);
}
@@ -0,0 +1,14 @@
// FormatUtils.h
#ifndef ZIP7_INC_FORMAT_UTILS_H
#define ZIP7_INC_FORMAT_UTILS_H
#include "../../../Common/MyTypes.h"
#include "../../../Common/MyString.h"
UString NumberToString(UInt64 number);
UString MyFormatNew(const UString &format, const UString &argument);
UString MyFormatNew(UINT resourceID, const UString &argument);
#endif
@@ -0,0 +1,78 @@
// HelpUtils.cpp
#include "StdAfx.h"
#include "HelpUtils.h"
#if defined(UNDER_CE) || defined(__MINGW32_VERSION)
void ShowHelpWindow(LPCSTR)
{
}
#else
/* USE_EXTERNAL_HELP creates new help process window for each HtmlHelp() call.
HtmlHelp() call uses one window. */
#if defined(__MINGW32_VERSION) /* || defined(Z7_OLD_WIN_SDK) */
#define USE_EXTERNAL_HELP
#endif
// #define USE_EXTERNAL_HELP
#ifdef USE_EXTERNAL_HELP
#include "../../../Windows/ProcessUtils.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileName.h"
#else
#include <HtmlHelp.h>
#endif
#include "../../../Common/StringConvert.h"
#include "../../../Windows/DLL.h"
#define kHelpFileName "7-zip.chm::/"
void ShowHelpWindow(LPCSTR topicFile)
{
FString path = NWindows::NDLL::GetModuleDirPrefix();
path += kHelpFileName;
path += topicFile;
#ifdef USE_EXTERNAL_HELP
FString prog;
#ifdef UNDER_CE
prog = "\\Windows\\";
#else
if (!NWindows::NFile::NDir::GetWindowsDir(prog))
return;
NWindows::NFile::NName::NormalizeDirPathPrefix(prog);
#endif
prog += "hh.exe";
UString params;
params += '"';
params += fs2us(path);
params += '"';
NWindows::CProcess process;
const WRes wres = process.Create(fs2us(prog), params, NULL); // curDir);
if (wres != 0)
{
/*
HRESULT hres = HRESULT_FROM_WIN32(wres);
ErrorMessageHRESULT(hres, imageName);
return hres;
*/
}
#else
// HWND hwnd = NULL;
HtmlHelp(NULL, GetSystemString(fs2us(path)), HH_DISPLAY_TOPIC, 0);
#endif
}
#endif
@@ -0,0 +1,10 @@
// HelpUtils.h
#ifndef ZIP7_INC_HELP_UTILS_H
#define ZIP7_INC_HELP_UTILS_H
#include "../../../Common/MyString.h"
void ShowHelpWindow(LPCSTR topicFile);
#endif
@@ -0,0 +1,187 @@
// IFolder.h
#ifndef ZIP7_INC_IFOLDER_H
#define ZIP7_INC_IFOLDER_H
#include "../../IProgress.h"
#include "../../IStream.h"
Z7_PURE_INTERFACES_BEGIN
#define Z7_IFACE_CONSTR_FOLDER_SUB(i, base, n) \
Z7_DECL_IFACE_7ZIP_SUB(i, base, 8, n) \
{ Z7_IFACE_COM7_PURE(i) };
#define Z7_IFACE_CONSTR_FOLDER(i, n) \
Z7_IFACE_CONSTR_FOLDER_SUB(i, IUnknown, n)
namespace NPlugin
{
enum
{
kName = 0,
kType,
kClassID,
kOptionsClassID
};
}
#define Z7_IFACEM_IFolderFolder(x) \
x(LoadItems()) \
x(GetNumberOfItems(UInt32 *numItems)) \
x(GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)) \
x(BindToFolder(UInt32 index, IFolderFolder **resultFolder)) \
x(BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)) \
x(BindToParentFolder(IFolderFolder **resultFolder)) \
x(GetNumberOfProperties(UInt32 *numProperties)) \
x(GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
x(GetFolderProperty(PROPID propID, PROPVARIANT *value)) \
Z7_IFACE_CONSTR_FOLDER(IFolderFolder, 0x00)
/*
IFolderAltStreams::
BindToAltStreams((UInt32)(Int32)-1, ... ) means alt streams of that folder
*/
#define Z7_IFACEM_IFolderAltStreams(x) \
x(BindToAltStreams(UInt32 index, IFolderFolder **resultFolder)) \
x(BindToAltStreams(const wchar_t *name, IFolderFolder **resultFolder)) \
x(AreAltStreamsSupported(UInt32 index, Int32 *isSupported)) \
Z7_IFACE_CONSTR_FOLDER(IFolderAltStreams, 0x17)
#define Z7_IFACEM_IFolderWasChanged(x) \
x(WasChanged(Int32 *wasChanged))
Z7_IFACE_CONSTR_FOLDER(IFolderWasChanged, 0x04)
/* x(SetTotalFiles(UInt64 total)) */ \
/* x(SetCompletedFiles(const UInt64 *completedValue)) */ \
#define Z7_IFACEM_IFolderOperationsExtractCallback(x) \
x(AskWrite( \
const wchar_t *srcPath, \
Int32 srcIsFolder, \
const FILETIME *srcTime, \
const UInt64 *srcSize, \
const wchar_t *destPathRequest, \
BSTR *destPathResult, \
Int32 *writeAnswer)) \
x(ShowMessage(const wchar_t *message)) \
x(SetCurrentFilePath(const wchar_t *filePath)) \
x(SetNumFiles(UInt64 numFiles)) \
Z7_IFACE_CONSTR_FOLDER_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B)
#define Z7_IFACEM_IFolderOperations(x) \
x(CreateFolder(const wchar_t *name, IProgress *progress)) \
x(CreateFile(const wchar_t *name, IProgress *progress)) \
x(Rename(UInt32 index, const wchar_t *newName, IProgress *progress)) \
x(Delete(const UInt32 *indices, UInt32 numItems, IProgress *progress)) \
x(CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems, \
Int32 includeAltStreams, Int32 replaceAltStreamCharsMode, \
const wchar_t *path, IFolderOperationsExtractCallback *callback)) \
x(CopyFrom(Int32 moveMode, const wchar_t *fromFolderPath, \
const wchar_t * const *itemsPaths, UInt32 numItems, IProgress *progress)) \
x(SetProperty(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress)) \
x(CopyFromFile(UInt32 index, const wchar_t *fullFilePath, IProgress *progress)) \
Z7_IFACE_CONSTR_FOLDER(IFolderOperations, 0x13)
/*
FOLDER_INTERFACE2(IFolderOperationsDeleteToRecycleBin, 0x06, 0x03)
{
x(DeleteToRecycleBin(const UInt32 *indices, UInt32 numItems, IProgress *progress)) \
};
*/
#define Z7_IFACEM_IFolderGetSystemIconIndex(x) \
x(GetSystemIconIndex(UInt32 index, Int32 *iconIndex))
Z7_IFACE_CONSTR_FOLDER(IFolderGetSystemIconIndex, 0x07)
#define Z7_IFACEM_IFolderGetItemFullSize(x) \
x(GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress))
Z7_IFACE_CONSTR_FOLDER(IFolderGetItemFullSize, 0x08)
#define Z7_IFACEM_IFolderCalcItemFullSize(x) \
x(CalcItemFullSize(UInt32 index, IProgress *progress))
Z7_IFACE_CONSTR_FOLDER(IFolderCalcItemFullSize, 0x14)
#define Z7_IFACEM_IFolderClone(x) \
x(Clone(IFolderFolder **resultFolder))
Z7_IFACE_CONSTR_FOLDER(IFolderClone, 0x09)
#define Z7_IFACEM_IFolderSetFlatMode(x) \
x(SetFlatMode(Int32 flatMode))
Z7_IFACE_CONSTR_FOLDER(IFolderSetFlatMode, 0x0A)
/*
#define Z7_IFACEM_IFolderSetShowNtfsStreamsMode(x) \
x(SetShowNtfsStreamsMode(Int32 showStreamsMode))
Z7_IFACE_CONSTR_FOLDER(IFolderSetShowNtfsStreamsMode, 0xFA)
*/
#define Z7_IFACEM_IFolderProperties(x) \
x(GetNumberOfFolderProperties(UInt32 *numProperties)) \
x(GetFolderPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
Z7_IFACE_CONSTR_FOLDER(IFolderProperties, 0x0E)
#define Z7_IFACEM_IFolderArcProps(x) \
x(GetArcNumLevels(UInt32 *numLevels)) \
x(GetArcProp(UInt32 level, PROPID propID, PROPVARIANT *value)) \
x(GetArcNumProps(UInt32 level, UInt32 *numProps)) \
x(GetArcPropInfo(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
x(GetArcProp2(UInt32 level, PROPID propID, PROPVARIANT *value)) \
x(GetArcNumProps2(UInt32 level, UInt32 *numProps)) \
x(GetArcPropInfo2(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
Z7_IFACE_CONSTR_FOLDER(IFolderArcProps, 0x10)
#define Z7_IFACEM_IGetFolderArcProps(x) \
x(GetFolderArcProps(IFolderArcProps **object))
Z7_IFACE_CONSTR_FOLDER(IGetFolderArcProps, 0x11)
#define Z7_IFACEM_IFolderCompare(x) \
x##2(Int32, CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw))
Z7_IFACE_CONSTR_FOLDER(IFolderCompare, 0x15)
#define Z7_IFACEM_IFolderGetItemName(x) \
x(GetItemName(UInt32 index, const wchar_t **name, unsigned *len)) \
x(GetItemPrefix(UInt32 index, const wchar_t **name, unsigned *len)) \
x##2(UInt64, GetItemSize(UInt32 index)) \
Z7_IFACE_CONSTR_FOLDER(IFolderGetItemName, 0x16)
#define Z7_IFACEM_IFolderManager(x) \
x(OpenFolderFile(IInStream *inStream, const wchar_t *filePath, const wchar_t *arcFormat, IFolderFolder **resultFolder, IProgress *progress)) \
x(GetExtensions(BSTR *extensions)) \
x(GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex)) \
// x(GetTypes(BSTR *types))
// x(CreateFolderFile(const wchar_t *type, const wchar_t *filePath, IProgress *progress))
Z7_DECL_IFACE_7ZIP(IFolderManager, 9, 5)
{ Z7_IFACE_COM7_PURE(IFolderManager) };
/*
const CMy_STATPROPSTG_2 &srcItem = k[index]; \
*propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \
*/
#define IMP_IFolderFolder_GetProp(fn, k) \
Z7_COM7F_IMF(fn(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
{ if (index >= Z7_ARRAY_SIZE(k)) return E_INVALIDARG; \
*propID = k[index]; *varType = k7z_PROPID_To_VARTYPE[(unsigned)*propID]; *name = NULL; return S_OK; } \
#define IMP_IFolderFolder_Props(c) \
Z7_COM7F_IMF(c::GetNumberOfProperties(UInt32 *numProperties)) \
{ *numProperties = Z7_ARRAY_SIZE(kProps); return S_OK; } \
IMP_IFolderFolder_GetProp(c::GetPropertyInfo, kProps)
int CompareFileNames_ForFolderList(const wchar_t *s1, const wchar_t *s2);
// int CompareFileNames_ForFolderList(const FChar *s1, const FChar *s2);
Z7_PURE_INTERFACES_END
#endif
Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

@@ -0,0 +1,360 @@
// LangPage.cpp
#include "StdAfx.h"
#include "../../../Common/Lang.h"
#include "../../../Windows/FileFind.h"
#include "../../../Windows/ResourceString.h"
#include "HelpUtils.h"
#include "LangPage.h"
#include "LangPageRes.h"
#include "LangUtils.h"
#include "RegistryUtils.h"
using namespace NWindows;
static const unsigned k_NumLangLines_EN = 443;
#ifdef Z7_LANG
static const UInt32 kLangIDs[] =
{
IDT_LANG_LANG
};
#endif
#define kLangTopic "fm/options.htm#language"
struct CLangListRecord
{
int Order;
unsigned LangInfoIndex;
bool IsSelected;
UString Mark;
UString Name;
CLangListRecord(): Order (10), IsSelected(false) {}
int Compare(const CLangListRecord &a) const
{
if (Order < a.Order) return -1;
if (Order > a.Order) return 1;
return MyStringCompareNoCase(Name, a.Name);
}
};
static void NativeLangString(UString &dest, const wchar_t *s)
{
dest += " (";
dest += s;
dest.Add_Char(')');
}
bool LangOpen(CLang &lang, CFSTR fileName);
bool CLangPage::OnInit()
{
#ifdef Z7_LANG
LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
#endif
_langCombo.Attach(GetItem(IDC_LANG_LANG));
unsigned listRecords_SelectedIndex = 0;
CObjectVector<CLangListRecord> listRecords;
{
CLangListRecord listRecord;
listRecord.Order = 0;
listRecord.Mark = "---";
listRecord.Name = MyLoadString(IDS_LANG_ENGLISH);
NativeLangString(listRecord.Name, MyLoadString(IDS_LANG_NATIVE));
listRecord.LangInfoIndex = _langs.Size();
listRecords.Add(listRecord);
}
AStringVector names;
unsigned subLangIndex = 0;
Lang_GetShortNames_for_DefaultLang(names, subLangIndex);
const FString dirPrefix = GetLangDirPrefix();
NFile::NFind::CEnumerator enumerator;
enumerator.SetDirPrefix(dirPrefix);
NFile::NFind::CFileInfo fi;
CLang lang_en;
{
CLangInfo &langInfo = _langs.AddNew();
langInfo.Name = "-";
if (LangOpen(lang_en, dirPrefix + FTEXT("en.ttt")))
{
langInfo.NumLines = lang_en._ids.Size();
// langInfo.Comments = lang_en.Comments;
}
else
langInfo.NumLines = k_NumLangLines_EN;
NumLangLines_EN = langInfo.NumLines;
}
CLang lang;
UString error;
UString n;
while (enumerator.Next(fi))
{
if (fi.IsDir())
continue;
const unsigned kExtSize = 4;
if (fi.Name.Len() < kExtSize)
continue;
const unsigned pos = fi.Name.Len() - kExtSize;
if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".txt"))
{
// if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".ttt"))
continue;
}
if (!LangOpen(lang, dirPrefix + fi.Name))
{
error.Add_Space_if_NotEmpty();
error += fs2us(fi.Name);
continue;
}
const UString shortName = fs2us(fi.Name.Left(pos));
CLangListRecord listRecord;
if (!names.IsEmpty())
{
for (unsigned i = 0; i < names.Size(); i++)
if (shortName.IsEqualTo_Ascii_NoCase(names[i]))
{
if (subLangIndex == i || names.Size() == 1)
{
listRecord.Mark = "***";
// listRecord.Order = 1;
}
else
{
listRecord.Mark = "+++";
// listRecord.Order = 2;
}
break;
}
if (listRecord.Mark.IsEmpty())
{
const int minusPos = shortName.Find(L'-');
if (minusPos >= 0)
{
const UString shortName2 = shortName.Left(minusPos);
if (shortName2.IsEqualTo_Ascii_NoCase(names[0]))
{
listRecord.Mark = "+++";
// listRecord.Order = 3;
}
}
}
}
UString s = shortName;
const wchar_t *eng = lang.Get(IDS_LANG_ENGLISH);
if (eng)
s = eng;
const wchar_t *native = lang.Get(IDS_LANG_NATIVE);
if (native)
NativeLangString(s, native);
listRecord.Name = s;
listRecord.LangInfoIndex = _langs.Size();
listRecords.Add(listRecord);
if (g_LangID.IsEqualTo_NoCase(shortName))
listRecords_SelectedIndex = listRecords.Size() - 1;
CLangInfo &langInfo = _langs.AddNew();
langInfo.Comments = lang.Comments;
langInfo.Name = shortName;
unsigned numLines = lang._ids.Size();
if (!lang_en.IsEmpty())
{
numLines = 0;
unsigned i1 = 0;
unsigned i2 = 0;
for (;;)
{
UInt32 id1 = (UInt32)0 - 1;
UInt32 id2 = (UInt32)0 - 1;
bool id1_defined = false;
bool id2_defined = false;
if (i1 < lang_en._ids.Size())
{
id1 = lang_en._ids[i1];
id1_defined = true;
}
if (i2 < lang._ids.Size())
{
id2 = lang._ids[i2];
id2_defined = true;
}
bool id1_is_smaller = true;
if (id1_defined)
{
if (id2_defined)
{
if (id1 == id2)
{
i1++;
i2++;
numLines++;
continue;
}
if (id1 > id2)
id1_is_smaller = false;
}
}
else if (!id2_defined)
break;
else
id1_is_smaller = false;
n.Empty();
if (id1_is_smaller)
{
n.Add_UInt32(id1);
n += " : ";
n += lang_en.Get_by_index(i1);
langInfo.MissingLines.Add(n);
i1++;
}
else
{
n.Add_UInt32(id2);
n += " : ";
n += lang.Get_by_index(i2);
langInfo.ExtraLines.Add(n);
i2++;
}
}
}
langInfo.NumLines = numLines + langInfo.ExtraLines.Size();
}
listRecords[listRecords_SelectedIndex].IsSelected = true;
listRecords.Sort();
FOR_VECTOR (i, listRecords)
{
const CLangListRecord &rec= listRecords[i];
UString temp = rec.Name;
if (!rec.Mark.IsEmpty())
{
temp += " ";
temp += rec.Mark;
}
const int index = (int)_langCombo.AddString_SetItemData(temp, (LPARAM)rec.LangInfoIndex);
if (rec.IsSelected)
_langCombo.SetCurSel(index);
}
ShowLangInfo();
if (!error.IsEmpty())
MessageBoxW(NULL, error, L"Error in Lang file", MB_ICONERROR);
return CPropertyPage::OnInit();
}
LONG CLangPage::OnApply()
{
if (_needSave)
{
const int pathIndex = (int)_langCombo.GetItemData_of_CurSel();
if ((unsigned)pathIndex < _langs.Size())
SaveRegLang(_langs[pathIndex].Name);
}
_needSave = false;
#ifdef Z7_LANG
ReloadLang();
#endif
LangWasChanged = true;
return PSNRET_NOERROR;
}
void CLangPage::OnNotifyHelp()
{
ShowHelpWindow(kLangTopic);
}
bool CLangPage::OnCommand(unsigned code, unsigned itemID, LPARAM param)
{
if (code == CBN_SELCHANGE && itemID == IDC_LANG_LANG)
{
_needSave = true;
Changed();
ShowLangInfo();
return true;
}
return CPropertyPage::OnCommand(code, itemID, param);
}
static void AddVectorToString(UString &s, const UStringVector &v)
{
UString a;
FOR_VECTOR (i, v)
{
if (i >= 50)
break;
a = v[i];
if (a.Len() > 1500)
continue;
if (a[0] == ';')
{
a.DeleteFrontal(1);
a.Trim();
}
s += a;
s.Add_LF();
}
}
static void AddVectorToString2(UString &s, const char *name, const UStringVector &v)
{
if (v.IsEmpty())
return;
s.Add_LF();
s += "------ ";
s += name;
s += ": ";
s.Add_UInt32(v.Size());
s += " :";
s.Add_LF();
AddVectorToString(s, v);
}
void CLangPage::ShowLangInfo()
{
UString s;
const int pathIndex = (int)_langCombo.GetItemData_of_CurSel();
if ((unsigned)pathIndex < _langs.Size())
{
const CLangInfo &langInfo = _langs[pathIndex];
const unsigned numLines = langInfo.NumLines;
s += langInfo.Name;
s += " : ";
s.Add_UInt32(numLines);
if (NumLangLines_EN != 0)
{
s += " / ";
s.Add_UInt32(NumLangLines_EN);
s += " = ";
s.Add_UInt32(numLines * 100 / NumLangLines_EN);
s += "%";
}
s.Add_LF();
AddVectorToString(s, langInfo.Comments);
AddVectorToString2(s, "Missing lines", langInfo.MissingLines);
AddVectorToString2(s, "Extra lines", langInfo.ExtraLines);
}
SetItemText(IDT_LANG_INFO, s);
}
@@ -0,0 +1,36 @@
// LangPage.h
#ifndef ZIP7_INC_LANG_PAGE_H
#define ZIP7_INC_LANG_PAGE_H
#include "../../../Windows/Control/PropertyPage.h"
#include "../../../Windows/Control/ComboBox.h"
struct CLangInfo
{
unsigned NumLines;
UString Name;
UStringVector Comments;
UStringVector MissingLines;
UStringVector ExtraLines;
};
class CLangPage: public NWindows::NControl::CPropertyPage
{
NWindows::NControl::CComboBox _langCombo;
CObjectVector<CLangInfo> _langs;
unsigned NumLangLines_EN;
bool _needSave;
void ShowLangInfo();
public:
bool LangWasChanged;
CLangPage(): _needSave(false), LangWasChanged(false) {}
virtual bool OnInit() Z7_override;
virtual void OnNotifyHelp() Z7_override;
virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM param) Z7_override;
virtual LONG OnApply() Z7_override;
};
#endif
@@ -0,0 +1,40 @@
#include "LangPageRes.h"
#include "../../GuiCommon.rc"
#define xc OPTIONS_PAGE_XC_SIZE
#define yc OPTIONS_PAGE_YC_SIZE
#define y 32
IDD_LANG DIALOG MY_PAGE_POSTFIX
CAPTION "Language"
{
LTEXT "Language:", IDT_LANG_LANG, m, m, xc, 8
COMBOBOX IDC_LANG_LANG, m, 20, 160, yc - 20, MY_COMBO // MY_COMBO_SORTED
LTEXT "", IDT_LANG_INFO, m, m + y, xc, yc - y, SS_NOPREFIX
}
#ifdef UNDER_CE
#undef m
#undef xc
#define m 4
#define xc (SMALL_PAGE_SIZE_X + 8)
IDD_LANG_2 MY_PAGE
CAPTION "Language"
{
LTEXT "Language:", IDT_LANG_LANG, m, m, xc, 8
COMBOBOX IDC_LANG_LANG, m, 20, xc, yc - 20, MY_COMBO // MY_COMBO_SORTED
}
#endif
STRINGTABLE
BEGIN
IDS_LANG_ENGLISH "English"
IDS_LANG_NATIVE "English"
END
@@ -0,0 +1,9 @@
#define IDD_LANG 2101
#define IDD_LANG_2 12101
#define IDS_LANG_ENGLISH 1
#define IDS_LANG_NATIVE 2
#define IDT_LANG_LANG 2102
#define IDC_LANG_LANG 100
#define IDT_LANG_INFO 101
@@ -0,0 +1,333 @@
// LangUtils.cpp
#include "StdAfx.h"
#include "../../../Common/Lang.h"
#include "../../../Windows/DLL.h"
#include "../../../Windows/Synchronization.h"
#include "../../../Windows/Window.h"
#include "LangUtils.h"
#include "RegistryUtils.h"
using namespace NWindows;
#ifndef _UNICODE
extern bool g_IsNT;
#endif
UString g_LangID;
// static
CLang g_Lang;
static bool g_Loaded = false;
static NSynchronization::CCriticalSection g_CriticalSection;
bool LangOpen(CLang &lang, CFSTR fileName);
bool LangOpen(CLang &lang, CFSTR fileName)
{
return lang.Open(fileName, "7-Zip");
}
FString GetLangDirPrefix()
{
return NDLL::GetModuleDirPrefix() + FTEXT("Lang") FSTRING_PATH_SEPARATOR;
}
#ifdef Z7_LANG
void LoadLangOneTime()
{
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
if (g_Loaded)
return;
g_Loaded = true;
ReloadLang();
}
void LangSetDlgItemText(HWND dialog, UInt32 controlID, UInt32 langID)
{
const wchar_t *s = g_Lang.Get(langID);
if (s)
{
CWindow window(GetDlgItem(dialog, (int)controlID));
window.SetText(s);
}
}
#ifndef IDCONTINUE
#define IDCONTINUE 11
#endif
static const CIDLangPair kLangPairs[] =
{
{ IDOK, 401 },
{ IDCANCEL, 402 },
{ IDYES, 406 },
{ IDNO, 407 },
{ IDCLOSE, 408 },
{ IDHELP, 409 },
{ IDCONTINUE, 411 }
};
void LangSetDlgItems(HWND dialog, const UInt32 *ids, unsigned numItems)
{
unsigned i;
for (i = 0; i < Z7_ARRAY_SIZE(kLangPairs); i++)
{
const CIDLangPair &pair = kLangPairs[i];
CWindow window(GetDlgItem(dialog, (int)pair.ControlID));
if (window)
{
const wchar_t *s = g_Lang.Get(pair.LangID);
if (s)
window.SetText(s);
}
}
for (i = 0; i < numItems; i++)
{
const UInt32 id = ids[i];
LangSetDlgItemText(dialog, id, id);
}
}
void LangSetDlgItems_Colon(HWND dialog, const UInt32 *ids, unsigned numItems)
{
for (unsigned i = 0; i < numItems; i++)
{
const UInt32 id = ids[i];
const wchar_t *s = g_Lang.Get(id);
if (s)
{
CWindow window(GetDlgItem(dialog, (int)id));
UString s2 = s;
s2.Add_Colon();
window.SetText(s2);
}
}
}
void LangSetDlgItems_RemoveColon(HWND dialog, const UInt32 *ids, unsigned numItems)
{
for (unsigned i = 0; i < numItems; i++)
{
const UInt32 id = ids[i];
const wchar_t *s = g_Lang.Get(id);
if (s)
{
CWindow window(GetDlgItem(dialog, (int)id));
UString s2 = s;
if (!s2.IsEmpty() && s2.Back() == ':')
s2.DeleteBack();
window.SetText(s2);
}
}
}
void LangSetWindowText(HWND window, UInt32 langID)
{
const wchar_t *s = g_Lang.Get(langID);
if (s)
MySetWindowText(window, s);
}
UString LangString(UInt32 langID)
{
const wchar_t *s = g_Lang.Get(langID);
if (s)
return s;
return MyLoadString(langID);
}
void AddLangString(UString &s, UInt32 langID)
{
s += LangString(langID);
}
void LangString(UInt32 langID, UString &dest)
{
const wchar_t *s = g_Lang.Get(langID);
if (s)
{
dest = s;
return;
}
MyLoadString(langID, dest);
}
void LangString_OnlyFromLangFile(UInt32 langID, UString &dest)
{
dest.Empty();
const wchar_t *s = g_Lang.Get(langID);
if (s)
dest = s;
}
static const char * const kLangs =
"ar.bg.ca.zh.-tw.-cn.cs.da.de.el.en.es.fi.fr.he.hu.is."
"it.ja.ko.nl.no.=nb.=nn.pl.pt.-br.rm.ro.ru.sr.=hr.-spl.-spc.=hr.=bs.sk.sq.sv.th.tr."
"ur.id.uk.be.sl.et.lv.lt.tg.fa.vi.hy.az.eu.hsb.mk."
"st.ts.tn.ve.xh.zu.af.ka.fo.hi.mt.se.ga.yi.ms.kk."
"ky.sw.tk.uz.-latn.-cyrl.tt.bn.pa.-in.gu.or.ta.te.kn.ml.as.mr.sa."
"mn.=mn.=mng.bo.cy.kh.lo.my.gl.kok..sd.syr.si..iu.am.tzm."
"ks.ne.fy.ps.tl.dv..ff.ha..yo.qu.st.ba.lb.kl."
"ig.kr.om.ti.gn..la.so.ii..arn..moh..br.."
"ug.mi.oc.co."
// "gsw.sah.qut.rw.wo....prs...."
// ".gd."
;
static void FindShortNames(UInt32 primeLang, AStringVector &names)
{
UInt32 index = 0;
for (const char *p = kLangs; *p != 0;)
{
const char *p2 = p;
for (; *p2 != '.'; p2++);
bool isSub = (p[0] == '-' || p[0] == '=');
if (!isSub)
index++;
if (index >= primeLang)
{
if (index > primeLang)
break;
AString s;
if (isSub)
{
if (p[0] == '-')
s = names[0];
else
p++;
}
while (p != p2)
s.Add_Char((char)(Byte)*p++);
names.Add(s);
}
p = p2 + 1;
}
}
/*
#include "../../../Common/IntToString.h"
static struct CC1Lang
{
CC1Lang()
{
for (int i = 1; i < 150; i++)
{
UString s;
char ttt[32];
ConvertUInt32ToHex(i, ttt);
s += ttt;
UStringVector names;
FindShortNames(i, names);
FOR_VECTOR (k, names)
{
s.Add_Space();
s += names[k];
}
OutputDebugStringW(s);
}
}
} g_cc1;
*/
// typedef LANGID (WINAPI *GetUserDefaultUILanguageP)();
void Lang_GetShortNames_for_DefaultLang(AStringVector &names, unsigned &subLang)
{
names.Clear();
subLang = 0;
// Region / Administative / Language for non-Unicode programs:
const LANGID sysLang = GetSystemDefaultLangID();
// Region / Formats / Format:
const LANGID userLang = GetUserDefaultLangID();
if (PRIMARYLANGID(sysLang) !=
PRIMARYLANGID(userLang))
return;
const LANGID langID = userLang;
// const LANGID langID = MAKELANGID(0x1a, 1); // for debug
/*
LANGID sysUILang; // english in XP64
LANGID userUILang; // english in XP64
GetUserDefaultUILanguageP fn = (GetUserDefaultUILanguageP)GetProcAddress(
GetModuleHandle("kernel32"), "GetUserDefaultUILanguage");
if (fn)
userUILang = fn();
fn = (GetUserDefaultUILanguageP)GetProcAddress(
GetModuleHandle("kernel32"), "GetSystemDefaultUILanguage");
if (fn)
sysUILang = fn();
*/
const WORD primLang = (WORD)(PRIMARYLANGID(langID));
subLang = SUBLANGID(langID);
FindShortNames(primLang, names);
}
static void OpenDefaultLang()
{
AStringVector names;
unsigned subLang;
Lang_GetShortNames_for_DefaultLang(names, subLang);
{
const FString dirPrefix (GetLangDirPrefix());
for (unsigned i = 0; i < 2; i++)
{
const unsigned index = (i == 0 ? subLang : 0);
if (index < names.Size())
{
const AString &name = names[index];
if (!name.IsEmpty())
{
FString path (dirPrefix);
path += name;
path += ".txt";
if (LangOpen(g_Lang, path))
{
g_LangID = name;
return;
}
}
}
}
}
}
void ReloadLang()
{
g_Lang.Clear();
ReadRegLang(g_LangID);
if (g_LangID.IsEmpty())
{
#ifndef _UNICODE
if (g_IsNT)
#endif
OpenDefaultLang();
return;
}
if (g_LangID.Len() > 1 || g_LangID[0] != L'-')
{
FString s = us2fs(g_LangID);
if (s.ReverseFind_PathSepar() < 0)
{
if (s.ReverseFind_Dot() < 0)
s += ".txt";
s.Insert(0, GetLangDirPrefix());
LangOpen(g_Lang, s);
}
}
}
#endif
@@ -0,0 +1,48 @@
// LangUtils.h
#ifndef ZIP7_INC_LANG_UTILS_H
#define ZIP7_INC_LANG_UTILS_H
#include "../../../Common/Lang.h"
#include "../../../Windows/ResourceString.h"
extern UString g_LangID;
extern CLang g_Lang;
#ifdef Z7_LANG
struct CIDLangPair
{
UInt32 ControlID;
UInt32 LangID;
};
void ReloadLang();
void LoadLangOneTime();
void LangSetDlgItemText(HWND dialog, UInt32 controlID, UInt32 langID);
void LangSetDlgItems(HWND dialog, const UInt32 *ids, unsigned numItems);
void LangSetDlgItems_Colon(HWND dialog, const UInt32 *ids, unsigned numItems);
void LangSetDlgItems_RemoveColon(HWND dialog, const UInt32 *ids, unsigned numItems);
void LangSetWindowText(HWND window, UInt32 langID);
UString LangString(UInt32 langID);
void AddLangString(UString &s, UInt32 langID);
void LangString(UInt32 langID, UString &dest);
void LangString_OnlyFromLangFile(UInt32 langID, UString &dest);
#else
inline UString LangString(UInt32 langID) { return NWindows::MyLoadString(langID); }
inline void LangString(UInt32 langID, UString &dest) { NWindows::MyLoadString(langID, dest); }
inline void AddLangString(UString &s, UInt32 langID) { s += NWindows::MyLoadString(langID); }
#endif
FString GetLangDirPrefix();
// bool LangOpen(CLang &lang, CFSTR fileName);
void Lang_GetShortNames_for_DefaultLang(AStringVector &names, unsigned &subLang);
#endif
@@ -0,0 +1,402 @@
// LinkDialog.cpp
#include "StdAfx.h"
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileFind.h"
#include "../../../Windows/FileIO.h"
#include "../../../Windows/FileName.h"
#include "LangUtils.h"
#include "BrowseDialog.h"
#include "CopyDialogRes.h"
#include "LinkDialog.h"
#include "resourceGui.h"
#include "App.h"
#include "resource.h"
extern bool g_SymLink_Supported;
using namespace NWindows;
using namespace NFile;
#ifdef Z7_LANG
static const UInt32 kLangIDs[] =
{
IDB_LINK_LINK,
IDT_LINK_PATH_FROM,
IDT_LINK_PATH_TO,
IDG_LINK_TYPE,
IDR_LINK_TYPE_HARD,
IDR_LINK_TYPE_SYM_FILE,
IDR_LINK_TYPE_SYM_DIR,
IDR_LINK_TYPE_JUNCTION,
IDR_LINK_TYPE_WSL
};
#endif
static bool GetSymLink(CFSTR path, CReparseAttr &attr, UString &errorMessage)
{
CByteBuffer buf;
if (!NIO::GetReparseData(path, buf, NULL))
return false;
if (!attr.Parse(buf, buf.Size()))
{
SetLastError(attr.ErrorCode);
return false;
}
CByteBuffer data2;
FillLinkData(data2, attr.GetPath(),
!attr.IsMountPoint(), attr.IsSymLink_WSL());
if (data2.Size() == 0)
{
errorMessage = "Cannot reproduce reparse point";
return false;
}
if (data2 != buf)
{
errorMessage = "mismatch for reproduced reparse point";
return false;
}
return true;
}
static const unsigned k_LinkType_Buttons[] =
{
IDR_LINK_TYPE_HARD,
IDR_LINK_TYPE_SYM_FILE,
IDR_LINK_TYPE_SYM_DIR,
IDR_LINK_TYPE_JUNCTION,
IDR_LINK_TYPE_WSL
};
void CLinkDialog::Set_LinkType_Radio(unsigned idb)
{
CheckRadioButton(
k_LinkType_Buttons[0],
k_LinkType_Buttons[Z7_ARRAY_SIZE(k_LinkType_Buttons) - 1],
idb);
}
bool CLinkDialog::OnInit()
{
#ifdef Z7_LANG
LangSetWindowText(*this, IDD_LINK);
LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
#endif
_pathFromCombo.Attach(GetItem(IDC_LINK_PATH_FROM));
_pathToCombo.Attach(GetItem(IDC_LINK_PATH_TO));
if (!FilePath.IsEmpty())
{
NFind::CFileInfo fi;
unsigned linkType = 0;
if (!fi.Find(us2fs(FilePath)))
linkType = IDR_LINK_TYPE_SYM_FILE;
else
{
if (fi.HasReparsePoint())
{
CReparseAttr attr;
UString error;
const bool res = GetSymLink(us2fs(FilePath), attr, error);
if (!res && error.IsEmpty())
{
const DWORD lastError = GetLastError();
if (lastError)
error = NError::MyFormatMessage(lastError);
}
UString s = attr.GetPath();
if (!attr.IsSymLink_WSL())
if (!attr.IsOkNamePair())
{
s += " : ";
s += attr.PrintName;
}
if (!res)
{
s.Insert(0, L"ERROR: ");
if (!error.IsEmpty())
{
s += " : ";
s += error;
}
}
SetItemText(IDT_LINK_PATH_TO_CUR, s);
const UString destPath = attr.GetPath();
_pathFromCombo.SetText(FilePath);
_pathToCombo.SetText(destPath);
// if (res)
{
if (attr.IsMountPoint())
linkType = IDR_LINK_TYPE_JUNCTION;
else if (attr.IsSymLink_WSL())
linkType = IDR_LINK_TYPE_WSL;
else if (attr.IsSymLink_Win())
{
linkType =
fi.IsDir() ?
IDR_LINK_TYPE_SYM_DIR :
IDR_LINK_TYPE_SYM_FILE;
// if (attr.IsRelative()) linkType = IDR_LINK_TYPE_SYM_RELATIVE;
}
if (linkType != 0)
Set_LinkType_Radio(linkType);
}
}
else
{
// no ReparsePoint
_pathFromCombo.SetText(AnotherPath);
_pathToCombo.SetText(FilePath);
if (fi.IsDir())
linkType = g_SymLink_Supported ?
IDR_LINK_TYPE_SYM_DIR :
IDR_LINK_TYPE_JUNCTION;
else
linkType = IDR_LINK_TYPE_HARD;
}
}
if (linkType != 0)
Set_LinkType_Radio(linkType);
}
NormalizeSize();
return CModalDialog::OnInit();
}
bool CLinkDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
{
int mx, my;
GetMargins(8, mx, my);
int bx1, bx2, by;
GetItemSizes(IDCANCEL, bx1, by);
GetItemSizes(IDB_LINK_LINK, bx2, by);
int yPos = ySize - my - by;
int xPos = xSize - mx - bx1;
InvalidateRect(NULL);
{
RECT r, r2;
GetClientRectOfItem(IDB_LINK_PATH_FROM, r);
GetClientRectOfItem(IDB_LINK_PATH_TO, r2);
int bx = RECT_SIZE_X(r);
int newButtonXpos = xSize - mx - bx;
MoveItem(IDB_LINK_PATH_FROM, newButtonXpos, r.top, bx, RECT_SIZE_Y(r));
MoveItem(IDB_LINK_PATH_TO, newButtonXpos, r2.top, bx, RECT_SIZE_Y(r2));
int newComboXsize = newButtonXpos - mx - mx;
ChangeSubWindowSizeX(_pathFromCombo, newComboXsize);
ChangeSubWindowSizeX(_pathToCombo, newComboXsize);
}
MoveItem(IDCANCEL, xPos, yPos, bx1, by);
MoveItem(IDB_LINK_LINK, xPos - mx - bx2, yPos, bx2, by);
return false;
}
bool CLinkDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
switch (buttonID)
{
case IDB_LINK_PATH_FROM:
OnButton_SetPath(false);
return true;
case IDB_LINK_PATH_TO:
OnButton_SetPath(true);
return true;
case IDB_LINK_LINK:
OnButton_Link();
return true;
}
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
void CLinkDialog::OnButton_SetPath(bool to)
{
UString currentPath;
NWindows::NControl::CComboBox &combo = to ?
_pathToCombo :
_pathFromCombo;
combo.GetText(currentPath);
// UString title = "Specify a location for output folder";
const UString title = LangString(IDS_SET_FOLDER);
UString resultPath;
if (!MyBrowseForFolder(*this, title, currentPath, resultPath))
return;
NName::NormalizeDirPathPrefix(resultPath);
combo.SetCurSel(-1);
combo.SetText(resultPath);
}
void CLinkDialog::ShowError(const wchar_t *s)
{
::MessageBoxW(*this, s, L"7-Zip", MB_ICONERROR);
}
void CLinkDialog::ShowLastErrorMessage()
{
ShowError(NError::MyFormatMessage(GetLastError()));
}
void CLinkDialog::OnButton_Link()
{
UString from, to;
_pathFromCombo.GetText(from);
_pathToCombo.GetText(to);
if (from.IsEmpty())
return;
if (!NName::IsAbsolutePath(from))
from.Insert(0, CurDirPrefix);
unsigned idb = 0;
for (unsigned i = 0;; i++)
{
if (i >= Z7_ARRAY_SIZE(k_LinkType_Buttons))
return;
idb = k_LinkType_Buttons[i];
if (IsButtonCheckedBool(idb))
break;
}
NFind::CFileInfo info1, info2;
const bool finded1 = info1.Find(us2fs(from));
const bool finded2 = info2.Find(us2fs(to));
const bool isDirLink = (
idb == IDR_LINK_TYPE_SYM_DIR ||
idb == IDR_LINK_TYPE_JUNCTION);
const bool isWSL = (idb == IDR_LINK_TYPE_WSL);
if (!isWSL)
if ((finded1 && info1.IsDir() != isDirLink) ||
(finded2 && info2.IsDir() != isDirLink))
{
ShowError(L"Incorrect link type");
return;
}
if (idb == IDR_LINK_TYPE_HARD)
{
if (!NDir::MyCreateHardLink(us2fs(from), us2fs(to)))
{
ShowLastErrorMessage();
return;
}
}
else
{
if (finded1 && !info1.IsDir() && !info1.HasReparsePoint() && info1.Size != 0)
{
UString s ("WARNING: reparse point will hide the data of existing file");
s.Add_LF();
s += from;
ShowError(s);
return;
}
CByteBuffer data;
const bool isSymLink = (idb != IDR_LINK_TYPE_JUNCTION);
FillLinkData(data, to, isSymLink, isWSL);
if (data.Size() == 0)
{
ShowError(L"Incorrect link");
return;
}
CReparseAttr attr;
if (!attr.Parse(data, data.Size()))
{
ShowError(L"Internal conversion error");
return;
}
bool res;
if (to.IsEmpty())
{
// res = NIO::SetReparseData(us2fs(from), isDirLink, NULL, 0);
res = NIO::DeleteReparseData(us2fs(from));
}
else
res = NIO::SetReparseData(us2fs(from), isDirLink, data, (DWORD)data.Size());
if (!res)
{
ShowLastErrorMessage();
return;
}
}
End(IDOK);
}
void CApp::Link()
{
const unsigned srcPanelIndex = GetFocusedPanelIndex();
CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder())
{
srcPanel.MessageBox_Error_UnsupportOperation();
return;
}
CRecordVector<UInt32> indices;
srcPanel.Get_ItemIndices_Operated(indices);
if (indices.IsEmpty())
return;
if (indices.Size() != 1)
{
srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE);
return;
}
const UInt32 index = indices[0];
const UString itemName = srcPanel.GetItemName(index);
const UString fsPrefix = srcPanel.GetFsPath();
const UString srcPath = fsPrefix + srcPanel.GetItemPrefix(index);
UString path = srcPath;
{
const unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
CPanel &destPanel = Panels[destPanelIndex];
if (NumPanels > 1)
if (destPanel.IsFSFolder())
path = destPanel.GetFsPath();
}
CSelectedState srcSelState;
srcPanel.SaveSelectedState(srcSelState);
CLinkDialog dlg;
dlg.CurDirPrefix = fsPrefix;
dlg.FilePath = srcPath + itemName;
dlg.AnotherPath = path;
if (dlg.Create(srcPanel.GetParent()) != IDOK)
return;
// we refresh srcPanel to show changes in "Link" (kpidNtReparse) column.
// maybe we should refresh another panel also?
if (srcPanel._visibleColumns.FindItem_for_PropID(kpidNtReparse) >= 0)
srcPanel.RefreshListCtrl(srcSelState);
RefreshTitleAlways();
}
@@ -0,0 +1,34 @@
// LinkDialog.h
#ifndef ZIP7_INC_LINK_DIALOG_H
#define ZIP7_INC_LINK_DIALOG_H
#include "../../../Windows/Control/Dialog.h"
#include "../../../Windows/Control/ComboBox.h"
#include "LinkDialogRes.h"
class CLinkDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox _pathFromCombo;
NWindows::NControl::CComboBox _pathToCombo;
virtual bool OnInit() Z7_override;
virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
void OnButton_SetPath(bool to);
void OnButton_Link();
void ShowLastErrorMessage();
void ShowError(const wchar_t *s);
void Set_LinkType_Radio(unsigned idb);
public:
UString CurDirPrefix;
UString FilePath;
UString AnotherPath;
INT_PTR Create(HWND parentWindow = NULL)
{ return CModalDialog::Create(IDD_LINK, parentWindow); }
};
#endif
@@ -0,0 +1,38 @@
#include "LinkDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 288
#define yc 214
#undef xRadioSize
#define xRadioSize xc - m - 2
IDD_LINK DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT
CAPTION "Link"
BEGIN
LTEXT "Link from:", IDT_LINK_PATH_FROM, m, m, xc, 8
COMBOBOX IDC_LINK_PATH_FROM, m, 20, xc - bxsDots - m, 64, MY_COMBO_WITH_EDIT
PUSHBUTTON "...", IDB_LINK_PATH_FROM, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP
LTEXT "Link to:", IDT_LINK_PATH_TO, m, 48, xc, 8
COMBOBOX IDC_LINK_PATH_TO, m, 60, xc - bxsDots - m, 64, MY_COMBO_WITH_EDIT
PUSHBUTTON "...", IDB_LINK_PATH_TO, xs - m - bxsDots, 58, bxsDots, bys, WS_GROUP
LTEXT "", IDT_LINK_PATH_TO_CUR, m, 78, xc, 8
GROUPBOX "Link Type", IDG_LINK_TYPE, m, 104, xc, 90
CONTROL "Hard Link", IDR_LINK_TYPE_HARD, "Button", BS_AUTORADIOBUTTON | WS_GROUP,
m + m, 120, xRadioSize, 10
CONTROL "File Symbolic Link", IDR_LINK_TYPE_SYM_FILE, "Button", BS_AUTORADIOBUTTON,
m + m, 134, xRadioSize, 10
CONTROL "Directory Symbolic Link", IDR_LINK_TYPE_SYM_DIR, "Button", BS_AUTORADIOBUTTON,
m + m, 148, xRadioSize, 10
CONTROL "Directory Junction", IDR_LINK_TYPE_JUNCTION, "Button", BS_AUTORADIOBUTTON,
m + m, 162, xRadioSize, 10
CONTROL "WSL", IDR_LINK_TYPE_WSL, "Button", BS_AUTORADIOBUTTON,
m + m, 176, xRadioSize, 10
DEFPUSHBUTTON "Link", IDB_LINK_LINK, bx2, by, bxs, bys
PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
END
@@ -0,0 +1,22 @@
#define IDD_LINK 7700
#define IDB_LINK_LINK 7701
#define IDT_LINK_PATH_FROM 7702
#define IDT_LINK_PATH_TO 7703
#define IDG_LINK_TYPE 7710
#define IDR_LINK_TYPE_HARD 7711
#define IDR_LINK_TYPE_SYM_FILE 7712
#define IDR_LINK_TYPE_SYM_DIR 7713
#define IDR_LINK_TYPE_JUNCTION 7714
#define IDR_LINK_TYPE_WSL 7715
#define IDC_LINK_PATH_FROM 100
#define IDC_LINK_PATH_TO 101
#define IDT_LINK_PATH_TO_CUR 102
#define IDB_LINK_PATH_FROM 103
#define IDB_LINK_PATH_TO 104
@@ -0,0 +1,321 @@
// ListViewDialog.cpp
#include "StdAfx.h"
#include "../../../Windows/Clipboard.h"
#include "EditDialog.h"
#include "ListViewDialog.h"
#include "RegistryUtils.h"
#ifdef Z7_LANG
#include "LangUtils.h"
#endif
using namespace NWindows;
static const unsigned kOneStringMaxSize = 1024;
static void ListView_GetSelected(NControl::CListView &listView, CUIntVector &vector)
{
vector.Clear();
int index = -1;
for (;;)
{
index = listView.GetNextSelectedItem(index);
if (index < 0)
break;
vector.Add((unsigned)index);
}
}
bool CListViewDialog::OnInit()
{
#ifdef Z7_LANG
LangSetDlgItems(*this, NULL, 0);
#endif
_listView.Attach(GetItem(IDL_LISTVIEW));
if (NumColumns > 1)
{
LONG_PTR style = _listView.GetStyle();
style &= ~(LONG_PTR)LVS_NOCOLUMNHEADER;
_listView.SetStyle(style);
}
CFmSettings st;
st.Load();
DWORD exStyle = 0;
if (st.SingleClick)
exStyle |= LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT;
exStyle |= LVS_EX_FULLROWSELECT;
if (exStyle != 0)
_listView.SetExtendedListViewStyle(exStyle);
SetText(Title);
const int kWidth = 400;
LVCOLUMN columnInfo;
columnInfo.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
columnInfo.fmt = LVCFMT_LEFT;
columnInfo.iSubItem = 0;
columnInfo.cx = kWidth;
columnInfo.pszText = NULL; // (TCHAR *)(const TCHAR *)""; // "Property"
if (NumColumns > 1)
{
columnInfo.cx = 100;
/*
// Windows always uses LVCFMT_LEFT for first column.
// if we need LVCFMT_RIGHT, we can create dummy column and then remove it
// columnInfo.mask |= LVCF_TEXT;
_listView.InsertColumn(0, &columnInfo);
columnInfo.iSubItem = 1;
columnInfo.fmt = LVCFMT_RIGHT;
_listView.InsertColumn(1, &columnInfo);
_listView.DeleteColumn(0);
*/
}
// else
_listView.InsertColumn(0, &columnInfo);
if (NumColumns > 1)
{
// columnInfo.fmt = LVCFMT_LEFT;
columnInfo.cx = kWidth - columnInfo.cx;
columnInfo.iSubItem = 1;
// columnInfo.pszText = NULL; // (TCHAR *)(const TCHAR *)""; // "Value"
_listView.InsertColumn(1, &columnInfo);
}
UString s;
FOR_VECTOR (i, Strings)
{
_listView.InsertItem(i, Strings[i]);
if (NumColumns > 1 && i < Values.Size())
{
s = Values[i];
if (s.Len() > kOneStringMaxSize)
{
s.DeleteFrom(kOneStringMaxSize);
s += " ...";
}
s.Replace(L"\r\n", L" ");
s.Replace(L"\n", L" ");
_listView.SetSubItem(i, 1, s);
}
}
if (SelectFirst && Strings.Size() > 0)
_listView.SetItemState_FocusedSelected(0);
_listView.SetColumnWidthAuto(0);
if (NumColumns > 1)
_listView.SetColumnWidthAuto(1);
StringsWereChanged = false;
NormalizeSize();
return CModalDialog::OnInit();
}
bool CListViewDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
{
int mx, my;
GetMargins(8, mx, my);
int bx1, bx2, by;
GetItemSizes(IDCANCEL, bx1, by);
GetItemSizes(IDOK, bx2, by);
int y = ySize - my - by;
int x = xSize - mx - bx1;
/*
RECT rect;
GetClientRect(&rect);
rect.top = y - my;
InvalidateRect(&rect);
*/
InvalidateRect(NULL);
MoveItem(IDCANCEL, x, y, bx1, by);
MoveItem(IDOK, x - mx - bx2, y, bx2, by);
/*
if (wParam == SIZE_MAXSHOW || wParam == SIZE_MAXIMIZED || wParam == SIZE_MAXHIDE)
mx = 0;
*/
_listView.Move(mx, my, xSize - mx * 2, y - my * 2);
return false;
}
extern bool g_LVN_ITEMACTIVATE_Support;
void CListViewDialog::CopyToClipboard()
{
CUIntVector indexes;
ListView_GetSelected(_listView, indexes);
UString s;
FOR_VECTOR (i, indexes)
{
unsigned index = indexes[i];
s += Strings[index];
if (NumColumns > 1 && index < Values.Size())
{
const UString &v = Values[index];
// if (!v.IsEmpty())
{
s += ": ";
s += v;
}
}
// if (indexes.Size() > 1)
{
s +=
#ifdef _WIN32
"\r\n"
#else
"\n"
#endif
;
}
}
ClipboardSetText(*this, s);
}
void CListViewDialog::ShowItemInfo()
{
CUIntVector indexes;
ListView_GetSelected(_listView, indexes);
if (indexes.Size() != 1)
return;
unsigned index = indexes[0];
CEditDialog dlg;
if (NumColumns == 1)
dlg.Text = Strings[index];
else
{
dlg.Title = Strings[index];
if (index < Values.Size())
dlg.Text = Values[index];
}
#ifdef _WIN32
if (dlg.Text.Find(L'\r') < 0)
dlg.Text.Replace(L"\n", L"\r\n");
#endif
dlg.Create(*this);
}
void CListViewDialog::DeleteItems()
{
for (;;)
{
const int index = _listView.GetNextSelectedItem(-1);
if (index < 0)
break;
StringsWereChanged = true;
_listView.DeleteItem((unsigned)index);
if ((unsigned)index < Strings.Size())
Strings.Delete((unsigned)index);
if ((unsigned)index < Values.Size())
Values.Delete((unsigned)index);
}
const int focusedIndex = _listView.GetFocusedItem();
if (focusedIndex >= 0)
_listView.SetItemState_FocusedSelected(focusedIndex);
_listView.SetColumnWidthAuto(0);
}
void CListViewDialog::OnEnter()
{
if (IsKeyDown(VK_MENU)
|| NumColumns > 1)
{
ShowItemInfo();
return;
}
OnOK();
}
bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
{
if (header->hwndFrom != _listView)
return false;
switch (header->code)
{
case LVN_ITEMACTIVATE:
if (g_LVN_ITEMACTIVATE_Support)
{
OnEnter();
return true;
}
break;
case NM_DBLCLK:
case NM_RETURN: // probabably it's unused
if (!g_LVN_ITEMACTIVATE_Support)
{
OnEnter();
return true;
}
break;
case LVN_KEYDOWN:
{
LPNMLVKEYDOWN keyDownInfo = LPNMLVKEYDOWN(header);
switch (keyDownInfo->wVKey)
{
case VK_DELETE:
{
if (!DeleteIsAllowed)
return false;
DeleteItems();
return true;
}
case 'A':
{
if (IsKeyDown(VK_CONTROL))
{
_listView.SelectAll();
return true;
}
break;
}
case VK_INSERT:
case 'C':
{
if (IsKeyDown(VK_CONTROL))
{
CopyToClipboard();
return true;
}
break;
}
}
}
}
return false;
}
void CListViewDialog::OnOK()
{
FocusedItemIndex = _listView.GetFocusedItem();
CModalDialog::OnOK();
}
@@ -0,0 +1,46 @@
// ListViewDialog.h
#ifndef ZIP7_INC_LISTVIEW_DIALOG_H
#define ZIP7_INC_LISTVIEW_DIALOG_H
#include "../../../Windows/Control/Dialog.h"
#include "../../../Windows/Control/ListView.h"
#include "ListViewDialogRes.h"
class CListViewDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CListView _listView;
virtual void OnOK() Z7_override;
virtual bool OnInit() Z7_override;
virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
virtual bool OnNotify(UINT controlID, LPNMHDR header) Z7_override;
void CopyToClipboard();
void DeleteItems();
void ShowItemInfo();
void OnEnter();
public:
UString Title;
bool SelectFirst;
bool DeleteIsAllowed;
bool StringsWereChanged;
UStringVector Strings;
UStringVector Values;
int FocusedItemIndex;
unsigned NumColumns;
INT_PTR Create(HWND wndParent = NULL) { return CModalDialog::Create(IDD_LISTVIEW, wndParent); }
CListViewDialog():
SelectFirst(false),
DeleteIsAllowed(false),
StringsWereChanged(false),
FocusedItemIndex(-1),
NumColumns(1)
{}
};
#endif
@@ -0,0 +1,14 @@
#include "ListViewDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 480
#define yc 320
IDD_LISTVIEW DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT
CAPTION "ListView"
{
CONTROL "List1", IDL_LISTVIEW, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS |
LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,
m, m, xc, yc - bys - m
OK_CANCEL
}
@@ -0,0 +1,2 @@
#define IDD_LISTVIEW 99
#define IDL_LISTVIEW 100
@@ -0,0 +1,218 @@
// MemDialog.cpp
#include "StdAfx.h"
#include <CommCtrl.h>
#include "MemDialog.h"
#include "../../../Common/StringToInt.h"
#include "../../../Windows/System.h"
#include "../../../Windows/ErrorMsg.h"
#include "../Explorer/MyMessages.h"
#include "../GUI/ExtractRes.h"
#include "resourceGui.h"
#ifdef Z7_LANG
#include "LangUtils.h"
#endif
#ifdef Z7_LANG
static const UInt32 kLangIDs[] =
{
IDX_MEM_SAVE_LIMIT,
IDX_MEM_REMEMBER,
IDG_MEM_ACTION,
IDR_MEM_ACTION_ALLOW,
IDR_MEM_ACTION_SKIP_ARC
// , IDR_MEM_SKIP_FILE
};
#endif
static const unsigned k_Action_Buttons[] =
{
IDR_MEM_ACTION_ALLOW,
IDR_MEM_ACTION_SKIP_ARC
// , IDR_MEM_SKIP_FILE
};
void CMemDialog::EnableSpin(bool enable)
{
EnableItem(IDC_MEM_SPIN, enable);
EnableItem(IDE_MEM_SPIN_EDIT, enable);
}
static void AddSize_GB(UString &s, UInt32 size_GB, UInt32 id)
{
s.Add_LF();
s += " ";
s.Add_UInt32(size_GB);
s += " GB : ";
AddLangString(s, id);
}
void CMemDialog::AddInfoMessage_To_String(UString &s, const UInt32 *ramSize_GB)
{
AddLangString(s, IDS_MEM_REQUIRES_BIG_MEM);
AddSize_GB(s, Required_GB, IDS_MEM_REQUIRED_MEM_SIZE);
AddSize_GB(s, Limit_GB, IDS_MEM_CURRENT_MEM_LIMIT);
if (ramSize_GB)
AddSize_GB(s, *ramSize_GB, IDS_MEM_RAM_SIZE);
if (!FilePath.IsEmpty())
{
s.Add_LF();
s += "File: ";
s += FilePath;
}
}
/*
int CMemDialog::AddAction(UINT id)
{
const int index = (int)m_Action.AddString(LangString(id));
m_Action.SetItemData(index, (LPARAM)id);
return index;
}
*/
bool CMemDialog::OnInit()
{
#ifdef Z7_LANG
LangSetWindowText(*this, IDD_MEM);
LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
#endif
// m_Action.Attach(GetItem(IDC_MEM_ACTION));
size_t ramSize = (size_t)sizeof(size_t) << 29;
const bool ramSize_defined = NWindows::NSystem::GetRamSize(ramSize);
// ramSize *= 10; // for debug
UInt32 ramSize_GB = (UInt32)(((UInt64)ramSize + (1u << 29)) >> 30);
if (ramSize_GB == 0)
ramSize_GB = 1;
const bool is_Allowed = (!ramSize_defined || ramSize > ((UInt64)Required_GB << 30));
{
UString s;
if (!is_Allowed)
{
AddLangString(s, IDS_MEM_ERROR);
s.Add_LF();
}
AddInfoMessage_To_String(s, is_Allowed ? NULL : &ramSize_GB);
if (!ArcPath.IsEmpty())
// for (int i = 0; i < 10; i++)
{
s.Add_LF();
AddLangString(s, TestMode ?
IDS_PROGRESS_TESTING :
IDS_PROGRESS_EXTRACTING);
s += ": ";
s += ArcPath;
}
SetItemText(IDT_MEM_MESSAGE, s);
s = "GB";
if (ramSize_defined)
{
s += " / ";
s.Add_UInt32(ramSize_GB);
s += " GB (RAM)";
}
SetItemText(IDT_MEM_GB, s);
}
const UINT valMin = 1;
UINT valMax = 64; // 64GB for RAR7
if (ramSize_defined /* && ramSize_GB > valMax */)
{
const UINT k_max_val = 1u << 14;
if (ramSize_GB >= k_max_val)
valMax = k_max_val;
else if (ramSize_GB > 1)
valMax = (UINT)ramSize_GB - 1;
else
valMax = 1;
}
SendItemMessage(IDC_MEM_SPIN, UDM_SETRANGE, 0, MAKELPARAM(valMax, valMin)); // Sets the controls direction
// UDM_SETPOS doesn't set value larger than max value (valMax) of range:
SendItemMessage(IDC_MEM_SPIN, UDM_SETPOS, 0, Required_GB);
{
UString s;
s.Add_UInt32(Required_GB);
SetItemText(IDE_MEM_SPIN_EDIT, s);
}
EnableSpin(false);
/*
AddAction(IDB_ALLOW_OPERATION);
m_Action.SetCurSel(0);
AddAction(IDB_MEM_SKIP_ARC);
AddAction(IDB_MEM_SKIP_FILE);
*/
const UINT buttonId = is_Allowed ?
IDR_MEM_ACTION_ALLOW :
IDR_MEM_ACTION_SKIP_ARC;
CheckRadioButton(
k_Action_Buttons[0],
k_Action_Buttons[Z7_ARRAY_SIZE(k_Action_Buttons) - 1],
buttonId);
/*
if (!ShowSkipFile)
HideItem(IDR_MEM_SKIP_FILE);
*/
if (!ShowRemember)
HideItem(IDX_MEM_REMEMBER);
return CModalDialog::OnInit();
}
bool CMemDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
if (buttonID == IDX_MEM_SAVE_LIMIT)
{
EnableSpin(IsButtonCheckedBool(IDX_MEM_SAVE_LIMIT));
return true;
}
return CDialog::OnButtonClicked(buttonID, buttonHWND);
}
void CMemDialog::OnContinue()
{
Remember = IsButtonCheckedBool(IDX_MEM_REMEMBER);
NeedSave = IsButtonCheckedBool(IDX_MEM_SAVE_LIMIT);
SkipArc = IsButtonCheckedBool(IDR_MEM_ACTION_SKIP_ARC);
if (NeedSave)
{
#if 0
// UDM_GETPOS doesn't support value outside of range that was set:
LRESULT lresult = SendItemMessage(IDC_MEM_SPIN, UDM_GETPOS, 0, 0);
const UInt32 val = LOWORD(lresult);
if (HIWORD(lresult) != 0) // the value outside of allowed range
#else
UString s;
GetItemText(IDE_MEM_SPIN_EDIT, s);
const wchar_t *end;
const UInt32 val = ConvertStringToUInt32(s.Ptr(), &end);
if (s.IsEmpty() || *end != 0 || val > (1u << 30))
#endif
{
ShowErrorMessage(*this,
NWindows::NError::MyFormatMessage(E_INVALIDARG)
// L"Incorrect value"
);
return;
}
Limit_GB = val;
}
CModalDialog::OnContinue();
}
@@ -0,0 +1,48 @@
// MemDialog.h
#ifndef ZIP7_INC_MEM_DIALOG_H
#define ZIP7_INC_MEM_DIALOG_H
#include "../../../Windows/Control/Dialog.h"
// #include "../../../Windows/Control/ComboBox.h"
#include "MemDialogRes.h"
class CMemDialog: public NWindows::NControl::CModalDialog
{
// NWindows::NControl::CComboBox m_Action;
// we can disable default OnOK() when we press Enter
// virtual void OnOK() Z7_override { }
virtual void OnContinue() Z7_override;
virtual bool OnInit() Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
void EnableSpin(bool enable);
// int AddAction(UINT id);
public:
bool NeedSave;
bool Remember;
bool SkipArc;
bool TestMode;
bool ShowRemember;
// bool ShowSkipFile;
UInt32 Required_GB;
UInt32 Limit_GB;
UString ArcPath;
UString FilePath;
void AddInfoMessage_To_String(UString &s, const UInt32 *ramSize_GB = NULL);
CMemDialog():
NeedSave(false),
Remember(false),
SkipArc(false),
TestMode(false),
ShowRemember(true),
// ShowSkipFile(true),
Required_GB(4),
Limit_GB(4)
{}
INT_PTR Create(HWND parentWindow = NULL) { return CModalDialog::Create(IDD_MEM, parentWindow); }
};
#endif
@@ -0,0 +1,49 @@
#include "MemDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 320
#define yc 200
#define spin_x_size 50
#define info_y_size 72
#define save_y (m + info_y_size + 4)
#define spin_y (save_y + 16)
#define xsg (xc - m - m)
#define xg (m + m)
#define yg (spin_y + 20)
IDD_MEM DIALOG MY_MODAL_DIALOG_POSTFIX
CAPTION "Memory usage request"
BEGIN
LTEXT "", IDT_MEM_MESSAGE, m, m, xc, info_y_size, SS_NOPREFIX
CONTROL "Change allowed limit for next operations", IDX_MEM_SAVE_LIMIT, MY_CHECKBOX,
m, save_y, xc, 10
MY_CONTROL_EDIT_WITH_SPIN(
IDE_MEM_SPIN_EDIT,
IDC_MEM_SPIN,
"4", m + 10, spin_y, spin_x_size)
LTEXT "GB", IDT_MEM_GB, m + 10 + spin_x_size + 8, spin_y + 2, 160, 10
GROUPBOX "Action", IDG_MEM_ACTION, m, yg, xc, 62
MY_CONTROL_AUTORADIOBUTTON_GROUP (
"&Allow archive unpacking", IDR_MEM_ACTION_ALLOW,
xg, yg + 14, xsg)
MY_CONTROL_AUTORADIOBUTTON (
"&Skip archive unpacking", IDR_MEM_ACTION_SKIP_ARC,
xg, yg + 28, xsg)
// CONTROL "&Skip file extracting", IDR_MEM_SKIP_FILE, MY_AUTORADIOBUTTON,
// xg, yg + 42, xsg, 10
CONTROL "&Repeat selected action for current operation", IDX_MEM_REMEMBER, MY_CHECKBOX,
xg + 10, yg + 44, xsg - 10, 10
CONTINUE_CANCEL
END
#undef save_y
#undef spin_y
#undef spin_x_size
@@ -0,0 +1,13 @@
#define IDD_MEM 7800
#define IDX_MEM_SAVE_LIMIT 7801
#define IDX_MEM_REMEMBER 7802
#define IDG_MEM_ACTION 7803
#define IDR_MEM_ACTION_ALLOW 7820
#define IDR_MEM_ACTION_SKIP_ARC 7821
#define IDT_MEM_MESSAGE 101
#define IDE_MEM_SPIN_EDIT 110
#define IDC_MEM_SPIN 111
#define IDT_MEM_GB 112
@@ -0,0 +1,439 @@
// MenuPage.cpp
#include "StdAfx.h"
#include "../Common/ZipRegistry.h"
#include "../../../Windows/DLL.h"
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/FileFind.h"
#include "../Explorer/ContextMenuFlags.h"
#include "../Explorer/RegistryContextMenu.h"
#include "../Explorer/resource.h"
#include "../FileManager/PropertyNameRes.h"
#include "../GUI/ExtractDialogRes.h"
#include "FormatUtils.h"
#include "HelpUtils.h"
#include "LangUtils.h"
#include "MenuPage.h"
#include "MenuPageRes.h"
using namespace NWindows;
using namespace NContextMenuFlags;
#ifdef Z7_LANG
static const UInt32 kLangIDs[] =
{
IDX_SYSTEM_INTEGRATE_TO_MENU,
IDX_SYSTEM_CASCADED_MENU,
IDX_SYSTEM_ICON_IN_MENU,
IDX_EXTRACT_ELIM_DUP,
IDT_SYSTEM_ZONE,
IDT_SYSTEM_CONTEXT_MENU_ITEMS
};
#endif
#define kMenuTopic "fm/options.htm#sevenZip"
struct CContextMenuItem
{
unsigned ControlID;
UInt32 Flag;
};
static const CContextMenuItem kMenuItems[] =
{
{ IDS_CONTEXT_OPEN, kOpen },
{ IDS_CONTEXT_OPEN, kOpenAs },
{ IDS_CONTEXT_EXTRACT, kExtract },
{ IDS_CONTEXT_EXTRACT_HERE, kExtractHere },
{ IDS_CONTEXT_EXTRACT_TO, kExtractTo },
{ IDS_CONTEXT_TEST, kTest },
{ IDS_CONTEXT_COMPRESS, kCompress },
{ IDS_CONTEXT_COMPRESS_TO, kCompressTo7z },
{ IDS_CONTEXT_COMPRESS_TO, kCompressToZip },
#ifndef UNDER_CE
{ IDS_CONTEXT_COMPRESS_EMAIL, kCompressEmail },
{ IDS_CONTEXT_COMPRESS_TO_EMAIL, kCompressTo7zEmail },
{ IDS_CONTEXT_COMPRESS_TO_EMAIL, kCompressToZipEmail },
#endif
{ IDS_PROP_CHECKSUM, kCRC },
{ IDS_PROP_CHECKSUM, kCRC_Cascaded },
};
#if !defined(_WIN64)
extern bool g_Is_Wow64;
#endif
#ifndef KEY_WOW64_64KEY
#define KEY_WOW64_64KEY (0x0100)
#endif
#ifndef KEY_WOW64_32KEY
#define KEY_WOW64_32KEY (0x0200)
#endif
static void LoadLang_Spec(UString &s, UInt32 id, const char *eng)
{
LangString(id, s);
if (s.IsEmpty())
s = eng;
s.RemoveChar(L'&');
}
bool CMenuPage::OnInit()
{
_initMode = true;
Clear_MenuChanged();
#ifdef Z7_LANG
LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
#endif
#ifdef UNDER_CE
HideItem(IDX_SYSTEM_INTEGRATE_TO_MENU);
HideItem(IDX_SYSTEM_INTEGRATE_TO_MENU_2);
#else
{
UString s;
{
CWindow window(GetItem(IDX_SYSTEM_INTEGRATE_TO_MENU));
window.GetText(s);
}
UString bit64 = LangString(IDS_PROP_BIT64);
if (bit64.IsEmpty())
bit64 = "64-bit";
#ifdef _WIN64
bit64.Replace(L"64", L"32");
#endif
s.Add_Space();
s.Add_Char('(');
s += bit64;
s.Add_Char(')');
SetItemText(IDX_SYSTEM_INTEGRATE_TO_MENU_2, s);
}
const FString prefix = NDLL::GetModuleDirPrefix();
_dlls[0].ctrl = IDX_SYSTEM_INTEGRATE_TO_MENU;
_dlls[1].ctrl = IDX_SYSTEM_INTEGRATE_TO_MENU_2;
_dlls[0].wow = 0;
_dlls[1].wow =
#ifdef _WIN64
KEY_WOW64_32KEY
#else
KEY_WOW64_64KEY
#endif
;
for (unsigned d = 0; d < 2; d++)
{
CShellDll &dll = _dlls[d];
dll.wasChanged = false;
#ifndef _WIN64
if (d != 0 && !g_Is_Wow64)
{
HideItem(dll.ctrl);
continue;
}
#endif
FString &path = dll.Path;
path = prefix;
path += (d == 0 ? "7-zip.dll" :
#ifdef _WIN64
"7-zip32.dll"
#else
"7-zip64.dll"
#endif
);
if (!NFile::NFind::DoesFileExist_Raw(path))
{
path.Empty();
EnableItem(dll.ctrl, false);
}
else
{
dll.prevValue = CheckContextMenuHandler(fs2us(path), dll.wow);
CheckButton(dll.ctrl, dll.prevValue);
}
}
#endif
CContextMenuInfo ci;
ci.Load();
CheckButton(IDX_SYSTEM_CASCADED_MENU, ci.Cascaded.Val);
CheckButton(IDX_SYSTEM_ICON_IN_MENU, ci.MenuIcons.Val);
CheckButton(IDX_EXTRACT_ELIM_DUP, ci.ElimDup.Val);
_listView.Attach(GetItem(IDL_SYSTEM_OPTIONS));
_zoneCombo.Attach(GetItem(IDC_SYSTEM_ZONE));
{
unsigned wz = ci.WriteZone;
if (wz == (UInt32)(Int32)-1)
wz = 0;
for (unsigned i = 0; i <= 3; i++)
{
unsigned val = i;
UString s;
if (i == 3)
{
if (wz < 3)
break;
val = wz;
}
else
{
#define MY_IDYES 406
#define MY_IDNO 407
if (i == 0)
LoadLang_Spec(s, MY_IDNO, "No");
else if (i == 1)
LoadLang_Spec(s, MY_IDYES, "Yes");
else
LangString(IDT_ZONE_FOR_OFFICE, s);
}
if (s.IsEmpty())
s.Add_UInt32(val);
if (i == 0)
s.Insert(0, L"* ");
const int index = (int)_zoneCombo.AddString_SetItemData(s, (LPARAM)val);
if (val == wz)
_zoneCombo.SetCurSel(index);
}
}
const UInt32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT;
_listView.SetExtendedListViewStyle(newFlags, newFlags);
_listView.InsertColumn(0, L"", 200);
for (unsigned i = 0; i < Z7_ARRAY_SIZE(kMenuItems); i++)
{
const CContextMenuItem &menuItem = kMenuItems[i];
UString s = LangString(menuItem.ControlID);
if (menuItem.Flag == kCRC)
s = "CRC SHA";
else if (menuItem.Flag == kCRC_Cascaded)
s = "7-Zip > CRC SHA";
if (menuItem.Flag == kOpenAs
|| menuItem.Flag == kCRC
|| menuItem.Flag == kCRC_Cascaded)
s += " >";
switch (menuItem.ControlID)
{
case IDS_CONTEXT_EXTRACT_TO:
{
s = MyFormatNew(s, LangString(IDS_CONTEXT_FOLDER));
break;
}
case IDS_CONTEXT_COMPRESS_TO:
case IDS_CONTEXT_COMPRESS_TO_EMAIL:
{
UString s2 = LangString(IDS_CONTEXT_ARCHIVE);
switch (menuItem.Flag)
{
case kCompressTo7z:
case kCompressTo7zEmail:
s2 += (".7z");
break;
case kCompressToZip:
case kCompressToZipEmail:
s2 += (".zip");
break;
}
s = MyFormatNew(s, s2);
break;
}
}
const int itemIndex = _listView.InsertItem(i, s);
_listView.SetCheckState((unsigned)itemIndex, ((ci.Flags & menuItem.Flag) != 0));
}
_listView.SetColumnWidthAuto(0);
_initMode = false;
return CPropertyPage::OnInit();
}
#ifndef UNDER_CE
static void ShowMenuErrorMessage(const wchar_t *m, HWND hwnd)
{
MessageBoxW(hwnd, m, L"7-Zip", MB_ICONERROR);
}
#endif
LONG CMenuPage::OnApply()
{
#ifndef UNDER_CE
for (unsigned d = 2; d != 0;)
{
d--;
CShellDll &dll = _dlls[d];
if (dll.wasChanged && !dll.Path.IsEmpty())
{
const bool newVal = IsButtonCheckedBool(dll.ctrl);
const LONG res = SetContextMenuHandler(newVal, fs2us(dll.Path), dll.wow);
if (res != ERROR_SUCCESS && (dll.prevValue != newVal || newVal))
ShowMenuErrorMessage(NError::MyFormatMessage(res), *this);
dll.prevValue = CheckContextMenuHandler(fs2us(dll.Path), dll.wow);
CheckButton(dll.ctrl, dll.prevValue);
dll.wasChanged = false;
}
}
#endif
if (_cascaded_Changed
|| _menuIcons_Changed
|| _elimDup_Changed
|| _writeZone_Changed
|| _flags_Changed)
{
CContextMenuInfo ci;
ci.Cascaded.Val = IsButtonCheckedBool(IDX_SYSTEM_CASCADED_MENU);
ci.Cascaded.Def = _cascaded_Changed;
ci.MenuIcons.Val = IsButtonCheckedBool(IDX_SYSTEM_ICON_IN_MENU);
ci.MenuIcons.Def = _menuIcons_Changed;
ci.ElimDup.Val = IsButtonCheckedBool(IDX_EXTRACT_ELIM_DUP);
ci.ElimDup.Def = _elimDup_Changed;
{
int zoneIndex = (int)_zoneCombo.GetItemData_of_CurSel();
if (zoneIndex <= 0)
zoneIndex = -1;
ci.WriteZone = (UInt32)(Int32)zoneIndex;
}
ci.Flags = 0;
for (unsigned i = 0; i < Z7_ARRAY_SIZE(kMenuItems); i++)
if (_listView.GetCheckState(i))
ci.Flags |= kMenuItems[i].Flag;
ci.Flags_Def = _flags_Changed;
ci.Save();
Clear_MenuChanged();
}
// UnChanged();
return PSNRET_NOERROR;
}
void CMenuPage::OnNotifyHelp()
{
ShowHelpWindow(kMenuTopic);
}
bool CMenuPage::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
switch (buttonID)
{
#ifndef UNDER_CE
case IDX_SYSTEM_INTEGRATE_TO_MENU:
case IDX_SYSTEM_INTEGRATE_TO_MENU_2:
{
for (unsigned d = 0; d < 2; d++)
{
CShellDll &dll = _dlls[d];
if (buttonID == dll.ctrl && !dll.Path.IsEmpty())
dll.wasChanged = true;
}
break;
}
#endif
case IDX_SYSTEM_CASCADED_MENU: _cascaded_Changed = true; break;
case IDX_SYSTEM_ICON_IN_MENU: _menuIcons_Changed = true; break;
case IDX_EXTRACT_ELIM_DUP: _elimDup_Changed = true; break;
// case IDX_EXTRACT_WRITE_ZONE: _writeZone_Changed = true; break;
default:
return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
}
Changed();
return true;
}
bool CMenuPage::OnCommand(unsigned code, unsigned itemID, LPARAM param)
{
if (code == CBN_SELCHANGE && itemID == IDC_SYSTEM_ZONE)
{
_writeZone_Changed = true;
Changed();
return true;
}
return CPropertyPage::OnCommand(code, itemID, param);
}
bool CMenuPage::OnNotify(UINT controlID, LPNMHDR lParam)
{
if (lParam->hwndFrom == HWND(_listView))
{
switch (lParam->code)
{
case (LVN_ITEMCHANGED):
return OnItemChanged((const NMLISTVIEW *)lParam);
}
}
return CPropertyPage::OnNotify(controlID, lParam);
}
bool CMenuPage::OnItemChanged(const NMLISTVIEW *info)
{
if (_initMode)
return true;
if ((info->uChanged & LVIF_STATE) != 0)
{
UINT oldState = info->uOldState & LVIS_STATEIMAGEMASK;
UINT newState = info->uNewState & LVIS_STATEIMAGEMASK;
if (oldState != newState)
{
_flags_Changed = true;
Changed();
}
}
return true;
}
@@ -0,0 +1,57 @@
// MenuPage.h
#ifndef ZIP7_INC_MENU_PAGE_H
#define ZIP7_INC_MENU_PAGE_H
#include "../../../Windows/Control/PropertyPage.h"
#include "../../../Windows/Control/ComboBox.h"
#include "../../../Windows/Control/ListView.h"
struct CShellDll
{
FString Path;
bool wasChanged;
bool prevValue;
unsigned ctrl;
UInt32 wow;
CShellDll(): wasChanged (false), prevValue(false), ctrl(0), wow(0) {}
};
class CMenuPage: public NWindows::NControl::CPropertyPage
{
bool _initMode;
bool _cascaded_Changed;
bool _menuIcons_Changed;
bool _elimDup_Changed;
bool _writeZone_Changed;
bool _flags_Changed;
void Clear_MenuChanged()
{
_cascaded_Changed = false;
_menuIcons_Changed = false;
_elimDup_Changed = false;
_writeZone_Changed = false;
_flags_Changed = false;
}
#ifndef UNDER_CE
CShellDll _dlls[2];
#endif
NWindows::NControl::CListView _listView;
NWindows::NControl::CComboBox _zoneCombo;
virtual bool OnInit() Z7_override;
virtual void OnNotifyHelp() Z7_override;
virtual bool OnNotify(UINT controlID, LPNMHDR lParam) Z7_override;
virtual LONG OnApply() Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM param) Z7_override;
bool OnItemChanged(const NMLISTVIEW* info);
};
#endif
@@ -0,0 +1,24 @@
#include "MenuPageRes.h"
#include "../../GuiCommon.rc"
#define xc OPTIONS_PAGE_XC_SIZE
#define yc OPTIONS_PAGE_YC_SIZE
IDD_MENU MY_PAGE
#include "MenuPage2.rc"
#ifdef UNDER_CE
#undef m
#undef xc
#undef yc
#define m 4
#define xc (SMALL_PAGE_SIZE_X + 8)
#define yc 112
IDD_MENU_2 MY_PAGE
#include "MenuPage2.rc"
#endif
@@ -0,0 +1,28 @@
#include "../GUI/ExtractDialogRes.h"
#define y 96
#define zoneX 100
CAPTION "7-Zip"
BEGIN
MY_CONTROL_CHECKBOX ( "Integrate 7-Zip to shell context menu", IDX_SYSTEM_INTEGRATE_TO_MENU, m, m, xc)
MY_CONTROL_CHECKBOX ( "(32-bit)", IDX_SYSTEM_INTEGRATE_TO_MENU_2, m, m + 14, xc)
MY_CONTROL_CHECKBOX ( "Cascaded context menu", IDX_SYSTEM_CASCADED_MENU, m, m + 28, xc)
MY_CONTROL_CHECKBOX ( "Icons in context menu", IDX_SYSTEM_ICON_IN_MENU, m, m + 42, xc)
MY_CONTROL_CHECKBOX ( "Eliminate duplication of root folder", IDX_EXTRACT_ELIM_DUP, m, m + 56, xc)
LTEXT "Propagate Zone.Id stream:", IDT_SYSTEM_ZONE, m, m + 70, xc - zoneX, 8
COMBOBOX IDC_SYSTEM_ZONE, m + xc - zoneX, m + 70 - 2, zoneX, 50, MY_COMBO
LTEXT "Context menu items:", IDT_SYSTEM_CONTEXT_MENU_ITEMS, m, m + 84, xc, 8
CONTROL "List", IDL_SYSTEM_OPTIONS, "SysListView32",
LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,
m, m + y, xc, yc - y
END
STRINGTABLE
BEGIN
IDT_ZONE_FOR_OFFICE "For Office files"
END
@@ -0,0 +1,15 @@
#define IDD_MENU 2300
#define IDD_MENU_2 12300
#define IDX_SYSTEM_INTEGRATE_TO_MENU 2301
#define IDX_SYSTEM_CASCADED_MENU 2302
#define IDT_SYSTEM_CONTEXT_MENU_ITEMS 2303
#define IDX_SYSTEM_ICON_IN_MENU 2304
#define IDX_SYSTEM_INTEGRATE_TO_MENU_2 2310
#define IDT_SYSTEM_ZONE 3440
#define IDT_ZONE_FOR_OFFICE 3441
#define IDL_SYSTEM_OPTIONS 100
#define IDC_SYSTEM_ZONE 101
@@ -0,0 +1,76 @@
// MessagesDialog.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "../../../Windows/ResourceString.h"
#include "MessagesDialog.h"
#include "LangUtils.h"
#include "ProgressDialog2Res.h"
using namespace NWindows;
void CMessagesDialog::AddMessageDirect(LPCWSTR message)
{
const unsigned i = (unsigned)_messageList.GetItemCount();
wchar_t sz[16];
ConvertUInt32ToString(i, sz);
_messageList.InsertItem(i, sz);
_messageList.SetSubItem(i, 1, message);
}
void CMessagesDialog::AddMessage(LPCWSTR message)
{
UString s = message;
while (!s.IsEmpty())
{
const int pos = s.Find(L'\n');
if (pos < 0)
break;
AddMessageDirect(s.Left(pos));
s.DeleteFrontal((unsigned)pos + 1);
}
AddMessageDirect(s);
}
bool CMessagesDialog::OnInit()
{
#ifdef Z7_LANG
LangSetWindowText(*this, IDD_MESSAGES);
LangSetDlgItems(*this, NULL, 0);
SetItemText(IDOK, LangString(IDS_CLOSE));
#endif
_messageList.Attach(GetItem(IDL_MESSAGE));
_messageList.SetUnicodeFormat();
_messageList.InsertColumn(0, L"", 30);
_messageList.InsertColumn(1, LangString(IDS_MESSAGE), 600);
FOR_VECTOR (i, *Messages)
AddMessage((*Messages)[i]);
_messageList.SetColumnWidthAuto(0);
_messageList.SetColumnWidthAuto(1);
NormalizeSize();
return CModalDialog::OnInit();
}
bool CMessagesDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
{
int mx, my;
GetMargins(8, mx, my);
int bx, by;
GetItemSizes(IDOK, bx, by);
int y = ySize - my - by;
int x = xSize - mx - bx;
InvalidateRect(NULL);
MoveItem(IDOK, x, y, bx, by);
_messageList.Move(mx, my, xSize - mx * 2, y - my * 2);
return false;
}

Some files were not shown because too many files have changed in this diff Show More