mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-09 14:07:08 -06:00
4.30 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
bcd1db2f5a
commit
e18587ba51
@@ -18,9 +18,10 @@ static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#endif
|
||||
|
||||
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
#include "../../Compress/LZMA/LZMAEncoder.h"
|
||||
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
@@ -114,7 +115,7 @@ static void ConvertBindInfoToFolderItemInfo(const NCoderMixer2::CBindInfo &bindI
|
||||
folder.PackStreams.Add(bindInfo.InStreams[i]);
|
||||
}
|
||||
|
||||
HRESULT CEncoder::CreateMixerCoder()
|
||||
HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
{
|
||||
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
|
||||
_mixerCoder = _mixerCoderSpec;
|
||||
@@ -203,6 +204,30 @@ HRESULT CEncoder::CreateMixerCoder()
|
||||
return E_FAIL;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool tryReduce = false;
|
||||
UInt32 reducedDictionarySize = 1 << 10;
|
||||
if (inSizeForReduce != 0 && methodFull.MethodID == k_LZMA)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
const UInt32 step = (reducedDictionarySize >> 1);
|
||||
if (reducedDictionarySize >= *inSizeForReduce)
|
||||
{
|
||||
tryReduce = true;
|
||||
break;
|
||||
}
|
||||
reducedDictionarySize += step;
|
||||
if (reducedDictionarySize >= *inSizeForReduce)
|
||||
{
|
||||
tryReduce = true;
|
||||
break;
|
||||
}
|
||||
if (reducedDictionarySize >= ((UInt32)11 << 30))
|
||||
break;
|
||||
reducedDictionarySize += step;
|
||||
}
|
||||
}
|
||||
|
||||
if (methodFull.CoderProperties.Size() > 0)
|
||||
{
|
||||
@@ -215,7 +240,10 @@ HRESULT CEncoder::CreateMixerCoder()
|
||||
{
|
||||
const CProperty &property = methodFull.CoderProperties[i];
|
||||
propIDs.Add(property.PropID);
|
||||
values[i] = property.Value;
|
||||
NWindows::NCOM::CPropVariant value = property.Value;
|
||||
if (tryReduce && property.PropID == NCoderPropID::kDictionarySize && value.vt == VT_UI4 && reducedDictionarySize < value.ulVal)
|
||||
value.ulVal = reducedDictionarySize;
|
||||
values[i] = value;
|
||||
}
|
||||
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
|
||||
if (methodFull.IsSimpleCoder())
|
||||
@@ -308,7 +336,7 @@ HRESULT CEncoder::CreateMixerCoder()
|
||||
}
|
||||
|
||||
HRESULT CEncoder::Encode(ISequentialInStream *inStream,
|
||||
const UInt64 *inStreamSize,
|
||||
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
|
||||
CFolder &folderItem,
|
||||
ISequentialOutStream *outStream,
|
||||
CRecordVector<UInt64> &packSizes,
|
||||
@@ -316,7 +344,7 @@ HRESULT CEncoder::Encode(ISequentialInStream *inStream,
|
||||
{
|
||||
if (_mixerCoderSpec == NULL)
|
||||
{
|
||||
RINOK(CreateMixerCoder());
|
||||
RINOK(CreateMixerCoder(inSizeForReduce));
|
||||
}
|
||||
_mixerCoderSpec->ReInit();
|
||||
// _mixerCoderSpec->SetCoderInfo(0, NULL, NULL, progress);
|
||||
|
||||
@@ -38,13 +38,13 @@ class CEncoder
|
||||
NCoderMixer2::CBindReverseConverter *_bindReverseConverter;
|
||||
CRecordVector<CMethodID> _decompressionMethods;
|
||||
|
||||
HRESULT CreateMixerCoder();
|
||||
HRESULT CreateMixerCoder(const UInt64 *inSizeForReduce);
|
||||
|
||||
public:
|
||||
CEncoder(const CCompressionMethodMode &options);
|
||||
~CEncoder();
|
||||
HRESULT Encode(ISequentialInStream *inStream,
|
||||
const UInt64 *inStreamSize,
|
||||
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
|
||||
CFolder &folderItem,
|
||||
ISequentialOutStream *outStream,
|
||||
CRecordVector<UInt64> &packSizes,
|
||||
|
||||
@@ -81,7 +81,7 @@ const wchar_t *kDefaultMethodName = kLZMAMethodName;
|
||||
|
||||
static const wchar_t *kMatchFinderForHeaders = L"BT2";
|
||||
static const UInt32 kDictionaryForHeaders = 1 << 20;
|
||||
static const UInt32 kNumFastBytesForHeaders = 254;
|
||||
static const UInt32 kNumFastBytesForHeaders = 273;
|
||||
|
||||
static bool IsLZMAMethod(const UString &methodName)
|
||||
{ return (methodName.CompareNoCase(kLZMAMethodName) == 0); }
|
||||
|
||||
@@ -576,8 +576,8 @@ HRESULT COutArchive::EncodeStream(CEncoder &encoder, const Byte *data, size_t da
|
||||
CFolder folderItem;
|
||||
folderItem.UnPackCRCDefined = true;
|
||||
folderItem.UnPackCRC = CCRC::CalculateDigest(data, dataSize);
|
||||
RINOK(encoder.Encode(stream, NULL, folderItem, SeqStream,
|
||||
packSizes, NULL));
|
||||
UInt64 dataSize64 = dataSize;
|
||||
RINOK(encoder.Encode(stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL));
|
||||
folders.Add(folderItem);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -566,11 +566,21 @@ static HRESULT Update2(
|
||||
UInt64 complexity = 0;
|
||||
for(i = 0; i < folderRefs.Size(); i++)
|
||||
complexity += database->GetFolderFullPackSize(folderRefs[i]);
|
||||
UInt64 inSizeForReduce = 0;
|
||||
for(i = 0; i < updateItems.Size(); i++)
|
||||
{
|
||||
const CUpdateItem &updateItem = updateItems[i];
|
||||
if (updateItem.NewData)
|
||||
{
|
||||
complexity += updateItem.Size;
|
||||
if (numSolidFiles == 1)
|
||||
{
|
||||
if (updateItem.Size > inSizeForReduce)
|
||||
inSizeForReduce = updateItem.Size;
|
||||
}
|
||||
else
|
||||
inSizeForReduce += updateItem.Size;
|
||||
}
|
||||
}
|
||||
RINOK(updateCallback->SetTotal(complexity));
|
||||
complexity = 0;
|
||||
@@ -636,6 +646,10 @@ static HRESULT Update2(
|
||||
SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter,
|
||||
updateItems, groups);
|
||||
|
||||
const UInt32 kMinReduceSize = (1 << 16);
|
||||
if (inSizeForReduce < kMinReduceSize)
|
||||
inSizeForReduce = kMinReduceSize;
|
||||
|
||||
for (int groupIndex = 0; groupIndex < groups.Size(); groupIndex++)
|
||||
{
|
||||
const CSolidGroup &group = groups[groupIndex];
|
||||
@@ -708,7 +722,7 @@ static HRESULT Update2(
|
||||
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
|
||||
localCompressProgressSpec->Init(localProgress, &complexity, NULL);
|
||||
|
||||
RINOK(encoder.Encode(solidInStream, NULL, folderItem,
|
||||
RINOK(encoder.Encode(solidInStream, NULL, &inSizeForReduce, folderItem,
|
||||
archive.SeqStream, newDatabase.PackSizes, compressProgress));
|
||||
// for()
|
||||
// newDatabase.PackCRCsDefined.Add(false);
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "../../../Common/MyInitGuid.h"
|
||||
#include "../../../Common/ComTry.h"
|
||||
#ifdef _WIN32
|
||||
#include "../../../Common/Alloc.h"
|
||||
#endif
|
||||
|
||||
#include "../../ICoder.h"
|
||||
|
||||
@@ -18,12 +21,32 @@ DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
|
||||
#endif
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +256,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_items.Clear();
|
||||
_stream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,17 @@ DEFINE_GUID(CLSID_CBZip2Handler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x02, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COMPRESS_BZIP2
|
||||
#include "../Common/CodecsPath.h"
|
||||
@@ -34,7 +45,12 @@ extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -86,10 +102,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"bz2 tbz2";
|
||||
propVariant = L"bz2 bzip2 tbz2 tbz";
|
||||
break;
|
||||
case NArchive::kAddExtension:
|
||||
propVariant = L"* .tar";
|
||||
propVariant = L"* * .tar .tar";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = true;
|
||||
|
||||
@@ -224,6 +224,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
m_Database.Clear();
|
||||
m_Stream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ static const int kBufferSize = 1 << 17;
|
||||
|
||||
CFilterCoder::CFilterCoder()
|
||||
{
|
||||
_buffer = (Byte *)::BigAlloc(kBufferSize);
|
||||
_buffer = (Byte *)::MidAlloc(kBufferSize);
|
||||
}
|
||||
|
||||
CFilterCoder::~CFilterCoder()
|
||||
{
|
||||
BigFree(_buffer);
|
||||
::MidFree(_buffer);
|
||||
}
|
||||
|
||||
HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 size)
|
||||
|
||||
@@ -36,7 +36,7 @@ class CInStreamWithCRC:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInStream)
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
|
||||
@@ -21,6 +21,17 @@ DEFINE_GUID(CLSID_CCompressDeflateDecoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COMPRESS_DEFLATE
|
||||
#include "../Common/CodecsPath.h"
|
||||
@@ -34,7 +45,12 @@ extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -85,10 +101,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"gz tgz";
|
||||
propVariant = L"gz gzip tgz tpz";
|
||||
break;
|
||||
case NArchive::kAddExtension:
|
||||
propVariant = L"* .tar";
|
||||
propVariant = L"* * .tar .tar";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = true;
|
||||
|
||||
@@ -192,7 +192,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
m_Method.NumPasses = value.ulVal;
|
||||
if (m_Method.NumPasses < 1 || m_Method.NumPasses > 4)
|
||||
if (m_Method.NumPasses < 1 || m_Method.NumPasses > 10)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
else if (name == L"FB")
|
||||
@@ -200,8 +200,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
m_Method.NumFastBytes = value.ulVal;
|
||||
/*
|
||||
if (m_Method.NumFastBytes < 3 || m_Method.NumFastBytes > 255)
|
||||
return E_INVALIDARG;
|
||||
*/
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
|
||||
@@ -270,6 +270,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_items.Clear();
|
||||
_stream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,17 @@ DEFINE_GUID(CLSID_CCrypto_AES128_Decoder,
|
||||
#include "RarHandler.h"
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
void GetCryptoFolderPrefix(TCHAR *path)
|
||||
{
|
||||
@@ -54,7 +65,12 @@ extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -276,6 +276,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_sizes.Clear();
|
||||
_streams.Clear();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_items.Clear();
|
||||
_inStream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -120,10 +120,12 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
|
||||
RIF(OctalToNumber32(cur, 8, item.Mode));
|
||||
cur += 8;
|
||||
|
||||
RIF(OctalToNumber32(cur, 8, item.UID));
|
||||
if (!OctalToNumber32(cur, 8, item.UID))
|
||||
item.UID = 0;
|
||||
cur += 8;
|
||||
|
||||
RIF(OctalToNumber32(cur, 8, item.GID));
|
||||
if (!OctalToNumber32(cur, 8, item.GID))
|
||||
item.GID = 0;
|
||||
cur += 8;
|
||||
|
||||
RIF(OctalToNumber(cur, 12, item.Size));
|
||||
|
||||
@@ -70,7 +70,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"z";
|
||||
propVariant = L"z taz";
|
||||
break;
|
||||
case NArchive::kAddExtension:
|
||||
propVariant = L"* .tar";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = false;
|
||||
|
||||
@@ -50,12 +50,28 @@ DEFINE_GUID(CLSID_CZipHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x01, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,14 @@ SOURCE=..\..\..\Common\CRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Random.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -57,7 +57,7 @@ CAddCommon::CAddCommon(const CCompressionMethodMode &options):
|
||||
_cryptoStreamSpec(0)
|
||||
{}
|
||||
|
||||
static HRESULT GetStreamCRC(IInStream *inStream, UInt32 &resultCRC)
|
||||
static HRESULT GetStreamCRC(ISequentialInStream *inStream, UInt32 &resultCRC)
|
||||
{
|
||||
CCRC crc;
|
||||
crc.Init();
|
||||
@@ -76,7 +76,7 @@ static HRESULT GetStreamCRC(IInStream *inStream, UInt32 &resultCRC)
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
|
||||
HRESULT CAddCommon::Compress(ISequentialInStream *inStream, IOutStream *outStream,
|
||||
UInt64 inSize, ICompressProgressInfo *progress, CCompressingResult &operationResult)
|
||||
{
|
||||
/*
|
||||
@@ -88,13 +88,25 @@ HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
CMyComPtr<IInStream> inStream2;
|
||||
int numTestMethods = _options.MethodSequence.Size();
|
||||
if (numTestMethods > 1 || _options.PasswordIsDefined)
|
||||
{
|
||||
inStream->QueryInterface(IID_IInStream, (void **)&inStream2);
|
||||
if (!inStream2)
|
||||
{
|
||||
if (_options.PasswordIsDefined)
|
||||
return E_NOTIMPL;
|
||||
numTestMethods = 1;
|
||||
}
|
||||
}
|
||||
Byte method;
|
||||
UInt64 resultSize = 0;
|
||||
COutStreamReleaser outStreamReleaser;
|
||||
for(int i = 0; i < numTestMethods; i++)
|
||||
{
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
if (inStream2)
|
||||
RINOK(inStream2->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
if (_options.PasswordIsDefined)
|
||||
{
|
||||
@@ -109,7 +121,7 @@ HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
|
||||
(const Byte *)(const char *)_options.Password, _options.Password.Length()));
|
||||
UInt32 crc;
|
||||
RINOK(GetStreamCRC(inStream, crc));
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
RINOK(inStream2->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
RINOK(_cryptoStreamSpec->SetOutStream(outStream));
|
||||
outStreamReleaser.FilterCoder = _cryptoStreamSpec;
|
||||
RINOK(_filterSpec->CryptoSetCRC(crc));
|
||||
|
||||
@@ -41,7 +41,7 @@ class CAddCommon
|
||||
|
||||
public:
|
||||
CAddCommon(const CCompressionMethodMode &options);
|
||||
HRESULT Compress(IInStream *inStream, IOutStream *outStream,
|
||||
HRESULT Compress(ISequentialInStream *inStream, IOutStream *outStream,
|
||||
UInt64 inSize, ICompressProgressInfo *progress, CCompressingResult &operationResult);
|
||||
};
|
||||
|
||||
|
||||
@@ -323,6 +323,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
m_Items.Clear();
|
||||
m_Archive.Close();
|
||||
m_ArchiveIsOpen = false;
|
||||
return S_OK;
|
||||
|
||||
@@ -303,8 +303,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
{
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
/*
|
||||
if (value.ulVal < 3 || value.ulVal > 255)
|
||||
return E_INVALIDARG;
|
||||
*/
|
||||
m_NumFastBytes = value.ulVal;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -121,9 +121,22 @@ static HRESULT UpdateOneFile(IInStream *inStream,
|
||||
else
|
||||
{
|
||||
{
|
||||
CInStreamWithCRC *inStreamSpec = new CInStreamWithCRC;
|
||||
CMyComPtr<IInStream> inStream(inStreamSpec);
|
||||
inStreamSpec->Init(fileInStream);
|
||||
CSequentialInStreamWithCRC *inSecStreamSpec = 0;
|
||||
CInStreamWithCRC *inStreamSpec = 0;
|
||||
CMyComPtr<ISequentialInStream> fileSecInStream;
|
||||
if (fileInStream)
|
||||
{
|
||||
inStreamSpec = new CInStreamWithCRC;
|
||||
fileSecInStream = inStreamSpec;
|
||||
inStreamSpec->Init(fileInStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
inSecStreamSpec = new CSequentialInStreamWithCRC;
|
||||
fileSecInStream = inSecStreamSpec;
|
||||
inSecStreamSpec->Init(fileInStream2);
|
||||
}
|
||||
|
||||
CCompressingResult compressingResult;
|
||||
CMyComPtr<IOutStream> outStream;
|
||||
archive.CreateStreamForCompressing(&outStream);
|
||||
@@ -132,20 +145,26 @@ static HRESULT UpdateOneFile(IInStream *inStream,
|
||||
CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
|
||||
localProgressSpec->Init(updateCallback, true);
|
||||
|
||||
CLocalCompressProgressInfo *localCompressProgressSpec =
|
||||
new CLocalCompressProgressInfo;
|
||||
CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
|
||||
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
|
||||
|
||||
localCompressProgressSpec->Init(localProgress, ¤tComplexity, NULL);
|
||||
|
||||
RINOK(compressor.Compress(inStream, outStream,
|
||||
fileSize, compressProgress, compressingResult));
|
||||
RINOK(compressor.Compress(fileSecInStream, outStream, fileSize, compressProgress, compressingResult));
|
||||
|
||||
fileHeader.PackSize = compressingResult.PackSize;
|
||||
fileHeader.CompressionMethod = compressingResult.Method;
|
||||
fileHeader.ExtractVersion.Version = compressingResult.ExtractVersion;
|
||||
fileHeader.FileCRC = inStreamSpec->GetCRC();
|
||||
fileHeader.UnPackSize = inStreamSpec->GetSize();
|
||||
if (inStreamSpec != 0)
|
||||
{
|
||||
fileHeader.FileCRC = inStreamSpec->GetCRC();
|
||||
fileHeader.UnPackSize = inStreamSpec->GetSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
fileHeader.FileCRC = inSecStreamSpec->GetCRC();
|
||||
fileHeader.UnPackSize = inSecStreamSpec->GetSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
fileHeader.SetEncrypted(options.PasswordIsDefined);
|
||||
|
||||
@@ -138,6 +138,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
m_Items.Clear();
|
||||
m_InStream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -481,6 +481,14 @@ SOURCE=..\..\..\Windows\Handle.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\MemoryLock.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\MemoryLock.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
PROG = 7za.exe
|
||||
LIBS = $(LIBS) user32.lib oleaut32.lib
|
||||
LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib
|
||||
|
||||
CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DEXCLUDE_COM \
|
||||
@@ -61,6 +61,7 @@ WIN_OBJS = \
|
||||
$O\FileFind.obj \
|
||||
$O\FileIO.obj \
|
||||
$O\FileName.obj \
|
||||
$O\MemoryLock.obj \
|
||||
$O\PropVariant.obj \
|
||||
$O\PropVariantConversions.obj \
|
||||
$O\Synchronization.obj
|
||||
|
||||
3
7zip/Bundles/Alone7z/StdAfx.cpp
Executable file
3
7zip/Bundles/Alone7z/StdAfx.cpp
Executable file
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
9
7zip/Bundles/Alone7z/StdAfx.h
Executable file
9
7zip/Bundles/Alone7z/StdAfx.h
Executable file
@@ -0,0 +1,9 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
#include "../../../Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
179
7zip/Bundles/Alone7z/makefile
Executable file
179
7zip/Bundles/Alone7z/makefile
Executable file
@@ -0,0 +1,179 @@
|
||||
PROG = 7za.exe
|
||||
LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib
|
||||
|
||||
CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DEXCLUDE_COM \
|
||||
-DNO_REGISTRY \
|
||||
-DFORMAT_7Z \
|
||||
-DCOMPRESS_BCJ_X86 \
|
||||
-DCOMPRESS_BCJ2 \
|
||||
-DCOMPRESS_COPY \
|
||||
-DCOMPRESS_LZMA \
|
||||
-DCOMPRESS_MF_MT \
|
||||
|
||||
|
||||
CONSOLE_OBJS = \
|
||||
$O\ConsoleClose.obj \
|
||||
$O\ExtractCallbackConsole.obj \
|
||||
$O\List.obj \
|
||||
$O\Main.obj \
|
||||
$O\MainAr.obj \
|
||||
$O\OpenCallbackConsole.obj \
|
||||
$O\PercentPrinter.obj \
|
||||
$O\UpdateCallbackConsole.obj \
|
||||
$O\UserInputUtils.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\CommandLineParser.obj \
|
||||
$O\CRC.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\ListFileUtils.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\Random.obj \
|
||||
$O\StdInStream.obj \
|
||||
$O\StdOutStream.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
$O\UTFConvert.obj \
|
||||
$O\Vector.obj \
|
||||
$O\Wildcard.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\Error.obj \
|
||||
$O\FileDir.obj \
|
||||
$O\FileFind.obj \
|
||||
$O\FileIO.obj \
|
||||
$O\FileName.obj \
|
||||
$O\MemoryLock.obj \
|
||||
$O\PropVariant.obj \
|
||||
$O\PropVariantConversions.obj \
|
||||
$O\Synchronization.obj
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\FilePathAutoRename.obj \
|
||||
$O\FileStreams.obj \
|
||||
$O\InBuffer.obj \
|
||||
$O\InOutTempBuffer.obj \
|
||||
$O\LimitedStreams.obj \
|
||||
$O\LockedStream.obj \
|
||||
$O\OffsetStream.obj \
|
||||
$O\OutBuffer.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamBinder.obj \
|
||||
$O\StreamObjects.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
UI_COMMON_OBJS = \
|
||||
$O\ArchiveCommandLine.obj \
|
||||
$O\ArchiveExtractCallback.obj \
|
||||
$O\ArchiveOpenCallback.obj \
|
||||
$O\ArchiverInfo.obj \
|
||||
$O\DefaultName.obj \
|
||||
$O\EnumDirItems.obj \
|
||||
$O\Extract.obj \
|
||||
$O\ExtractingFilePath.obj \
|
||||
$O\OpenArchive.obj \
|
||||
$O\PropIDUtils.obj \
|
||||
$O\SortUtils.obj \
|
||||
$O\TempFiles.obj \
|
||||
$O\Update.obj \
|
||||
$O\UpdateAction.obj \
|
||||
$O\UpdateCallback.obj \
|
||||
$O\UpdatePair.obj \
|
||||
$O\UpdateProduce.obj \
|
||||
$O\WorkDir.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CoderMixer2MT.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\FilterCoder.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zCompressionMode.obj \
|
||||
$O\7zDecode.obj \
|
||||
$O\7zEncode.obj \
|
||||
$O\7zExtract.obj \
|
||||
$O\7zFolderInStream.obj \
|
||||
$O\7zFolderOutStream.obj \
|
||||
$O\7zHandler.obj \
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
$O\7zIn.obj \
|
||||
$O\7zMethodID.obj \
|
||||
$O\7zOut.obj \
|
||||
$O\7zProperties.obj \
|
||||
$O\7zSpecStream.obj \
|
||||
$O\7zUpdate.obj \
|
||||
|
||||
|
||||
BRANCH_OPT_OBJS = \
|
||||
$O\BranchCoder.obj \
|
||||
$O\x86.obj \
|
||||
$O\x86_2.obj \
|
||||
|
||||
LZ_OBJS = \
|
||||
$O\LZInWindow.obj \
|
||||
$O\LZOutWindow.obj \
|
||||
|
||||
LZMA_OPT_OBJS = \
|
||||
$O\LZMADecoder.obj \
|
||||
$O\LZMAEncoder.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(CONSOLE_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(UI_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$(7Z_OBJS) \
|
||||
$(BRANCH_OPT_OBJS) \
|
||||
$(LZ_OBJS) \
|
||||
$(LZMA_OPT_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$O\MT.obj \
|
||||
$O\RangeCoderBit.obj \
|
||||
$O\resource.res
|
||||
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(CONSOLE_OBJS): ../../UI/Console/$(*B).cpp
|
||||
$(COMPL)
|
||||
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
|
||||
$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
|
||||
$(COMPL_O2)
|
||||
$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
|
||||
$(COMPL_O2)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\MT.obj: ../../Compress/LZ/MT/$(*B).cpp
|
||||
$(COMPL_O2)
|
||||
$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp
|
||||
$(COMPL)
|
||||
3
7zip/Bundles/Alone7z/resource.rc
Executable file
3
7zip/Bundles/Alone7z/resource.rc
Executable file
@@ -0,0 +1,3 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_APP("7-Zip Standalone Console", "7za")
|
||||
@@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "COMPRESS_BCJ2" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_COPY" /D "COMPRESS_PPMD" /D "_SFX" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "COMPRESS_BCJ2" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_COPY" /D "COMPRESS_PPMD" /D "_SFX" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
||||
@@ -118,14 +118,29 @@ public:
|
||||
{ return BOOLToBool(::SetCurrentDirectory(m_CurrentDirectory)); }
|
||||
};
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static inline bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
int APIENTRY WinMain(
|
||||
HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
InitCommonControls();
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
InitCommonControls();
|
||||
|
||||
UString archiveName, switches;
|
||||
NCommandLineParser::SplitCommandLine(GetCommandLineW(), archiveName, switches);
|
||||
|
||||
@@ -19,6 +19,17 @@
|
||||
#include "../../UI/GUI/ExtractGUI.h"
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static inline bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
int APIENTRY WinMain(
|
||||
HINSTANCE hInstance,
|
||||
@@ -27,6 +38,10 @@ int APIENTRY WinMain(
|
||||
int nCmdShow)
|
||||
{
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
|
||||
UString password;
|
||||
bool assumeYes = false;
|
||||
bool outputFolderDefined = false;
|
||||
|
||||
@@ -44,7 +44,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_PPMD" /D "_SFX" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_PPMD" /D "_SFX" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
|
||||
@@ -23,13 +23,13 @@ bool CInBuffer::Create(UInt32 bufferSize)
|
||||
return true;
|
||||
Free();
|
||||
_bufferSize = bufferSize;
|
||||
_bufferBase = (Byte *)::BigAlloc(bufferSize);
|
||||
_bufferBase = (Byte *)::MidAlloc(bufferSize);
|
||||
return (_bufferBase != 0);
|
||||
}
|
||||
|
||||
void CInBuffer::Free()
|
||||
{
|
||||
BigFree(_bufferBase);
|
||||
::MidFree(_bufferBase);
|
||||
_bufferBase = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@ bool COutBuffer::Create(UInt32 bufferSize)
|
||||
return true;
|
||||
Free();
|
||||
_bufferSize = bufferSize;
|
||||
_buffer = (Byte *)::BigAlloc(bufferSize);
|
||||
_buffer = (Byte *)::MidAlloc(bufferSize);
|
||||
return (_buffer != 0);
|
||||
}
|
||||
|
||||
void COutBuffer::Free()
|
||||
{
|
||||
BigFree(_buffer);
|
||||
::MidFree(_buffer);
|
||||
_buffer = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#ifdef _WIN32
|
||||
#include "Common/Alloc.h"
|
||||
#endif
|
||||
|
||||
#include "BZip2Encoder.h"
|
||||
#include "BZip2Decoder.h"
|
||||
@@ -19,6 +22,10 @@ DEFINE_GUID(CLSID_CCompressBZip2Encoder,
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ bool CBCJ2_x86_Encoder::Create()
|
||||
return false;
|
||||
if (_buffer == 0)
|
||||
{
|
||||
_buffer = (Byte *)BigAlloc(kBufferSize);
|
||||
_buffer = (Byte *)MidAlloc(kBufferSize);
|
||||
if (_buffer == 0)
|
||||
return false;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ bool CBCJ2_x86_Encoder::Create()
|
||||
|
||||
CBCJ2_x86_Encoder::~CBCJ2_x86_Encoder()
|
||||
{
|
||||
BigFree(_buffer);
|
||||
::MidFree(_buffer);
|
||||
}
|
||||
|
||||
HRESULT CBCJ2_x86_Encoder::Flush()
|
||||
|
||||
@@ -12,7 +12,7 @@ static const UInt32 kBufferSize = 1 << 17;
|
||||
|
||||
CCopyCoder::~CCopyCoder()
|
||||
{
|
||||
BigFree(_buffer);
|
||||
::MidFree(_buffer);
|
||||
}
|
||||
|
||||
STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
|
||||
@@ -22,7 +22,7 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
|
||||
{
|
||||
if (_buffer == 0)
|
||||
{
|
||||
_buffer = (Byte *)BigAlloc(kBufferSize);
|
||||
_buffer = (Byte *)::MidAlloc(kBufferSize);
|
||||
if (_buffer == 0)
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
@@ -116,12 +116,11 @@ HRESULT CCoder::Create()
|
||||
kNumOpts + kNumGoodBacks, m_NumFastBytes, m_MatchMaxLen - m_NumFastBytes));
|
||||
if (!m_OutStream.Create(1 << 20))
|
||||
return E_OUTOFMEMORY;
|
||||
m_MatchLengthEdge = m_NumFastBytes + 1;
|
||||
|
||||
Free();
|
||||
if (m_NumPasses > 1)
|
||||
{
|
||||
m_OnePosMatchesMemory = (UInt16 *)BigAlloc(kNumGoodBacks * (m_NumFastBytes + 1) * sizeof(UInt16));
|
||||
m_OnePosMatchesMemory = (UInt16 *)::MidAlloc(kNumGoodBacks * (m_NumFastBytes + 1) * sizeof(UInt16));
|
||||
if (m_OnePosMatchesMemory == 0)
|
||||
return E_OUTOFMEMORY;
|
||||
m_OnePosMatchesArray = (COnePosMatches *)MyAlloc(kNumGoodBacks * sizeof(COnePosMatches));
|
||||
@@ -177,7 +176,7 @@ void CCoder::Free()
|
||||
{
|
||||
if (m_NumPasses > 1)
|
||||
{
|
||||
BigFree(m_OnePosMatchesMemory);
|
||||
::MidFree(m_OnePosMatchesMemory);
|
||||
MyFree(m_OnePosMatchesArray);
|
||||
}
|
||||
else
|
||||
@@ -308,7 +307,7 @@ UInt32 CCoder::GetOptimal(UInt32 &backRes)
|
||||
|
||||
if(lenMain < kMatchMinLen)
|
||||
return 1;
|
||||
if(lenMain >= m_MatchLengthEdge)
|
||||
if(lenMain > m_NumFastBytes)
|
||||
{
|
||||
backRes = backMain;
|
||||
MovePos(lenMain - 1);
|
||||
@@ -337,7 +336,7 @@ UInt32 CCoder::GetOptimal(UInt32 &backRes)
|
||||
return Backward(backRes, cur);
|
||||
GetBacks(UInt32(m_BlockStartPostion + m_CurrentBlockUncompressedSize + cur));
|
||||
UInt32 newLen = m_LongestMatchLength;
|
||||
if(newLen >= m_MatchLengthEdge)
|
||||
if(newLen > m_NumFastBytes)
|
||||
return Backward(backRes, cur);
|
||||
|
||||
UInt32 curPrice = m_Optimum[cur].Price;
|
||||
|
||||
@@ -77,7 +77,6 @@ class CCoder
|
||||
UInt16 *m_MatchDistances;
|
||||
|
||||
UInt32 m_NumFastBytes;
|
||||
UInt32 m_MatchLengthEdge;
|
||||
|
||||
Byte m_LiteralPrices[256];
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "../../../Common/MyInitGuid.h"
|
||||
#include "../../../Common/ComTry.h"
|
||||
#ifdef _WIN32
|
||||
#include "../../../Common/Alloc.h"
|
||||
#endif
|
||||
|
||||
#include "LZMAEncoder.h"
|
||||
#include "LZMADecoder.h"
|
||||
@@ -20,8 +23,14 @@ DEFINE_GUID(CLSID_CLZMAEncoder,
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
// NCompress::NRangeCoder::g_PriceTables.Init();
|
||||
// CCRC::InitTable();
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
// NCompress::NRangeCoder::g_PriceTables.Init();
|
||||
// CCRC::InitTable();
|
||||
#ifdef _WIN32
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ HRESULT CEncoder::Create()
|
||||
if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes)
|
||||
return S_OK;
|
||||
RINOK(_matchFinder->Create(_dictionarySize, kNumOpts, _numFastBytes,
|
||||
kMatchMaxLen - _numFastBytes));
|
||||
kMatchMaxLen * 2 + 1 - _numFastBytes));
|
||||
_dictionarySizePrev = _dictionarySize;
|
||||
_numFastBytesPrev = _numFastBytes;
|
||||
return S_OK;
|
||||
@@ -614,13 +614,20 @@ inline UInt32 GetMatchLen(const Byte *data, UInt32 back, UInt32 limit)
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Out:
|
||||
(lenRes == 1) && (backRes == 0xFFFFFFFF) means Literal
|
||||
*/
|
||||
|
||||
HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
{
|
||||
if(_optimumEndIndex != _optimumCurrentIndex)
|
||||
{
|
||||
lenRes = _optimum[_optimumCurrentIndex].PosPrev - _optimumCurrentIndex;
|
||||
backRes = _optimum[_optimumCurrentIndex].BackPrev;
|
||||
_optimumCurrentIndex = _optimum[_optimumCurrentIndex].PosPrev;
|
||||
const COptimal &optimum = _optimum[_optimumCurrentIndex];
|
||||
lenRes = optimum.PosPrev - _optimumCurrentIndex;
|
||||
backRes = optimum.BackPrev;
|
||||
_optimumCurrentIndex = optimum.PosPrev;
|
||||
return S_OK;
|
||||
}
|
||||
_optimumCurrentIndex = 0;
|
||||
@@ -649,14 +656,14 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
if (i == 0 || repLens[i] > repLens[repMaxIndex])
|
||||
repMaxIndex = i;
|
||||
}
|
||||
if(repLens[repMaxIndex] > _numFastBytes)
|
||||
if(repLens[repMaxIndex] >= _numFastBytes)
|
||||
{
|
||||
backRes = repMaxIndex;
|
||||
lenRes = repLens[repMaxIndex];
|
||||
return MovePos(lenRes - 1);
|
||||
}
|
||||
|
||||
if(lenMain > _numFastBytes)
|
||||
if(lenMain >= _numFastBytes)
|
||||
{
|
||||
backRes = _matchDistances[_numFastBytes] + kNumRepDistances;
|
||||
lenRes = lenMain;
|
||||
@@ -752,15 +759,16 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
return S_OK;
|
||||
}
|
||||
position++;
|
||||
UInt32 posPrev = _optimum[cur].PosPrev;
|
||||
COptimal &curOptimum = _optimum[cur];
|
||||
UInt32 posPrev = curOptimum.PosPrev;
|
||||
CState state;
|
||||
if (_optimum[cur].Prev1IsChar)
|
||||
if (curOptimum.Prev1IsChar)
|
||||
{
|
||||
posPrev--;
|
||||
if (_optimum[cur].Prev2)
|
||||
if (curOptimum.Prev2)
|
||||
{
|
||||
state = _optimum[_optimum[cur].PosPrev2].State;
|
||||
if (_optimum[cur].BackPrev2 < kNumRepDistances)
|
||||
state = _optimum[curOptimum.PosPrev2].State;
|
||||
if (curOptimum.BackPrev2 < kNumRepDistances)
|
||||
state.UpdateRep();
|
||||
else
|
||||
state.UpdateMatch();
|
||||
@@ -773,12 +781,12 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
state = _optimum[posPrev].State;
|
||||
if (posPrev == cur - 1)
|
||||
{
|
||||
if (_optimum[cur].IsShortRep())
|
||||
if (curOptimum.IsShortRep())
|
||||
state.UpdateShortRep();
|
||||
else
|
||||
state.UpdateChar();
|
||||
/*
|
||||
if (_optimum[cur].Prev1IsChar)
|
||||
if (curOptimum.Prev1IsChar)
|
||||
for(int i = 0; i < kNumRepDistances; i++)
|
||||
reps[i] = _optimum[posPrev].Backs[i];
|
||||
*/
|
||||
@@ -786,49 +794,50 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
else
|
||||
{
|
||||
UInt32 pos;
|
||||
if (_optimum[cur].Prev1IsChar && _optimum[cur].Prev2)
|
||||
if (curOptimum.Prev1IsChar && curOptimum.Prev2)
|
||||
{
|
||||
posPrev = _optimum[cur].PosPrev2;
|
||||
pos = _optimum[cur].BackPrev2;
|
||||
posPrev = curOptimum.PosPrev2;
|
||||
pos = curOptimum.BackPrev2;
|
||||
state.UpdateRep();
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = _optimum[cur].BackPrev;
|
||||
pos = curOptimum.BackPrev;
|
||||
if (pos < kNumRepDistances)
|
||||
state.UpdateRep();
|
||||
else
|
||||
state.UpdateMatch();
|
||||
}
|
||||
const COptimal &prevOptimum = _optimum[posPrev];
|
||||
if (pos < kNumRepDistances)
|
||||
{
|
||||
reps[0] = _optimum[posPrev].Backs[pos];
|
||||
reps[0] = prevOptimum.Backs[pos];
|
||||
UInt32 i;
|
||||
for(i = 1; i <= pos; i++)
|
||||
reps[i] = _optimum[posPrev].Backs[i - 1];
|
||||
reps[i] = prevOptimum.Backs[i - 1];
|
||||
for(; i < kNumRepDistances; i++)
|
||||
reps[i] = _optimum[posPrev].Backs[i];
|
||||
reps[i] = prevOptimum.Backs[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
reps[0] = (pos - kNumRepDistances);
|
||||
for(UInt32 i = 1; i < kNumRepDistances; i++)
|
||||
reps[i] = _optimum[posPrev].Backs[i - 1];
|
||||
reps[i] = prevOptimum.Backs[i - 1];
|
||||
}
|
||||
}
|
||||
_optimum[cur].State = state;
|
||||
curOptimum.State = state;
|
||||
for(UInt32 i = 0; i < kNumRepDistances; i++)
|
||||
_optimum[cur].Backs[i] = reps[i];
|
||||
curOptimum.Backs[i] = reps[i];
|
||||
UInt32 newLen;
|
||||
RINOK(ReadMatchDistances(newLen));
|
||||
if(newLen > _numFastBytes)
|
||||
if(newLen >= _numFastBytes)
|
||||
{
|
||||
_longestMatchLength = newLen;
|
||||
_longestMatchWasFound = true;
|
||||
lenRes = Backward(backRes, cur);
|
||||
return S_OK;
|
||||
}
|
||||
UInt32 curPrice = _optimum[cur].Price;
|
||||
UInt32 curPrice = curOptimum.Price;
|
||||
// Byte currentByte = _matchFinder->GetIndexByte(0 - 1);
|
||||
// Byte matchByte = _matchFinder->GetIndexByte(0 - reps[0] - 1 - 1);
|
||||
const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
|
||||
@@ -872,8 +881,9 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
continue;
|
||||
*/
|
||||
|
||||
UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;
|
||||
numAvailableBytes = MyMin(kNumOpts - 1 - cur, numAvailableBytes);
|
||||
UInt32 numAvailableBytesFull = _matchFinder->GetNumAvailableBytes() + 1;
|
||||
numAvailableBytesFull = MyMin(kNumOpts - 1 - cur, numAvailableBytesFull);
|
||||
UInt32 numAvailableBytes = numAvailableBytesFull;
|
||||
|
||||
if (numAvailableBytes < 2)
|
||||
continue;
|
||||
@@ -881,6 +891,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
numAvailableBytes = _numFastBytes;
|
||||
if (numAvailableBytes >= 3 && !nextIsChar)
|
||||
{
|
||||
// try Literal + rep0
|
||||
UInt32 backOffset = reps[0] + 1;
|
||||
UInt32 temp;
|
||||
for (temp = 1; temp < numAvailableBytes; temp++)
|
||||
@@ -917,11 +928,15 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
{
|
||||
// UInt32 repLen = _matchFinder->GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;
|
||||
UInt32 backOffset = reps[repIndex] + 1;
|
||||
if (data[0] != data[(size_t)0 - backOffset] ||
|
||||
data[1] != data[(size_t)1 - backOffset])
|
||||
continue;
|
||||
UInt32 lenTest;
|
||||
for (lenTest = 0; lenTest < numAvailableBytes; lenTest++)
|
||||
for (lenTest = 2; lenTest < numAvailableBytes; lenTest++)
|
||||
if (data[lenTest] != data[(size_t)lenTest - backOffset])
|
||||
break;
|
||||
for(; lenTest >= 2; lenTest--)
|
||||
UInt32 lenTestTemp = lenTest;
|
||||
do
|
||||
{
|
||||
while(lenEnd < cur + lenTest)
|
||||
_optimum[++lenEnd].Price = kIfinityPrice;
|
||||
@@ -934,21 +949,25 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
optimum.BackPrev = repIndex;
|
||||
optimum.Prev1IsChar = false;
|
||||
}
|
||||
}
|
||||
while(--lenTest >= 2);
|
||||
lenTest = lenTestTemp;
|
||||
|
||||
/*
|
||||
if (_maxMode)
|
||||
{
|
||||
UInt32 temp;
|
||||
for (temp = lenTest + 1; temp < numAvailableBytes; temp++)
|
||||
if (data[temp] != data[(size_t)temp - backOffset])
|
||||
UInt32 lenTest2 = lenTest + 1;
|
||||
UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
|
||||
for (; lenTest2 < limit; lenTest2++)
|
||||
if (data[lenTest2] != data[(size_t)lenTest2 - backOffset])
|
||||
break;
|
||||
UInt32 lenTest2 = temp - (lenTest + 1);
|
||||
lenTest2 -= lenTest + 1;
|
||||
if (lenTest2 >= 2)
|
||||
{
|
||||
CState state2 = state;
|
||||
state2.UpdateRep();
|
||||
UInt32 posStateNext = (position + lenTest) & _posStateMask;
|
||||
UInt32 curAndLenCharPrice = curAndLenPrice +
|
||||
UInt32 curAndLenCharPrice =
|
||||
repMatchPrice + GetRepPrice(repIndex, lenTest, state, posState) +
|
||||
_isMatch[state2.Index][posStateNext].GetPrice0() +
|
||||
_literalEncoder.GetPrice(position + lenTest, data[(size_t)lenTest - 1],
|
||||
true, data[(size_t)lenTest - backOffset], data[lenTest]);
|
||||
@@ -978,9 +997,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// for(UInt32 lenTest = 2; lenTest <= newLen; lenTest++)
|
||||
if (newLen > numAvailableBytes)
|
||||
@@ -1007,14 +1024,16 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
|
||||
optimum.Prev1IsChar = false;
|
||||
}
|
||||
|
||||
if (_maxMode)
|
||||
if (_maxMode && (lenTest == newLen || curBack != _matchDistances[lenTest + 1]))
|
||||
{
|
||||
// Try Match + Literal + Rep0
|
||||
UInt32 backOffset = curBack + 1;
|
||||
UInt32 temp;
|
||||
for (temp = lenTest + 1; temp < numAvailableBytes; temp++)
|
||||
if (data[temp] != data[(size_t)temp - backOffset])
|
||||
UInt32 lenTest2 = lenTest + 1;
|
||||
UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
|
||||
for (; lenTest2 < limit; lenTest2++)
|
||||
if (data[lenTest2] != data[(size_t)lenTest2 - backOffset])
|
||||
break;
|
||||
UInt32 lenTest2 = temp - (lenTest + 1);
|
||||
lenTest2 -= lenTest + 1;
|
||||
if (lenTest2 >= 2)
|
||||
{
|
||||
CState state2 = state;
|
||||
@@ -1247,9 +1266,9 @@ HRESULT CEncoder::SetStreams(ISequentialInStream *inStream,
|
||||
FillAlignPrices();
|
||||
}
|
||||
|
||||
_lenEncoder.SetTableSize(_numFastBytes);
|
||||
_lenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
|
||||
_lenEncoder.UpdateTables(1 << _posStateBits);
|
||||
_repMatchLenEncoder.SetTableSize(_numFastBytes);
|
||||
_repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
|
||||
_repMatchLenEncoder.UpdateTables(1 << _posStateBits);
|
||||
|
||||
lastPosSlotFillingPos = 0;
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#ifdef _WIN32
|
||||
#include "Common/Alloc.h"
|
||||
#endif
|
||||
|
||||
#include "PPMDEncoder.h"
|
||||
#include "PPMDDecoder.h"
|
||||
@@ -19,6 +22,10 @@ DEFINE_GUID(CLSID_CCompressPPMDEncoder,
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
PROG = Rar29.dll
|
||||
DEF_FILE = ../Codec.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -DSILENT -DNOCRYPT -DNOVOLUME
|
||||
LIBS = $(LIBS) oleaut32.lib
|
||||
|
||||
RAR29_OBJS = \
|
||||
@@ -46,7 +46,7 @@ OBJS = \
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
COMPL_SPEC = $(CPP) $(CFLAGS_O2) -DSILENT -DNOCRYPT -DNOVOLUME $**
|
||||
COMPL_SPEC = $(CPP) $(CFLAGS_O2) $**
|
||||
|
||||
$(RAR29_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
|
||||
@@ -21,12 +21,28 @@ DEFINE_GUID(CLSID_CCrypto7zAESDecoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,10 +114,8 @@ void CApp::CreateOnePanel(int panelIndex, const UString &mainPath)
|
||||
UString path;
|
||||
if (mainPath.IsEmpty())
|
||||
{
|
||||
CSysString sysPath;
|
||||
if (!::ReadPanelPath(panelIndex, sysPath))
|
||||
sysPath.Empty();
|
||||
path = GetUnicodeString(sysPath);
|
||||
if (!::ReadPanelPath(panelIndex, path))
|
||||
path.Empty();
|
||||
}
|
||||
else
|
||||
path = mainPath;
|
||||
@@ -165,8 +163,7 @@ struct CButtonInfo
|
||||
UINT Bitmap2ResID;
|
||||
UINT StringResID;
|
||||
UINT32 LangID;
|
||||
CSysString GetText()const
|
||||
{ return LangLoadString(StringResID, LangID); };
|
||||
UString GetText()const { return LangString(StringResID, LangID); };
|
||||
};
|
||||
|
||||
static CButtonInfo g_StandardButtons[] =
|
||||
@@ -184,7 +181,7 @@ static CButtonInfo g_ArchiveButtons[] =
|
||||
{ kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402}
|
||||
};
|
||||
|
||||
bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, CSysString &s)
|
||||
bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, UString &s)
|
||||
{
|
||||
for (int i = 0; i < numButtons; i++)
|
||||
{
|
||||
@@ -192,19 +189,19 @@ bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, CSysS
|
||||
if (b.commandID == commandID)
|
||||
{
|
||||
s = b.GetText();
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetButtonText(UINT32 commandID, CSysString &s)
|
||||
void SetButtonText(UINT32 commandID, UString &s)
|
||||
{
|
||||
if (SetButtonText(commandID, g_StandardButtons, sizeof(g_StandardButtons) /
|
||||
sizeof(g_StandardButtons[0]), s))
|
||||
if (SetButtonText(commandID, g_StandardButtons,
|
||||
sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s))
|
||||
return;
|
||||
SetButtonText(commandID, g_ArchiveButtons, sizeof(g_StandardButtons) /
|
||||
sizeof(g_ArchiveButtons[0]), s);
|
||||
SetButtonText(commandID, g_ArchiveButtons,
|
||||
sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s);
|
||||
}
|
||||
|
||||
static void AddButton(
|
||||
@@ -223,10 +220,10 @@ static void AddButton(
|
||||
;
|
||||
but.dwData = 0;
|
||||
|
||||
CSysString s = butInfo.GetText();
|
||||
UString s = butInfo.GetText();
|
||||
but.iString = 0;
|
||||
if (showText)
|
||||
but.iString = (INT_PTR )(LPCTSTR)s;
|
||||
but.iString = (INT_PTR)(LPCWSTR)s;
|
||||
|
||||
but.iBitmap = imageList.GetImageCount();
|
||||
HBITMAP b = ::LoadBitmap(g_hInstance,
|
||||
@@ -238,7 +235,11 @@ static void AddButton(
|
||||
imageList.AddMasked(b, RGB(255, 0, 255));
|
||||
::DeleteObject(b);
|
||||
}
|
||||
#ifdef _UNICODE
|
||||
toolBar.AddButton(1, &but);
|
||||
#else
|
||||
toolBar.AddButtonW(1, &but);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar)
|
||||
@@ -402,7 +403,7 @@ void CApp::Save()
|
||||
path = panel._currentFolderPrefix;
|
||||
else
|
||||
path = GetFolderPath(panel._parentFolders[0].ParentFolder);
|
||||
SavePanelPath(i, GetSystemString(path));
|
||||
SavePanelPath(i, path);
|
||||
listMode.Panels[i] = panel.GetListViewMode();
|
||||
}
|
||||
SaveListMode(listMode);
|
||||
@@ -473,7 +474,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
|
||||
if (!srcPanel.DoesItSupportOperations())
|
||||
{
|
||||
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -511,11 +512,11 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
copyDialog.Value = destPath;
|
||||
|
||||
copyDialog.Title = move ?
|
||||
LangLoadStringW(IDS_MOVE, 0x03020202):
|
||||
LangLoadStringW(IDS_COPY, 0x03020201);
|
||||
LangString(IDS_MOVE, 0x03020202):
|
||||
LangString(IDS_COPY, 0x03020201);
|
||||
copyDialog.Static = move ?
|
||||
LangLoadStringW(IDS_MOVE_TO, 0x03020204):
|
||||
LangLoadStringW(IDS_COPY_TO, 0x03020203);
|
||||
LangString(IDS_MOVE_TO, 0x03020204):
|
||||
LangString(IDS_COPY_TO, 0x03020203);
|
||||
|
||||
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
|
||||
return;
|
||||
@@ -526,7 +527,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
{
|
||||
if (!srcPanel.IsFSFolder())
|
||||
{
|
||||
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
destPath = srcPanel._currentFolderPrefix + destPath;
|
||||
@@ -541,7 +542,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
{
|
||||
if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
|
||||
{
|
||||
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
useDestPanel = true;
|
||||
@@ -556,7 +557,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
NDirectory::CreateComplexDirectory(prefix);
|
||||
if (!CheckFolderPath(prefix))
|
||||
{
|
||||
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -705,7 +706,8 @@ int CApp::GetFocusedPanelIndex() const
|
||||
}
|
||||
*/
|
||||
|
||||
static CSysString g_ToolTipBuffer;
|
||||
static UString g_ToolTipBuffer;
|
||||
static CSysString g_ToolTipBufferSys;
|
||||
|
||||
void CApp::OnNotify(int ctrlID, LPNMHDR pnmh)
|
||||
{
|
||||
@@ -729,8 +731,20 @@ void CApp::OnNotify(int ctrlID, LPNMHDR pnmh)
|
||||
info->hinst = 0;
|
||||
g_ToolTipBuffer.Empty();
|
||||
SetButtonText(info->hdr.idFrom, g_ToolTipBuffer);
|
||||
info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBuffer;
|
||||
g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
|
||||
info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBufferSys;
|
||||
return;
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
if (pnmh->code == TTN_GETDISPINFOW)
|
||||
{
|
||||
LPNMTTDISPINFOW info = (LPNMTTDISPINFOW)pnmh;
|
||||
info->hinst = 0;
|
||||
g_ToolTipBuffer.Empty();
|
||||
SetButtonText(info->hdr.idFrom, g_ToolTipBuffer);
|
||||
info->lpszText = (LPWSTR)(LPCWSTR)g_ToolTipBuffer;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,6 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
// CSysString _directoryPath;
|
||||
// CSysString m_DiskFilePath;
|
||||
// bool _extractMode;
|
||||
UString _currentArchivePath;
|
||||
bool _needWriteArchivePath;
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "Windows/Control/Toolbar.h"
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/COM.h"
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/Security.h"
|
||||
#include "Windows/MemoryLock.h"
|
||||
|
||||
#include "ViewSettings.h"
|
||||
|
||||
@@ -19,6 +22,7 @@
|
||||
|
||||
#include "MyLoadMenu.h"
|
||||
#include "LangUtils.h"
|
||||
#include "RegistryUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -28,6 +32,9 @@ using namespace NWindows;
|
||||
|
||||
#define MENU_HEIGHT 26
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
#endif
|
||||
HINSTANCE g_hInstance;
|
||||
HWND g_HWND;
|
||||
static UString g_MainPath;
|
||||
@@ -39,17 +46,17 @@ int kSplitterRateMax = 1 << 16;
|
||||
|
||||
// bool OnMenuCommand(HWND hWnd, int id);
|
||||
|
||||
static CSysString GetProgramPath()
|
||||
static UString GetProgramPath()
|
||||
{
|
||||
TCHAR fullPath[MAX_PATH + 1];
|
||||
::GetModuleFileName(g_hInstance, fullPath, MAX_PATH);
|
||||
return fullPath;
|
||||
UString s;
|
||||
NDLL::MyGetModuleFileName(g_hInstance, s);
|
||||
return s;
|
||||
}
|
||||
|
||||
CSysString GetProgramFolderPrefix()
|
||||
UString GetProgramFolderPrefix()
|
||||
{
|
||||
CSysString path = GetProgramPath();
|
||||
int pos = path.ReverseFind(TEXT('\\'));
|
||||
UString path = GetProgramPath();
|
||||
int pos = path.ReverseFind(L'\\');
|
||||
return path.Left(pos + 1);
|
||||
}
|
||||
|
||||
@@ -117,12 +124,21 @@ void OnSize(HWND hWnd);
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
// FUNCTION: InitInstance(HANDLE, int)
|
||||
const wchar_t *kWindowClass = L"FM";
|
||||
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
|
||||
// FUNCTION: InitInstance(HANDLE, int)
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
HWND hWnd = NULL;
|
||||
TCHAR windowClass[MAX_LOADSTRING]; // The window class name
|
||||
lstrcpy(windowClass, TEXT("FM"));
|
||||
CWindow wnd;
|
||||
|
||||
g_hInstance = hInstance;
|
||||
|
||||
@@ -131,7 +147,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
// LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING);
|
||||
|
||||
// LoadString(hInstance, IDS_APP_TITLE, title, MAX_LOADSTRING);
|
||||
UString title = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
|
||||
UString title = LangString(IDS_APP_TITLE, 0x03000000);
|
||||
|
||||
/*
|
||||
//If it is already running, then focus on the window
|
||||
@@ -143,7 +159,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
}
|
||||
*/
|
||||
|
||||
WNDCLASS wc;
|
||||
WNDCLASSW wc;
|
||||
|
||||
// wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.style = 0;
|
||||
@@ -158,10 +174,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
// wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
|
||||
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
|
||||
|
||||
wc.lpszMenuName = MAKEINTRESOURCE(IDM_MENU);
|
||||
wc.lpszClassName = windowClass;
|
||||
wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
|
||||
wc.lpszClassName = kWindowClass;
|
||||
|
||||
RegisterClass(&wc);
|
||||
MyRegisterClass(&wc);
|
||||
|
||||
// RECT rect;
|
||||
// GetClientRect(hWnd, &rect);
|
||||
@@ -200,17 +216,14 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
g_App.NumPanels = numPanels;
|
||||
g_App.LastFocusedPanel = currentPanel;
|
||||
|
||||
hWnd = CreateWindow(windowClass, GetSystemString(title), style,
|
||||
x, y, xSize, ySize, NULL, NULL, hInstance, NULL);
|
||||
if (!hWnd)
|
||||
return FALSE;
|
||||
g_HWND = hWnd;
|
||||
|
||||
CWindow window(hWnd);
|
||||
if (!wnd.Create(kWindowClass, title, style,
|
||||
x, y, xSize, ySize, NULL, NULL, hInstance, NULL))
|
||||
return FALSE;
|
||||
g_HWND = (HWND)wnd;
|
||||
|
||||
WINDOWPLACEMENT placement;
|
||||
placement.length = sizeof(placement);
|
||||
if (window.GetPlacement(&placement))
|
||||
if (wnd.GetPlacement(&placement))
|
||||
{
|
||||
if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
|
||||
nCmdShow == SW_SHOWDEFAULT)
|
||||
@@ -224,11 +237,11 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
placement.showCmd = nCmdShow;
|
||||
if (windowPosIsRead)
|
||||
placement.rcNormalPosition = rect;
|
||||
window.SetPlacement(&placement);
|
||||
wnd.SetPlacement(&placement);
|
||||
// window.Show(nCmdShow);
|
||||
}
|
||||
else
|
||||
window.Show(nCmdShow);
|
||||
wnd.Show(nCmdShow);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -295,11 +308,65 @@ DWORD GetDllVersion(LPCTSTR lpszDllName)
|
||||
|
||||
DWORD g_ComCtl32Version;
|
||||
|
||||
/*
|
||||
#ifndef _WIN64
|
||||
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
|
||||
|
||||
static bool IsWow64()
|
||||
{
|
||||
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
|
||||
GetModuleHandle("kernel32"), "IsWow64Process");
|
||||
if (fnIsWow64Process == NULL)
|
||||
return false;
|
||||
BOOL isWow;
|
||||
if (!fnIsWow64Process(GetCurrentProcess(),&isWow))
|
||||
return false;
|
||||
return isWow != FALSE;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
bool IsLargePageSupported()
|
||||
{
|
||||
#ifdef _WIN64
|
||||
return true;
|
||||
#else
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 5)
|
||||
return false;
|
||||
if (versionInfo.dwMajorVersion > 5)
|
||||
return true;
|
||||
if (versionInfo.dwMinorVersion < 1)
|
||||
return false;
|
||||
if (versionInfo.dwMinorVersion > 1)
|
||||
return true;
|
||||
// return IsWow64();
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SetMemoryLock()
|
||||
{
|
||||
if (!IsLargePageSupported())
|
||||
return;
|
||||
// if (ReadLockMemoryAdd())
|
||||
NSecurity::AddLockMemoryPrivilege();
|
||||
|
||||
if (ReadLockMemoryEnable())
|
||||
NSecurity::EnableLockMemoryPrivilege();
|
||||
}
|
||||
|
||||
int WINAPI WinMain( HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
InitCommonControls();
|
||||
|
||||
g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
|
||||
@@ -324,6 +391,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
||||
// MessageBoxW(0, paramString, L"", 0);
|
||||
}
|
||||
|
||||
SetMemoryLock();
|
||||
|
||||
MSG msg;
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
@@ -331,19 +399,34 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
||||
|
||||
MyLoadMenu(g_HWND);
|
||||
|
||||
HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
if (!TranslateAccelerator(g_HWND, hAccels, &msg))
|
||||
{
|
||||
// if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
|
||||
// if (!IsDialogMessage(g_Hwnd, &msg))
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
{
|
||||
HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
|
||||
while (GetMessageW(&msg, NULL, 0, 0))
|
||||
{
|
||||
if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
|
||||
{
|
||||
// if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
|
||||
// if (!IsDialogMessage(g_Hwnd, &msg))
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_HWND = 0;
|
||||
OleUninitialize();
|
||||
@@ -578,7 +661,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
*/
|
||||
}
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||
else
|
||||
#endif
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
}
|
||||
|
||||
void OnSize(HWND hWnd)
|
||||
|
||||
@@ -259,6 +259,14 @@ SOURCE=.\NetFolder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PhysDriveFolder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PhysDriveFolder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\RootFolder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -682,6 +690,14 @@ SOURCE=..\..\Windows\Control\Window2.h
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\CommonDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\CommonDialog.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\Defs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -706,6 +722,14 @@ SOURCE=..\..\Windows\Error.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\FileDevice.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\FileDevice.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\FileDir.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -758,6 +782,18 @@ SOURCE=..\..\Windows\Memory.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\MemoryLock.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\MemoryLock.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\Menu.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\Menu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -806,6 +842,14 @@ SOURCE=..\..\Windows\ResourceString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\Security.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\Security.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Windows\Shell.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "SysIconUtils.h"
|
||||
#include "FSFolder.h"
|
||||
#include "PhysDriveFolder.h"
|
||||
#include "LangUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
@@ -44,30 +45,26 @@ static const wchar_t *kDriveTypes[] =
|
||||
L"RAM disk"
|
||||
};
|
||||
|
||||
static inline UINT GetCurrentFileCodePage()
|
||||
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
|
||||
STDMETHODIMP CFSDrives::LoadItems()
|
||||
{
|
||||
UINT fileCodePage = GetCurrentFileCodePage();
|
||||
_drives.Clear();
|
||||
|
||||
CSysStringVector driveStrings;
|
||||
UStringVector driveStrings;
|
||||
MyGetLogicalDriveStrings(driveStrings);
|
||||
for (int i = 0; i < driveStrings.Size(); i++)
|
||||
{
|
||||
CDriveInfo driveInfo;
|
||||
|
||||
const CSysString &driveName = driveStrings[i];
|
||||
const UString &driveName = driveStrings[i];
|
||||
|
||||
driveInfo.FullSystemName = GetUnicodeString(driveName, fileCodePage);
|
||||
driveInfo.FullSystemName = driveName;
|
||||
|
||||
driveInfo.Name = driveInfo.FullSystemName.Left(
|
||||
driveInfo.FullSystemName.Length() - 1);
|
||||
driveInfo.ClusterSize = 0;
|
||||
driveInfo.DriveSize = 0;
|
||||
driveInfo.FreeSpace = 0;
|
||||
UINT driveType = ::GetDriveType(driveName);
|
||||
UINT driveType = NFile::NSystem::MyGetDriveType(driveName);
|
||||
if (driveType < sizeof(kDriveTypes) / sizeof(kDriveTypes[0]))
|
||||
{
|
||||
driveInfo.Type = kDriveTypes[driveType];
|
||||
@@ -87,14 +84,14 @@ STDMETHODIMP CFSDrives::LoadItems()
|
||||
}
|
||||
if (needRead)
|
||||
{
|
||||
CSysString volumeName, fileSystemName;
|
||||
UString volumeName, fileSystemName;
|
||||
DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
|
||||
NFile::NSystem::MyGetVolumeInformation(driveName,
|
||||
volumeName,
|
||||
&volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
|
||||
fileSystemName);
|
||||
driveInfo.VolumeName = GetUnicodeString(volumeName, fileCodePage);
|
||||
driveInfo.FileSystemName = GetUnicodeString(fileSystemName, fileCodePage);
|
||||
driveInfo.VolumeName = volumeName;
|
||||
driveInfo.FileSystemName = fileSystemName;
|
||||
|
||||
NFile::NSystem::MyGetDiskFreeSpace(driveName,
|
||||
driveInfo.ClusterSize, driveInfo.DriveSize, driveInfo.FreeSpace);
|
||||
@@ -105,15 +102,15 @@ STDMETHODIMP CFSDrives::LoadItems()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetNumberOfItems(UINT32 *numItems)
|
||||
STDMETHODIMP CFSDrives::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _drives.Size();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
if (itemIndex >= (UINT32)_drives.Size())
|
||||
if (itemIndex >= (UInt32)_drives.Size())
|
||||
return E_INVALIDARG;
|
||||
NCOM::CPropVariant propVariant;
|
||||
const CDriveInfo &driveInfo = _drives[itemIndex];
|
||||
@@ -161,12 +158,22 @@ HRESULT CFSDrives::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultF
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
|
||||
STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
if (index >= (UINT32)_drives.Size())
|
||||
if (index >= (UInt32)_drives.Size())
|
||||
return E_INVALIDARG;
|
||||
return BindToFolderSpec(_drives[index].FullSystemName, resultFolder);
|
||||
const CDriveInfo &driveInfo = _drives[index];
|
||||
if (_volumeMode)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
|
||||
CMyComPtr<IFolderFolder> subFolder = folderSpec;
|
||||
RINOK(folderSpec->Init(driveInfo.Name));
|
||||
*resultFolder = subFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
return BindToFolderSpec(driveInfo.FullSystemName, resultFolder);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
@@ -185,13 +192,13 @@ STDMETHODIMP CFSDrives::GetName(BSTR *name)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetNumberOfProperties(UINT32 *numProperties)
|
||||
STDMETHODIMP CFSDrives::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetPropertyInfo(UINT32 index,
|
||||
STDMETHODIMP CFSDrives::GetPropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
@@ -213,18 +220,17 @@ STDMETHODIMP CFSDrives::GetTypeID(BSTR *name)
|
||||
|
||||
STDMETHODIMP CFSDrives::GetPath(BSTR *path)
|
||||
{
|
||||
CMyComBSTR temp = (LangLoadStringW(IDS_COMPUTER, 0x03020300)) +
|
||||
UString(L'\\');
|
||||
CMyComBSTR temp = LangString(IDS_COMPUTER, 0x03020300) + UString(L'\\');
|
||||
*path = temp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSDrives::GetSystemIconIndex(UINT32 index, INT32 *iconIndex)
|
||||
STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
|
||||
{
|
||||
*iconIndex = 0;
|
||||
const CDriveInfo &driveInfo = _drives[index];
|
||||
int iconIndexTemp;
|
||||
if (GetRealIconIndex(GetSystemString(driveInfo.FullSystemName), 0, iconIndexTemp) != 0)
|
||||
if (GetRealIconIndex(driveInfo.FullSystemName, 0, iconIndexTemp) != 0)
|
||||
{
|
||||
*iconIndex = iconIndexTemp;
|
||||
return S_OK;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define __FSDRIVES_H
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/Types.h"
|
||||
#include "Common/MyCom.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
@@ -15,9 +16,9 @@ struct CDriveInfo
|
||||
UString Name;
|
||||
UString FullSystemName;
|
||||
bool KnownSizes;
|
||||
UINT64 DriveSize;
|
||||
UINT64 FreeSpace;
|
||||
UINT64 ClusterSize;
|
||||
UInt64 DriveSize;
|
||||
UInt64 FreeSpace;
|
||||
UInt64 ClusterSize;
|
||||
UString Type;
|
||||
UString VolumeName;
|
||||
UString FileSystemName;
|
||||
@@ -40,25 +41,26 @@ public:
|
||||
)
|
||||
|
||||
STDMETHOD(LoadItems)();
|
||||
STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
|
||||
STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
|
||||
STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetName)(BSTR *name);
|
||||
|
||||
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UINT32 index,
|
||||
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
STDMETHOD(GetTypeID)(BSTR *name);
|
||||
STDMETHOD(GetPath)(BSTR *path);
|
||||
STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex);
|
||||
STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
|
||||
|
||||
private:
|
||||
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
CObjectVector<CDriveInfo> _drives;
|
||||
bool _volumeMode;
|
||||
public:
|
||||
void Init() {}
|
||||
void Init() { _volumeMode = false;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,14 +37,10 @@ static STATPROPSTG kProperties[] =
|
||||
{ NULL, kpidComment, VT_BSTR}
|
||||
};
|
||||
|
||||
static inline UINT GetCurrentFileCodePage()
|
||||
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
|
||||
HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
|
||||
{
|
||||
_parentFolder = parentFolder;
|
||||
_path = path;
|
||||
_fileCodePage = GetCurrentFileCodePage();
|
||||
|
||||
if (_findChangeNotification.FindFirst(_path, false,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME |
|
||||
@@ -70,7 +66,7 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT GetFolderSize(const UString &path, UINT64 &size, IProgress *progress)
|
||||
static HRESULT GetFolderSize(const UString &path, UInt64 &size, IProgress *progress)
|
||||
{
|
||||
RINOK(progress->SetCompleted(NULL));
|
||||
size = 0;
|
||||
@@ -80,7 +76,7 @@ static HRESULT GetFolderSize(const UString &path, UINT64 &size, IProgress *progr
|
||||
{
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
UINT64 subSize;
|
||||
UInt64 subSize;
|
||||
RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name,
|
||||
subSize, progress));
|
||||
size += subSize;
|
||||
@@ -137,7 +133,7 @@ bool CFSFolder::LoadComments()
|
||||
return false;
|
||||
AString s;
|
||||
char *p = s.GetBuffer((size_t)length + 1);
|
||||
UINT32 processedSize;
|
||||
UInt32 processedSize;
|
||||
file.Read(p, (UInt32)length, processedSize);
|
||||
p[length] = 0;
|
||||
s.ReleaseBuffer();
|
||||
@@ -168,7 +164,7 @@ bool CFSFolder::SaveComments()
|
||||
_comments.SaveToString(unicodeString);
|
||||
AString utfString;
|
||||
ConvertUnicodeToUTF8(unicodeString, utfString);
|
||||
UINT32 processedSize;
|
||||
UInt32 processedSize;
|
||||
if (!IsAscii(unicodeString))
|
||||
{
|
||||
Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A };
|
||||
@@ -180,28 +176,28 @@ bool CFSFolder::SaveComments()
|
||||
return true;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetNumberOfItems(UINT32 *numItems)
|
||||
STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _files.Size();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UINT32 *aNumSubFolders)
|
||||
STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
|
||||
{
|
||||
UINT32 aNumSubFoldersLoc = 0;
|
||||
UInt32 numSubFoldersLoc = 0;
|
||||
for (int i = 0; i < _files.Size(); i++)
|
||||
if (_files[i].IsDirectory())
|
||||
aNumSubFoldersLoc++;
|
||||
*aNumSubFolders = aNumSubFoldersLoc;
|
||||
numSubFoldersLoc++;
|
||||
*numSubFolders = numSubFoldersLoc;
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (itemIndex >= (UINT32)_files.Size())
|
||||
if (itemIndex >= (UInt32)_files.Size())
|
||||
return E_INVALIDARG;
|
||||
CFileInfoEx &fileInfo = _files[itemIndex];
|
||||
switch(propID)
|
||||
@@ -210,7 +206,7 @@ STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT
|
||||
propVariant = fileInfo.IsDirectory();
|
||||
break;
|
||||
case kpidName:
|
||||
propVariant = GetUnicodeString(fileInfo.Name);
|
||||
propVariant = fileInfo.Name;
|
||||
break;
|
||||
case kpidSize:
|
||||
propVariant = fileInfo.Size;
|
||||
@@ -227,7 +223,7 @@ STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT
|
||||
propVariant = fileInfo.CompressedSize;
|
||||
break;
|
||||
case kpidAttributes:
|
||||
propVariant = (UINT32)fileInfo.Attributes;
|
||||
propVariant = (UInt32)fileInfo.Attributes;
|
||||
break;
|
||||
case kpidCreationTime:
|
||||
propVariant = fileInfo.CreationTime;
|
||||
@@ -241,7 +237,7 @@ STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT
|
||||
case kpidComment:
|
||||
LoadComments();
|
||||
UString comment;
|
||||
if (_comments.GetValue(GetUnicodeString(fileInfo.Name), comment))
|
||||
if (_comments.GetValue(fileInfo.Name, comment))
|
||||
propVariant = comment;
|
||||
break;
|
||||
}
|
||||
@@ -260,7 +256,7 @@ HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultF
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CFSFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
|
||||
STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
const NFind::CFileInfoW &fileInfo = _files[index];
|
||||
@@ -285,11 +281,11 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
}
|
||||
if (_path.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
int pos = _path.ReverseFind(TEXT('\\'));
|
||||
int pos = _path.ReverseFind(L'\\');
|
||||
if (pos < 0 || pos != _path.Length() - 1)
|
||||
return E_FAIL;
|
||||
UString parentPath = _path.Left(pos);
|
||||
pos = parentPath.ReverseFind(TEXT('\\'));
|
||||
pos = parentPath.ReverseFind(L'\\');
|
||||
if (pos < 0)
|
||||
{
|
||||
parentPath.Empty();
|
||||
@@ -301,14 +297,14 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
}
|
||||
UString parentPathReduced = parentPath.Left(pos);
|
||||
parentPath = parentPath.Left(pos + 1);
|
||||
pos = parentPathReduced.ReverseFind(TEXT('\\'));
|
||||
pos = parentPathReduced.ReverseFind(L'\\');
|
||||
if (pos == 1)
|
||||
{
|
||||
if (parentPath[0] != TEXT('\\'))
|
||||
if (parentPath[0] != L'\\')
|
||||
return E_FAIL;
|
||||
CNetFolder *netFolderSpec = new CNetFolder;
|
||||
CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
|
||||
netFolderSpec->Init(GetUnicodeString(parentPath));
|
||||
netFolderSpec->Init(parentPath);
|
||||
*resultFolder = netFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
@@ -329,13 +325,13 @@ STDMETHODIMP CFSFolder::GetName(BSTR *name)
|
||||
*/
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetNumberOfProperties(UINT32 *numProperties)
|
||||
STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetPropertyInfo(UINT32 index,
|
||||
STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
@@ -357,7 +353,7 @@ STDMETHODIMP CFSFolder::GetTypeID(BSTR *name)
|
||||
|
||||
STDMETHODIMP CFSFolder::GetPath(BSTR *path)
|
||||
{
|
||||
CMyComBSTR temp = GetUnicodeString(_path, _fileCodePage);
|
||||
CMyComBSTR temp = _path;
|
||||
*path = temp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
@@ -397,7 +393,7 @@ STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CFSFolder::GetItemFullSize(int index, UINT64 &size, IProgress *progress)
|
||||
HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
|
||||
{
|
||||
const CFileInfoW &fileInfo = _files[index];
|
||||
if (fileInfo.IsDirectory())
|
||||
@@ -408,13 +404,13 @@ HRESULT CFSFolder::GetItemFullSize(int index, UINT64 &size, IProgress *progress)
|
||||
CMyComPtr<IFolderReload> aFolderReload;
|
||||
subFolder.QueryInterface(&aFolderReload);
|
||||
aFolderReload->Reload();
|
||||
UINT32 numItems;
|
||||
UInt32 numItems;
|
||||
RINOK(subFolder->GetNumberOfItems(&numItems));
|
||||
CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize;
|
||||
subFolder.QueryInterface(&aGetItemFullSize);
|
||||
for (UINT32 i = 0; i < numItems; i++)
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
UINT64 size;
|
||||
UInt64 size;
|
||||
RINOK(aGetItemFullSize->GetItemFullSize(i, &size));
|
||||
*totalSize += size;
|
||||
}
|
||||
@@ -425,12 +421,12 @@ HRESULT CFSFolder::GetItemFullSize(int index, UINT64 &size, IProgress *progress)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetItemFullSize(UINT32 index, PROPVARIANT *value, IProgress *progress)
|
||||
STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (index >= (UINT32)_files.Size())
|
||||
if (index >= (UInt32)_files.Size())
|
||||
return E_INVALIDARG;
|
||||
UINT64 size = 0;
|
||||
UInt64 size = 0;
|
||||
HRESULT result = GetItemFullSize(index, size, progress);
|
||||
propVariant = size;
|
||||
propVariant.Detach(value);
|
||||
@@ -478,7 +474,7 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress *progress)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::Rename(UINT32 index, const wchar_t *newName, IProgress *progress)
|
||||
STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress)
|
||||
{
|
||||
const CFileInfoW &fileInfo = _files[index];
|
||||
if (!NDirectory::MyMoveFile(_path + fileInfo.Name, _path + newName))
|
||||
@@ -486,11 +482,11 @@ STDMETHODIMP CFSFolder::Rename(UINT32 index, const wchar_t *newName, IProgress *
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::Delete(const UINT32 *indices, UINT32 numItems,
|
||||
STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,
|
||||
IProgress *progress)
|
||||
{
|
||||
RINOK(progress->SetTotal(numItems));
|
||||
for (UINT32 i = 0; i < numItems; i++)
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
int index = indices[i];
|
||||
const CFileInfoW &fileInfo = _files[indices[i]];
|
||||
@@ -502,57 +498,23 @@ STDMETHODIMP CFSFolder::Delete(const UINT32 *indices, UINT32 numItems,
|
||||
result = NDirectory::DeleteFileAlways(fullPath);
|
||||
if (!result)
|
||||
return GetLastError();
|
||||
UINT64 completed = i;
|
||||
UInt64 completed = i;
|
||||
RINOK(progress->SetCompleted(&completed));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
STDMETHODIMP CFSFolder::DeleteToRecycleBin(const UINT32 *indices, UINT32 numItems,
|
||||
IProgress *progress)
|
||||
{
|
||||
RINOK(progress->SetTotal(numItems));
|
||||
for (UINT32 i = 0; i < numItems; i++)
|
||||
{
|
||||
int index = indices[i];
|
||||
const CFileInfoW &fileInfo = _files[indices[i]];
|
||||
const UString fullPath = _path + fileInfo.Name;
|
||||
CBuffer<TCHAR> buffer;
|
||||
const CSysString fullPathSys = GetSystemString(fullPath);
|
||||
buffer.SetCapacity(fullPathSys.Length() + 2);
|
||||
memmove((TCHAR *)buffer, (const TCHAR *)fullPathSys, (fullPathSys.Length() + 1) * sizeof(TCHAR));
|
||||
((TCHAR *)buffer)[fullPathSys.Length() + 1] = 0;
|
||||
SHFILEOPSTRUCT fo;
|
||||
fo.hwnd = 0;
|
||||
fo.wFunc = FO_DELETE;
|
||||
fo.pFrom = (const TCHAR *)buffer;
|
||||
fo.pTo = 0;
|
||||
fo.fFlags = FOF_ALLOWUNDO;
|
||||
fo.fAnyOperationsAborted = FALSE;
|
||||
fo.hNameMappings = 0;
|
||||
fo.lpszProgressTitle = 0;
|
||||
int res = SHFileOperation(&fo);
|
||||
if (fo.fAnyOperationsAborted)
|
||||
return E_ABORT;
|
||||
UINT64 completed = i;
|
||||
RINOK(progress->SetCompleted(&completed));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
STDMETHODIMP CFSFolder::SetProperty(UINT32 index, PROPID propID,
|
||||
STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
|
||||
const PROPVARIANT *value, IProgress *progress)
|
||||
{
|
||||
if (index >= (UINT32)_files.Size())
|
||||
if (index >= (UInt32)_files.Size())
|
||||
return E_INVALIDARG;
|
||||
CFileInfoEx &fileInfo = _files[index];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidComment:
|
||||
{
|
||||
UString filename = GetUnicodeString(fileInfo.Name);
|
||||
UString filename = fileInfo.Name;
|
||||
filename.Trim();
|
||||
if (value->vt == VT_EMPTY)
|
||||
_comments.DeletePair(filename);
|
||||
@@ -579,15 +541,14 @@ STDMETHODIMP CFSFolder::SetProperty(UINT32 index, PROPID propID,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetSystemIconIndex(UINT32 index, INT32 *iconIndex)
|
||||
STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
|
||||
{
|
||||
if (index >= (UINT32)_files.Size())
|
||||
if (index >= (UInt32)_files.Size())
|
||||
return E_INVALIDARG;
|
||||
const CFileInfoEx &fileInfo = _files[index];
|
||||
*iconIndex = 0;
|
||||
int iconIndexTemp;
|
||||
if (GetRealIconIndex(GetSystemString(_path + fileInfo.Name),
|
||||
fileInfo.Attributes, iconIndexTemp) != 0)
|
||||
if (GetRealIconIndex(_path + fileInfo.Name, fileInfo.Attributes, iconIndexTemp) != 0)
|
||||
{
|
||||
*iconIndex = iconIndexTemp;
|
||||
return S_OK;
|
||||
|
||||
@@ -17,7 +17,7 @@ class CFSFolder;
|
||||
struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
|
||||
{
|
||||
bool CompressedSizeIsDefined;
|
||||
UINT64 CompressedSize;
|
||||
UInt64 CompressedSize;
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class CFSFolder:
|
||||
public IFolderGetSystemIconIndex,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
UINT64 GetSizeOfItem(int anIndex) const;
|
||||
UInt64 GetSizeOfItem(int anIndex) const;
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IEnumProperties)
|
||||
@@ -51,41 +51,38 @@ public:
|
||||
|
||||
|
||||
STDMETHOD(LoadItems)();
|
||||
STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
|
||||
STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
|
||||
STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetName)(BSTR *name);
|
||||
|
||||
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UINT32 index,
|
||||
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
STDMETHOD(GetTypeID)(BSTR *name);
|
||||
STDMETHOD(GetPath)(BSTR *path);
|
||||
STDMETHOD(WasChanged)(INT32 *wasChanged);
|
||||
STDMETHOD(Clone)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetItemFullSize)(UINT32 index, PROPVARIANT *value, IProgress *progress);
|
||||
STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
|
||||
|
||||
// IFolderOperations
|
||||
|
||||
STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress);
|
||||
STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress);
|
||||
STDMETHOD(Rename)(UINT32 index, const wchar_t *newName, IProgress *progress);
|
||||
STDMETHOD(Delete)(const UINT32 *indices, UINT32 numItems, IProgress *progress);
|
||||
STDMETHOD(CopyTo)(const UINT32 *indices, UINT32 numItems,
|
||||
STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress);
|
||||
STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress);
|
||||
STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback);
|
||||
STDMETHOD(MoveTo)(const UINT32 *indices, UINT32 numItems,
|
||||
STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback);
|
||||
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
|
||||
const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress);
|
||||
STDMETHOD(SetProperty)(UINT32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
|
||||
STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex);
|
||||
|
||||
// STDMETHOD(DeleteToRecycleBin)(const UINT32 *indices, UINT32 numItems, IProgress *progress);
|
||||
const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress);
|
||||
STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
|
||||
STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
|
||||
|
||||
private:
|
||||
UINT _fileCodePage;
|
||||
UString _path;
|
||||
CObjectVector<CFileInfoEx> _files;
|
||||
CMyComPtr<IFolderFolder> _parentFolder;
|
||||
@@ -97,7 +94,7 @@ private:
|
||||
|
||||
NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
|
||||
|
||||
HRESULT GetItemFullSize(int index, UINT64 &size, IProgress *progress);
|
||||
HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
|
||||
HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
|
||||
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
|
||||
|
||||
@@ -16,17 +16,9 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
static inline UINT GetCurrentCodePage()
|
||||
{ return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
static bool IsItWindows2000orHigher()
|
||||
{
|
||||
@@ -81,47 +73,48 @@ typedef BOOL (WINAPI * CopyFileExPointerW)(
|
||||
IN DWORD dwCopyFlags
|
||||
);
|
||||
|
||||
#ifndef _UNICODE
|
||||
static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
static CSysString GetSysPath(LPCWSTR sysPath)
|
||||
{ return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
|
||||
#endif
|
||||
|
||||
static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile,
|
||||
IProgress *progress, UINT64 &completedSize)
|
||||
{
|
||||
// if (IsItWindowsNT())
|
||||
// {
|
||||
CProgressInfo progressInfo;
|
||||
progressInfo.Progress = progress;
|
||||
progressInfo.StartPos = completedSize;
|
||||
BOOL CancelFlag = FALSE;
|
||||
CProgressInfo progressInfo;
|
||||
progressInfo.Progress = progress;
|
||||
progressInfo.StartPos = completedSize;
|
||||
BOOL CancelFlag = FALSE;
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
#endif
|
||||
{
|
||||
CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
|
||||
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
|
||||
::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"),
|
||||
"CopyFileExW");
|
||||
if (copyFunctionW != 0)
|
||||
{
|
||||
if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
|
||||
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
|
||||
return true;
|
||||
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (copyFunctionW == 0)
|
||||
return false;
|
||||
return BOOLToBool(copyFunctionW(existingFile, newFile, CopyProgressRoutine,
|
||||
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS));
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
else
|
||||
{
|
||||
CopyFileExPointer copyFunction = (CopyFileExPointer)
|
||||
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
|
||||
::GetProcAddress(::GetModuleHandleA("kernel32.dll"),
|
||||
"CopyFileExA");
|
||||
UINT codePage = GetCurrentCodePage();
|
||||
if (copyFunction != 0)
|
||||
{
|
||||
if (copyFunction(
|
||||
UnicodeStringToMultiByte(existingFile, codePage),
|
||||
UnicodeStringToMultiByte(newFile, codePage),
|
||||
CopyProgressRoutine,
|
||||
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
|
||||
if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
|
||||
CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
|
||||
return true;
|
||||
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return false;
|
||||
}
|
||||
// }
|
||||
return BOOLToBool(::CopyFile(
|
||||
GetSystemString(existingFile, codePage),
|
||||
GetSystemString(newFile, codePage),
|
||||
TRUE));
|
||||
return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
|
||||
@@ -167,14 +160,12 @@ static HRESULT MyCopyFile(
|
||||
const CFileInfoW &srcFileInfo,
|
||||
const UString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UINT fileCodePage,
|
||||
UINT64 &completedSize)
|
||||
{
|
||||
UString destPath = destPathSpec;
|
||||
if (destPath.CompareNoCase(srcPath) == 0)
|
||||
{
|
||||
UString message = UString(L"can not move file \'") +
|
||||
GetUnicodeString(destPath, fileCodePage) + UString(L"\' onto itself");
|
||||
UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
@@ -182,10 +173,10 @@ static HRESULT MyCopyFile(
|
||||
INT32 writeAskResult;
|
||||
CMyComBSTR destPathResult;
|
||||
RINOK(callback->AskWrite(
|
||||
GetUnicodeString(srcPath, fileCodePage),
|
||||
srcPath,
|
||||
BoolToInt(false),
|
||||
&srcFileInfo.LastWriteTime, &srcFileInfo.Size,
|
||||
GetUnicodeString(destPath, fileCodePage),
|
||||
destPath,
|
||||
&destPathResult,
|
||||
&writeAskResult));
|
||||
if (IntToBool(writeAskResult))
|
||||
@@ -194,9 +185,9 @@ static HRESULT MyCopyFile(
|
||||
RINOK(callback->SetCurrentFilePath(srcPath));
|
||||
if (!::MyCopyFile(srcPath, destPathNew, callback, completedSize))
|
||||
{
|
||||
UString message = GetUnicodeString(NError::MyFormatMessage(GetLastError())) +
|
||||
UString message = NError::MyFormatMessageW(GetLastError()) +
|
||||
UString(L" \'") +
|
||||
GetUnicodeString(destPathNew, fileCodePage)+
|
||||
UString(destPathNew) +
|
||||
UString(L"\'");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
@@ -210,7 +201,6 @@ static HRESULT CopyFolder(
|
||||
const UString &srcPath,
|
||||
const UString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UINT fileCodePage,
|
||||
UINT64 &completedSize)
|
||||
{
|
||||
RINOK(callback->SetCompleted(&completedSize));
|
||||
@@ -222,7 +212,7 @@ static HRESULT CopyFolder(
|
||||
if (destPath.Length() == len || destPath[len] == L'\\')
|
||||
{
|
||||
UString message = UString(L"can not copy folder \'") +
|
||||
GetUnicodeString(destPath, fileCodePage) + UString(L"\' onto itself");
|
||||
destPath + UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
@@ -230,8 +220,7 @@ static HRESULT CopyFolder(
|
||||
|
||||
if (!NDirectory::CreateComplexDirectory(destPath))
|
||||
{
|
||||
UString message = UString(L"can not create folder ") +
|
||||
GetUnicodeString(destPath, fileCodePage);
|
||||
UString message = UString(L"can not create folder ") + destPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
@@ -243,25 +232,23 @@ static HRESULT CopyFolder(
|
||||
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(CopyFolder(srcPath2, destPath2,
|
||||
callback, fileCodePage, completedSize));
|
||||
RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(MyCopyFile(srcPath2, fileInfo, destPath2,
|
||||
callback, fileCodePage, completedSize));
|
||||
RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
|
||||
STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback)
|
||||
{
|
||||
if (numItems == 0)
|
||||
return S_OK;
|
||||
UINT64 totalSize = 0;
|
||||
UINT32 i;
|
||||
UInt32 i;
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
int index = indices[i];
|
||||
@@ -285,7 +272,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
|
||||
/*
|
||||
// doesn't work in network
|
||||
else
|
||||
if (!NDirectory::CreateComplexDirectory(GetSystemString(destPath, _fileCodePage)))
|
||||
if (!NDirectory::CreateComplexDirectory(destPath)))
|
||||
{
|
||||
DWORD lastError = ::GetLastError();
|
||||
UString message = UString(L"can not create folder ") +
|
||||
@@ -306,13 +293,11 @@ STDMETHODIMP CFSFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
|
||||
UString srcPath = _path + fileInfo.Name;
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(CopyFolder(srcPath, destPath2, callback,
|
||||
_fileCodePage, completedSize));
|
||||
RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(MyCopyFile(srcPath, fileInfo, destPath2,
|
||||
callback, _fileCodePage, completedSize));
|
||||
RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
@@ -326,14 +311,13 @@ HRESULT MyMoveFile(
|
||||
const CFileInfoW &srcFileInfo,
|
||||
const UString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UINT fileCodePage,
|
||||
UINT64 &completedSize)
|
||||
{
|
||||
UString destPath = destPathSpec;
|
||||
if (destPath.CompareNoCase(srcPath) == 0)
|
||||
{
|
||||
UString message = UString(L"can not move file \'")
|
||||
+ GetUnicodeString(destPath, fileCodePage) +
|
||||
+ destPath +
|
||||
UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
@@ -342,10 +326,10 @@ HRESULT MyMoveFile(
|
||||
INT32 writeAskResult;
|
||||
CMyComBSTR destPathResult;
|
||||
RINOK(callback->AskWrite(
|
||||
GetUnicodeString(srcPath, fileCodePage),
|
||||
srcPath,
|
||||
BoolToInt(false),
|
||||
&srcFileInfo.LastWriteTime, &srcFileInfo.Size,
|
||||
GetUnicodeString(destPath, fileCodePage),
|
||||
destPath,
|
||||
&destPathResult,
|
||||
&writeAskResult));
|
||||
if (IntToBool(writeAskResult))
|
||||
@@ -354,8 +338,7 @@ HRESULT MyMoveFile(
|
||||
RINOK(callback->SetCurrentFilePath(srcPath));
|
||||
if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
|
||||
{
|
||||
UString message = UString(L"can not move to file ") +
|
||||
GetUnicodeString(destPathNew, fileCodePage);
|
||||
UString message = UString(L"can not move to file ") + destPathNew;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
}
|
||||
}
|
||||
@@ -368,7 +351,6 @@ HRESULT MyMoveFolder(
|
||||
const UString &srcPath,
|
||||
const UString &destPathSpec,
|
||||
IFolderOperationsExtractCallback *callback,
|
||||
UINT fileCodePage,
|
||||
UINT64 &completedSize)
|
||||
{
|
||||
UString destPath = destPathSpec;
|
||||
@@ -377,9 +359,8 @@ HRESULT MyMoveFolder(
|
||||
{
|
||||
if (destPath.Length() == len || destPath[len] == L'\\')
|
||||
{
|
||||
UString message = UString(L"can not move folder \'")
|
||||
+ GetUnicodeString(destPath, fileCodePage) +
|
||||
UString(L"\' onto itself");
|
||||
UString message = UString(L"can not move folder \'") +
|
||||
destPath + UString(L"\' onto itself");
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
@@ -390,8 +371,7 @@ HRESULT MyMoveFolder(
|
||||
|
||||
if (!NDirectory::CreateComplexDirectory(destPath))
|
||||
{
|
||||
UString message = UString(L"can not create folder ") +
|
||||
GetUnicodeString(destPath, fileCodePage);
|
||||
UString message = UString(L"can not create folder ") + destPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
@@ -404,20 +384,17 @@ HRESULT MyMoveFolder(
|
||||
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(MyMoveFolder(srcPath2, destPath2,
|
||||
callback, fileCodePage, completedSize));
|
||||
RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(MyMoveFile(srcPath2, fileInfo, destPath2,
|
||||
callback, fileCodePage, completedSize));
|
||||
RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, callback, completedSize));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!NDirectory::MyRemoveDirectory(srcPath))
|
||||
{
|
||||
UString message = UString(L"can not remove folder") +
|
||||
GetUnicodeString(srcPath, fileCodePage);
|
||||
UString message = UString(L"can not remove folder") + srcPath;
|
||||
RINOK(callback->ShowMessage(message));
|
||||
return E_ABORT;
|
||||
}
|
||||
@@ -425,8 +402,8 @@ HRESULT MyMoveFolder(
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::MoveTo(
|
||||
const UINT32 *indices,
|
||||
UINT32 numItems,
|
||||
const UInt32 *indices,
|
||||
UInt32 numItems,
|
||||
const wchar_t *path,
|
||||
IFolderOperationsExtractCallback *callback)
|
||||
{
|
||||
@@ -434,7 +411,7 @@ STDMETHODIMP CFSFolder::MoveTo(
|
||||
return S_OK;
|
||||
|
||||
UINT64 totalSize = 0;
|
||||
UINT32 i;
|
||||
UInt32 i;
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
int index = indices[i];
|
||||
@@ -456,7 +433,7 @@ STDMETHODIMP CFSFolder::MoveTo(
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
else
|
||||
if (!NDirectory::CreateComplexDirectory(GetSystemString(destPath, _fileCodePage)))
|
||||
if (!NDirectory::CreateComplexDirectory(destPath))
|
||||
{
|
||||
UString message = UString(L"can not create folder ") +
|
||||
destPath;
|
||||
@@ -475,13 +452,11 @@ STDMETHODIMP CFSFolder::MoveTo(
|
||||
UString srcPath = _path + fileInfo.Name;
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(MyMoveFolder(srcPath, destPath2, callback,
|
||||
_fileCodePage, completedSize));
|
||||
RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(MyMoveFile(srcPath, fileInfo, destPath2,
|
||||
callback, _fileCodePage, completedSize));
|
||||
RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
@@ -489,7 +464,7 @@ STDMETHODIMP CFSFolder::MoveTo(
|
||||
|
||||
STDMETHODIMP CFSFolder::CopyFrom(
|
||||
const wchar_t *fromFolderPath,
|
||||
const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress)
|
||||
const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
@@ -3,49 +3,14 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "FormatUtils.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#ifdef LANG
|
||||
#include "LangUtils.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
CSysString MyFormat(const CSysString &format, const CSysString &argument)
|
||||
{
|
||||
CSysString result;
|
||||
_stprintf(result.GetBuffer(format.Length() + argument.Length() + 2),
|
||||
format, argument);
|
||||
result.ReleaseBuffer();
|
||||
return result;
|
||||
}
|
||||
|
||||
CSysString MyFormat(UINT32 resourceID,
|
||||
#ifdef LANG
|
||||
UINT32 aLangID,
|
||||
#endif
|
||||
const CSysString &argument)
|
||||
{
|
||||
return MyFormat(
|
||||
#ifdef LANG
|
||||
LangLoadString(resourceID, aLangID),
|
||||
#else
|
||||
NWindows::MyLoadString(resourceID),
|
||||
#endif
|
||||
|
||||
argument);
|
||||
}
|
||||
*/
|
||||
|
||||
CSysString NumberToString(UINT64 number)
|
||||
{
|
||||
TCHAR temp[32];
|
||||
ConvertUInt64ToString(number, temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
UString NumberToStringW(UINT64 number)
|
||||
UString NumberToString(UInt64 number)
|
||||
{
|
||||
wchar_t numberString[32];
|
||||
ConvertUInt64ToString(number, numberString);
|
||||
@@ -59,16 +24,15 @@ UString MyFormatNew(const UString &format, const UString &argument)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
UString MyFormatNew(UINT32 resourceID,
|
||||
UString MyFormatNew(UINT resourceID,
|
||||
#ifdef LANG
|
||||
UINT32 aLangID,
|
||||
UInt32 langID,
|
||||
#endif
|
||||
const UString &argument)
|
||||
{
|
||||
return MyFormatNew(
|
||||
#ifdef LANG
|
||||
LangLoadStringW(resourceID, aLangID),
|
||||
LangString(resourceID, langID),
|
||||
#else
|
||||
NWindows::MyLoadStringW(resourceID),
|
||||
#endif
|
||||
|
||||
@@ -3,18 +3,15 @@
|
||||
#ifndef __FORMATUTILS_H
|
||||
#define __FORMATUTILS_H
|
||||
|
||||
#include "Common/Types.h"
|
||||
#include "Common/String.h"
|
||||
|
||||
// CSysString MyFormat(const CSysString &format, const CSysString &argument);
|
||||
|
||||
// CSysString NumberToString(UINT64 number);
|
||||
|
||||
UString NumberToStringW(UINT64 number);
|
||||
UString NumberToString(UInt64 number);
|
||||
|
||||
UString MyFormatNew(const UString &format, const UString &argument);
|
||||
UString MyFormatNew(UINT32 resourceID,
|
||||
UString MyFormatNew(UINT resourceID,
|
||||
#ifdef LANG
|
||||
UINT32 aLangID,
|
||||
UInt32 langID,
|
||||
#endif
|
||||
const UString &argument);
|
||||
|
||||
|
||||
@@ -14,10 +14,7 @@ void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
|
||||
{
|
||||
UString path;
|
||||
if (!::GetProgramFolderPath(path))
|
||||
{
|
||||
// AfxMessageBox(TEXT("App Path Registry Item not found"));
|
||||
return;
|
||||
}
|
||||
path += kHelpFileName;
|
||||
path += topicFile;
|
||||
HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);
|
||||
|
||||
@@ -28,10 +28,10 @@ namespace NPlugin
|
||||
FOLDER_INTERFACE(IFolderFolder, 0x00)
|
||||
{
|
||||
STDMETHOD(LoadItems)() PURE;
|
||||
STDMETHOD(GetNumberOfItems)(UINT32 *numItems) PURE;
|
||||
// STDMETHOD(GetNumberOfSubFolders)(UINT32 *numSubFolders) PURE;
|
||||
STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value) PURE;
|
||||
STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder) PURE;
|
||||
STDMETHOD(GetNumberOfItems)(UInt32 *numItems) PURE;
|
||||
// STDMETHOD(GetNumberOfSubFolders)(UInt32 *numSubFolders) PURE;
|
||||
STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) PURE;
|
||||
STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder) PURE;
|
||||
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder) PURE;
|
||||
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder) PURE;
|
||||
STDMETHOD(GetName)(BSTR *name) PURE;
|
||||
@@ -40,8 +40,8 @@ FOLDER_INTERFACE(IFolderFolder, 0x00)
|
||||
FOLDER_INTERFACE(IEnumProperties, 0x01)
|
||||
{
|
||||
// STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator) PURE;
|
||||
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties) PURE;
|
||||
STDMETHOD(GetPropertyInfo)(UINT32 index,
|
||||
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) PURE;
|
||||
STDMETHOD(GetPropertyInfo)(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@ FOLDER_INTERFACE(IFolderGetPath, 0x03)
|
||||
|
||||
FOLDER_INTERFACE(IFolderWasChanged, 0x04)
|
||||
{
|
||||
STDMETHOD(WasChanged)(INT32 *wasChanged) PURE;
|
||||
STDMETHOD(WasChanged)(Int32 *wasChanged) PURE;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -71,12 +71,12 @@ FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x06, 0x01)
|
||||
{
|
||||
STDMETHOD(AskWrite)(
|
||||
const wchar_t *srcPath,
|
||||
INT32 srcIsFolder,
|
||||
Int32 srcIsFolder,
|
||||
const FILETIME *srcTime,
|
||||
const UINT64 *srcSize,
|
||||
const UInt64 *srcSize,
|
||||
const wchar_t *destPathRequest,
|
||||
BSTR *destPathResult,
|
||||
INT32 *writeAnswer) PURE;
|
||||
Int32 *writeAnswer) PURE;
|
||||
STDMETHOD(ShowMessage)(const wchar_t *message) PURE;
|
||||
STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE;
|
||||
};
|
||||
@@ -86,13 +86,13 @@ FOLDER_INTERFACE_SUB(IFolderOperationsUpdateCallback, IProgress, 0x06, 0x02)
|
||||
{
|
||||
STDMETHOD(AskOverwrite)(
|
||||
const wchar_t *srcPath,
|
||||
INT32 destIsFolder,
|
||||
Int32 destIsFolder,
|
||||
const FILETIME *destTime,
|
||||
const UINT64 *destSize,
|
||||
const UInt64 *destSize,
|
||||
const wchar_t *aDestPathRequest,
|
||||
const wchar_t *aDestName,
|
||||
BSTR *aDestPathResult,
|
||||
INT32 *aResult);
|
||||
Int32 *aResult);
|
||||
};
|
||||
*/
|
||||
|
||||
@@ -100,32 +100,32 @@ FOLDER_INTERFACE(IFolderOperations, 0x06)
|
||||
{
|
||||
STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress) PURE;
|
||||
STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress) PURE;
|
||||
STDMETHOD(Rename)(UINT32 index, const wchar_t *newName, IProgress *progress) PURE;
|
||||
STDMETHOD(Delete)(const UINT32 *indices, UINT32 numItems, IProgress *progress) PURE;
|
||||
STDMETHOD(CopyTo)(const UINT32 *indices, UINT32 numItems,
|
||||
STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress) PURE;
|
||||
STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress) PURE;
|
||||
STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback) PURE;
|
||||
STDMETHOD(MoveTo)(const UINT32 *indices, UINT32 numItems,
|
||||
STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback) PURE;
|
||||
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
|
||||
const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress) PURE;
|
||||
STDMETHOD(SetProperty)(UINT32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) PURE;
|
||||
const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress) PURE;
|
||||
STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) PURE;
|
||||
};
|
||||
|
||||
/*
|
||||
FOLDER_INTERFACE2(IFolderOperationsDeleteToRecycleBin, 0x06, 0x03)
|
||||
{
|
||||
STDMETHOD(DeleteToRecycleBin)(const UINT32 *indices, UINT32 numItems, IProgress *progress) PURE;
|
||||
STDMETHOD(DeleteToRecycleBin)(const UInt32 *indices, UInt32 numItems, IProgress *progress) PURE;
|
||||
};
|
||||
*/
|
||||
|
||||
FOLDER_INTERFACE(IFolderGetSystemIconIndex, 0x07)
|
||||
{
|
||||
STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex) PURE;
|
||||
STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex) PURE;
|
||||
};
|
||||
|
||||
FOLDER_INTERFACE(IFolderGetItemFullSize, 0x08)
|
||||
{
|
||||
STDMETHOD(GetItemFullSize)(UINT32 index, PROPVARIANT *value, IProgress *progress) PURE;
|
||||
STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress) PURE;
|
||||
};
|
||||
|
||||
FOLDER_INTERFACE(IFolderClone, 0x09)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "LangUtils.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/StringToInt.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
#include "Windows/Synchronization.h"
|
||||
#include "Windows/Window.h"
|
||||
#include "Windows/FileFind.h"
|
||||
@@ -15,24 +14,28 @@
|
||||
using namespace NWindows;
|
||||
|
||||
static CLang g_Lang;
|
||||
CSysString g_LangID;
|
||||
UString g_LangID;
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
void ReloadLang()
|
||||
{
|
||||
ReadRegLang(g_LangID);
|
||||
g_Lang.Clear();
|
||||
if (!g_LangID.IsEmpty() && g_LangID != TEXT("-"))
|
||||
if (!g_LangID.IsEmpty() && g_LangID != L"-")
|
||||
{
|
||||
CSysString langPath = g_LangID;
|
||||
UString langPath = g_LangID;
|
||||
if (langPath.Find('\\') < 0)
|
||||
{
|
||||
if (langPath.Find('.') < 0)
|
||||
langPath += TEXT(".txt");
|
||||
langPath += L".txt";
|
||||
UString folderPath;
|
||||
if (GetProgramFolderPath(folderPath))
|
||||
langPath = GetSystemString(folderPath) + CSysString(TEXT("Lang\\")) + langPath;
|
||||
langPath = folderPath + UString(L"Lang\\") + langPath;
|
||||
}
|
||||
g_Lang.Open(langPath);
|
||||
g_Lang.Open(GetSystemString(langPath));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,14 +51,6 @@ void LoadLangOneTime()
|
||||
ReloadLang();
|
||||
}
|
||||
|
||||
/*
|
||||
class CLangLoader
|
||||
{
|
||||
public:
|
||||
CLangLoader() { ReloadLang(); }
|
||||
} g_LangLoader;
|
||||
*/
|
||||
|
||||
void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems)
|
||||
{
|
||||
for (int i = 0; i < numItems; i++)
|
||||
@@ -74,10 +69,10 @@ void LangSetWindowText(HWND window, UInt32 langID)
|
||||
{
|
||||
UString message;
|
||||
if (g_Lang.GetMessage(langID, message))
|
||||
SetWindowText(window, GetSystemString(message));
|
||||
MySetWindowText(window, message);
|
||||
}
|
||||
|
||||
UString LangLoadString(UInt32 langID)
|
||||
UString LangString(UInt32 langID)
|
||||
{
|
||||
UString message;
|
||||
if (g_Lang.GetMessage(langID, message))
|
||||
@@ -85,15 +80,7 @@ UString LangLoadString(UInt32 langID)
|
||||
return UString();
|
||||
}
|
||||
|
||||
CSysString LangLoadString(UINT resourceID, UInt32 langID)
|
||||
{
|
||||
UString message;
|
||||
if (g_Lang.GetMessage(langID, message))
|
||||
return GetSystemString(message);
|
||||
return NWindows::MyLoadString(resourceID);
|
||||
}
|
||||
|
||||
UString LangLoadStringW(UINT resourceID, UInt32 langID)
|
||||
UString LangString(UINT resourceID, UInt32 langID)
|
||||
{
|
||||
UString message;
|
||||
if (g_Lang.GetMessage(langID, message))
|
||||
@@ -180,16 +167,19 @@ void FindMatchLang(UString &shortName)
|
||||
|
||||
void ReloadLangSmart()
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
ReadRegLang(g_LangID);
|
||||
if (g_LangID.IsEmpty())
|
||||
{
|
||||
UString shortName;
|
||||
FindMatchLang(shortName);
|
||||
if (shortName.IsEmpty())
|
||||
shortName = L"-";
|
||||
SaveRegLang(GetSystemString(shortName));
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
#endif
|
||||
{
|
||||
ReadRegLang(g_LangID);
|
||||
if (g_LangID.IsEmpty())
|
||||
{
|
||||
UString shortName;
|
||||
FindMatchLang(shortName);
|
||||
if (shortName.IsEmpty())
|
||||
shortName = L"-";
|
||||
SaveRegLang(shortName);
|
||||
}
|
||||
}
|
||||
ReloadLang();
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
#define __LANGUTILS_H
|
||||
|
||||
#include "Common/Lang.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
extern CSysString g_LangID;
|
||||
extern UString g_LangID;
|
||||
|
||||
struct CIDLangPair
|
||||
{
|
||||
@@ -28,9 +29,13 @@ void LoadLangs(CObjectVector<CLangEx> &langs);
|
||||
void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems);
|
||||
void LangSetWindowText(HWND window, UInt32 langID);
|
||||
|
||||
UString LangLoadString(UInt32 langID);
|
||||
CSysString LangLoadString(UINT resourceID, UInt32 langID);
|
||||
UString LangLoadStringW(UINT resourceID, UInt32 langID);
|
||||
UString LangString(UInt32 langID);
|
||||
UString LangString(UINT resourceID, UInt32 langID);
|
||||
|
||||
#ifdef LANG
|
||||
#define LangStringSpec(resourceID, langID) LangString(resourceID, langID)
|
||||
#else
|
||||
#define LangStringSpec(resourceID, langID) NWindows::MyLoadStringW(resourceID)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -135,61 +135,6 @@ static int FindLangItem(int ControlID)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
void MyChangeMenu(HMENU menuLoc, int baseIndex = -1)
|
||||
{
|
||||
CMenu menu;
|
||||
menu.Attach(menuLoc);
|
||||
for (int i = 0; i < menu.GetItemCount(); i++)
|
||||
{
|
||||
HMENU subMenu = menu.GetSubMenu(i);
|
||||
CSysString menuString;
|
||||
menu.GetMenuString(i, MF_BYPOSITION, menuString);
|
||||
|
||||
// if (menu.GetItemInfo(i, true, &menuInfo))
|
||||
{
|
||||
CSysString newString;
|
||||
if (subMenu)
|
||||
{
|
||||
MyChangeMenu(subMenu);
|
||||
if (baseIndex >= 0 && baseIndex < sizeof(kStringLangPairs) /
|
||||
sizeof(kStringLangPairs[0]))
|
||||
newString = LangLoadString(kStringLangPairs[baseIndex++].LangID);
|
||||
else
|
||||
continue;
|
||||
if (newString.IsEmpty())
|
||||
continue;
|
||||
|
||||
// int langPos = FindStringLangItem(GetUnicodeString(menuInfo.dwTypeData));
|
||||
// if (langPos >= 0)
|
||||
// newString = LangLoadString(kStringLangPairs[langPos].LangID);
|
||||
// else
|
||||
// newString = menuInfo.dwTypeData;
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT id = menu.GetItemID(i);
|
||||
int langPos = FindLangItem(id);
|
||||
if (langPos < 0)
|
||||
continue;
|
||||
newString = LangLoadString(kIDLangPairs[langPos].LangID);
|
||||
if (newString.IsEmpty())
|
||||
continue;
|
||||
int tabPos = menuString.ReverseFind(wchar_t('\t'));
|
||||
if (tabPos >= 0)
|
||||
newString += menuString.Mid(tabPos);
|
||||
}
|
||||
MENUITEMINFO menuInfo;
|
||||
menuInfo.cbSize = sizeof(menuInfo);
|
||||
menuInfo.fType = MFT_STRING;
|
||||
menuInfo.fMask = MIIM_TYPE;
|
||||
menuInfo.dwTypeData = (LPTSTR)(LPCTSTR)newString;
|
||||
menu.SetItemInfo(i, true, &menuInfo);
|
||||
// HMENU subMenu = menu.GetSubMenu(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
static bool g_IsNew_fMask = true;
|
||||
@@ -241,70 +186,62 @@ static UINT Get_fMaskForFTypeAndString()
|
||||
return MIIM_TYPE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
|
||||
{
|
||||
CMenu menu;
|
||||
menu.Attach(menuLoc);
|
||||
for (int i = 0; i < menu.GetItemCount(); i++)
|
||||
{
|
||||
MENUITEMINFO menuInfo;
|
||||
ZeroMemory(&menuInfo, sizeof(menuInfo));
|
||||
menuInfo.cbSize = sizeof(menuInfo);
|
||||
menuInfo.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID;
|
||||
menuInfo.fType = MFT_STRING;
|
||||
const int kBufferSize = 1024;
|
||||
TCHAR buffer[kBufferSize + 1];
|
||||
menuInfo.dwTypeData = buffer;
|
||||
menuInfo.cch = kBufferSize;
|
||||
if (menu.GetItemInfo(i, true, &menuInfo))
|
||||
CMenuItem item;
|
||||
item.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID;
|
||||
item.fType = MFT_STRING;
|
||||
if (menu.GetItem(i, true, item))
|
||||
{
|
||||
CSysString newString;
|
||||
if (menuInfo.hSubMenu)
|
||||
UString newString;
|
||||
if (item.hSubMenu)
|
||||
{
|
||||
if (level == 1 && menuIndex == kBookmarksMenuIndex)
|
||||
newString = GetSystemString(LangLoadString(kAddToFavoritesLangID));
|
||||
newString = LangString(kAddToFavoritesLangID);
|
||||
else
|
||||
{
|
||||
MyChangeMenu(menuInfo.hSubMenu, level + 1, i);
|
||||
MyChangeMenu(item.hSubMenu, level + 1, i);
|
||||
if (level == 1 && menuIndex == kViewMenuIndex)
|
||||
{
|
||||
newString = GetSystemString(LangLoadString(kToolbarsLangID));
|
||||
newString = LangString(kToolbarsLangID);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (level == 0 && i < sizeof(kStringLangPairs) /
|
||||
sizeof(kStringLangPairs[0]))
|
||||
newString = GetSystemString(LangLoadString(kStringLangPairs[i].LangID));
|
||||
newString = LangString(kStringLangPairs[i].LangID);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (newString.IsEmpty())
|
||||
continue;
|
||||
|
||||
// int langPos = FindStringLangItem(GetUnicodeString(menuInfo.dwTypeData));
|
||||
// if (langPos >= 0)
|
||||
// newString = LangLoadString(kStringLangPairs[langPos].LangID);
|
||||
// else
|
||||
// newString = menuInfo.dwTypeData;
|
||||
}
|
||||
else
|
||||
{
|
||||
int langPos = FindLangItem(menuInfo.wID);
|
||||
int langPos = FindLangItem(item.wID);
|
||||
if (langPos < 0)
|
||||
continue;
|
||||
newString = GetSystemString(LangLoadString(kIDLangPairs[langPos].LangID));
|
||||
newString = LangString(kIDLangPairs[langPos].LangID);
|
||||
if (newString.IsEmpty())
|
||||
continue;
|
||||
CSysString shorcutString = menuInfo.dwTypeData;
|
||||
UString shorcutString = item.StringValue;
|
||||
int tabPos = shorcutString.ReverseFind(wchar_t('\t'));
|
||||
if (tabPos >= 0)
|
||||
newString += shorcutString.Mid(tabPos);
|
||||
}
|
||||
menuInfo.dwTypeData = (LPTSTR)(LPCTSTR)newString;
|
||||
menuInfo.fMask = Get_fMaskForString();
|
||||
menuInfo.fType = MFT_STRING;
|
||||
menu.SetItemInfo(i, true, &menuInfo);
|
||||
{
|
||||
item.StringValue = newString;
|
||||
item.fMask = Get_fMaskForString();
|
||||
item.fType = MFT_STRING;
|
||||
menu.SetItem(i, true, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,20 +290,12 @@ static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
|
||||
int startPos = 0;
|
||||
for (int i = 0; i < srcMenu.GetItemCount(); i++)
|
||||
{
|
||||
MENUITEMINFO menuInfo;
|
||||
ZeroMemory(&menuInfo, sizeof(menuInfo));
|
||||
menuInfo.cbSize = sizeof(menuInfo);
|
||||
menuInfo.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
|
||||
menuInfo.fType = MFT_STRING;
|
||||
const int kBufferSize = 1024;
|
||||
TCHAR buffer[kBufferSize + 1];
|
||||
menuInfo.dwTypeData = buffer;
|
||||
menuInfo.cch = kBufferSize;
|
||||
if (srcMenu.GetItemInfo(i, true, &menuInfo))
|
||||
{
|
||||
if (destMenu.InsertItem(startPos, true, &menuInfo))
|
||||
CMenuItem item;
|
||||
item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
|
||||
item.fType = MFT_STRING;
|
||||
if (srcMenu.GetItem(i, true, item))
|
||||
if (destMenu.InsertItem(startPos, true, item))
|
||||
startPos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,14 +351,13 @@ void OnMenuActivating(HWND hWnd, HMENU hMenu, int position)
|
||||
int i;
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
UString s = LangLoadStringW(IDS_BOOKMARK, 0x03000720);
|
||||
UString s = LangString(IDS_BOOKMARK, 0x03000720);
|
||||
s += L" ";
|
||||
wchar_t c = L'0' + i;
|
||||
s += c;
|
||||
s += L"\tAlt+Shift+";
|
||||
s += c;
|
||||
subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i,
|
||||
GetSystemString(s));
|
||||
subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s);
|
||||
}
|
||||
|
||||
while (menu.GetItemCount() > 2)
|
||||
@@ -445,15 +373,13 @@ void OnMenuActivating(HWND hWnd, HMENU hMenu, int position)
|
||||
path = path.Left(kFirstPartSize) + UString(L" ... ") +
|
||||
path.Right(kMaxSize - kFirstPartSize);
|
||||
}
|
||||
CSysString s = GetSystemString(path);
|
||||
UString s = path;
|
||||
if (s.IsEmpty())
|
||||
s = TEXT("-");
|
||||
s += TEXT("\tAlt+");
|
||||
s += ('0' + i);
|
||||
s = L"-";
|
||||
s += L"\tAlt+";
|
||||
s += (L'0' + i);
|
||||
menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
|
||||
}
|
||||
|
||||
// menu.AppendItem(MF_STRING, 100, TEXT("Test2\tAlt+2"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,47 +416,17 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool forFileMode,
|
||||
|
||||
for (int i = 0; i < g_FileMenu.GetItemCount(); i++)
|
||||
{
|
||||
MENUITEMINFO menuInfo;
|
||||
ZeroMemory(&menuInfo, sizeof(menuInfo));
|
||||
menuInfo.cbSize = sizeof(menuInfo);
|
||||
CMenuItem item;
|
||||
|
||||
/*
|
||||
menuInfo.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
|
||||
menuInfo.fType = MFT_STRING;
|
||||
|
||||
if (!srcMenu.GetItemInfo(i, true, &menuInfo))
|
||||
{
|
||||
// MessageBox(0, NError::MyFormatMessage(GetLastError()), "Error", 0);
|
||||
continue;
|
||||
}
|
||||
// menuInfo.wID = srcMenu.GetItemID(i);
|
||||
// menuInfo.fState = srcMenu.GetItemState(i, MF_BYPOSITION);
|
||||
|
||||
// menuInfo.hSubMenu = srcMenu.GetSubMenu(i);
|
||||
CSysString menuString;
|
||||
if (menuInfo.fType == MFT_STRING)
|
||||
{
|
||||
srcMenu.GetMenuString(i, MF_BYPOSITION, menuString);
|
||||
menuInfo.dwTypeData = (LPTSTR)(LPCTSTR)menuString;
|
||||
}
|
||||
menuInfo.dwTypeData = (LPTSTR)(LPCTSTR)menuString;
|
||||
*/
|
||||
|
||||
menuInfo.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
|
||||
menuInfo.fType = MFT_STRING;
|
||||
const int kBufferSize = 1024;
|
||||
TCHAR buffer[kBufferSize + 1];
|
||||
menuInfo.dwTypeData = buffer;
|
||||
menuInfo.cch = kBufferSize;
|
||||
|
||||
if (g_FileMenu.GetItemInfo(i, true, &menuInfo))
|
||||
item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
|
||||
item.fType = MFT_STRING;
|
||||
if (g_FileMenu.GetItem(i, true, item))
|
||||
{
|
||||
if (!programMenu)
|
||||
if (menuInfo.wID == IDCLOSE)
|
||||
if (item.wID == IDCLOSE)
|
||||
continue;
|
||||
/*
|
||||
bool createItem = (menuInfo.wID == IDM_CREATE_FOLDER ||
|
||||
menuInfo.wID == IDM_CREATE_FILE);
|
||||
bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE);
|
||||
if (forFileMode)
|
||||
{
|
||||
if (createItem)
|
||||
@@ -542,21 +438,20 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool forFileMode,
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
if (destMenu.InsertItem(startPos, true, &menuInfo))
|
||||
if (destMenu.InsertItem(startPos, true, item))
|
||||
startPos++;
|
||||
}
|
||||
}
|
||||
while (destMenu.GetItemCount() > 0)
|
||||
{
|
||||
MENUITEMINFO menuInfo;
|
||||
ZeroMemory(&menuInfo, sizeof(menuInfo));
|
||||
menuInfo.cbSize = sizeof(menuInfo);
|
||||
menuInfo.fMask = MIIM_TYPE;
|
||||
menuInfo.dwTypeData = 0;
|
||||
CMenuItem item;
|
||||
item.fMask = MIIM_TYPE;
|
||||
item.fType = 0;
|
||||
// item.dwTypeData = 0;
|
||||
int lastIndex = destMenu.GetItemCount() - 1;
|
||||
if (!destMenu.GetItemInfo(lastIndex, true, &menuInfo))
|
||||
if (!destMenu.GetItem(lastIndex, true, item))
|
||||
break;
|
||||
if(menuInfo.fType != MFT_SEPARATOR)
|
||||
if(item.fType != MFT_SEPARATOR)
|
||||
break;
|
||||
if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION))
|
||||
break;
|
||||
|
||||
@@ -43,9 +43,9 @@ void CNetFolder::Init(const UString &path)
|
||||
}
|
||||
Init(0, 0 , L"");
|
||||
*/
|
||||
CResource resource;
|
||||
CResourceW resource;
|
||||
resource.RemoteNameIsDefined = true;
|
||||
resource.RemoteName = GetSystemString(path.Left(path.Length() - 1));
|
||||
resource.RemoteName = path.Left(path.Length() - 1);
|
||||
resource.ProviderIsDefined = false;
|
||||
resource.LocalNameIsDefined = false;
|
||||
resource.CommentIsDefined = false;
|
||||
@@ -53,18 +53,17 @@ void CNetFolder::Init(const UString &path)
|
||||
resource.Scope = RESOURCE_GLOBALNET;
|
||||
resource.Usage = 0;
|
||||
resource.DisplayType = 0;
|
||||
CResource aDestResource;
|
||||
CSysString aSystemPathPart;
|
||||
DWORD result = GetResourceInformation(resource, aDestResource,
|
||||
aSystemPathPart);
|
||||
CResourceW destResource;
|
||||
UString systemPathPart;
|
||||
DWORD result = GetResourceInformation(resource, destResource, systemPathPart);
|
||||
if (result == NO_ERROR)
|
||||
Init(&aDestResource, 0, path);
|
||||
Init(&destResource, 0, path);
|
||||
else
|
||||
Init(0, 0 , L"");
|
||||
return;
|
||||
}
|
||||
|
||||
void CNetFolder::Init(const NWindows::NNet::CResource *netResource,
|
||||
void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource,
|
||||
IFolderFolder *parentFolder, const UString &path)
|
||||
{
|
||||
_path = path;
|
||||
@@ -76,7 +75,7 @@ void CNetFolder::Init(const NWindows::NNet::CResource *netResource,
|
||||
_netResourcePointer = &_netResource;
|
||||
|
||||
// if (_netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER)
|
||||
_path = GetUnicodeString(_netResource.RemoteName) + L'\\';
|
||||
_path = _netResource.RemoteName + L'\\';
|
||||
}
|
||||
_parentFolder = parentFolder;
|
||||
}
|
||||
@@ -113,7 +112,7 @@ STDMETHODIMP CNetFolder::LoadItems()
|
||||
{
|
||||
if (!resource.RemoteNameIsDefined) // For Win 98, I don't know what's wrong
|
||||
resource.RemoteName = resource.Comment;
|
||||
resource.Name = GetUnicodeString(resource.RemoteName);
|
||||
resource.Name = resource.RemoteName;
|
||||
int aPos = resource.Name.ReverseFind(L'\\');
|
||||
if (aPos >= 0)
|
||||
{
|
||||
@@ -128,6 +127,8 @@ STDMETHODIMP CNetFolder::LoadItems()
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
It's too slow for some systems.
|
||||
if (_netResourcePointer && _netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER)
|
||||
{
|
||||
for (char c = 'a'; c <= 'z'; c++)
|
||||
@@ -135,11 +136,11 @@ STDMETHODIMP CNetFolder::LoadItems()
|
||||
CResourceEx resource;
|
||||
resource.Name = UString(wchar_t(c)) + L'$';
|
||||
resource.RemoteNameIsDefined = true;
|
||||
resource.RemoteName = GetSystemString(_path + resource.Name);
|
||||
resource.RemoteName = _path + resource.Name;
|
||||
|
||||
NFile::NFind::CFindFile aFindFile;
|
||||
NFile::NFind::CFileInfo aFileInfo;
|
||||
if (!aFindFile.FindFirst(resource.RemoteName + CSysString(TEXT("\\*")), aFileInfo))
|
||||
NFile::NFind::CFindFile findFile;
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
if (!findFile.FindFirst(resource.RemoteName + UString(L"\\*"), fileInfo))
|
||||
continue;
|
||||
resource.Usage = RESOURCEUSAGE_CONNECTABLE;
|
||||
resource.LocalNameIsDefined = false;
|
||||
@@ -148,17 +149,18 @@ STDMETHODIMP CNetFolder::LoadItems()
|
||||
_items.Add(resource);
|
||||
}
|
||||
}
|
||||
*/
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CNetFolder::GetNumberOfItems(UINT32 *numItems)
|
||||
STDMETHODIMP CNetFolder::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _items.Size();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CNetFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
STDMETHODIMP CNetFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
const CResourceEx &item = _items[itemIndex];
|
||||
@@ -173,25 +175,22 @@ STDMETHODIMP CNetFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIAN
|
||||
break;
|
||||
case kpidLocalName:
|
||||
if (item.LocalNameIsDefined)
|
||||
propVariant = GetUnicodeString(item.LocalName);
|
||||
propVariant = item.LocalName;
|
||||
break;
|
||||
case kpidComment:
|
||||
if (item.CommentIsDefined)
|
||||
propVariant = GetUnicodeString(item.Comment);
|
||||
propVariant = item.Comment;
|
||||
break;
|
||||
case kpidProvider:
|
||||
if (item.ProviderIsDefined)
|
||||
propVariant = GetUnicodeString(item.Provider);
|
||||
propVariant = item.Provider;
|
||||
break;
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static inline UINT GetCurrentCodePage()
|
||||
{ return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
|
||||
STDMETHODIMP CNetFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
|
||||
STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
const CResourceEx &resource = _items[index];
|
||||
@@ -200,16 +199,14 @@ STDMETHODIMP CNetFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder
|
||||
{
|
||||
CFSFolder *fsFolderSpec = new CFSFolder;
|
||||
CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
|
||||
RINOK(fsFolderSpec->Init(
|
||||
GetUnicodeString(resource.RemoteName, GetCurrentCodePage())
|
||||
+ L'\\', this));
|
||||
RINOK(fsFolderSpec->Init(resource.RemoteName + L'\\', this));
|
||||
*resultFolder = subFolder.Detach();
|
||||
}
|
||||
else
|
||||
{
|
||||
CNetFolder *netFolder = new CNetFolder;
|
||||
CMyComPtr<IFolderFolder> subFolder = netFolder;
|
||||
netFolder->Init(&resource, this, GetUnicodeString(resource.Name) + L'\\');
|
||||
netFolder->Init(&resource, this, resource.Name + L'\\');
|
||||
*resultFolder = subFolder.Detach();
|
||||
}
|
||||
return S_OK;
|
||||
@@ -231,7 +228,7 @@ STDMETHODIMP CNetFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
}
|
||||
if (_netResourcePointer != 0)
|
||||
{
|
||||
CResource resourceParent;
|
||||
CResourceW resourceParent;
|
||||
DWORD result = GetResourceParent(_netResource, resourceParent);
|
||||
if (result != NO_ERROR)
|
||||
return result;
|
||||
@@ -257,13 +254,13 @@ STDMETHODIMP CNetFolder::GetName(BSTR *name)
|
||||
*/
|
||||
}
|
||||
|
||||
STDMETHODIMP CNetFolder::GetNumberOfProperties(UINT32 *numProperties)
|
||||
STDMETHODIMP CNetFolder::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CNetFolder::GetPropertyInfo(UINT32 index,
|
||||
STDMETHODIMP CNetFolder::GetPropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
@@ -289,12 +286,12 @@ STDMETHODIMP CNetFolder::GetPath(BSTR *path)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CNetFolder::GetSystemIconIndex(UINT32 index, INT32 *iconIndex)
|
||||
STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
|
||||
{
|
||||
if (index >= (UINT32)_items.Size())
|
||||
if (index >= (UInt32)_items.Size())
|
||||
return E_INVALIDARG;
|
||||
*iconIndex = 0;
|
||||
const CResource &resource = _items[index];
|
||||
const CResourceW &resource = _items[index];
|
||||
int iconIndexTemp;
|
||||
if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER ||
|
||||
resource.Usage == RESOURCEUSAGE_CONNECTABLE)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "IFolder.h"
|
||||
|
||||
struct CResourceEx: public NWindows::NNet::CResource
|
||||
struct CResourceEx: public NWindows::NNet::CResourceW
|
||||
{
|
||||
UString Name;
|
||||
};
|
||||
@@ -33,23 +33,23 @@ public:
|
||||
)
|
||||
|
||||
STDMETHOD(LoadItems)();
|
||||
STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
|
||||
STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
|
||||
STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetName)(BSTR *name);
|
||||
|
||||
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UINT32 index,
|
||||
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
STDMETHOD(GetTypeID)(BSTR *name);
|
||||
STDMETHOD(GetPath)(BSTR *path);
|
||||
STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex);
|
||||
STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
|
||||
|
||||
private:
|
||||
NWindows::NNet::CResource _netResource;
|
||||
NWindows::NNet::CResource *_netResourcePointer;
|
||||
NWindows::NNet::CResourceW _netResource;
|
||||
NWindows::NNet::CResourceW *_netResourcePointer;
|
||||
|
||||
CObjectVector<CResourceEx> _items;
|
||||
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
|
||||
public:
|
||||
void Init(const UString &path);
|
||||
void Init(const NWindows::NNet::CResource *netResource,
|
||||
void Init(const NWindows::NNet::CResourceW *netResource,
|
||||
IFolderFolder *parentFolder, const UString &path);
|
||||
CNetFolder(): _netResourcePointer(0) {}
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value
|
||||
switch(propID)
|
||||
{
|
||||
case kpidName:
|
||||
propVariant = GetUnicodeString(_fileInfo.Name);
|
||||
propVariant = _fileInfo.Name;
|
||||
break;
|
||||
case kpidIsFolder:
|
||||
propVariant = _fileInfo.IsDirectory();
|
||||
|
||||
@@ -24,33 +24,7 @@
|
||||
#include "MyLoadMenu.h"
|
||||
#include "App.h"
|
||||
|
||||
void FillInPropertyPage(PROPSHEETPAGE* page, HINSTANCE instance, int dialogID,
|
||||
NWindows::NControl::CPropertyPage *propertyPage, const CSysString &title)
|
||||
{
|
||||
page->dwSize = sizeof(PROPSHEETPAGE);
|
||||
// page->dwSize = sizeof(PROPSHEETPAGEW_V1_SIZE);
|
||||
|
||||
page->dwFlags = PSP_HASHELP;
|
||||
page->hInstance = instance;
|
||||
page->pszTemplate = MAKEINTRESOURCE(dialogID);
|
||||
page->pszIcon = NULL;
|
||||
page->pfnDlgProc = NWindows::NControl::ProperyPageProcedure;
|
||||
|
||||
if (title.IsEmpty())
|
||||
page->pszTitle = NULL;
|
||||
else
|
||||
{
|
||||
page->dwFlags |= PSP_USETITLE;
|
||||
page->pszTitle = title;
|
||||
}
|
||||
|
||||
page->lParam = LPARAM(propertyPage);
|
||||
page->pfnCallback = NULL;
|
||||
|
||||
// page->dwFlags = 0;
|
||||
// page->pszTitle = NULL;
|
||||
// page->lParam = 0;
|
||||
}
|
||||
using namespace NWindows;
|
||||
|
||||
void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance)
|
||||
{
|
||||
@@ -60,54 +34,32 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance)
|
||||
CSettingsPage settingsPage;
|
||||
CLangPage langPage;
|
||||
|
||||
CSysStringVector titles;
|
||||
CObjectVector<NControl::CPageInfo> pages;
|
||||
UINT32 langIDs[] = { 0x03010300, 0x03010100, 0x03010200, 0x03010400, 0x01000400};
|
||||
UINT pageIDs[] = { IDD_SYSTEM, IDD_PLUGINS, IDD_EDIT, IDD_SETTINGS, IDD_LANG};
|
||||
NControl::CPropertyPage *pagePinters[] = { &systemPage, &pluginsPage, &editPage, &settingsPage, &langPage };
|
||||
const int kNumPages = sizeof(langIDs) / sizeof(langIDs[0]);
|
||||
for (int i = 0; i < kNumPages; i++)
|
||||
titles.Add(GetSystemString(LangLoadString(langIDs[i])));
|
||||
|
||||
PROPSHEETPAGE pages[kNumPages];
|
||||
{
|
||||
NControl::CPageInfo page;
|
||||
page.Title = LangString(langIDs[i]);
|
||||
page.ID = pageIDs[i];
|
||||
page.Page = pagePinters[i];
|
||||
pages.Add(page);
|
||||
}
|
||||
|
||||
FillInPropertyPage(&pages[0], hInstance, IDD_SYSTEM, &systemPage, titles[0]);
|
||||
FillInPropertyPage(&pages[1], hInstance, IDD_PLUGINS, &pluginsPage, titles[1]);
|
||||
FillInPropertyPage(&pages[2], hInstance, IDD_EDIT, &editPage, titles[2]);
|
||||
FillInPropertyPage(&pages[3], hInstance, IDD_SETTINGS, &settingsPage, titles[3]);
|
||||
FillInPropertyPage(&pages[4], hInstance, IDD_LANG, &langPage, titles[4]);
|
||||
|
||||
PROPSHEETHEADER sheet;
|
||||
|
||||
// sheet.dwSize = sizeof(PROPSHEETHEADER_V1_SIZE);
|
||||
|
||||
sheet.dwSize = sizeof(PROPSHEETHEADER);
|
||||
sheet.dwFlags = PSH_PROPSHEETPAGE;
|
||||
sheet.hwndParent = hwndOwner;
|
||||
sheet.hInstance = hInstance;
|
||||
|
||||
CSysString title = LangLoadString(IDS_OPTIONS, 0x03010000);
|
||||
|
||||
sheet.pszCaption = title;
|
||||
sheet.nPages = sizeof(pages) / sizeof(PROPSHEETPAGE);
|
||||
sheet.nStartPage = 0;
|
||||
sheet.ppsp = pages;
|
||||
sheet.pfnCallback = NULL;
|
||||
|
||||
if (::PropertySheet(&sheet) != -1)
|
||||
int res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS, 0x03010000));
|
||||
if (res != -1 && res != 0)
|
||||
{
|
||||
if (langPage._langWasChanged)
|
||||
{
|
||||
g_App._window.SetText(LangLoadStringW(IDS_APP_TITLE, 0x03000000));
|
||||
g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000));
|
||||
MyLoadMenu();
|
||||
}
|
||||
g_App.SetListSettings();
|
||||
g_App.SetShowSystemMenu();
|
||||
g_App.RefreshAllPanels();
|
||||
g_App.ReloadToolbars();
|
||||
// ::PostMessage(hwndOwner, kLangWasChangedMessage, 0 , 0);
|
||||
// ::PostMessage(hwndOwner, kLangWasChangedMessage, 0 , 0);
|
||||
}
|
||||
/*
|
||||
else
|
||||
MessageBox(0, NWindows::NError::MyFormatMessage(GetLastError()), TEXT("PropertySheet"), 0);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
static const UINT_PTR kTimerID = 1;
|
||||
static const UINT kTimerElapse = 1000;
|
||||
|
||||
@@ -49,7 +53,7 @@ CPanel::~CPanel()
|
||||
CloseOpenFolders();
|
||||
}
|
||||
|
||||
static LPCTSTR kClassName = TEXT("7-Zip::Panel");
|
||||
static LPCWSTR kClassName = L"7-Zip::Panel";
|
||||
|
||||
|
||||
LRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
|
||||
@@ -196,7 +200,12 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
_panel->_lastFocusedIsList = true;
|
||||
_panel->_panelCallback->PanelWasFocused();
|
||||
}
|
||||
return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
|
||||
else
|
||||
#endif
|
||||
return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -278,7 +287,12 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
|
||||
else
|
||||
#endif
|
||||
return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
|
||||
}
|
||||
|
||||
bool CPanel::OnCreate(CREATESTRUCT *createStruct)
|
||||
@@ -318,11 +332,19 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
|
||||
HWND(*this), (HMENU)_baseID + 1, g_hInstance, NULL))
|
||||
return false;
|
||||
|
||||
_listView.SetUnicodeFormat(true);
|
||||
|
||||
_listView.SetUserDataLongPtr(LONG_PTR(&_listView));
|
||||
_listView._panel = this;
|
||||
_listView._origWindowProc = (WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC,
|
||||
LONG_PTR(ListViewSubclassProc));
|
||||
|
||||
#ifndef _UNICODE
|
||||
if(g_IsNT)
|
||||
_listView._origWindowProc =
|
||||
(WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
|
||||
else
|
||||
#endif
|
||||
_listView._origWindowProc =
|
||||
(WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
|
||||
|
||||
SHFILEINFO shellInfo;
|
||||
HIMAGELIST imageList = (HIMAGELIST)SHGetFileInfo(TEXT(""),
|
||||
@@ -401,8 +423,6 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
_headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle,
|
||||
_baseID + 2, 11,
|
||||
(HINSTANCE)HINST_COMMCTRL,
|
||||
@@ -414,12 +434,15 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
|
||||
icex.dwICC = ICC_USEREX_CLASSES;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
_headerComboBox.CreateEx(0, WC_COMBOBOXEX, NULL,
|
||||
_headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
|
||||
WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
|
||||
0, 0, 100, 20,
|
||||
((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
|
||||
(HMENU)(_comboBoxID),
|
||||
g_hInstance, NULL);
|
||||
// _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
|
||||
|
||||
|
||||
_headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
|
||||
|
||||
/*
|
||||
@@ -430,11 +453,20 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
|
||||
LONG_PTR(ComboBoxSubclassProc));
|
||||
*/
|
||||
_comboBoxEdit.Attach(_headerComboBox.GetEditControl());
|
||||
|
||||
// _comboBoxEdit.SendMessage(CCM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
|
||||
|
||||
_comboBoxEdit.SetUserDataLongPtr(LONG_PTR(&_comboBoxEdit));
|
||||
_comboBoxEdit._panel = this;
|
||||
_comboBoxEdit._origWindowProc =
|
||||
(WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC,
|
||||
LONG_PTR(ComboBoxEditSubclassProc));
|
||||
#ifndef _UNICODE
|
||||
if(g_IsNT)
|
||||
_comboBoxEdit._origWindowProc =
|
||||
(WNDPROC)_comboBoxEdit.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
|
||||
else
|
||||
#endif
|
||||
_comboBoxEdit._origWindowProc =
|
||||
(WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
|
||||
|
||||
|
||||
|
||||
if (_headerReBar)
|
||||
@@ -472,8 +504,8 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
|
||||
// _headerReBar.MaximizeBand(1, false);
|
||||
}
|
||||
|
||||
_statusBar.Create(WS_CHILD | WS_VISIBLE, TEXT("Status"), (*this), _statusBarID);
|
||||
// _statusBar2.Create(WS_CHILD | WS_VISIBLE, TEXT("Status"), (*this), _statusBarID + 1);
|
||||
_statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
|
||||
// _statusBar2.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID + 1);
|
||||
|
||||
int sizes[] = {150, 200, 250, -1};
|
||||
_statusBar.SetParts(4, sizes);
|
||||
@@ -607,7 +639,7 @@ void CPanel::MessageBox(LPCWSTR message)
|
||||
void CPanel::MessageBoxMyError(LPCWSTR message)
|
||||
{ MessageBox(message, L"Error"); }
|
||||
void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption)
|
||||
{ MessageBox(GetUnicodeString(NError::MyFormatMessage(errorCode)), caption); }
|
||||
{ MessageBox(NError::MyFormatMessageW(errorCode), caption); }
|
||||
void CPanel::MessageBoxError(HRESULT errorCode)
|
||||
{ MessageBoxError(errorCode, L"7-Zip"); }
|
||||
void CPanel::MessageBoxLastError(LPCWSTR caption)
|
||||
@@ -629,11 +661,6 @@ void CPanel::SetFocusToLastRememberedItem()
|
||||
_headerComboBox.SetFocus();
|
||||
}
|
||||
|
||||
CSysString CPanel::GetFileType(UINT32 index)
|
||||
{
|
||||
return TEXT("Test type");
|
||||
}
|
||||
|
||||
UString CPanel::GetFolderTypeID() const
|
||||
{
|
||||
CMyComPtr<IFolderGetTypeID> folderGetTypeID;
|
||||
|
||||
@@ -159,15 +159,18 @@ class CPanel:public NWindows::NControl::CWindow2
|
||||
virtual void OnDestroy();
|
||||
virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result);
|
||||
void OnComboBoxCommand(UINT code, LPARAM &aParam);
|
||||
bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
|
||||
#ifndef _UNICODE
|
||||
bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
|
||||
#endif
|
||||
bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result);
|
||||
bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result);
|
||||
void OnItemChanged(NMLISTVIEW *item);
|
||||
bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
|
||||
void OnDrag(LPNMLISTVIEW nmListView);
|
||||
bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
|
||||
BOOL OnBeginLabelEdit(LV_DISPINFO * lpnmh);
|
||||
BOOL OnEndLabelEdit(LV_DISPINFO * lpnmh);
|
||||
BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
|
||||
BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
|
||||
void OnColumnClick(LPNMLISTVIEW info);
|
||||
bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
|
||||
|
||||
@@ -204,8 +207,8 @@ public:
|
||||
void InvertSelection();
|
||||
private:
|
||||
|
||||
CSysString GetFileType(UInt32 index);
|
||||
LRESULT SetItemText(LVITEM &item);
|
||||
// UString GetFileType(UInt32 index);
|
||||
LRESULT SetItemText(LVITEMW &item);
|
||||
|
||||
// CRecordVector<PROPID> m_ColumnsPropIDs;
|
||||
|
||||
@@ -231,7 +234,7 @@ public:
|
||||
|
||||
UString _focusedName;
|
||||
|
||||
UInt32 GetRealIndex(const LVITEM &item) const
|
||||
UInt32 GetRealIndex(const LVITEMW &item) const
|
||||
{
|
||||
/*
|
||||
if (_virtualMode)
|
||||
@@ -326,7 +329,7 @@ public:
|
||||
|
||||
|
||||
bool _needSaveInfo;
|
||||
CSysString _typeIDString;
|
||||
UString _typeIDString;
|
||||
CListViewInfo _listViewInfo;
|
||||
CItemProperties _properties;
|
||||
CItemProperties _visibleProperties;
|
||||
|
||||
@@ -55,7 +55,7 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
|
||||
{
|
||||
UString errorMessage = LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
|
||||
UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
|
||||
if (showErrorMessages)
|
||||
MessageBox(errorMessage);
|
||||
else if (messages != 0)
|
||||
@@ -71,9 +71,9 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold
|
||||
extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages;
|
||||
|
||||
UString title = moveMode ?
|
||||
LangLoadStringW(IDS_MOVING, 0x03020206):
|
||||
LangLoadStringW(IDS_COPYING, 0x03020205);
|
||||
UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
|
||||
LangString(IDS_MOVING, 0x03020206):
|
||||
LangString(IDS_COPYING, 0x03020205);
|
||||
UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
|
||||
|
||||
extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent();
|
||||
extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
|
||||
@@ -133,7 +133,7 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
|
||||
{
|
||||
UString errorMessage = LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
|
||||
UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
|
||||
if (showErrorMessages)
|
||||
MessageBox(errorMessage);
|
||||
else if (messages != 0)
|
||||
@@ -145,8 +145,8 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP
|
||||
updater.UpdateCallbackSpec = new CUpdateCallback100Imp;
|
||||
updater.UpdateCallback = updater.UpdateCallbackSpec;
|
||||
|
||||
UString title = LangLoadStringW(IDS_COPYING, 0x03020205);
|
||||
UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
|
||||
UString title = LangString(IDS_COPYING, 0x03020205);
|
||||
UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
|
||||
|
||||
updater.UpdateCallbackSpec->ProgressDialog.MainWindow = GetParent();
|
||||
updater.UpdateCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
|
||||
@@ -176,8 +176,8 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP
|
||||
|
||||
void CPanel::CopyFrom(const UStringVector &filePaths)
|
||||
{
|
||||
UString title = LangLoadStringW(IDS_CONFIRM_FILE_COPY, 0x03020222);
|
||||
UString message = LangLoadStringW(IDS_WANT_TO_COPY_FILES, 0x03020223);
|
||||
UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222);
|
||||
UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223);
|
||||
message += L"\n\'";
|
||||
message += _currentFolderPrefix;
|
||||
message += L"\' ?";
|
||||
|
||||
@@ -2,21 +2,26 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Memory.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/Shell.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "../UI/Common/ArchiveName.h"
|
||||
#include "../UI/Common/CompressCall.h"
|
||||
|
||||
#include "Resource/MessagesDialog/MessagesDialog.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
#include "App.h"
|
||||
#include "EnumFormatEtc.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
static wchar_t *kTempDirPrefix = L"7zE";
|
||||
static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
|
||||
|
||||
@@ -212,39 +217,73 @@ STDMETHODIMP CDropSource::GiveFeedback(DWORD effect)
|
||||
return DRAGDROP_S_USEDEFAULTCURSORS;
|
||||
}
|
||||
|
||||
static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const CSysStringVector &names)
|
||||
static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &names)
|
||||
{
|
||||
size_t totalLength = 1;
|
||||
int i;
|
||||
for (i = 0; i < names.Size(); i++)
|
||||
totalLength += names[i].Length() + 1;
|
||||
|
||||
if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(TCHAR) + sizeof(DROPFILES)))
|
||||
return false;
|
||||
|
||||
NMemory::CGlobalLock dropLock(hgDrop);
|
||||
DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
|
||||
if (dropFiles == 0)
|
||||
return false;
|
||||
dropFiles->fNC = FALSE;
|
||||
dropFiles->pt.x = 0;
|
||||
dropFiles->pt.y = 0;
|
||||
dropFiles->pFiles = sizeof(DROPFILES);
|
||||
#ifdef _UNICODE
|
||||
dropFiles->fWide = TRUE;
|
||||
#else
|
||||
dropFiles->fWide = FALSE;
|
||||
#endif
|
||||
TCHAR *p = (TCHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
|
||||
for (i = 0; i < names.Size(); i++)
|
||||
#ifndef _UNICODE
|
||||
if (!g_IsNT)
|
||||
{
|
||||
const CSysString &s = names[i];
|
||||
int fullLength = s.Length() + 1;
|
||||
lstrcpy(p, s);
|
||||
p += fullLength;
|
||||
totalLength -= fullLength;
|
||||
AStringVector namesA;
|
||||
int i;
|
||||
for (i = 0; i < names.Size(); i++)
|
||||
namesA.Add(GetSystemString(names[i]));
|
||||
for (i = 0; i < names.Size(); i++)
|
||||
totalLength += namesA[i].Length() + 1;
|
||||
|
||||
if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(CHAR) + sizeof(DROPFILES)))
|
||||
return false;
|
||||
|
||||
NMemory::CGlobalLock dropLock(hgDrop);
|
||||
DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
|
||||
if (dropFiles == 0)
|
||||
return false;
|
||||
dropFiles->fNC = FALSE;
|
||||
dropFiles->pt.x = 0;
|
||||
dropFiles->pt.y = 0;
|
||||
dropFiles->pFiles = sizeof(DROPFILES);
|
||||
dropFiles->fWide = FALSE;
|
||||
CHAR *p = (CHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
|
||||
for (i = 0; i < names.Size(); i++)
|
||||
{
|
||||
const AString &s = namesA[i];
|
||||
int fullLength = s.Length() + 1;
|
||||
strcpy(p, s);
|
||||
p += fullLength;
|
||||
totalLength -= fullLength;
|
||||
}
|
||||
*p = 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < names.Size(); i++)
|
||||
totalLength += names[i].Length() + 1;
|
||||
|
||||
if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(WCHAR) + sizeof(DROPFILES)))
|
||||
return false;
|
||||
|
||||
NMemory::CGlobalLock dropLock(hgDrop);
|
||||
DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
|
||||
if (dropFiles == 0)
|
||||
return false;
|
||||
dropFiles->fNC = FALSE;
|
||||
dropFiles->pt.x = 0;
|
||||
dropFiles->pt.y = 0;
|
||||
dropFiles->pFiles = sizeof(DROPFILES);
|
||||
dropFiles->fWide = TRUE;
|
||||
WCHAR *p = (WCHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
|
||||
for (i = 0; i < names.Size(); i++)
|
||||
{
|
||||
const UString &s = names[i];
|
||||
int fullLength = s.Length() + 1;
|
||||
wcscpy(p, s);
|
||||
p += fullLength;
|
||||
totalLength -= fullLength;
|
||||
}
|
||||
*p = 0;
|
||||
}
|
||||
*p = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -278,9 +317,9 @@ void CPanel::OnDrag(LPNMLISTVIEW nmListView)
|
||||
CMyComPtr<IDataObject> dataObject = dataObjectSpec;
|
||||
|
||||
{
|
||||
CSysStringVector names;
|
||||
UStringVector names;
|
||||
for (int i = 0; i < indices.Size(); i++)
|
||||
names.Add(GetSystemString(dirPrefix + GetItemName(indices[i])));
|
||||
names.Add(dirPrefix + GetItemName(indices[i]));
|
||||
if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names))
|
||||
return;
|
||||
}
|
||||
@@ -686,15 +725,12 @@ void CPanel::DropObject(IDataObject *dataObject, const UString &folderPath)
|
||||
/*
|
||||
void CPanel::CompressDropFiles(HDROP dr)
|
||||
{
|
||||
CSysStringVector fileNames;
|
||||
UStringVector fileNames;
|
||||
{
|
||||
NShell::CDrop drop(true);
|
||||
drop.Attach(dr);
|
||||
drop.QueryFileNames(fileNames);
|
||||
}
|
||||
UStringVector fileNamesUnicode;
|
||||
for (int i = 0; i < fileNames.Size(); i++)
|
||||
fileNamesUnicode.Add(GetUnicodeString(fileNames[i]));
|
||||
CompressDropFiles(fileNamesUnicode);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -141,12 +141,12 @@ void CPanel::LoadFullPathAndShow()
|
||||
_appState->FolderHistory.AddString(_currentFolderPrefix);
|
||||
|
||||
// _headerComboBox.SendMessage(CB_RESETCONTENT, 0, 0);
|
||||
_headerComboBox.SetText(GetSystemString(_currentFolderPrefix));
|
||||
_headerComboBox.SetText(_currentFolderPrefix);
|
||||
|
||||
/*
|
||||
for (int i = 0; i < g_Folders.m_Strings.Size(); i++)
|
||||
{
|
||||
CSysString string = GetSystemString(g_Folders.m_Strings[i]);
|
||||
UString string = g_Folders.m_Strings[i];
|
||||
COMBOBOXEXITEM item;
|
||||
item.mask = CBEIF_TEXT;
|
||||
item.iItem = i;
|
||||
@@ -156,11 +156,41 @@ void CPanel::LoadFullPathAndShow()
|
||||
*/
|
||||
}
|
||||
|
||||
bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result)
|
||||
{
|
||||
if (info->iWhy == CBENF_ESCAPE)
|
||||
{
|
||||
_headerComboBox.SetText(_currentFolderPrefix);
|
||||
PostMessage(kSetFocusToListView);
|
||||
result = FALSE;
|
||||
return true;
|
||||
}
|
||||
if (info->iWhy == CBENF_DROPDOWN)
|
||||
{
|
||||
result = FALSE;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (info->iWhy == CBENF_RETURN)
|
||||
{
|
||||
if (BindToPathAndRefresh(info->szText) != S_OK)
|
||||
{
|
||||
result = TRUE;
|
||||
return true;
|
||||
}
|
||||
result = FALSE;
|
||||
PostMessage(kSetFocusToListView);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef _UNICODE
|
||||
bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
|
||||
{
|
||||
if (info->iWhy == CBENF_ESCAPE)
|
||||
{
|
||||
_headerComboBox.SetText(GetSystemString(_currentFolderPrefix));
|
||||
_headerComboBox.SetText(_currentFolderPrefix);
|
||||
PostMessage(kSetFocusToListView);
|
||||
result = FALSE;
|
||||
return true;
|
||||
@@ -175,7 +205,6 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
|
||||
{
|
||||
if (BindToPathAndRefresh(GetUnicodeString(info->szText)) != S_OK)
|
||||
{
|
||||
// MessageBeep((UINT)-1);
|
||||
result = TRUE;
|
||||
return true;
|
||||
}
|
||||
@@ -185,24 +214,22 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CPanel::OnComboBoxCommand(UINT code, LPARAM ¶m)
|
||||
{
|
||||
/*
|
||||
if (code == CBN_SELENDOK)
|
||||
{
|
||||
CSysString path;
|
||||
UString path;
|
||||
if (!_headerComboBox.GetText(path))
|
||||
return;
|
||||
CRootFolder *rootFolderSpec = new CRootFolder;
|
||||
CMyComPtr<IFolderFolder> rootFolder = rootFolderSpec;
|
||||
rootFolderSpec->Init();
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
if (rootFolder->BindToFolder(GetUnicodeString(path),
|
||||
&newFolder) != S_OK)
|
||||
{
|
||||
if (rootFolder->BindToFolder(path, &newFolder) != S_OK)
|
||||
return;
|
||||
}
|
||||
_folder = newFolder;
|
||||
SetCurrentPathText();
|
||||
RefreshListCtrl(UString(), -1, UStringVector());
|
||||
@@ -220,10 +247,16 @@ bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result)
|
||||
_lastFocusedIsList = false;
|
||||
_panelCallback->PanelWasFocused();
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
case CBEN_ENDEDIT:
|
||||
{
|
||||
return OnNotifyComboBoxEndEdit((PNMCBEENDEDIT)header, result);
|
||||
}
|
||||
#endif
|
||||
case CBEN_ENDEDITW:
|
||||
{
|
||||
return OnNotifyComboBoxEndEdit((PNMCBEENDEDITW)header, result);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -233,28 +266,23 @@ void CPanel::FoldersHistory()
|
||||
{
|
||||
CListViewDialog listViewDialog;
|
||||
listViewDialog.DeleteIsAllowed = true;
|
||||
// listViewDialog.m_Value = TEXT("*");
|
||||
listViewDialog.Title = LangLoadStringW(IDS_FOLDERS_HISTORY, 0x03020260);
|
||||
UStringVector strings;
|
||||
_appState->FolderHistory.GetList(strings);
|
||||
int i;
|
||||
for(i = 0; i < strings.Size(); i++)
|
||||
listViewDialog.Strings.Add(GetSystemString(strings[i]));
|
||||
listViewDialog.Title = LangString(IDS_FOLDERS_HISTORY, 0x03020260);
|
||||
_appState->FolderHistory.GetList(listViewDialog.Strings);
|
||||
if (listViewDialog.Create(GetParent()) == IDCANCEL)
|
||||
return;
|
||||
UString selectString;
|
||||
if (listViewDialog.StringsWereChanged)
|
||||
{
|
||||
_appState->FolderHistory.RemoveAll();
|
||||
for (i = listViewDialog.Strings.Size() - 1; i >= 0; i--)
|
||||
_appState->FolderHistory.AddString(GetUnicodeString(listViewDialog.Strings[i]));
|
||||
for (int i = listViewDialog.Strings.Size() - 1; i >= 0; i--)
|
||||
_appState->FolderHistory.AddString(listViewDialog.Strings[i]);
|
||||
if (listViewDialog.FocusedItemIndex >= 0)
|
||||
selectString = GetUnicodeString(listViewDialog.Strings[listViewDialog.FocusedItemIndex]);
|
||||
selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (listViewDialog.FocusedItemIndex >= 0)
|
||||
selectString = strings[listViewDialog.FocusedItemIndex];
|
||||
selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
|
||||
}
|
||||
if (listViewDialog.FocusedItemIndex >= 0)
|
||||
BindToPathAndRefresh(selectString);
|
||||
@@ -273,7 +301,7 @@ void CPanel::OpenParentFolder()
|
||||
pos = 0;
|
||||
else
|
||||
pos++;
|
||||
focucedName = GetUnicodeString(string.Mid(pos));
|
||||
focucedName = string.Mid(pos);
|
||||
}
|
||||
|
||||
CDisableTimerProcessing disableTimerProcessing1(*this);
|
||||
@@ -309,7 +337,7 @@ void CPanel::OpenParentFolder()
|
||||
selectedItems.Add(focucedName);
|
||||
*/
|
||||
LoadFullPath();
|
||||
::SetCurrentDirectory(::GetSystemString(_currentFolderPrefix));
|
||||
// ::SetCurrentDirectory(::_currentFolderPrefix);
|
||||
RefreshListCtrl(focucedName, -1, true, selectedItems);
|
||||
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
|
||||
RefreshStatusBar();
|
||||
@@ -337,13 +365,13 @@ void CPanel::OpenRootFolder()
|
||||
_parentFolders.Clear();
|
||||
SetToRootFolder();
|
||||
RefreshListCtrl(UString(), -1, true, UStringVector());
|
||||
// ::SetCurrentDirectory(::GetSystemString(_currentFolderPrefix));
|
||||
// ::SetCurrentDirectory(::_currentFolderPrefix);
|
||||
/*
|
||||
BeforeChangeFolder();
|
||||
_currentFolderPrefix.Empty();
|
||||
AfterChangeFolder();
|
||||
SetCurrentPathText();
|
||||
RefreshListCtrl(CSysString(), 0, CSysStringVector());
|
||||
RefreshListCtrl(UString(), 0, UStringVector());
|
||||
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
|
||||
*/
|
||||
}
|
||||
@@ -370,7 +398,7 @@ void CPanel::OpenFolder(int index)
|
||||
return;
|
||||
_folder = newFolder;
|
||||
LoadFullPath();
|
||||
::SetCurrentDirectory(::GetSystemString(_currentFolderPrefix));
|
||||
// ::SetCurrentDirectory(::_currentFolderPrefix);
|
||||
RefreshListCtrl();
|
||||
UINT state = LVIS_SELECTED;
|
||||
_listView.SetItemState(_listView.GetFocusedItem(), state, state);
|
||||
|
||||
@@ -29,9 +29,9 @@ using namespace NFile;
|
||||
using namespace NDirectory;
|
||||
|
||||
extern HWND g_HWND;
|
||||
|
||||
static inline UINT GetCurrentFileCodePage()
|
||||
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP;}
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
static wchar_t *kTempDirPrefix = L"7zO";
|
||||
|
||||
@@ -81,8 +81,7 @@ HRESULT CPanel::OpenItemAsArchive(const UString &name,
|
||||
// _password.Empty();
|
||||
|
||||
NDLL::CLibrary library;
|
||||
RINOK(OpenFileFolderPlugin(GetUnicodeString(filePath),
|
||||
&library, &newFolder, GetParent()));
|
||||
RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent()));
|
||||
|
||||
folderLink.ParentFolder = _folder;
|
||||
folderLink.ItemName = name;
|
||||
@@ -130,7 +129,7 @@ HRESULT CPanel::OpenParentArchiveFolder()
|
||||
if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName) != S_OK)
|
||||
{
|
||||
::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
|
||||
0x03020281, GetUnicodeString(folderLink.FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
@@ -151,69 +150,114 @@ static bool DoItemAlwaysStart(const UString &name)
|
||||
|
||||
static HANDLE StartEditApplication(const UString &path, HWND window)
|
||||
{
|
||||
CSysString command;
|
||||
UString command;
|
||||
ReadRegEditor(command);
|
||||
if (command.IsEmpty())
|
||||
{
|
||||
if (!MyGetWindowsDirectory(command))
|
||||
return 0;
|
||||
NFile::NName::NormalizeDirPathPrefix(command);
|
||||
command += TEXT("notepad.exe");
|
||||
command += L"notepad.exe";
|
||||
}
|
||||
command = CSysString(TEXT("\"")) + command + CSysString(TEXT("\""));
|
||||
command += TEXT(" \"");
|
||||
command += GetSystemString(path);
|
||||
command += TEXT("\"");
|
||||
command = UString(L"\"") + command + UString(L"\"");
|
||||
command += L" \"";
|
||||
command += UString(path);
|
||||
command += L"\"";
|
||||
|
||||
STARTUPINFO startupInfo;
|
||||
startupInfo.cb = sizeof(startupInfo);
|
||||
startupInfo.lpReserved = 0;
|
||||
startupInfo.lpDesktop = 0;
|
||||
startupInfo.lpTitle = 0;
|
||||
startupInfo.dwFlags = 0;
|
||||
startupInfo.cbReserved2 = 0;
|
||||
startupInfo.lpReserved2 = 0;
|
||||
|
||||
PROCESS_INFORMATION processInformation;
|
||||
BOOL result = ::CreateProcess(NULL, (TCHAR *)(const TCHAR *)command,
|
||||
BOOL result;
|
||||
#ifndef _UNICODE
|
||||
if (!g_IsNT)
|
||||
{
|
||||
STARTUPINFOA startupInfo;
|
||||
startupInfo.cb = sizeof(startupInfo);
|
||||
startupInfo.lpReserved = 0;
|
||||
startupInfo.lpDesktop = 0;
|
||||
startupInfo.lpTitle = 0;
|
||||
startupInfo.dwFlags = 0;
|
||||
startupInfo.cbReserved2 = 0;
|
||||
startupInfo.lpReserved2 = 0;
|
||||
|
||||
result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command),
|
||||
NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
STARTUPINFOW startupInfo;
|
||||
startupInfo.cb = sizeof(startupInfo);
|
||||
startupInfo.lpReserved = 0;
|
||||
startupInfo.lpDesktop = 0;
|
||||
startupInfo.lpTitle = 0;
|
||||
startupInfo.dwFlags = 0;
|
||||
startupInfo.cbReserved2 = 0;
|
||||
startupInfo.lpReserved2 = 0;
|
||||
|
||||
result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command,
|
||||
NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
|
||||
}
|
||||
|
||||
if (result != FALSE)
|
||||
{
|
||||
::CloseHandle(processInformation.hThread);
|
||||
return processInformation.hProcess;
|
||||
}
|
||||
::MessageBoxW(window, LangLoadStringW(IDS_CANNOT_START_EDITOR, 0x03020282),
|
||||
::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282),
|
||||
L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HANDLE StartApplication(const UString &path, HWND window)
|
||||
{
|
||||
SHELLEXECUTEINFO execInfo;
|
||||
execInfo.cbSize = sizeof(execInfo);
|
||||
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
|
||||
execInfo.hwnd = NULL;
|
||||
execInfo.lpVerb = NULL;
|
||||
const CSysString sysPath = GetSystemString(path);
|
||||
execInfo.lpFile = sysPath;
|
||||
execInfo.lpParameters = NULL;
|
||||
execInfo.lpDirectory = NULL;
|
||||
execInfo.nShow = SW_SHOWNORMAL;
|
||||
execInfo.hProcess = 0;
|
||||
bool success = BOOLToBool(::ShellExecuteEx(&execInfo));
|
||||
UINT32 result = (UINT32)execInfo.hInstApp;
|
||||
UINT32 result;
|
||||
HANDLE hProcess;
|
||||
#ifndef _UNICODE
|
||||
if (g_IsNT)
|
||||
{
|
||||
SHELLEXECUTEINFOW execInfo;
|
||||
execInfo.cbSize = sizeof(execInfo);
|
||||
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
|
||||
execInfo.hwnd = NULL;
|
||||
execInfo.lpVerb = NULL;
|
||||
execInfo.lpFile = path;
|
||||
execInfo.lpParameters = NULL;
|
||||
execInfo.lpDirectory = NULL;
|
||||
execInfo.nShow = SW_SHOWNORMAL;
|
||||
execInfo.hProcess = 0;
|
||||
::ShellExecuteExW(&execInfo);
|
||||
result = (UINT32)execInfo.hInstApp;
|
||||
hProcess = execInfo.hProcess;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
SHELLEXECUTEINFO execInfo;
|
||||
execInfo.cbSize = sizeof(execInfo);
|
||||
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
|
||||
execInfo.hwnd = NULL;
|
||||
execInfo.lpVerb = NULL;
|
||||
const CSysString sysPath = GetSystemString(path);
|
||||
execInfo.lpFile = sysPath;
|
||||
execInfo.lpParameters = NULL;
|
||||
execInfo.lpDirectory = NULL;
|
||||
execInfo.nShow = SW_SHOWNORMAL;
|
||||
execInfo.hProcess = 0;
|
||||
::ShellExecuteEx(&execInfo);
|
||||
result = (UINT32)execInfo.hInstApp;
|
||||
hProcess = execInfo.hProcess;
|
||||
}
|
||||
if(result <= 32)
|
||||
{
|
||||
switch(result)
|
||||
{
|
||||
case SE_ERR_NOASSOC:
|
||||
::MessageBox(window,
|
||||
NError::MyFormatMessage(::GetLastError()),
|
||||
// TEXT("There is no application associated with the given file name extension"),
|
||||
TEXT("7-Zip"), MB_OK | MB_ICONSTOP);
|
||||
::MessageBoxW(window,
|
||||
NError::MyFormatMessageW(::GetLastError()),
|
||||
// L"There is no application associated with the given file name extension",
|
||||
L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
}
|
||||
}
|
||||
return execInfo.hProcess;
|
||||
return hProcess;
|
||||
}
|
||||
|
||||
void CPanel::EditItem(int index)
|
||||
@@ -268,7 +312,7 @@ LRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
|
||||
{
|
||||
MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return E_FAIL;
|
||||
}
|
||||
UStringVector fileNames;
|
||||
@@ -342,7 +386,7 @@ static DWORD WINAPI MyThreadFunction(void *param)
|
||||
if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
|
||||
{
|
||||
::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
|
||||
0x03020281, GetUnicodeString(tmpProcessInfo->FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -365,7 +409,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
|
||||
{
|
||||
MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -443,7 +487,7 @@ static bool CheckDeleteItem(UINT64 currentFileTime, UINT64 folderFileTime)
|
||||
|
||||
void DeleteOldTempFiles()
|
||||
{
|
||||
CSysString tempPath;
|
||||
UString tempPath;
|
||||
if(!NFile::NDirectory::MyGetTempPath(tempPath))
|
||||
throw 1;
|
||||
|
||||
@@ -452,10 +496,10 @@ void DeleteOldTempFiles()
|
||||
UINT64 currentFileTime;
|
||||
if(!::SystemTimeToFileTime(&systemTime, (FILETIME *)¤tFileTime))
|
||||
throw 2;
|
||||
CSysString searchWildCard = tempPath + kTempDirPrefix + TEXT("*.tmp");
|
||||
searchWildCard += TCHAR(NName::kAnyStringWildcard);
|
||||
NFind::CEnumerator enumerator(searchWildCard);
|
||||
NFind::CFileInfo fileInfo;
|
||||
UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
|
||||
searchWildCard += WCHAR(NName::kAnyStringWildcard);
|
||||
NFind::CEnumeratorW enumerator(searchWildCard);
|
||||
NFind::CFileInfoW fileInfo;
|
||||
while(enumerator.Next(fileInfo))
|
||||
{
|
||||
if (!fileInfo.IsDirectory())
|
||||
|
||||
@@ -186,10 +186,8 @@ void CPanel::InitColumns()
|
||||
void CPanel::InsertColumn(int index)
|
||||
{
|
||||
const CItemProperty &property = _visibleProperties[index];
|
||||
LV_COLUMN column;
|
||||
LV_COLUMNW column;
|
||||
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
|
||||
TCHAR string[1024];
|
||||
column.pszText = string;
|
||||
column.cx = property.Width;
|
||||
column.fmt = GetColumnAlign(property.ID, property.Type);
|
||||
column.iOrder = property.Order;
|
||||
@@ -197,7 +195,7 @@ void CPanel::InsertColumn(int index)
|
||||
UString propertyName = GetNameOfProperty(property.ID);
|
||||
if (propertyName.IsEmpty())
|
||||
propertyName = property.Name;
|
||||
lstrcpy(string, GetSystemString(propertyName));
|
||||
column.pszText = (wchar_t *)(const wchar_t *)propertyName;
|
||||
_listView.InsertColumn(index, &column);
|
||||
}
|
||||
|
||||
@@ -223,8 +221,8 @@ void CPanel::GetSelectedNames(UStringVector &selectedNames)
|
||||
for (int i = 0; i < _listView.GetItemCount(); i++)
|
||||
{
|
||||
const int kSize = 1024;
|
||||
TCHAR name[kSize + 1];
|
||||
LVITEM item;
|
||||
WCHAR name[kSize + 1];
|
||||
LVITEMW item;
|
||||
item.iItem = i;
|
||||
item.pszText = name;
|
||||
item.cchTextMax = kSize;
|
||||
@@ -236,7 +234,7 @@ void CPanel::GetSelectedNames(UStringVector &selectedNames)
|
||||
if (realIndex == kParentIndex)
|
||||
continue;
|
||||
if (_selectedStatusVector[realIndex])
|
||||
selectedNames.Add(GetUnicodeString(item.pszText));
|
||||
selectedNames.Add(item.pszText);
|
||||
}
|
||||
*/
|
||||
selectedNames.Sort();
|
||||
@@ -262,15 +260,15 @@ void CPanel::SaveSelectedState(CSelectedState &s)
|
||||
s.FocusedName = GetItemName(realIndex);
|
||||
/*
|
||||
const int kSize = 1024;
|
||||
TCHAR name[kSize + 1];
|
||||
LVITEM item;
|
||||
WCHAR name[kSize + 1];
|
||||
LVITEMW item;
|
||||
item.iItem = focusedItem;
|
||||
item.pszText = name;
|
||||
item.cchTextMax = kSize;
|
||||
item.iSubItem = 0;
|
||||
item.mask = LVIF_TEXT;
|
||||
if (_listView.GetItem(&item))
|
||||
focusedName = GetUnicodeString(item.pszText);
|
||||
focusedName = item.pszText;
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -320,7 +318,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
_listView.SetRedraw(false);
|
||||
// m_RedrawEnabled = false;
|
||||
|
||||
LVITEM item;
|
||||
LVITEMW item;
|
||||
ZeroMemory(&item, sizeof(item));
|
||||
|
||||
_listView.DeleteAllItems();
|
||||
@@ -373,13 +371,9 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
int subItem = 0;
|
||||
item.iSubItem = subItem++;
|
||||
item.lParam = kParentIndex;
|
||||
const int kMaxNameSize = MAX_PATH * 2;
|
||||
TCHAR string[kMaxNameSize];
|
||||
lstrcpyn(string, GetSystemString(itemName), kMaxNameSize);
|
||||
item.pszText = string;
|
||||
item.pszText = (wchar_t *)(const wchar_t *)itemName;
|
||||
UINT32 attributes = FILE_ATTRIBUTE_DIRECTORY;
|
||||
item.iImage = _extToIconMap.GetIconIndex(attributes,
|
||||
GetSystemString(itemName));
|
||||
item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
|
||||
if (item.iImage < 0)
|
||||
item.iImage = 0;
|
||||
if(_listView.InsertItem(&item) == -1)
|
||||
@@ -413,11 +407,9 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
item.iSubItem = subItem++;
|
||||
item.lParam = i;
|
||||
|
||||
const int kMaxNameSize = MAX_PATH * 2;
|
||||
TCHAR string[kMaxNameSize + 1];
|
||||
UString correctedName;
|
||||
if (itemName.Find(L" ") >= 0)
|
||||
{
|
||||
UString correctedName;
|
||||
int pos = 0;
|
||||
while (true)
|
||||
{
|
||||
@@ -432,11 +424,10 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
pos = posNew;
|
||||
while (itemName[++pos] == ' ');
|
||||
}
|
||||
lstrcpyn(string, GetSystemString(correctedName), kMaxNameSize);
|
||||
item.pszText = (wchar_t *)(const wchar_t *)correctedName;
|
||||
}
|
||||
else
|
||||
lstrcpyn(string, GetSystemString(itemName), kMaxNameSize);
|
||||
item.pszText = string;
|
||||
item.pszText = (wchar_t *)(const wchar_t *)itemName;
|
||||
|
||||
NCOM::CPropVariant propVariant;
|
||||
_folder->GetProperty(i, kpidAttributes, &propVariant);
|
||||
@@ -461,13 +452,12 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
if (_currentFolderPrefix.IsEmpty())
|
||||
{
|
||||
int iconIndexTemp;
|
||||
GetRealIconIndex(GetSystemString(itemName + L"\\"), attributes, iconIndexTemp);
|
||||
GetRealIconIndex(itemName + L"\\", attributes, iconIndexTemp);
|
||||
item.iImage = iconIndexTemp;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.iImage = _extToIconMap.GetIconIndex(attributes,
|
||||
GetSystemString(itemName));
|
||||
item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
|
||||
}
|
||||
}
|
||||
if (item.iImage < 0)
|
||||
@@ -585,7 +575,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
|
||||
GetOperatedItemIndices(indices);
|
||||
if (indices.Size() > 20)
|
||||
{
|
||||
MessageBox(LangLoadStringW(IDS_TOO_MANY_ITEMS, 0x02000606));
|
||||
MessageBox(LangString(IDS_TOO_MANY_ITEMS, 0x02000606));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -667,7 +657,7 @@ void CPanel::ReadListViewInfo()
|
||||
return;
|
||||
CMyComBSTR typeID;
|
||||
folderGetTypeID->GetTypeID(&typeID);
|
||||
_typeIDString = GetSystemString((const wchar_t *)typeID);
|
||||
_typeIDString = typeID;
|
||||
::ReadListViewInfo(_typeIDString, _listViewInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "../PropID.h"
|
||||
#include "App.h"
|
||||
|
||||
// static LPCTSTR kHelpTopic = _T("FM/index.htm");
|
||||
// static LPCWSTR kHelpTopic = L"FM/index.htm";
|
||||
|
||||
struct CVKeyPropIDPair
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ static UString ConvertSizeToString(UINT64 value)
|
||||
return UString(s) + L" G";
|
||||
}
|
||||
|
||||
LRESULT CPanel::SetItemText(LVITEM &item)
|
||||
LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
{
|
||||
UINT32 realIndex = GetRealIndex(item);
|
||||
/*
|
||||
@@ -84,7 +84,7 @@ LRESULT CPanel::SetItemText(LVITEM &item)
|
||||
|
||||
if (realIndex == kParentIndex)
|
||||
return 0;
|
||||
UString string;
|
||||
UString s;
|
||||
UINT32 subItemIndex = item.iSubItem;
|
||||
PROPID propID = _visibleProperties[subItemIndex].ID;
|
||||
/*
|
||||
@@ -120,6 +120,7 @@ LRESULT CPanel::SetItemText(LVITEM &item)
|
||||
}
|
||||
if (needRead)
|
||||
*/
|
||||
|
||||
if (_folder->GetProperty(realIndex, propID, &propVariant) != S_OK)
|
||||
throw 2723407;
|
||||
|
||||
@@ -128,20 +129,16 @@ LRESULT CPanel::SetItemText(LVITEM &item)
|
||||
propID == kpidClusterSize)
|
||||
&&
|
||||
(propVariant.vt == VT_UI8 || propVariant.vt == VT_UI4))
|
||||
{
|
||||
string = ConvertSizeToString(ConvertPropVariantToUInt64(propVariant));
|
||||
}
|
||||
s = ConvertSizeToString(ConvertPropVariantToUInt64(propVariant));
|
||||
else
|
||||
{
|
||||
string = ConvertPropertyToString(propVariant, propID, false);
|
||||
}
|
||||
s = ConvertPropertyToString(propVariant, propID, false);
|
||||
|
||||
int size = item.cchTextMax;
|
||||
if(size > 0)
|
||||
{
|
||||
if(string.Length() + 1 > size)
|
||||
string = string.Left(size - 1);
|
||||
lstrcpy(item.pszText, GetSystemString(string));
|
||||
if(s.Length() + 1 > size)
|
||||
s = s.Left(size - 1);
|
||||
wcscpy(item.pszText, s);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -185,9 +182,9 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
|
||||
}
|
||||
*/
|
||||
|
||||
case LVN_GETDISPINFO:
|
||||
case LVN_GETDISPINFOW:
|
||||
{
|
||||
LV_DISPINFO *dispInfo = (LV_DISPINFO *)header;
|
||||
LV_DISPINFOW *dispInfo = (LV_DISPINFOW *)header;
|
||||
|
||||
//is the sub-item information being requested?
|
||||
|
||||
@@ -268,11 +265,11 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
|
||||
OnLeftClick((LPNMITEMACTIVATE)header);
|
||||
return false;
|
||||
}
|
||||
case LVN_BEGINLABELEDIT:
|
||||
result = OnBeginLabelEdit((LV_DISPINFO *)header);
|
||||
case LVN_BEGINLABELEDITW:
|
||||
result = OnBeginLabelEdit((LV_DISPINFOW *)header);
|
||||
return true;
|
||||
case LVN_ENDLABELEDIT:
|
||||
result = OnEndLabelEdit((LV_DISPINFO *)header);
|
||||
case LVN_ENDLABELEDITW:
|
||||
result = OnEndLabelEdit((LV_DISPINFOW *)header);
|
||||
return true;
|
||||
|
||||
case NM_CUSTOMDRAW:
|
||||
@@ -354,8 +351,7 @@ void CPanel::OnRefreshStatusBar()
|
||||
CRecordVector<UINT32> indices;
|
||||
GetOperatedItemIndices(indices);
|
||||
|
||||
_statusBar.SetText(0, GetSystemString(MyFormatNew(IDS_N_SELECTED_ITEMS,
|
||||
0x02000301, NumberToStringW(indices.Size()))));
|
||||
_statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, 0x02000301, NumberToString(indices.Size())));
|
||||
|
||||
UString selectSizeString;
|
||||
|
||||
@@ -366,12 +362,11 @@ void CPanel::OnRefreshStatusBar()
|
||||
totalSize += GetItemSize(indices[i]);
|
||||
selectSizeString = ConvertSizeToString(totalSize);
|
||||
}
|
||||
_statusBar.SetText(1, GetSystemString(selectSizeString));
|
||||
_statusBar.SetText(1, selectSizeString);
|
||||
|
||||
int focusedItem = _listView.GetFocusedItem();
|
||||
UString sizeString;
|
||||
UString dateString;
|
||||
// CSysString nameString;
|
||||
if (focusedItem >= 0 && _listView.GetSelectedCount() > 0)
|
||||
{
|
||||
int realIndex = GetRealItemIndex(focusedItem);
|
||||
@@ -382,16 +377,9 @@ void CPanel::OnRefreshStatusBar()
|
||||
if (_folder->GetProperty(realIndex, kpidLastWriteTime, &propVariant) == S_OK)
|
||||
dateString = ConvertPropertyToString(propVariant, kpidLastWriteTime, false);
|
||||
}
|
||||
// nameString = GetSystemString(GetItemName(realIndex));
|
||||
}
|
||||
_statusBar.SetText(2, GetSystemString(sizeString));
|
||||
_statusBar.SetText(3, GetSystemString(dateString));
|
||||
_statusBar.SetText(2, sizeString);
|
||||
_statusBar.SetText(3, dateString);
|
||||
// _statusBar.SetText(4, nameString);
|
||||
|
||||
|
||||
/*
|
||||
_statusBar2.SetText(1, GetSystemString(MyFormatNew(L"{0} bytes",
|
||||
NumberToStringW(totalSize))));
|
||||
*/
|
||||
// _statusBar.SetText(L"yyy"));
|
||||
// _statusBar2.SetText(1, MyFormatNew(L"{0} bytes", NumberToStringW(totalSize)));
|
||||
}
|
||||
|
||||
@@ -198,17 +198,17 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
|
||||
systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, Flags);
|
||||
|
||||
|
||||
MENUITEMINFO menuItem;
|
||||
menuItem.cbSize = sizeof(menuItem);
|
||||
menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
|
||||
menuItem.fType = MFT_STRING;
|
||||
menuItem.hSubMenu = popupMenu.Detach();
|
||||
// menuDestroyer.Disable();
|
||||
CSysString popupMenuCaption = LangLoadString(IDS_SYSTEM, 0x030202A0);
|
||||
menuItem.dwTypeData = (LPTSTR)(LPCTSTR)popupMenuCaption;
|
||||
|
||||
InsertMenuItem(menuSpec, 0, TRUE, &menuItem);
|
||||
|
||||
{
|
||||
CMenu menu;
|
||||
menu.Attach(menuSpec);
|
||||
CMenuItem menuItem;
|
||||
menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
|
||||
menuItem.fType = MFT_STRING;
|
||||
menuItem.hSubMenu = popupMenu.Detach();
|
||||
// menuDestroyer.Disable();
|
||||
menuItem.StringValue = LangString(IDS_SYSTEM, 0x030202A0);
|
||||
menu.InsertItem(0, true, menuItem);
|
||||
}
|
||||
/*
|
||||
if (Cmd < 100 && Cmd != 0)
|
||||
{
|
||||
@@ -302,7 +302,7 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
|
||||
CreateSystemMenu(menu, operatedIndices, systemContextMenu);
|
||||
|
||||
if (menu.GetItemCount() > 0)
|
||||
menu.AppendItem(MF_SEPARATOR, 0, 0);
|
||||
menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0);
|
||||
|
||||
LoadFileMenu(menu, menu.GetItemCount(), !operatedIndices.IsEmpty(), programMenu);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
|
||||
#ifndef _UNICODE
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
struct CThreadDelete
|
||||
{
|
||||
CMyComPtr<IFolderOperations> FolderOperations;
|
||||
@@ -58,37 +62,68 @@ void CPanel::DeleteItems(bool toRecycleBin)
|
||||
SaveSelectedState(state);
|
||||
if (IsFSFolder())
|
||||
{
|
||||
CDynamicBuffer<TCHAR> buffer;
|
||||
size_t size = 0;
|
||||
for (int i = 0; i < indices.Size(); i++)
|
||||
#ifndef _UNICODE
|
||||
if (!g_IsNT)
|
||||
{
|
||||
const CSysString path = GetSystemString(GetFsPath() + GetItemName(indices[i]));
|
||||
buffer.EnsureCapacity(size + path.Length() + 1);
|
||||
memmove(((TCHAR *)buffer) + size, (const TCHAR *)path, (path.Length() + 1) * sizeof(TCHAR));
|
||||
size += path.Length() + 1;
|
||||
CDynamicBuffer<CHAR> buffer;
|
||||
size_t size = 0;
|
||||
for (int i = 0; i < indices.Size(); i++)
|
||||
{
|
||||
const AString path = GetSystemString(GetFsPath() + GetItemName(indices[i]));
|
||||
buffer.EnsureCapacity(size + path.Length() + 1);
|
||||
memmove(((CHAR *)buffer) + size, (const CHAR *)path, (path.Length() + 1) * sizeof(CHAR));
|
||||
size += path.Length() + 1;
|
||||
}
|
||||
buffer.EnsureCapacity(size + 1);
|
||||
((CHAR *)buffer)[size] = 0;
|
||||
SHFILEOPSTRUCTA fo;
|
||||
fo.hwnd = GetParent();
|
||||
fo.wFunc = FO_DELETE;
|
||||
fo.pFrom = (const CHAR *)buffer;
|
||||
fo.pTo = 0;
|
||||
fo.fFlags = 0;
|
||||
if (toRecycleBin)
|
||||
fo.fFlags |= FOF_ALLOWUNDO;
|
||||
// fo.fFlags |= FOF_NOCONFIRMATION;
|
||||
// fo.fFlags |= FOF_NOERRORUI;
|
||||
// fo.fFlags |= FOF_SILENT;
|
||||
// fo.fFlags |= FOF_WANTNUKEWARNING;
|
||||
fo.fAnyOperationsAborted = FALSE;
|
||||
fo.hNameMappings = 0;
|
||||
fo.lpszProgressTitle = 0;
|
||||
int res = ::SHFileOperationA(&fo);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
CDynamicBuffer<WCHAR> buffer;
|
||||
size_t size = 0;
|
||||
for (int i = 0; i < indices.Size(); i++)
|
||||
{
|
||||
const UString path = GetFsPath() + GetItemName(indices[i]);
|
||||
buffer.EnsureCapacity(size + path.Length() + 1);
|
||||
memmove(((WCHAR *)buffer) + size, (const WCHAR *)path, (path.Length() + 1) * sizeof(WCHAR));
|
||||
size += path.Length() + 1;
|
||||
}
|
||||
buffer.EnsureCapacity(size + 1);
|
||||
((WCHAR *)buffer)[size] = 0;
|
||||
SHFILEOPSTRUCTW fo;
|
||||
fo.hwnd = GetParent();
|
||||
fo.wFunc = FO_DELETE;
|
||||
fo.pFrom = (const WCHAR *)buffer;
|
||||
fo.pTo = 0;
|
||||
fo.fFlags = 0;
|
||||
if (toRecycleBin)
|
||||
fo.fFlags |= FOF_ALLOWUNDO;
|
||||
fo.fAnyOperationsAborted = FALSE;
|
||||
fo.hNameMappings = 0;
|
||||
fo.lpszProgressTitle = 0;
|
||||
int res = ::SHFileOperationW(&fo);
|
||||
}
|
||||
buffer.EnsureCapacity(size + 1);
|
||||
((TCHAR *)buffer)[size] = 0;
|
||||
SHFILEOPSTRUCT fo;
|
||||
fo.hwnd = GetParent();
|
||||
fo.wFunc = FO_DELETE;
|
||||
fo.pFrom = (const TCHAR *)buffer;
|
||||
fo.pTo = 0;
|
||||
fo.fFlags = 0;
|
||||
if (toRecycleBin)
|
||||
fo.fFlags |= FOF_ALLOWUNDO;
|
||||
// fo.fFlags |= FOF_NOCONFIRMATION;
|
||||
// fo.fFlags |= FOF_NOERRORUI;
|
||||
// fo.fFlags |= FOF_SILENT;
|
||||
// fo.fFlags |= FOF_WANTNUKEWARNING;
|
||||
fo.fAnyOperationsAborted = FALSE;
|
||||
fo.hNameMappings = 0;
|
||||
fo.lpszProgressTitle = 0;
|
||||
int res = SHFileOperation(&fo);
|
||||
/*
|
||||
if (fo.fAnyOperationsAborted)
|
||||
{
|
||||
MessageBoxError(result, LangLoadStringW(IDS_ERROR_DELETING, 0x03020217));
|
||||
MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
|
||||
}
|
||||
*/
|
||||
/*
|
||||
@@ -102,7 +137,7 @@ void CPanel::DeleteItems(bool toRecycleBin)
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
|
||||
{
|
||||
MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,20 +149,20 @@ void CPanel::DeleteItems(bool toRecycleBin)
|
||||
const UString itemName = GetItemName(index);
|
||||
if (IsItemFolder(index))
|
||||
{
|
||||
title = LangLoadStringW(IDS_CONFIRM_FOLDER_DELETE, 0x03020211);
|
||||
title = LangString(IDS_CONFIRM_FOLDER_DELETE, 0x03020211);
|
||||
message = MyFormatNew(IDS_WANT_TO_DELETE_FOLDER, 0x03020214, itemName);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = LangLoadStringW(IDS_CONFIRM_FILE_DELETE, 0x03020210);
|
||||
title = LangString(IDS_CONFIRM_FILE_DELETE, 0x03020210);
|
||||
message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
title = LangLoadStringW(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
|
||||
title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
|
||||
message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215,
|
||||
NumberToStringW(indices.Size()));
|
||||
NumberToString(indices.Size()));
|
||||
}
|
||||
if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK)
|
||||
return;
|
||||
@@ -137,10 +172,10 @@ void CPanel::DeleteItems(bool toRecycleBin)
|
||||
deleter.UpdateCallback = deleter.UpdateCallbackSpec;
|
||||
deleter.UpdateCallbackSpec->Init(GetParent(), false, L"");
|
||||
|
||||
UString progressTitle = LangLoadStringW(IDS_DELETING, 0x03020216);
|
||||
UString progressTitle = LangString(IDS_DELETING, 0x03020216);
|
||||
|
||||
deleter.UpdateCallbackSpec->ProgressDialog.MainWindow = _mainWindow;
|
||||
deleter.UpdateCallbackSpec->ProgressDialog.MainTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
|
||||
deleter.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
|
||||
deleter.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
|
||||
|
||||
deleter.FolderOperations = folderOperations;
|
||||
@@ -153,13 +188,13 @@ void CPanel::DeleteItems(bool toRecycleBin)
|
||||
|
||||
HRESULT result = deleter.Result;
|
||||
if (result != S_OK)
|
||||
MessageBoxError(result, LangLoadStringW(IDS_ERROR_DELETING, 0x03020217));
|
||||
MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
|
||||
}
|
||||
|
||||
RefreshListCtrl(state);
|
||||
}
|
||||
|
||||
BOOL CPanel::OnBeginLabelEdit(LV_DISPINFO * lpnmh)
|
||||
BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
|
||||
{
|
||||
int realIndex = GetRealIndex(lpnmh->item);
|
||||
if (realIndex == kParentIndex)
|
||||
@@ -170,7 +205,7 @@ BOOL CPanel::OnBeginLabelEdit(LV_DISPINFO * lpnmh)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CPanel::OnEndLabelEdit(LV_DISPINFO * lpnmh)
|
||||
BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
|
||||
{
|
||||
if (lpnmh->item.pszText == NULL)
|
||||
return FALSE;
|
||||
@@ -180,7 +215,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFO * lpnmh)
|
||||
MessageBoxMyError(L"Renaming is not supported");
|
||||
return FALSE;
|
||||
}
|
||||
UString newName = GetUnicodeString(lpnmh->item.pszText);
|
||||
UString newName = lpnmh->item.pszText;
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
|
||||
|
||||
int realIndex = GetRealIndex(lpnmh->item);
|
||||
@@ -189,7 +224,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFO * lpnmh)
|
||||
HRESULT result = folderOperations->Rename(realIndex, newName, 0);
|
||||
if (result != S_OK)
|
||||
{
|
||||
MessageBoxError(result, LangLoadStringW(IDS_ERROR_RENAMING, 0x03020221));
|
||||
MessageBoxError(result, LangString(IDS_ERROR_RENAMING, 0x03020221));
|
||||
return FALSE;
|
||||
}
|
||||
// Can't use RefreshListCtrl here.
|
||||
@@ -209,26 +244,26 @@ void CPanel::CreateFolder()
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
|
||||
{
|
||||
MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
|
||||
CSelectedState state;
|
||||
SaveSelectedState(state);
|
||||
CComboDialog comboDialog;
|
||||
comboDialog.Title = LangLoadStringW(IDS_CREATE_FOLDER, 0x03020230);
|
||||
comboDialog.Static = LangLoadStringW(IDS_CREATE_FOLDER_NAME, 0x03020231);
|
||||
comboDialog.Value = LangLoadStringW(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
|
||||
comboDialog.Title = LangString(IDS_CREATE_FOLDER, 0x03020230);
|
||||
comboDialog.Static = LangString(IDS_CREATE_FOLDER_NAME, 0x03020231);
|
||||
comboDialog.Value = LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
|
||||
if (comboDialog.Create(GetParent()) == IDCANCEL)
|
||||
return;
|
||||
UString newName = GetUnicodeString(comboDialog.Value);
|
||||
UString newName = comboDialog.Value;
|
||||
HRESULT result = folderOperations->CreateFolder(newName, 0);
|
||||
if (result != S_OK)
|
||||
{
|
||||
MessageBoxError(result, LangLoadStringW(IDS_CREATE_FOLDER_ERROR, 0x03020233));
|
||||
MessageBoxError(result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
|
||||
return;
|
||||
}
|
||||
int pos = newName.Find(TEXT('\\'));
|
||||
int pos = newName.Find(L'\\');
|
||||
if (pos >= 0)
|
||||
newName = newName.Left(pos);
|
||||
if (!_mySelectMode)
|
||||
@@ -243,26 +278,26 @@ void CPanel::CreateFile()
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
|
||||
{
|
||||
MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
|
||||
CSelectedState state;
|
||||
SaveSelectedState(state);
|
||||
CComboDialog comboDialog;
|
||||
comboDialog.Title = LangLoadStringW(IDS_CREATE_FILE, 0x03020240);
|
||||
comboDialog.Static = LangLoadStringW(IDS_CREATE_FILE_NAME, 0x03020241);
|
||||
comboDialog.Value = LangLoadStringW(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
|
||||
comboDialog.Title = LangString(IDS_CREATE_FILE, 0x03020240);
|
||||
comboDialog.Static = LangString(IDS_CREATE_FILE_NAME, 0x03020241);
|
||||
comboDialog.Value = LangString(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
|
||||
if (comboDialog.Create(GetParent()) == IDCANCEL)
|
||||
return;
|
||||
UString newName = GetUnicodeString(comboDialog.Value);
|
||||
UString newName = comboDialog.Value;
|
||||
HRESULT result = folderOperations->CreateFile(newName, 0);
|
||||
if (result != S_OK)
|
||||
{
|
||||
MessageBoxError(result, LangLoadStringW(IDS_CREATE_FILE_ERROR, 0x03020243));
|
||||
MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243));
|
||||
return;
|
||||
}
|
||||
int pos = newName.Find(TEXT('\\'));
|
||||
int pos = newName.Find(L'\\');
|
||||
if (pos >= 0)
|
||||
newName = newName.Left(pos);
|
||||
if (!_mySelectMode)
|
||||
@@ -293,7 +328,7 @@ void CPanel::ChangeComment()
|
||||
CMyComPtr<IFolderOperations> folderOperations;
|
||||
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
|
||||
{
|
||||
MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -309,12 +344,12 @@ void CPanel::ChangeComment()
|
||||
}
|
||||
UString name = GetItemName(realIndex);
|
||||
CComboDialog comboDialog;
|
||||
comboDialog.Title = name + L" " + LangLoadStringW(IDS_COMMENT, 0x03020290);
|
||||
comboDialog.Title = name + L" " + LangString(IDS_COMMENT, 0x03020290);
|
||||
comboDialog.Value = comment;
|
||||
comboDialog.Static = LangLoadStringW(IDS_COMMENT2, 0x03020291);
|
||||
comboDialog.Static = LangString(IDS_COMMENT2, 0x03020291);
|
||||
if (comboDialog.Create(GetParent()) == IDCANCEL)
|
||||
return;
|
||||
NCOM::CPropVariant propVariant = GetUnicodeString(comboDialog.Value);
|
||||
NCOM::CPropVariant propVariant = comboDialog.Value;
|
||||
|
||||
HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);
|
||||
if (result != S_OK)
|
||||
|
||||
@@ -152,9 +152,9 @@ void CPanel::SelectSpec(bool selectMode)
|
||||
{
|
||||
CComboDialog comboDialog;
|
||||
comboDialog.Title = selectMode ?
|
||||
LangLoadStringW(IDS_SELECT, 0x03020250):
|
||||
LangLoadStringW(IDS_DESELECT, 0x03020251);
|
||||
comboDialog.Static = LangLoadStringW(IDS_SELECT_MASK, 0x03020252);
|
||||
LangString(IDS_SELECT, 0x03020250):
|
||||
LangString(IDS_DESELECT, 0x03020251);
|
||||
comboDialog.Static = LangString(IDS_SELECT_MASK, 0x03020252);
|
||||
comboDialog.Value = L"*";
|
||||
if (comboDialog.Create(GetParent()) == IDCANCEL)
|
||||
return;
|
||||
|
||||
@@ -31,10 +31,10 @@ public:
|
||||
{
|
||||
if (_data != 0)
|
||||
return false;
|
||||
_data = BigAlloc(size);
|
||||
_data = ::MidAlloc(size);
|
||||
return _data != 0;
|
||||
}
|
||||
~CMyBuffer() { BigFree(_data); }
|
||||
~CMyBuffer() { ::MidFree(_data); }
|
||||
};
|
||||
|
||||
struct CVolSeqName
|
||||
@@ -184,7 +184,7 @@ void CApp::Split()
|
||||
CPanel &srcPanel = Panels[srcPanelIndex];
|
||||
if (!srcPanel.IsFSFolder())
|
||||
{
|
||||
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
CRecordVector<UInt32> indices;
|
||||
@@ -223,8 +223,8 @@ void CApp::Split()
|
||||
CProgressDialog progressDialog;
|
||||
spliter.ProgressDialog = &progressDialog;
|
||||
|
||||
UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
|
||||
UString title = LangLoadStringW(IDS_SPLITTING, 0x03020510);
|
||||
UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
|
||||
UString title = LangString(IDS_SPLITTING, 0x03020510);
|
||||
|
||||
progressDialog.MainWindow = _window;
|
||||
progressDialog.MainTitle = progressWindowTitle;
|
||||
@@ -392,7 +392,7 @@ void CApp::Combine()
|
||||
CPanel &srcPanel = Panels[srcPanelIndex];
|
||||
if (!srcPanel.IsFSFolder())
|
||||
{
|
||||
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
CRecordVector<UInt32> indices;
|
||||
@@ -421,11 +421,11 @@ void CApp::Combine()
|
||||
path = destPanel._currentFolderPrefix;
|
||||
CCopyDialog copyDialog;
|
||||
copyDialog.Value = path;
|
||||
copyDialog.Title = LangLoadStringW(IDS_COMBINE, 0x03020600);
|
||||
copyDialog.Title = LangString(IDS_COMBINE, 0x03020600);
|
||||
copyDialog.Title += ' ';
|
||||
copyDialog.Title += itemName;
|
||||
|
||||
copyDialog.Static = LangLoadStringW(IDS_COMBINE_TO, 0x03020601);;
|
||||
copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601);;
|
||||
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
|
||||
return;
|
||||
|
||||
@@ -435,8 +435,8 @@ void CApp::Combine()
|
||||
CProgressDialog progressDialog;
|
||||
combiner.ProgressDialog = &progressDialog;
|
||||
|
||||
UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000);
|
||||
UString title = LangLoadStringW(IDS_COMBINING, 0x03020610);
|
||||
UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
|
||||
UString title = LangString(IDS_COMBINING, 0x03020610);
|
||||
|
||||
progressDialog.MainWindow = _window;
|
||||
progressDialog.MainTitle = progressWindowTitle;
|
||||
|
||||
274
7zip/FileManager/PhysDriveFolder.cpp
Executable file
274
7zip/FileManager/PhysDriveFolder.cpp
Executable file
@@ -0,0 +1,274 @@
|
||||
// PhysDriveFolder.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "PhysDriveFolder.h"
|
||||
|
||||
#include "Common/Alloc.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/FileDevice.h"
|
||||
#include "Windows/FileSystem.h"
|
||||
|
||||
#include "../PropID.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static const UInt32 kBufferSize = (4 << 20);
|
||||
|
||||
static STATPROPSTG kProperties[] =
|
||||
{
|
||||
{ NULL, kpidName, VT_BSTR},
|
||||
{ NULL, kpidSize, VT_UI8}
|
||||
};
|
||||
|
||||
CPhysDriveFolder::~CPhysDriveFolder()
|
||||
{
|
||||
if (_buffer != 0)
|
||||
MyFree(_buffer);
|
||||
}
|
||||
|
||||
HRESULT CPhysDriveFolder::Init(const UString &path)
|
||||
{
|
||||
_prefix = L"\\\\.\\";
|
||||
_path = path;
|
||||
NFile::NDevice::CInFile inFile;
|
||||
if (!inFile.Open(GetFullPath()))
|
||||
return GetLastError();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::LoadItems()
|
||||
{
|
||||
_driveType = NFile::NSystem::MyGetDriveType(_path + L"\\");
|
||||
_name = _path.Left(1);
|
||||
_name += L'.';
|
||||
if (_driveType == DRIVE_CDROM)
|
||||
_name += L"iso";
|
||||
else
|
||||
_name += L"img";
|
||||
Int32 dummy;
|
||||
WasChanged(&dummy);
|
||||
return GetLength(_length);
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = 1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (itemIndex >= 1)
|
||||
return E_INVALIDARG;
|
||||
switch(propID)
|
||||
{
|
||||
case kpidIsFolder:
|
||||
propVariant = false;
|
||||
break;
|
||||
case kpidName:
|
||||
propVariant = _name;
|
||||
break;
|
||||
case kpidSize:
|
||||
propVariant = _length;
|
||||
break;
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
|
||||
{ return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
|
||||
{ return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::GetName(BSTR *name)
|
||||
{ return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::GetPropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
return E_INVALIDARG;
|
||||
const STATPROPSTG &prop = kProperties[index];
|
||||
*propID = prop.propid;
|
||||
*varType = prop.vt;
|
||||
*name = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::GetTypeID(BSTR *name)
|
||||
{
|
||||
CMyComBSTR temp = L"PhysDrive";
|
||||
*name = temp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::GetPath(BSTR *path)
|
||||
{
|
||||
UString tempPath = GetFullPath() + L"\\";
|
||||
CMyComBSTR temp = tempPath;
|
||||
*path = temp.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::WasChanged(Int32 *wasChanged)
|
||||
{
|
||||
bool wasChangedMain = false;
|
||||
*wasChanged = BoolToInt(wasChangedMain);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::Clone(IFolderFolder **resultFolder)
|
||||
{
|
||||
CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
|
||||
CMyComPtr<IFolderFolder> folderNew = folderSpec;
|
||||
folderSpec->Init(_path);
|
||||
*resultFolder = folderNew.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (index >= 1)
|
||||
return E_INVALIDARG;
|
||||
UInt64 size = 0;
|
||||
HRESULT result = GetLength(size);
|
||||
propVariant = size;
|
||||
propVariant.Detach(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::CreateFolder(const wchar_t *name, IProgress *progress)
|
||||
{ return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::CreateFile(const wchar_t *name, IProgress *progress)
|
||||
{ return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress)
|
||||
{ return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::Delete(const UInt32 *indices, UInt32 numItems, IProgress *progress)
|
||||
{ return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::SetProperty(UInt32 index, PROPID propID,
|
||||
const PROPVARIANT *value, IProgress *progress)
|
||||
{
|
||||
if (index >= 1)
|
||||
return E_INVALIDARG;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT CPhysDriveFolder::GetLength(UInt64 &length) const
|
||||
{
|
||||
NFile::NDevice::CInFile inFile;
|
||||
if (!inFile.Open(GetFullPath()))
|
||||
return GetLastError();
|
||||
if (!inFile.GetLengthSmart(length))
|
||||
return GetLastError();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback)
|
||||
{
|
||||
if (numItems == 0)
|
||||
return S_OK;
|
||||
UString destPath = path;
|
||||
if (destPath.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
bool directName = (destPath[destPath.Length() - 1] != L'\\');
|
||||
if (directName)
|
||||
{
|
||||
if (numItems > 1)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
else
|
||||
destPath += _name;
|
||||
|
||||
UInt64 fileSize;
|
||||
if (GetLength(fileSize) == S_OK)
|
||||
{
|
||||
RINOK(callback->SetTotal(fileSize));
|
||||
}
|
||||
|
||||
Int32 writeAskResult;
|
||||
CMyComBSTR destPathResult;
|
||||
RINOK(callback->AskWrite(GetFullPath(), BoolToInt(false), NULL, &fileSize,
|
||||
destPath, &destPathResult, &writeAskResult));
|
||||
if (!IntToBool(writeAskResult))
|
||||
return S_OK;
|
||||
|
||||
RINOK(callback->SetCurrentFilePath(GetFullPathWithName()));
|
||||
|
||||
NFile::NDevice::CInFile inFile;
|
||||
if (!inFile.Open(GetFullPath()))
|
||||
return GetLastError();
|
||||
NFile::NIO::COutFile outFile;
|
||||
if (!outFile.Create(destPathResult, true))
|
||||
return GetLastError();
|
||||
if (_buffer == 0)
|
||||
{
|
||||
_buffer = MyAlloc(kBufferSize);
|
||||
if (_buffer == 0)
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
UInt64 pos = 0;
|
||||
UInt32 bufferSize = kBufferSize;
|
||||
if (_driveType == DRIVE_REMOVABLE)
|
||||
bufferSize = (18 << 10) * 4;
|
||||
pos = 0;
|
||||
while(pos < fileSize)
|
||||
{
|
||||
RINOK(callback->SetCompleted(&pos));
|
||||
UInt32 curSize = (UInt32)MyMin(fileSize - pos, (UInt64)bufferSize);
|
||||
UInt32 processedSize;
|
||||
if (!inFile.Read(_buffer, curSize, processedSize))
|
||||
return GetLastError();
|
||||
if (processedSize == 0)
|
||||
break;
|
||||
curSize = processedSize;
|
||||
if (!outFile.Write(_buffer, curSize, processedSize))
|
||||
return GetLastError();
|
||||
if (curSize != processedSize)
|
||||
return E_FAIL;
|
||||
pos += curSize;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Move Operations
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::MoveTo(
|
||||
const UInt32 *indices,
|
||||
UInt32 numItems,
|
||||
const wchar_t *path,
|
||||
IFolderOperationsExtractCallback *callback)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CPhysDriveFolder::CopyFrom(
|
||||
const wchar_t *fromFolderPath,
|
||||
const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
89
7zip/FileManager/PhysDriveFolder.h
Executable file
89
7zip/FileManager/PhysDriveFolder.h
Executable file
@@ -0,0 +1,89 @@
|
||||
// PhysDriveFolder.h
|
||||
|
||||
#ifndef __PHYSDRIVEFOLDER_H
|
||||
#define __PHYSDRIVEFOLDER_H
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "IFolder.h"
|
||||
|
||||
class CPhysDriveFolder:
|
||||
public IFolderFolder,
|
||||
public IEnumProperties,
|
||||
public IFolderGetTypeID,
|
||||
public IFolderGetPath,
|
||||
public IFolderWasChanged,
|
||||
public IFolderOperations,
|
||||
public IFolderGetItemFullSize,
|
||||
public IFolderClone,
|
||||
// public IFolderGetSystemIconIndex,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
UInt64 GetSizeOfItem(int anIndex) const;
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IEnumProperties)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderGetTypeID)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderGetPath)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderOperations)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize)
|
||||
MY_QUERYINTERFACE_ENTRY(IFolderClone)
|
||||
// MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex)
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
|
||||
STDMETHOD(LoadItems)();
|
||||
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
|
||||
STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
|
||||
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetName)(BSTR *name);
|
||||
|
||||
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
STDMETHOD(GetTypeID)(BSTR *name);
|
||||
STDMETHOD(GetPath)(BSTR *path);
|
||||
STDMETHOD(WasChanged)(INT32 *wasChanged);
|
||||
STDMETHOD(Clone)(IFolderFolder **resultFolder);
|
||||
STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
|
||||
|
||||
// IFolderOperations
|
||||
STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress);
|
||||
STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress);
|
||||
STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress);
|
||||
STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress);
|
||||
STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback);
|
||||
STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems,
|
||||
const wchar_t *path, IFolderOperationsExtractCallback *callback);
|
||||
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
|
||||
const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress);
|
||||
STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
|
||||
// STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
|
||||
|
||||
private:
|
||||
UString _name;
|
||||
UString _prefix;
|
||||
UString _path;
|
||||
UString GetFullPath() const { return _prefix + _path; }
|
||||
UString GetFullPathWithName() const { return GetFullPath() + L'\\' + _name; }
|
||||
CMyComPtr<IFolderFolder> _parentFolder;
|
||||
void *_buffer;
|
||||
|
||||
UINT _driveType;
|
||||
DISK_GEOMETRY geom;
|
||||
UInt64 _length;
|
||||
|
||||
public:
|
||||
HRESULT Init(const UString &path);
|
||||
HRESULT GetLength(UInt64 &size) const;
|
||||
CPhysDriveFolder(): _buffer(0) {}
|
||||
~CPhysDriveFolder();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
return GetLastError();
|
||||
return createObject(&clsID, &IID_IFolderManager, (void **)manager);
|
||||
}
|
||||
HRESULT LoadAndCreateManager(LPCTSTR filePath, REFGUID clsID, IFolderManager **manager)
|
||||
HRESULT LoadAndCreateManager(LPCWSTR filePath, REFGUID clsID, IFolderManager **manager)
|
||||
{
|
||||
if (!Load(filePath))
|
||||
return GetLastError();
|
||||
|
||||
@@ -69,5 +69,5 @@ UString GetNameOfProperty(PROPID propID)
|
||||
if (index < 0)
|
||||
return UString();
|
||||
const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index];
|
||||
return LangLoadStringW(pair.ResourceID, pair.LangID);
|
||||
return LangString(pair.ResourceID, pair.LangID);
|
||||
}
|
||||
|
||||
@@ -25,21 +25,24 @@ static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
|
||||
static const TCHAR *kCUKeyPath = TEXT("Software\\7-ZIP\\FM");
|
||||
static const TCHAR *kAssociations = TEXT("Associations");
|
||||
static const TCHAR *kExtPlugins = TEXT("Plugins");
|
||||
static const WCHAR *kExtPlugins = L"Plugins";
|
||||
static const TCHAR *kExtEnabled = TEXT("Enabled");
|
||||
|
||||
static CSysString GetAssociationsPath()
|
||||
{
|
||||
return CSysString(kCUKeyPath) + CSysString('\\') + CSysString(kAssociations);
|
||||
}
|
||||
|
||||
bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo)
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
|
||||
CKey key;
|
||||
if(key.Open(HKEY_CURRENT_USER, CSysString(kCUKeyPath)
|
||||
+ CSysString('\\') + CSysString(kAssociations)
|
||||
+ CSysString('\\') + CSysString(GetSystemString(ext)),
|
||||
KEY_READ) != ERROR_SUCCESS)
|
||||
if(key.Open(HKEY_CURRENT_USER, GetAssociationsPath() + CSysString('\\') +
|
||||
CSysString(GetSystemString(ext)), KEY_READ) != ERROR_SUCCESS)
|
||||
return false;
|
||||
CSysString pluginsString;
|
||||
UString pluginsString;
|
||||
key.QueryValue(kExtPlugins, pluginsString);
|
||||
SplitString(GetUnicodeString(pluginsString), extInfo.Plugins);
|
||||
SplitString(pluginsString, extInfo.Plugins);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -48,8 +51,7 @@ void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
|
||||
items.Clear();
|
||||
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
|
||||
CKey associationsKey;
|
||||
if(associationsKey.Open(HKEY_CURRENT_USER, CSysString(kCUKeyPath)
|
||||
+ CSysString('\\') + CSysString(kAssociations), KEY_READ) != ERROR_SUCCESS)
|
||||
if(associationsKey.Open(HKEY_CURRENT_USER, GetAssociationsPath(), KEY_READ) != ERROR_SUCCESS)
|
||||
return;
|
||||
CSysStringVector extNames;
|
||||
associationsKey.EnumKeys(extNames);
|
||||
@@ -62,9 +64,9 @@ void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
|
||||
CKey key;
|
||||
if(key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS)
|
||||
return;
|
||||
CSysString pluginsString;
|
||||
UString pluginsString;
|
||||
key.QueryValue(kExtPlugins, pluginsString);
|
||||
SplitString(GetUnicodeString(pluginsString), extInfo.Plugins);
|
||||
SplitString(pluginsString, extInfo.Plugins);
|
||||
/*
|
||||
if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS)
|
||||
extInfo.Enabled = false;
|
||||
@@ -86,7 +88,7 @@ void WriteInternalAssociations(const CObjectVector<CExtInfo> &items)
|
||||
const CExtInfo &extInfo = items[i];
|
||||
CKey key;
|
||||
key.Create(associationsKey, GetSystemString(extInfo.Ext));
|
||||
key.SetValue(kExtPlugins, GetSystemString(JoinStrings(extInfo.Plugins)));
|
||||
key.SetValue(kExtPlugins, JoinStrings(extInfo.Plugins));
|
||||
// key.SetValue(kExtEnabled, extInfo.Enabled);
|
||||
}
|
||||
}
|
||||
@@ -160,9 +162,9 @@ void DeleteShellExtensionInfo(const CSysString &extension)
|
||||
}
|
||||
|
||||
void AddShellExtensionInfo(const CSysString &extension,
|
||||
const CSysString &programTitle,
|
||||
const CSysString &programOpenCommand,
|
||||
const CSysString &iconPath,
|
||||
const UString &programTitle,
|
||||
const UString &programOpenCommand,
|
||||
const UString &iconPath,
|
||||
const void *shellNewData, int shellNewDataSize)
|
||||
{
|
||||
DeleteShellExtensionKey(extension);
|
||||
@@ -200,18 +202,7 @@ void AddShellExtensionInfo(const CSysString &extension,
|
||||
CKey commandKey;
|
||||
commandKey.Create(openKey, kCommandKeyName);
|
||||
|
||||
CSysString params;
|
||||
/*
|
||||
if (!NSystem::MyGetWindowsDirectory(aParams))
|
||||
{
|
||||
aParams.Empty();
|
||||
// return;
|
||||
}
|
||||
else
|
||||
NFile::NName::NormalizeDirPathPrefix(aParams);
|
||||
*/
|
||||
// aParams += kOpenCommandValue;
|
||||
HRESULT result = commandKey.SetValue(NULL, programOpenCommand);
|
||||
commandKey.SetValue(NULL, programOpenCommand);
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace NRegistryAssociations {
|
||||
void DeleteShellExtensionInfo(const CSysString &extension);
|
||||
|
||||
void AddShellExtensionInfo(const CSysString &extension,
|
||||
const CSysString &programTitle,
|
||||
const CSysString &programOpenCommand,
|
||||
const CSysString &iconPath,
|
||||
const UString &programTitle,
|
||||
const UString &programOpenCommand,
|
||||
const UString &iconPath,
|
||||
const void *shellNewData, int shellNewDataSize);
|
||||
|
||||
|
||||
|
||||
@@ -92,40 +92,22 @@ static bool ReadPluginInfo(CPluginInfo &pluginInfo)
|
||||
return true;
|
||||
}
|
||||
|
||||
CSysString GetProgramFolderPrefix();
|
||||
|
||||
#ifndef _WIN64
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
UString GetProgramFolderPrefix();
|
||||
|
||||
void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
|
||||
{
|
||||
plugins.Clear();
|
||||
|
||||
CSysString baseFolderPrefix = GetProgramFolderPrefix();
|
||||
UString baseFolderPrefix = GetProgramFolderPrefix();
|
||||
{
|
||||
CSysString path = baseFolderPrefix + TEXT("7-zip");
|
||||
#ifndef _WIN64
|
||||
if (IsItWindowsNT())
|
||||
path += TEXT("n");
|
||||
#endif
|
||||
path += TEXT(".dll");
|
||||
CPluginInfo pluginInfo;
|
||||
pluginInfo.FilePath = path;
|
||||
|
||||
pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll";
|
||||
if (::ReadPluginInfo(pluginInfo))
|
||||
plugins.Add(pluginInfo);
|
||||
}
|
||||
CSysString folderPath = baseFolderPrefix + TEXT("Plugins\\");
|
||||
NFind::CEnumerator enumerator(folderPath + TEXT("*"));
|
||||
NFind::CFileInfo fileInfo;
|
||||
UString folderPath = baseFolderPrefix + L"Plugins\\";
|
||||
NFind::CEnumeratorW enumerator(folderPath + L"*");
|
||||
NFind::CFileInfoW fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
{
|
||||
if (fileInfo.IsDirectory())
|
||||
|
||||
@@ -13,7 +13,7 @@ enum EPluginType
|
||||
|
||||
struct CPluginInfo
|
||||
{
|
||||
CSysString FilePath;
|
||||
UString FilePath;
|
||||
EPluginType Type;
|
||||
UString Name;
|
||||
CLSID ClassID;
|
||||
|
||||
@@ -10,9 +10,10 @@ using namespace NRegistry;
|
||||
|
||||
static const TCHAR *kCUBasePath = TEXT("Software\\7-ZIP");
|
||||
static const TCHAR *kCU_FMPath = TEXT("Software\\7-ZIP\\FM");
|
||||
static const TCHAR *kLM_Path = TEXT("Software\\7-ZIP\\FM");
|
||||
|
||||
static const TCHAR *kLangValueName = TEXT("Lang");
|
||||
static const TCHAR *kEditor = TEXT("Editor");
|
||||
static const WCHAR *kLangValueName = L"Lang";
|
||||
static const WCHAR *kEditor = L"Editor";
|
||||
static const TCHAR *kShowDots = TEXT("ShowDots");
|
||||
static const TCHAR *kShowRealFileIcons = TEXT("ShowRealFileIcons");
|
||||
static const TCHAR *kShowSystemMenu = TEXT("ShowSystemMenu");
|
||||
@@ -20,58 +21,96 @@ static const TCHAR *kShowSystemMenu = TEXT("ShowSystemMenu");
|
||||
static const TCHAR *kFullRow = TEXT("FullRow");
|
||||
static const TCHAR *kShowGrid = TEXT("ShowGrid");
|
||||
static const TCHAR *kAlternativeSelection = TEXT("AlternativeSelection");
|
||||
static const TCHAR *kLockMemoryAdd = TEXT("LockMemoryAdd");
|
||||
static const TCHAR *kLargePagesEnable = TEXT("LargePages");
|
||||
// static const TCHAR *kSingleClick = TEXT("SingleClick");
|
||||
// static const TCHAR *kUnderline = TEXT("Underline");
|
||||
|
||||
void SaveRegLang(const CSysString &langFile)
|
||||
void SaveRegLang(const UString &langFile)
|
||||
{
|
||||
CKey cuKey;
|
||||
cuKey.Create(HKEY_CURRENT_USER, kCUBasePath);
|
||||
cuKey.SetValue(kLangValueName, langFile);
|
||||
CKey key;
|
||||
key.Create(HKEY_CURRENT_USER, kCUBasePath);
|
||||
key.SetValue(kLangValueName, langFile);
|
||||
}
|
||||
|
||||
void ReadRegLang(CSysString &langFile)
|
||||
void ReadRegLang(UString &langFile)
|
||||
{
|
||||
langFile.Empty();
|
||||
CKey cuKey;
|
||||
cuKey.Create(HKEY_CURRENT_USER, kCUBasePath);
|
||||
cuKey.QueryValue(kLangValueName, langFile);
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
|
||||
key.QueryValue(kLangValueName, langFile);
|
||||
}
|
||||
|
||||
void SaveRegEditor(const CSysString &editorPath)
|
||||
void SaveRegEditor(const UString &editorPath)
|
||||
{
|
||||
CKey cuKey;
|
||||
cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath);
|
||||
cuKey.SetValue(kEditor, editorPath);
|
||||
CKey key;
|
||||
key.Create(HKEY_CURRENT_USER, kCU_FMPath);
|
||||
key.SetValue(kEditor, editorPath);
|
||||
}
|
||||
|
||||
void ReadRegEditor(CSysString &editorPath)
|
||||
void ReadRegEditor(UString &editorPath)
|
||||
{
|
||||
editorPath.Empty();
|
||||
CKey cuKey;
|
||||
cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath);
|
||||
cuKey.QueryValue(kEditor, editorPath);
|
||||
/*
|
||||
if (editorPath.IsEmpty())
|
||||
editorPath = TEXT("notepad.exe");
|
||||
*/
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
|
||||
key.QueryValue(kEditor, editorPath);
|
||||
}
|
||||
|
||||
static void Save7ZipOption(const TCHAR *value, bool enabled)
|
||||
{
|
||||
CKey key;
|
||||
key.Create(HKEY_CURRENT_USER, kCUBasePath);
|
||||
key.SetValue(value, enabled);
|
||||
}
|
||||
|
||||
static void SaveOption(const TCHAR *value, bool enabled)
|
||||
{
|
||||
CKey cuKey;
|
||||
cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath);
|
||||
cuKey.SetValue(value, enabled);
|
||||
CKey key;
|
||||
key.Create(HKEY_CURRENT_USER, kCU_FMPath);
|
||||
key.SetValue(value, enabled);
|
||||
}
|
||||
|
||||
static bool Read7ZipOption(const TCHAR *value, bool defaultValue)
|
||||
{
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
|
||||
{
|
||||
bool enabled;
|
||||
if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
|
||||
return enabled;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static bool ReadOption(const TCHAR *value, bool defaultValue)
|
||||
{
|
||||
CKey cuKey;
|
||||
cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath);
|
||||
bool enabled;
|
||||
if (cuKey.QueryValue(value, enabled) != ERROR_SUCCESS)
|
||||
return defaultValue;
|
||||
return enabled;
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
|
||||
{
|
||||
bool enabled;
|
||||
if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
|
||||
return enabled;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static void SaveLmOption(const TCHAR *value, bool enabled)
|
||||
{
|
||||
CKey key;
|
||||
key.Create(HKEY_LOCAL_MACHINE, kLM_Path);
|
||||
key.SetValue(value, enabled);
|
||||
}
|
||||
|
||||
static bool ReadLmOption(const TCHAR *value, bool defaultValue)
|
||||
{
|
||||
CKey key;
|
||||
if (key.Open(HKEY_LOCAL_MACHINE, kLM_Path, KEY_READ) == ERROR_SUCCESS)
|
||||
{
|
||||
bool enabled;
|
||||
if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
|
||||
return enabled;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
void SaveShowDots(bool showDots) { SaveOption(kShowDots, showDots); }
|
||||
@@ -98,4 +137,12 @@ bool ReadSingleClick(){ return ReadOption(kSingleClick, false); }
|
||||
|
||||
void SaveUnderline(bool enable) { SaveOption(kUnderline, enable); }
|
||||
bool ReadUnderline(){ return ReadOption(kUnderline, false); }
|
||||
*/
|
||||
*/
|
||||
|
||||
// void SaveLockMemoryAdd(bool enable) { SaveLmOption(kLockMemoryAdd, enable); }
|
||||
// bool ReadLockMemoryAdd() { return ReadLmOption(kLockMemoryAdd, true); }
|
||||
|
||||
void SaveLockMemoryEnable(bool enable) { Save7ZipOption(kLargePagesEnable, enable); }
|
||||
bool ReadLockMemoryEnable() { return Read7ZipOption(kLargePagesEnable, false); }
|
||||
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#ifndef __REGISTRYUTILS_H
|
||||
#define __REGISTRYUTILS_H
|
||||
|
||||
void SaveRegLang(const CSysString &langFile);
|
||||
void ReadRegLang(CSysString &langFile);
|
||||
void SaveRegLang(const UString &langFile);
|
||||
void ReadRegLang(UString &langFile);
|
||||
|
||||
void SaveRegEditor(const CSysString &langFile);
|
||||
void ReadRegEditor(CSysString &langFile);
|
||||
void SaveRegEditor(const UString &editorPath);
|
||||
void ReadRegEditor(UString &editorPath);
|
||||
|
||||
void SaveShowDots(bool showDots);
|
||||
bool ReadShowDots();
|
||||
@@ -29,6 +29,12 @@ bool ReadShowGrid();
|
||||
void SaveAlternativeSelection(bool enable);
|
||||
bool ReadAlternativeSelection();
|
||||
|
||||
// void SaveLockMemoryAdd(bool enable);
|
||||
// bool ReadLockMemoryAdd();
|
||||
|
||||
bool ReadLockMemoryEnable();
|
||||
void SaveLockMemoryEnable(bool enable);
|
||||
|
||||
/*
|
||||
void SaveSingleClick(bool enable);
|
||||
bool ReadSingleClick();
|
||||
|
||||
@@ -12,8 +12,7 @@ public:
|
||||
virtual bool OnInit();
|
||||
virtual void OnHelp();
|
||||
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
|
||||
INT_PTR Create(HWND aWndParent = 0)
|
||||
{ return CModalDialog::Create(MAKEINTRESOURCE(IDD_ABOUT), aWndParent); }
|
||||
INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_ABOUT, wndParent); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringToInt.h"
|
||||
#include "Common/Exception.h"
|
||||
#include "Common/Alloc.h"
|
||||
#include "Windows/Thread.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/Error.h"
|
||||
@@ -140,15 +141,22 @@ public:
|
||||
UInt32 BufferSize;
|
||||
Byte *Buffer;
|
||||
CBenchRandomGenerator(): Buffer(0) {}
|
||||
~CBenchRandomGenerator() { delete []Buffer; }
|
||||
void Init() { RG.Init(); }
|
||||
void Set(UInt32 bufferSize)
|
||||
{
|
||||
delete []Buffer;
|
||||
~CBenchRandomGenerator() { Free(); }
|
||||
void Free()
|
||||
{
|
||||
::MidFree(Buffer);
|
||||
Buffer = 0;
|
||||
Buffer = new Byte[bufferSize];
|
||||
}
|
||||
void Init() { RG.Init(); }
|
||||
bool Alloc(UInt32 bufferSize)
|
||||
{
|
||||
if (Buffer != 0 && BufferSize == bufferSize)
|
||||
return true;
|
||||
Free();
|
||||
Buffer = (Byte *)::MidAlloc(bufferSize);
|
||||
Pos = 0;
|
||||
BufferSize = bufferSize;
|
||||
return (Buffer != 0);
|
||||
}
|
||||
UInt32 GetRndBit() { return RG.GetRnd(1); }
|
||||
/*
|
||||
@@ -525,15 +533,29 @@ public:
|
||||
UInt32 Pos;
|
||||
Byte *Buffer;
|
||||
CBenchmarkOutStream(): Buffer(0) {}
|
||||
~CBenchmarkOutStream() { delete []Buffer; }
|
||||
void Init(UInt32 bufferSize)
|
||||
{
|
||||
delete []Buffer;
|
||||
~CBenchmarkOutStream() { Free(); }
|
||||
void Free()
|
||||
{
|
||||
::MidFree(Buffer);
|
||||
Buffer = 0;
|
||||
Buffer = new Byte[bufferSize];
|
||||
Pos = 0;
|
||||
BufferSize = bufferSize;
|
||||
}
|
||||
|
||||
bool Alloc(UInt32 bufferSize)
|
||||
{
|
||||
if (Buffer != 0 && BufferSize == bufferSize)
|
||||
return true;
|
||||
Free();
|
||||
Buffer = (Byte *)::MidAlloc(bufferSize);
|
||||
Init();
|
||||
BufferSize = bufferSize;
|
||||
return (Buffer != 0);
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
Pos = 0;
|
||||
}
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
@@ -691,7 +713,9 @@ DWORD CThreadBenchmark::Process()
|
||||
writeCoderProperties->WriteCoderProperties(propStream);
|
||||
}
|
||||
|
||||
randomGenerator.Set(kBufferSize);
|
||||
if (!randomGenerator.Alloc(kBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
randomGenerator.Generate();
|
||||
CCRC crc;
|
||||
|
||||
@@ -705,11 +729,22 @@ DWORD CThreadBenchmark::Process()
|
||||
}
|
||||
|
||||
CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
|
||||
inStreamSpec->Init(randomGenerator.Buffer, randomGenerator.BufferSize);
|
||||
CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
|
||||
CBenchmarkOutStream *outStreamSpec = new CBenchmarkOutStream;
|
||||
outStreamSpec->Init(kCompressedBufferSize);
|
||||
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
|
||||
if (!outStreamSpec->Alloc(kCompressedBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
{
|
||||
// this code is for reducing time of memory allocationg
|
||||
inStreamSpec->Init(randomGenerator.Buffer, MyMin((UInt32)1, randomGenerator.BufferSize));
|
||||
outStreamSpec->Init();
|
||||
HRESULT result = Encoder->Code(inStream, outStream, 0, 0, NULL);
|
||||
}
|
||||
|
||||
inStreamSpec->Init(randomGenerator.Buffer, randomGenerator.BufferSize);
|
||||
outStreamSpec->Init();
|
||||
|
||||
_approvedStart = dictionarySize;
|
||||
_startTime = ::GetTimeCount();
|
||||
HRESULT result = Encoder->Code(inStream, outStream, 0, 0, this);
|
||||
|
||||
@@ -128,11 +128,7 @@ public:
|
||||
CProgressSyncInfo _syncInfo;
|
||||
|
||||
CBenchmarkDialog(): _timer(0) {}
|
||||
|
||||
INT_PTR Create(HWND wndParent = 0)
|
||||
{
|
||||
return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_BENCHMARK), wndParent);
|
||||
}
|
||||
INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
|
||||
};
|
||||
|
||||
void Benchmark(HWND hwnd);
|
||||
|
||||
@@ -17,10 +17,9 @@ public:
|
||||
UString Title;
|
||||
UString Static;
|
||||
UString Value;
|
||||
CSysStringVector Strings;
|
||||
UStringVector Strings;
|
||||
// CComboDialog(): Sorted(false) {};
|
||||
INT_PTR Create(HWND parentWindow = 0)
|
||||
{ return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_COMBO), parentWindow); }
|
||||
INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COMBO, parentWindow); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ bool CCopyDialog::OnInit()
|
||||
staticContol.Attach(GetItem(IDC_COPY_STATIC));
|
||||
staticContol.SetText(Static);
|
||||
for(int i = 0; i < Strings.Size(); i++)
|
||||
_path.AddString(GetSystemString(Strings[i]));
|
||||
_path.AddString(Strings[i]);
|
||||
_path.SetText(Value);
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
@@ -53,19 +53,19 @@ bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
|
||||
void CCopyDialog::OnButtonSetPath()
|
||||
{
|
||||
CSysString currentPath;
|
||||
UString currentPath;
|
||||
_path.GetText(currentPath);
|
||||
|
||||
/*
|
||||
#ifdef LANG
|
||||
CSysString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
|
||||
UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
|
||||
#else
|
||||
CSysString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
|
||||
UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
|
||||
#endif
|
||||
*/
|
||||
CSysString title = TEXT("Specify a location for output folder");
|
||||
UString title = L"Specify a location for output folder";
|
||||
|
||||
CSysString resultPath;
|
||||
UString resultPath;
|
||||
if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
|
||||
return;
|
||||
NFile::NName::NormalizeDirPathPrefix(resultPath);
|
||||
|
||||
@@ -20,8 +20,7 @@ public:
|
||||
UString Value;
|
||||
UStringVector Strings;
|
||||
|
||||
INT_PTR Create(HWND parentWindow = 0)
|
||||
{ return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_COPY), parentWindow); }
|
||||
INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/CommonDialog.h"
|
||||
// #include "Windows/FileFind.h"
|
||||
// #include "Windows/FileDir.h"
|
||||
|
||||
@@ -29,7 +30,7 @@ bool CEditPage::OnInit()
|
||||
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
|
||||
|
||||
_editorEdit.Attach(GetItem(IDC_EDIT_EDIT_EDITOR));
|
||||
CSysString editorPath;
|
||||
UString editorPath;
|
||||
ReadRegEditor(editorPath);
|
||||
_editorEdit.SetText(editorPath);
|
||||
return CPropertyPage::OnInit();
|
||||
@@ -40,7 +41,7 @@ LONG CEditPage::OnApply()
|
||||
// int selectedIndex = _langCombo.GetCurSel();
|
||||
// int pathIndex = _langCombo.GetItemData(selectedIndex);
|
||||
// ReloadLang();
|
||||
CSysString editorPath;
|
||||
UString editorPath;
|
||||
_editorEdit.GetText(editorPath);
|
||||
SaveRegEditor(editorPath);
|
||||
return PSNRET_NOERROR;
|
||||
@@ -66,85 +67,14 @@ bool CEditPage::OnButtonClicked(int aButtonID, HWND aButtonHWND)
|
||||
return CPropertyPage::OnButtonClicked(aButtonID, aButtonHWND);
|
||||
}
|
||||
|
||||
class CDoubleZeroStringList
|
||||
{
|
||||
CRecordVector<int> _indexes;
|
||||
CSysString _string;
|
||||
public:
|
||||
void Add(LPCTSTR string);
|
||||
void SetForBuffer(LPTSTR buffer);
|
||||
};
|
||||
|
||||
const TCHAR kDelimiterSymbol = TEXT(' ');
|
||||
void CDoubleZeroStringList::Add(LPCTSTR string)
|
||||
{
|
||||
_string += string;
|
||||
_indexes.Add(_string.Length());
|
||||
_string += kDelimiterSymbol;
|
||||
}
|
||||
|
||||
void CDoubleZeroStringList::SetForBuffer(LPTSTR buffer)
|
||||
{
|
||||
lstrcpy(buffer, _string);
|
||||
for (int i = 0; i < _indexes.Size(); i++)
|
||||
buffer[_indexes[i]] = TEXT('\0');
|
||||
}
|
||||
|
||||
void CEditPage::OnSetEditorButton()
|
||||
{
|
||||
OPENFILENAME info;
|
||||
info.lStructSize = sizeof(info);
|
||||
info.hwndOwner = HWND(*this);
|
||||
info.hInstance = 0;
|
||||
|
||||
const int kBufferSize = MAX_PATH * 2;
|
||||
TCHAR buffer[kBufferSize + 1];
|
||||
CSysString editorPath;
|
||||
UString editorPath;
|
||||
_editorEdit.GetText(editorPath);
|
||||
|
||||
lstrcpy(buffer, editorPath);
|
||||
|
||||
const int kFilterBufferSize = MAX_PATH;
|
||||
TCHAR filterBuffer[kFilterBufferSize];
|
||||
CDoubleZeroStringList doubleZeroStringList;
|
||||
CSysString string = TEXT("*.exe");
|
||||
doubleZeroStringList.Add(string);
|
||||
doubleZeroStringList.Add(string);
|
||||
doubleZeroStringList.SetForBuffer(filterBuffer);
|
||||
info.lpstrFilter = filterBuffer;
|
||||
|
||||
info.lpstrCustomFilter = NULL;
|
||||
info.nMaxCustFilter = 0;
|
||||
info.nFilterIndex = 0;
|
||||
|
||||
info.lpstrFile = buffer;
|
||||
info.nMaxFile = kBufferSize;
|
||||
|
||||
info.lpstrFileTitle = NULL;
|
||||
info.nMaxFileTitle = 0;
|
||||
|
||||
info.lpstrInitialDir= NULL;
|
||||
|
||||
/*
|
||||
CSysString title = "Open";
|
||||
LangLoadString(IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, 0x02000D90);
|
||||
info.lpstrTitle = title;
|
||||
*/
|
||||
info.lpstrTitle = 0;
|
||||
|
||||
|
||||
info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
|
||||
info.nFileOffset = 0;
|
||||
info.nFileExtension = 0;
|
||||
info.lpstrDefExt = NULL;
|
||||
|
||||
info.lCustData = 0;
|
||||
info.lpfnHook = NULL;
|
||||
info.lpTemplateName = NULL;
|
||||
|
||||
if(!GetOpenFileName(&info))
|
||||
UString resPath;
|
||||
if(!MyGetOpenFileName(HWND(*this), 0, editorPath, L"*.exe", resPath))
|
||||
return;
|
||||
_editorEdit.SetText(buffer);
|
||||
_editorEdit.SetText(resPath);
|
||||
// Changed();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ bool CLangPage::OnInit()
|
||||
|
||||
_langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG));
|
||||
|
||||
CSysString s = NWindows::MyLoadString(IDS_LANG_ENGLISH);
|
||||
s += TEXT(" (");
|
||||
s += NWindows::MyLoadString(IDS_LANG_NATIVE);
|
||||
s += TEXT(")");
|
||||
UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH);
|
||||
s += L" (";
|
||||
s += NWindows::MyLoadStringW(IDS_LANG_NATIVE);
|
||||
s += L")";
|
||||
int index = _langCombo.AddString(s);
|
||||
_langCombo.SetItemData(index, _paths.Size());
|
||||
_paths.Add(TEXT("-"));
|
||||
_paths.Add(L"-");
|
||||
_langCombo.SetCurSel(0);
|
||||
|
||||
CObjectVector<CLangEx> langs;
|
||||
@@ -55,10 +55,10 @@ bool CLangPage::OnInit()
|
||||
name += L")";
|
||||
}
|
||||
}
|
||||
index = _langCombo.AddString(GetSystemString(name));
|
||||
index = _langCombo.AddString(name);
|
||||
_langCombo.SetItemData(index, _paths.Size());
|
||||
_paths.Add(GetSystemString(lang.ShortName));
|
||||
if (g_LangID.CompareNoCase(GetSystemString(lang.ShortName)) == 0)
|
||||
_paths.Add(lang.ShortName);
|
||||
if (g_LangID.CompareNoCase(lang.ShortName) == 0)
|
||||
_langCombo.SetCurSel(index);
|
||||
}
|
||||
return CPropertyPage::OnInit();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user