4.30 beta

This commit is contained in:
Igor Pavlov
2005-11-18 00:00:00 +00:00
committed by Kornel Lesiński
parent bcd1db2f5a
commit e18587ba51
214 changed files with 5385 additions and 2712 deletions

View File

@@ -18,9 +18,10 @@ static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
#include "../../Compress/Copy/CopyCoder.h" #include "../../Compress/Copy/CopyCoder.h"
#endif #endif
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
#ifdef COMPRESS_LZMA #ifdef COMPRESS_LZMA
#include "../../Compress/LZMA/LZMAEncoder.h" #include "../../Compress/LZMA/LZMAEncoder.h"
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
#endif #endif
#ifdef COMPRESS_PPMD #ifdef COMPRESS_PPMD
@@ -114,7 +115,7 @@ static void ConvertBindInfoToFolderItemInfo(const NCoderMixer2::CBindInfo &bindI
folder.PackStreams.Add(bindInfo.InStreams[i]); folder.PackStreams.Add(bindInfo.InStreams[i]);
} }
HRESULT CEncoder::CreateMixerCoder() HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
{ {
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT; _mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
_mixerCoder = _mixerCoderSpec; _mixerCoder = _mixerCoderSpec;
@@ -203,6 +204,30 @@ HRESULT CEncoder::CreateMixerCoder()
return E_FAIL; return E_FAIL;
#endif #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) if (methodFull.CoderProperties.Size() > 0)
{ {
@@ -215,7 +240,10 @@ HRESULT CEncoder::CreateMixerCoder()
{ {
const CProperty &property = methodFull.CoderProperties[i]; const CProperty &property = methodFull.CoderProperties[i];
propIDs.Add(property.PropID); 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; CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
if (methodFull.IsSimpleCoder()) if (methodFull.IsSimpleCoder())
@@ -308,7 +336,7 @@ HRESULT CEncoder::CreateMixerCoder()
} }
HRESULT CEncoder::Encode(ISequentialInStream *inStream, HRESULT CEncoder::Encode(ISequentialInStream *inStream,
const UInt64 *inStreamSize, const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
CFolder &folderItem, CFolder &folderItem,
ISequentialOutStream *outStream, ISequentialOutStream *outStream,
CRecordVector<UInt64> &packSizes, CRecordVector<UInt64> &packSizes,
@@ -316,7 +344,7 @@ HRESULT CEncoder::Encode(ISequentialInStream *inStream,
{ {
if (_mixerCoderSpec == NULL) if (_mixerCoderSpec == NULL)
{ {
RINOK(CreateMixerCoder()); RINOK(CreateMixerCoder(inSizeForReduce));
} }
_mixerCoderSpec->ReInit(); _mixerCoderSpec->ReInit();
// _mixerCoderSpec->SetCoderInfo(0, NULL, NULL, progress); // _mixerCoderSpec->SetCoderInfo(0, NULL, NULL, progress);

View File

@@ -38,13 +38,13 @@ class CEncoder
NCoderMixer2::CBindReverseConverter *_bindReverseConverter; NCoderMixer2::CBindReverseConverter *_bindReverseConverter;
CRecordVector<CMethodID> _decompressionMethods; CRecordVector<CMethodID> _decompressionMethods;
HRESULT CreateMixerCoder(); HRESULT CreateMixerCoder(const UInt64 *inSizeForReduce);
public: public:
CEncoder(const CCompressionMethodMode &options); CEncoder(const CCompressionMethodMode &options);
~CEncoder(); ~CEncoder();
HRESULT Encode(ISequentialInStream *inStream, HRESULT Encode(ISequentialInStream *inStream,
const UInt64 *inStreamSize, const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
CFolder &folderItem, CFolder &folderItem,
ISequentialOutStream *outStream, ISequentialOutStream *outStream,
CRecordVector<UInt64> &packSizes, CRecordVector<UInt64> &packSizes,

View File

@@ -81,7 +81,7 @@ const wchar_t *kDefaultMethodName = kLZMAMethodName;
static const wchar_t *kMatchFinderForHeaders = L"BT2"; static const wchar_t *kMatchFinderForHeaders = L"BT2";
static const UInt32 kDictionaryForHeaders = 1 << 20; static const UInt32 kDictionaryForHeaders = 1 << 20;
static const UInt32 kNumFastBytesForHeaders = 254; static const UInt32 kNumFastBytesForHeaders = 273;
static bool IsLZMAMethod(const UString &methodName) static bool IsLZMAMethod(const UString &methodName)
{ return (methodName.CompareNoCase(kLZMAMethodName) == 0); } { return (methodName.CompareNoCase(kLZMAMethodName) == 0); }

View File

@@ -576,8 +576,8 @@ HRESULT COutArchive::EncodeStream(CEncoder &encoder, const Byte *data, size_t da
CFolder folderItem; CFolder folderItem;
folderItem.UnPackCRCDefined = true; folderItem.UnPackCRCDefined = true;
folderItem.UnPackCRC = CCRC::CalculateDigest(data, dataSize); folderItem.UnPackCRC = CCRC::CalculateDigest(data, dataSize);
RINOK(encoder.Encode(stream, NULL, folderItem, SeqStream, UInt64 dataSize64 = dataSize;
packSizes, NULL)); RINOK(encoder.Encode(stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL));
folders.Add(folderItem); folders.Add(folderItem);
return S_OK; return S_OK;
} }

View File

@@ -566,11 +566,21 @@ static HRESULT Update2(
UInt64 complexity = 0; UInt64 complexity = 0;
for(i = 0; i < folderRefs.Size(); i++) for(i = 0; i < folderRefs.Size(); i++)
complexity += database->GetFolderFullPackSize(folderRefs[i]); complexity += database->GetFolderFullPackSize(folderRefs[i]);
UInt64 inSizeForReduce = 0;
for(i = 0; i < updateItems.Size(); i++) for(i = 0; i < updateItems.Size(); i++)
{ {
const CUpdateItem &updateItem = updateItems[i]; const CUpdateItem &updateItem = updateItems[i];
if (updateItem.NewData) if (updateItem.NewData)
{
complexity += updateItem.Size; complexity += updateItem.Size;
if (numSolidFiles == 1)
{
if (updateItem.Size > inSizeForReduce)
inSizeForReduce = updateItem.Size;
}
else
inSizeForReduce += updateItem.Size;
}
} }
RINOK(updateCallback->SetTotal(complexity)); RINOK(updateCallback->SetTotal(complexity));
complexity = 0; complexity = 0;
@@ -636,6 +646,10 @@ static HRESULT Update2(
SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter, SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter,
updateItems, groups); updateItems, groups);
const UInt32 kMinReduceSize = (1 << 16);
if (inSizeForReduce < kMinReduceSize)
inSizeForReduce = kMinReduceSize;
for (int groupIndex = 0; groupIndex < groups.Size(); groupIndex++) for (int groupIndex = 0; groupIndex < groups.Size(); groupIndex++)
{ {
const CSolidGroup &group = groups[groupIndex]; const CSolidGroup &group = groups[groupIndex];
@@ -708,7 +722,7 @@ static HRESULT Update2(
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec; CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
localCompressProgressSpec->Init(localProgress, &complexity, NULL); localCompressProgressSpec->Init(localProgress, &complexity, NULL);
RINOK(encoder.Encode(solidInStream, NULL, folderItem, RINOK(encoder.Encode(solidInStream, NULL, &inSizeForReduce, folderItem,
archive.SeqStream, newDatabase.PackSizes, compressProgress)); archive.SeqStream, newDatabase.PackSizes, compressProgress));
// for() // for()
// newDatabase.PackCRCsDefined.Add(false); // newDatabase.PackCRCsDefined.Add(false);

View File

@@ -4,6 +4,9 @@
#include "../../../Common/MyInitGuid.h" #include "../../../Common/MyInitGuid.h"
#include "../../../Common/ComTry.h" #include "../../../Common/ComTry.h"
#ifdef _WIN32
#include "../../../Common/Alloc.h"
#endif
#include "../../ICoder.h" #include "../../ICoder.h"
@@ -18,12 +21,32 @@ DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
#endif #endif
HINSTANCE g_hInstance; 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" extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
if (dwReason == DLL_PROCESS_ATTACH) if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance; g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
#ifdef _WIN32
SetLargePageSize();
#endif
}
return TRUE; return TRUE;
} }

View File

@@ -256,6 +256,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close() STDMETHODIMP CHandler::Close()
{ {
_items.Clear();
_stream.Release(); _stream.Release();
return S_OK; return S_OK;
} }

View File

@@ -21,6 +21,17 @@ DEFINE_GUID(CLSID_CBZip2Handler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x02, 0x00, 0x00); 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x02, 0x00, 0x00);
HINSTANCE g_hInstance; 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 #ifndef COMPRESS_BZIP2
#include "../Common/CodecsPath.h" #include "../Common/CodecsPath.h"
@@ -34,7 +45,12 @@ extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
if (dwReason == DLL_PROCESS_ATTACH) if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance; g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
}
return TRUE; return TRUE;
} }
@@ -86,10 +102,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
return S_OK; return S_OK;
} }
case NArchive::kExtension: case NArchive::kExtension:
propVariant = L"bz2 tbz2"; propVariant = L"bz2 bzip2 tbz2 tbz";
break; break;
case NArchive::kAddExtension: case NArchive::kAddExtension:
propVariant = L"* .tar"; propVariant = L"* * .tar .tar";
break; break;
case NArchive::kUpdate: case NArchive::kUpdate:
propVariant = true; propVariant = true;

View File

@@ -224,6 +224,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close() STDMETHODIMP CHandler::Close()
{ {
m_Database.Clear();
m_Stream.Release(); m_Stream.Release();
return S_OK; return S_OK;
} }

View File

@@ -11,12 +11,12 @@ static const int kBufferSize = 1 << 17;
CFilterCoder::CFilterCoder() CFilterCoder::CFilterCoder()
{ {
_buffer = (Byte *)::BigAlloc(kBufferSize); _buffer = (Byte *)::MidAlloc(kBufferSize);
} }
CFilterCoder::~CFilterCoder() CFilterCoder::~CFilterCoder()
{ {
BigFree(_buffer); ::MidFree(_buffer);
} }
HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 size) HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 size)

View File

@@ -36,7 +36,7 @@ class CInStreamWithCRC:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IInStream)
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);

View File

@@ -21,6 +21,17 @@ DEFINE_GUID(CLSID_CCompressDeflateDecoder,
0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00); 0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00);
HINSTANCE g_hInstance; 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 #ifndef COMPRESS_DEFLATE
#include "../Common/CodecsPath.h" #include "../Common/CodecsPath.h"
@@ -34,7 +45,12 @@ extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
if (dwReason == DLL_PROCESS_ATTACH) if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance; g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
}
return TRUE; return TRUE;
} }
@@ -85,10 +101,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
return S_OK; return S_OK;
} }
case NArchive::kExtension: case NArchive::kExtension:
propVariant = L"gz tgz"; propVariant = L"gz gzip tgz tpz";
break; break;
case NArchive::kAddExtension: case NArchive::kAddExtension:
propVariant = L"* .tar"; propVariant = L"* * .tar .tar";
break; break;
case NArchive::kUpdate: case NArchive::kUpdate:
propVariant = true; propVariant = true;

View File

@@ -192,7 +192,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
if (value.vt != VT_UI4) if (value.vt != VT_UI4)
return E_INVALIDARG; return E_INVALIDARG;
m_Method.NumPasses = value.ulVal; 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; return E_INVALIDARG;
} }
else if (name == L"FB") else if (name == L"FB")
@@ -200,8 +200,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
if (value.vt != VT_UI4) if (value.vt != VT_UI4)
return E_INVALIDARG; return E_INVALIDARG;
m_Method.NumFastBytes = value.ulVal; m_Method.NumFastBytes = value.ulVal;
/*
if (m_Method.NumFastBytes < 3 || m_Method.NumFastBytes > 255) if (m_Method.NumFastBytes < 3 || m_Method.NumFastBytes > 255)
return E_INVALIDARG; return E_INVALIDARG;
*/
} }
else else
return E_INVALIDARG; return E_INVALIDARG;

View File

@@ -270,6 +270,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close() STDMETHODIMP CHandler::Close()
{ {
_items.Clear();
_stream.Release(); _stream.Release();
return S_OK; return S_OK;
} }

View File

@@ -16,6 +16,17 @@ DEFINE_GUID(CLSID_CCrypto_AES128_Decoder,
#include "RarHandler.h" #include "RarHandler.h"
HINSTANCE g_hInstance; 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) void GetCryptoFolderPrefix(TCHAR *path)
{ {
@@ -54,7 +65,12 @@ extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
if (dwReason == DLL_PROCESS_ATTACH) if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance; g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
}
return TRUE; return TRUE;
} }

View File

@@ -276,6 +276,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
STDMETHODIMP CHandler::Close() STDMETHODIMP CHandler::Close()
{ {
_sizes.Clear();
_streams.Clear(); _streams.Clear();
return S_OK; return S_OK;
} }

View File

@@ -130,6 +130,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
STDMETHODIMP CHandler::Close() STDMETHODIMP CHandler::Close()
{ {
_items.Clear();
_inStream.Release(); _inStream.Release();
return S_OK; return S_OK;
} }

View File

@@ -120,10 +120,12 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
RIF(OctalToNumber32(cur, 8, item.Mode)); RIF(OctalToNumber32(cur, 8, item.Mode));
cur += 8; cur += 8;
RIF(OctalToNumber32(cur, 8, item.UID)); if (!OctalToNumber32(cur, 8, item.UID))
item.UID = 0;
cur += 8; cur += 8;
RIF(OctalToNumber32(cur, 8, item.GID)); if (!OctalToNumber32(cur, 8, item.GID))
item.GID = 0;
cur += 8; cur += 8;
RIF(OctalToNumber(cur, 12, item.Size)); RIF(OctalToNumber(cur, 12, item.Size));

View File

@@ -70,7 +70,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
return S_OK; return S_OK;
} }
case NArchive::kExtension: case NArchive::kExtension:
propVariant = L"z"; propVariant = L"z taz";
break;
case NArchive::kAddExtension:
propVariant = L"* .tar";
break; break;
case NArchive::kUpdate: case NArchive::kUpdate:
propVariant = false; propVariant = false;

View File

@@ -50,12 +50,28 @@ DEFINE_GUID(CLSID_CZipHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x01, 0x00, 0x00); 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x01, 0x00, 0x00);
HINSTANCE g_hInstance; 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" extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
if (dwReason == DLL_PROCESS_ATTACH) if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance; g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
}
return TRUE; return TRUE;
} }

View File

@@ -142,6 +142,14 @@ SOURCE=..\..\..\Common\CRC.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\..\Common\Random.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -57,7 +57,7 @@ CAddCommon::CAddCommon(const CCompressionMethodMode &options):
_cryptoStreamSpec(0) _cryptoStreamSpec(0)
{} {}
static HRESULT GetStreamCRC(IInStream *inStream, UInt32 &resultCRC) static HRESULT GetStreamCRC(ISequentialInStream *inStream, UInt32 &resultCRC)
{ {
CCRC crc; CCRC crc;
crc.Init(); 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) UInt64 inSize, ICompressProgressInfo *progress, CCompressingResult &operationResult)
{ {
/* /*
@@ -88,13 +88,25 @@ HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
return S_OK; return S_OK;
} }
*/ */
CMyComPtr<IInStream> inStream2;
int numTestMethods = _options.MethodSequence.Size(); 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; Byte method;
UInt64 resultSize = 0; UInt64 resultSize = 0;
COutStreamReleaser outStreamReleaser; COutStreamReleaser outStreamReleaser;
for(int i = 0; i < numTestMethods; i++) 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)); RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL));
if (_options.PasswordIsDefined) if (_options.PasswordIsDefined)
{ {
@@ -109,7 +121,7 @@ HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
(const Byte *)(const char *)_options.Password, _options.Password.Length())); (const Byte *)(const char *)_options.Password, _options.Password.Length()));
UInt32 crc; UInt32 crc;
RINOK(GetStreamCRC(inStream, 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)); RINOK(_cryptoStreamSpec->SetOutStream(outStream));
outStreamReleaser.FilterCoder = _cryptoStreamSpec; outStreamReleaser.FilterCoder = _cryptoStreamSpec;
RINOK(_filterSpec->CryptoSetCRC(crc)); RINOK(_filterSpec->CryptoSetCRC(crc));

View File

@@ -41,7 +41,7 @@ class CAddCommon
public: public:
CAddCommon(const CCompressionMethodMode &options); CAddCommon(const CCompressionMethodMode &options);
HRESULT Compress(IInStream *inStream, IOutStream *outStream, HRESULT Compress(ISequentialInStream *inStream, IOutStream *outStream,
UInt64 inSize, ICompressProgressInfo *progress, CCompressingResult &operationResult); UInt64 inSize, ICompressProgressInfo *progress, CCompressingResult &operationResult);
}; };

View File

@@ -323,6 +323,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close() STDMETHODIMP CHandler::Close()
{ {
m_Items.Clear();
m_Archive.Close(); m_Archive.Close();
m_ArchiveIsOpen = false; m_ArchiveIsOpen = false;
return S_OK; return S_OK;

View File

@@ -303,8 +303,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
{ {
if (value.vt != VT_UI4) if (value.vt != VT_UI4)
return E_INVALIDARG; return E_INVALIDARG;
/*
if (value.ulVal < 3 || value.ulVal > 255) if (value.ulVal < 3 || value.ulVal > 255)
return E_INVALIDARG; return E_INVALIDARG;
*/
m_NumFastBytes = value.ulVal; m_NumFastBytes = value.ulVal;
} }
else else

View File

@@ -121,9 +121,22 @@ static HRESULT UpdateOneFile(IInStream *inStream,
else else
{ {
{ {
CInStreamWithCRC *inStreamSpec = new CInStreamWithCRC; CSequentialInStreamWithCRC *inSecStreamSpec = 0;
CMyComPtr<IInStream> inStream(inStreamSpec); CInStreamWithCRC *inStreamSpec = 0;
inStreamSpec->Init(fileInStream); CMyComPtr<ISequentialInStream> fileSecInStream;
if (fileInStream)
{
inStreamSpec = new CInStreamWithCRC;
fileSecInStream = inStreamSpec;
inStreamSpec->Init(fileInStream);
}
else
{
inSecStreamSpec = new CSequentialInStreamWithCRC;
fileSecInStream = inSecStreamSpec;
inSecStreamSpec->Init(fileInStream2);
}
CCompressingResult compressingResult; CCompressingResult compressingResult;
CMyComPtr<IOutStream> outStream; CMyComPtr<IOutStream> outStream;
archive.CreateStreamForCompressing(&outStream); archive.CreateStreamForCompressing(&outStream);
@@ -132,20 +145,26 @@ static HRESULT UpdateOneFile(IInStream *inStream,
CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec; CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
localProgressSpec->Init(updateCallback, true); localProgressSpec->Init(updateCallback, true);
CLocalCompressProgressInfo *localCompressProgressSpec = CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
new CLocalCompressProgressInfo;
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec; CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
localCompressProgressSpec->Init(localProgress, &currentComplexity, NULL); localCompressProgressSpec->Init(localProgress, &currentComplexity, NULL);
RINOK(compressor.Compress(inStream, outStream, RINOK(compressor.Compress(fileSecInStream, outStream, fileSize, compressProgress, compressingResult));
fileSize, compressProgress, compressingResult));
fileHeader.PackSize = compressingResult.PackSize; fileHeader.PackSize = compressingResult.PackSize;
fileHeader.CompressionMethod = compressingResult.Method; fileHeader.CompressionMethod = compressingResult.Method;
fileHeader.ExtractVersion.Version = compressingResult.ExtractVersion; fileHeader.ExtractVersion.Version = compressingResult.ExtractVersion;
fileHeader.FileCRC = inStreamSpec->GetCRC(); if (inStreamSpec != 0)
fileHeader.UnPackSize = inStreamSpec->GetSize(); {
fileHeader.FileCRC = inStreamSpec->GetCRC();
fileHeader.UnPackSize = inStreamSpec->GetSize();
}
else
{
fileHeader.FileCRC = inSecStreamSpec->GetCRC();
fileHeader.UnPackSize = inSecStreamSpec->GetSize();
}
} }
} }
fileHeader.SetEncrypted(options.PasswordIsDefined); fileHeader.SetEncrypted(options.PasswordIsDefined);

View File

@@ -138,6 +138,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
STDMETHODIMP CHandler::Close() STDMETHODIMP CHandler::Close()
{ {
m_Items.Clear();
m_InStream.Release(); m_InStream.Release();
return S_OK; return S_OK;
} }

View File

@@ -481,6 +481,14 @@ SOURCE=..\..\..\Windows\Handle.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\..\Windows\PropVariant.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -1,5 +1,5 @@
PROG = 7za.exe PROG = 7za.exe
LIBS = $(LIBS) user32.lib oleaut32.lib LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib
CFLAGS = $(CFLAGS) -I ../../../ \ CFLAGS = $(CFLAGS) -I ../../../ \
-DEXCLUDE_COM \ -DEXCLUDE_COM \
@@ -61,6 +61,7 @@ WIN_OBJS = \
$O\FileFind.obj \ $O\FileFind.obj \
$O\FileIO.obj \ $O\FileIO.obj \
$O\FileName.obj \ $O\FileName.obj \
$O\MemoryLock.obj \
$O\PropVariant.obj \ $O\PropVariant.obj \
$O\PropVariantConversions.obj \ $O\PropVariantConversions.obj \
$O\Synchronization.obj $O\Synchronization.obj

View File

@@ -0,0 +1,3 @@
// StdAfx.cpp
#include "StdAfx.h"

9
7zip/Bundles/Alone7z/StdAfx.h Executable file
View 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
View 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)

View File

@@ -0,0 +1,3 @@
#include "../../MyVersionInfo.rc"
MY_VERSION_INFO_APP("7-Zip Standalone Console", "7za")

View File

@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # 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 BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe

View File

@@ -118,14 +118,29 @@ public:
{ return BOOLToBool(::SetCurrentDirectory(m_CurrentDirectory)); } { 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( int APIENTRY WinMain(
HINSTANCE hInstance, HINSTANCE hInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, LPSTR lpCmdLine,
int nCmdShow) int nCmdShow)
{ {
InitCommonControls();
g_hInstance = (HINSTANCE)hInstance; g_hInstance = (HINSTANCE)hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
InitCommonControls();
UString archiveName, switches; UString archiveName, switches;
NCommandLineParser::SplitCommandLine(GetCommandLineW(), archiveName, switches); NCommandLineParser::SplitCommandLine(GetCommandLineW(), archiveName, switches);

View File

@@ -19,6 +19,17 @@
#include "../../UI/GUI/ExtractGUI.h" #include "../../UI/GUI/ExtractGUI.h"
HINSTANCE g_hInstance; 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( int APIENTRY WinMain(
HINSTANCE hInstance, HINSTANCE hInstance,
@@ -27,6 +38,10 @@ int APIENTRY WinMain(
int nCmdShow) int nCmdShow)
{ {
g_hInstance = (HINSTANCE)hInstance; g_hInstance = (HINSTANCE)hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
UString password; UString password;
bool assumeYes = false; bool assumeYes = false;
bool outputFolderDefined = false; bool outputFolderDefined = false;

View File

@@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # 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 BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD BASE RSC /l 0x419 /d "NDEBUG"

View File

@@ -23,13 +23,13 @@ bool CInBuffer::Create(UInt32 bufferSize)
return true; return true;
Free(); Free();
_bufferSize = bufferSize; _bufferSize = bufferSize;
_bufferBase = (Byte *)::BigAlloc(bufferSize); _bufferBase = (Byte *)::MidAlloc(bufferSize);
return (_bufferBase != 0); return (_bufferBase != 0);
} }
void CInBuffer::Free() void CInBuffer::Free()
{ {
BigFree(_bufferBase); ::MidFree(_bufferBase);
_bufferBase = 0; _bufferBase = 0;
} }

View File

@@ -15,13 +15,13 @@ bool COutBuffer::Create(UInt32 bufferSize)
return true; return true;
Free(); Free();
_bufferSize = bufferSize; _bufferSize = bufferSize;
_buffer = (Byte *)::BigAlloc(bufferSize); _buffer = (Byte *)::MidAlloc(bufferSize);
return (_buffer != 0); return (_buffer != 0);
} }
void COutBuffer::Free() void COutBuffer::Free()
{ {
BigFree(_buffer); ::MidFree(_buffer);
_buffer = 0; _buffer = 0;
} }

View File

@@ -4,6 +4,9 @@
#include "Common/MyInitGuid.h" #include "Common/MyInitGuid.h"
#include "Common/ComTry.h" #include "Common/ComTry.h"
#ifdef _WIN32
#include "Common/Alloc.h"
#endif
#include "BZip2Encoder.h" #include "BZip2Encoder.h"
#include "BZip2Decoder.h" #include "BZip2Decoder.h"
@@ -19,6 +22,10 @@ DEFINE_GUID(CLSID_CCompressBZip2Encoder,
extern "C" extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
#ifdef _WIN32
if (dwReason == DLL_PROCESS_ATTACH)
SetLargePageSize();
#endif
return TRUE; return TRUE;
} }

View File

@@ -31,7 +31,7 @@ bool CBCJ2_x86_Encoder::Create()
return false; return false;
if (_buffer == 0) if (_buffer == 0)
{ {
_buffer = (Byte *)BigAlloc(kBufferSize); _buffer = (Byte *)MidAlloc(kBufferSize);
if (_buffer == 0) if (_buffer == 0)
return false; return false;
} }
@@ -40,7 +40,7 @@ bool CBCJ2_x86_Encoder::Create()
CBCJ2_x86_Encoder::~CBCJ2_x86_Encoder() CBCJ2_x86_Encoder::~CBCJ2_x86_Encoder()
{ {
BigFree(_buffer); ::MidFree(_buffer);
} }
HRESULT CBCJ2_x86_Encoder::Flush() HRESULT CBCJ2_x86_Encoder::Flush()

View File

@@ -12,7 +12,7 @@ static const UInt32 kBufferSize = 1 << 17;
CCopyCoder::~CCopyCoder() CCopyCoder::~CCopyCoder()
{ {
BigFree(_buffer); ::MidFree(_buffer);
} }
STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream, STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
@@ -22,7 +22,7 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
{ {
if (_buffer == 0) if (_buffer == 0)
{ {
_buffer = (Byte *)BigAlloc(kBufferSize); _buffer = (Byte *)::MidAlloc(kBufferSize);
if (_buffer == 0) if (_buffer == 0)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }

View File

@@ -116,12 +116,11 @@ HRESULT CCoder::Create()
kNumOpts + kNumGoodBacks, m_NumFastBytes, m_MatchMaxLen - m_NumFastBytes)); kNumOpts + kNumGoodBacks, m_NumFastBytes, m_MatchMaxLen - m_NumFastBytes));
if (!m_OutStream.Create(1 << 20)) if (!m_OutStream.Create(1 << 20))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
m_MatchLengthEdge = m_NumFastBytes + 1;
Free(); Free();
if (m_NumPasses > 1) 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) if (m_OnePosMatchesMemory == 0)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
m_OnePosMatchesArray = (COnePosMatches *)MyAlloc(kNumGoodBacks * sizeof(COnePosMatches)); m_OnePosMatchesArray = (COnePosMatches *)MyAlloc(kNumGoodBacks * sizeof(COnePosMatches));
@@ -177,7 +176,7 @@ void CCoder::Free()
{ {
if (m_NumPasses > 1) if (m_NumPasses > 1)
{ {
BigFree(m_OnePosMatchesMemory); ::MidFree(m_OnePosMatchesMemory);
MyFree(m_OnePosMatchesArray); MyFree(m_OnePosMatchesArray);
} }
else else
@@ -308,7 +307,7 @@ UInt32 CCoder::GetOptimal(UInt32 &backRes)
if(lenMain < kMatchMinLen) if(lenMain < kMatchMinLen)
return 1; return 1;
if(lenMain >= m_MatchLengthEdge) if(lenMain > m_NumFastBytes)
{ {
backRes = backMain; backRes = backMain;
MovePos(lenMain - 1); MovePos(lenMain - 1);
@@ -337,7 +336,7 @@ UInt32 CCoder::GetOptimal(UInt32 &backRes)
return Backward(backRes, cur); return Backward(backRes, cur);
GetBacks(UInt32(m_BlockStartPostion + m_CurrentBlockUncompressedSize + cur)); GetBacks(UInt32(m_BlockStartPostion + m_CurrentBlockUncompressedSize + cur));
UInt32 newLen = m_LongestMatchLength; UInt32 newLen = m_LongestMatchLength;
if(newLen >= m_MatchLengthEdge) if(newLen > m_NumFastBytes)
return Backward(backRes, cur); return Backward(backRes, cur);
UInt32 curPrice = m_Optimum[cur].Price; UInt32 curPrice = m_Optimum[cur].Price;

View File

@@ -77,7 +77,6 @@ class CCoder
UInt16 *m_MatchDistances; UInt16 *m_MatchDistances;
UInt32 m_NumFastBytes; UInt32 m_NumFastBytes;
UInt32 m_MatchLengthEdge;
Byte m_LiteralPrices[256]; Byte m_LiteralPrices[256];

View File

@@ -4,6 +4,9 @@
#include "../../../Common/MyInitGuid.h" #include "../../../Common/MyInitGuid.h"
#include "../../../Common/ComTry.h" #include "../../../Common/ComTry.h"
#ifdef _WIN32
#include "../../../Common/Alloc.h"
#endif
#include "LZMAEncoder.h" #include "LZMAEncoder.h"
#include "LZMADecoder.h" #include "LZMADecoder.h"
@@ -20,8 +23,14 @@ DEFINE_GUID(CLSID_CLZMAEncoder,
extern "C" extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
// NCompress::NRangeCoder::g_PriceTables.Init(); if (dwReason == DLL_PROCESS_ATTACH)
// CCRC::InitTable(); {
// NCompress::NRangeCoder::g_PriceTables.Init();
// CCRC::InitTable();
#ifdef _WIN32
SetLargePageSize();
#endif
}
return TRUE; return TRUE;
} }

View File

@@ -342,7 +342,7 @@ HRESULT CEncoder::Create()
if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes) if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes)
return S_OK; return S_OK;
RINOK(_matchFinder->Create(_dictionarySize, kNumOpts, _numFastBytes, RINOK(_matchFinder->Create(_dictionarySize, kNumOpts, _numFastBytes,
kMatchMaxLen - _numFastBytes)); kMatchMaxLen * 2 + 1 - _numFastBytes));
_dictionarySizePrev = _dictionarySize; _dictionarySizePrev = _dictionarySize;
_numFastBytesPrev = _numFastBytes; _numFastBytesPrev = _numFastBytes;
return S_OK; 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) HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
{ {
if(_optimumEndIndex != _optimumCurrentIndex) if(_optimumEndIndex != _optimumCurrentIndex)
{ {
lenRes = _optimum[_optimumCurrentIndex].PosPrev - _optimumCurrentIndex; const COptimal &optimum = _optimum[_optimumCurrentIndex];
backRes = _optimum[_optimumCurrentIndex].BackPrev; lenRes = optimum.PosPrev - _optimumCurrentIndex;
_optimumCurrentIndex = _optimum[_optimumCurrentIndex].PosPrev; backRes = optimum.BackPrev;
_optimumCurrentIndex = optimum.PosPrev;
return S_OK; return S_OK;
} }
_optimumCurrentIndex = 0; _optimumCurrentIndex = 0;
@@ -649,14 +656,14 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
if (i == 0 || repLens[i] > repLens[repMaxIndex]) if (i == 0 || repLens[i] > repLens[repMaxIndex])
repMaxIndex = i; repMaxIndex = i;
} }
if(repLens[repMaxIndex] > _numFastBytes) if(repLens[repMaxIndex] >= _numFastBytes)
{ {
backRes = repMaxIndex; backRes = repMaxIndex;
lenRes = repLens[repMaxIndex]; lenRes = repLens[repMaxIndex];
return MovePos(lenRes - 1); return MovePos(lenRes - 1);
} }
if(lenMain > _numFastBytes) if(lenMain >= _numFastBytes)
{ {
backRes = _matchDistances[_numFastBytes] + kNumRepDistances; backRes = _matchDistances[_numFastBytes] + kNumRepDistances;
lenRes = lenMain; lenRes = lenMain;
@@ -752,15 +759,16 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
return S_OK; return S_OK;
} }
position++; position++;
UInt32 posPrev = _optimum[cur].PosPrev; COptimal &curOptimum = _optimum[cur];
UInt32 posPrev = curOptimum.PosPrev;
CState state; CState state;
if (_optimum[cur].Prev1IsChar) if (curOptimum.Prev1IsChar)
{ {
posPrev--; posPrev--;
if (_optimum[cur].Prev2) if (curOptimum.Prev2)
{ {
state = _optimum[_optimum[cur].PosPrev2].State; state = _optimum[curOptimum.PosPrev2].State;
if (_optimum[cur].BackPrev2 < kNumRepDistances) if (curOptimum.BackPrev2 < kNumRepDistances)
state.UpdateRep(); state.UpdateRep();
else else
state.UpdateMatch(); state.UpdateMatch();
@@ -773,12 +781,12 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
state = _optimum[posPrev].State; state = _optimum[posPrev].State;
if (posPrev == cur - 1) if (posPrev == cur - 1)
{ {
if (_optimum[cur].IsShortRep()) if (curOptimum.IsShortRep())
state.UpdateShortRep(); state.UpdateShortRep();
else else
state.UpdateChar(); state.UpdateChar();
/* /*
if (_optimum[cur].Prev1IsChar) if (curOptimum.Prev1IsChar)
for(int i = 0; i < kNumRepDistances; i++) for(int i = 0; i < kNumRepDistances; i++)
reps[i] = _optimum[posPrev].Backs[i]; reps[i] = _optimum[posPrev].Backs[i];
*/ */
@@ -786,49 +794,50 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
else else
{ {
UInt32 pos; UInt32 pos;
if (_optimum[cur].Prev1IsChar && _optimum[cur].Prev2) if (curOptimum.Prev1IsChar && curOptimum.Prev2)
{ {
posPrev = _optimum[cur].PosPrev2; posPrev = curOptimum.PosPrev2;
pos = _optimum[cur].BackPrev2; pos = curOptimum.BackPrev2;
state.UpdateRep(); state.UpdateRep();
} }
else else
{ {
pos = _optimum[cur].BackPrev; pos = curOptimum.BackPrev;
if (pos < kNumRepDistances) if (pos < kNumRepDistances)
state.UpdateRep(); state.UpdateRep();
else else
state.UpdateMatch(); state.UpdateMatch();
} }
const COptimal &prevOptimum = _optimum[posPrev];
if (pos < kNumRepDistances) if (pos < kNumRepDistances)
{ {
reps[0] = _optimum[posPrev].Backs[pos]; reps[0] = prevOptimum.Backs[pos];
UInt32 i; UInt32 i;
for(i = 1; i <= pos; i++) for(i = 1; i <= pos; i++)
reps[i] = _optimum[posPrev].Backs[i - 1]; reps[i] = prevOptimum.Backs[i - 1];
for(; i < kNumRepDistances; i++) for(; i < kNumRepDistances; i++)
reps[i] = _optimum[posPrev].Backs[i]; reps[i] = prevOptimum.Backs[i];
} }
else else
{ {
reps[0] = (pos - kNumRepDistances); reps[0] = (pos - kNumRepDistances);
for(UInt32 i = 1; i < kNumRepDistances; i++) 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++) for(UInt32 i = 0; i < kNumRepDistances; i++)
_optimum[cur].Backs[i] = reps[i]; curOptimum.Backs[i] = reps[i];
UInt32 newLen; UInt32 newLen;
RINOK(ReadMatchDistances(newLen)); RINOK(ReadMatchDistances(newLen));
if(newLen > _numFastBytes) if(newLen >= _numFastBytes)
{ {
_longestMatchLength = newLen; _longestMatchLength = newLen;
_longestMatchWasFound = true; _longestMatchWasFound = true;
lenRes = Backward(backRes, cur); lenRes = Backward(backRes, cur);
return S_OK; return S_OK;
} }
UInt32 curPrice = _optimum[cur].Price; UInt32 curPrice = curOptimum.Price;
// Byte currentByte = _matchFinder->GetIndexByte(0 - 1); // Byte currentByte = _matchFinder->GetIndexByte(0 - 1);
// Byte matchByte = _matchFinder->GetIndexByte(0 - reps[0] - 1 - 1); // Byte matchByte = _matchFinder->GetIndexByte(0 - reps[0] - 1 - 1);
const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1; const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
@@ -872,8 +881,9 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
continue; continue;
*/ */
UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1; UInt32 numAvailableBytesFull = _matchFinder->GetNumAvailableBytes() + 1;
numAvailableBytes = MyMin(kNumOpts - 1 - cur, numAvailableBytes); numAvailableBytesFull = MyMin(kNumOpts - 1 - cur, numAvailableBytesFull);
UInt32 numAvailableBytes = numAvailableBytesFull;
if (numAvailableBytes < 2) if (numAvailableBytes < 2)
continue; continue;
@@ -881,6 +891,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
numAvailableBytes = _numFastBytes; numAvailableBytes = _numFastBytes;
if (numAvailableBytes >= 3 && !nextIsChar) if (numAvailableBytes >= 3 && !nextIsChar)
{ {
// try Literal + rep0
UInt32 backOffset = reps[0] + 1; UInt32 backOffset = reps[0] + 1;
UInt32 temp; UInt32 temp;
for (temp = 1; temp < numAvailableBytes; 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 repLen = _matchFinder->GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;
UInt32 backOffset = reps[repIndex] + 1; UInt32 backOffset = reps[repIndex] + 1;
if (data[0] != data[(size_t)0 - backOffset] ||
data[1] != data[(size_t)1 - backOffset])
continue;
UInt32 lenTest; UInt32 lenTest;
for (lenTest = 0; lenTest < numAvailableBytes; lenTest++) for (lenTest = 2; lenTest < numAvailableBytes; lenTest++)
if (data[lenTest] != data[(size_t)lenTest - backOffset]) if (data[lenTest] != data[(size_t)lenTest - backOffset])
break; break;
for(; lenTest >= 2; lenTest--) UInt32 lenTestTemp = lenTest;
do
{ {
while(lenEnd < cur + lenTest) while(lenEnd < cur + lenTest)
_optimum[++lenEnd].Price = kIfinityPrice; _optimum[++lenEnd].Price = kIfinityPrice;
@@ -934,21 +949,25 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
optimum.BackPrev = repIndex; optimum.BackPrev = repIndex;
optimum.Prev1IsChar = false; optimum.Prev1IsChar = false;
} }
}
while(--lenTest >= 2);
lenTest = lenTestTemp;
/*
if (_maxMode) if (_maxMode)
{ {
UInt32 temp; UInt32 lenTest2 = lenTest + 1;
for (temp = lenTest + 1; temp < numAvailableBytes; temp++) UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
if (data[temp] != data[(size_t)temp - backOffset]) for (; lenTest2 < limit; lenTest2++)
if (data[lenTest2] != data[(size_t)lenTest2 - backOffset])
break; break;
UInt32 lenTest2 = temp - (lenTest + 1); lenTest2 -= lenTest + 1;
if (lenTest2 >= 2) if (lenTest2 >= 2)
{ {
CState state2 = state; CState state2 = state;
state2.UpdateRep(); state2.UpdateRep();
UInt32 posStateNext = (position + lenTest) & _posStateMask; UInt32 posStateNext = (position + lenTest) & _posStateMask;
UInt32 curAndLenCharPrice = curAndLenPrice + UInt32 curAndLenCharPrice =
repMatchPrice + GetRepPrice(repIndex, lenTest, state, posState) +
_isMatch[state2.Index][posStateNext].GetPrice0() + _isMatch[state2.Index][posStateNext].GetPrice0() +
_literalEncoder.GetPrice(position + lenTest, data[(size_t)lenTest - 1], _literalEncoder.GetPrice(position + lenTest, data[(size_t)lenTest - 1],
true, data[(size_t)lenTest - backOffset], data[lenTest]); 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++) // for(UInt32 lenTest = 2; lenTest <= newLen; lenTest++)
if (newLen > numAvailableBytes) if (newLen > numAvailableBytes)
@@ -1007,14 +1024,16 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
optimum.Prev1IsChar = false; optimum.Prev1IsChar = false;
} }
if (_maxMode) if (_maxMode && (lenTest == newLen || curBack != _matchDistances[lenTest + 1]))
{ {
// Try Match + Literal + Rep0
UInt32 backOffset = curBack + 1; UInt32 backOffset = curBack + 1;
UInt32 temp; UInt32 lenTest2 = lenTest + 1;
for (temp = lenTest + 1; temp < numAvailableBytes; temp++) UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
if (data[temp] != data[(size_t)temp - backOffset]) for (; lenTest2 < limit; lenTest2++)
if (data[lenTest2] != data[(size_t)lenTest2 - backOffset])
break; break;
UInt32 lenTest2 = temp - (lenTest + 1); lenTest2 -= lenTest + 1;
if (lenTest2 >= 2) if (lenTest2 >= 2)
{ {
CState state2 = state; CState state2 = state;
@@ -1247,9 +1266,9 @@ HRESULT CEncoder::SetStreams(ISequentialInStream *inStream,
FillAlignPrices(); FillAlignPrices();
} }
_lenEncoder.SetTableSize(_numFastBytes); _lenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
_lenEncoder.UpdateTables(1 << _posStateBits); _lenEncoder.UpdateTables(1 << _posStateBits);
_repMatchLenEncoder.SetTableSize(_numFastBytes); _repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
_repMatchLenEncoder.UpdateTables(1 << _posStateBits); _repMatchLenEncoder.UpdateTables(1 << _posStateBits);
lastPosSlotFillingPos = 0; lastPosSlotFillingPos = 0;

View File

@@ -4,6 +4,9 @@
#include "Common/MyInitGuid.h" #include "Common/MyInitGuid.h"
#include "Common/ComTry.h" #include "Common/ComTry.h"
#ifdef _WIN32
#include "Common/Alloc.h"
#endif
#include "PPMDEncoder.h" #include "PPMDEncoder.h"
#include "PPMDDecoder.h" #include "PPMDDecoder.h"
@@ -19,6 +22,10 @@ DEFINE_GUID(CLSID_CCompressPPMDEncoder,
extern "C" extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
#ifdef _WIN32
if (dwReason == DLL_PROCESS_ATTACH)
SetLargePageSize();
#endif
return TRUE; return TRUE;
} }

View File

@@ -1,6 +1,6 @@
PROG = Rar29.dll PROG = Rar29.dll
DEF_FILE = ../Codec.def DEF_FILE = ../Codec.def
CFLAGS = $(CFLAGS) -I ../../../ CFLAGS = $(CFLAGS) -I ../../../ -DSILENT -DNOCRYPT -DNOVOLUME
LIBS = $(LIBS) oleaut32.lib LIBS = $(LIBS) oleaut32.lib
RAR29_OBJS = \ RAR29_OBJS = \
@@ -46,7 +46,7 @@ OBJS = \
!include "../../../Build.mak" !include "../../../Build.mak"
COMPL_SPEC = $(CPP) $(CFLAGS_O2) -DSILENT -DNOCRYPT -DNOVOLUME $** COMPL_SPEC = $(CPP) $(CFLAGS_O2) $**
$(RAR29_OBJS): $(*B).cpp $(RAR29_OBJS): $(*B).cpp
$(COMPL) $(COMPL)

View File

@@ -21,12 +21,28 @@ DEFINE_GUID(CLSID_CCrypto7zAESDecoder,
0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00); 0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00);
HINSTANCE g_hInstance; 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" extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{ {
if (dwReason == DLL_PROCESS_ATTACH) if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance; g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
}
return TRUE; return TRUE;
} }

View File

@@ -114,10 +114,8 @@ void CApp::CreateOnePanel(int panelIndex, const UString &mainPath)
UString path; UString path;
if (mainPath.IsEmpty()) if (mainPath.IsEmpty())
{ {
CSysString sysPath; if (!::ReadPanelPath(panelIndex, path))
if (!::ReadPanelPath(panelIndex, sysPath)) path.Empty();
sysPath.Empty();
path = GetUnicodeString(sysPath);
} }
else else
path = mainPath; path = mainPath;
@@ -165,8 +163,7 @@ struct CButtonInfo
UINT Bitmap2ResID; UINT Bitmap2ResID;
UINT StringResID; UINT StringResID;
UINT32 LangID; UINT32 LangID;
CSysString GetText()const UString GetText()const { return LangString(StringResID, LangID); };
{ return LangLoadString(StringResID, LangID); };
}; };
static CButtonInfo g_StandardButtons[] = static CButtonInfo g_StandardButtons[] =
@@ -184,7 +181,7 @@ static CButtonInfo g_ArchiveButtons[] =
{ kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402} { 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++) for (int i = 0; i < numButtons; i++)
{ {
@@ -192,19 +189,19 @@ bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, CSysS
if (b.commandID == commandID) if (b.commandID == commandID)
{ {
s = b.GetText(); s = b.GetText();
return true; return true;
} }
} }
return false; return false;
} }
void SetButtonText(UINT32 commandID, CSysString &s) void SetButtonText(UINT32 commandID, UString &s)
{ {
if (SetButtonText(commandID, g_StandardButtons, sizeof(g_StandardButtons) / if (SetButtonText(commandID, g_StandardButtons,
sizeof(g_StandardButtons[0]), s)) sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s))
return; return;
SetButtonText(commandID, g_ArchiveButtons, sizeof(g_StandardButtons) / SetButtonText(commandID, g_ArchiveButtons,
sizeof(g_ArchiveButtons[0]), s); sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s);
} }
static void AddButton( static void AddButton(
@@ -223,10 +220,10 @@ static void AddButton(
; ;
but.dwData = 0; but.dwData = 0;
CSysString s = butInfo.GetText(); UString s = butInfo.GetText();
but.iString = 0; but.iString = 0;
if (showText) if (showText)
but.iString = (INT_PTR )(LPCTSTR)s; but.iString = (INT_PTR)(LPCWSTR)s;
but.iBitmap = imageList.GetImageCount(); but.iBitmap = imageList.GetImageCount();
HBITMAP b = ::LoadBitmap(g_hInstance, HBITMAP b = ::LoadBitmap(g_hInstance,
@@ -238,7 +235,11 @@ static void AddButton(
imageList.AddMasked(b, RGB(255, 0, 255)); imageList.AddMasked(b, RGB(255, 0, 255));
::DeleteObject(b); ::DeleteObject(b);
} }
#ifdef _UNICODE
toolBar.AddButton(1, &but); toolBar.AddButton(1, &but);
#else
toolBar.AddButtonW(1, &but);
#endif
} }
static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar) static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar)
@@ -402,7 +403,7 @@ void CApp::Save()
path = panel._currentFolderPrefix; path = panel._currentFolderPrefix;
else else
path = GetFolderPath(panel._parentFolders[0].ParentFolder); path = GetFolderPath(panel._parentFolders[0].ParentFolder);
SavePanelPath(i, GetSystemString(path)); SavePanelPath(i, path);
listMode.Panels[i] = panel.GetListViewMode(); listMode.Panels[i] = panel.GetListViewMode();
} }
SaveListMode(listMode); SaveListMode(listMode);
@@ -473,7 +474,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
if (!srcPanel.DoesItSupportOperations()) if (!srcPanel.DoesItSupportOperations())
{ {
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return; return;
} }
@@ -511,11 +512,11 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
copyDialog.Value = destPath; copyDialog.Value = destPath;
copyDialog.Title = move ? copyDialog.Title = move ?
LangLoadStringW(IDS_MOVE, 0x03020202): LangString(IDS_MOVE, 0x03020202):
LangLoadStringW(IDS_COPY, 0x03020201); LangString(IDS_COPY, 0x03020201);
copyDialog.Static = move ? copyDialog.Static = move ?
LangLoadStringW(IDS_MOVE_TO, 0x03020204): LangString(IDS_MOVE_TO, 0x03020204):
LangLoadStringW(IDS_COPY_TO, 0x03020203); LangString(IDS_COPY_TO, 0x03020203);
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL) if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
return; return;
@@ -526,7 +527,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{ {
if (!srcPanel.IsFSFolder()) if (!srcPanel.IsFSFolder())
{ {
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return; return;
} }
destPath = srcPanel._currentFolderPrefix + destPath; 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()) 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; return;
} }
useDestPanel = true; useDestPanel = true;
@@ -556,7 +557,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
NDirectory::CreateComplexDirectory(prefix); NDirectory::CreateComplexDirectory(prefix);
if (!CheckFolderPath(prefix)) if (!CheckFolderPath(prefix))
{ {
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return; 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) void CApp::OnNotify(int ctrlID, LPNMHDR pnmh)
{ {
@@ -729,8 +731,20 @@ void CApp::OnNotify(int ctrlID, LPNMHDR pnmh)
info->hinst = 0; info->hinst = 0;
g_ToolTipBuffer.Empty(); g_ToolTipBuffer.Empty();
SetButtonText(info->hdr.idFrom, g_ToolTipBuffer); SetButtonText(info->hdr.idFrom, g_ToolTipBuffer);
info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBuffer; g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBufferSys;
return; 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
} }
} }

View File

@@ -82,8 +82,6 @@ public:
#endif #endif
private: private:
// CSysString _directoryPath;
// CSysString m_DiskFilePath;
// bool _extractMode; // bool _extractMode;
UString _currentArchivePath; UString _currentArchivePath;
bool _needWriteArchivePath; bool _needWriteArchivePath;

View File

@@ -11,6 +11,9 @@
#include "Windows/Control/Toolbar.h" #include "Windows/Control/Toolbar.h"
#include "Windows/Error.h" #include "Windows/Error.h"
#include "Windows/COM.h" #include "Windows/COM.h"
#include "Windows/DLL.h"
#include "Windows/Security.h"
#include "Windows/MemoryLock.h"
#include "ViewSettings.h" #include "ViewSettings.h"
@@ -19,6 +22,7 @@
#include "MyLoadMenu.h" #include "MyLoadMenu.h"
#include "LangUtils.h" #include "LangUtils.h"
#include "RegistryUtils.h"
using namespace NWindows; using namespace NWindows;
@@ -28,6 +32,9 @@ using namespace NWindows;
#define MENU_HEIGHT 26 #define MENU_HEIGHT 26
#ifndef _UNICODE
bool g_IsNT = false;
#endif
HINSTANCE g_hInstance; HINSTANCE g_hInstance;
HWND g_HWND; HWND g_HWND;
static UString g_MainPath; static UString g_MainPath;
@@ -39,17 +46,17 @@ int kSplitterRateMax = 1 << 16;
// bool OnMenuCommand(HWND hWnd, int id); // bool OnMenuCommand(HWND hWnd, int id);
static CSysString GetProgramPath() static UString GetProgramPath()
{ {
TCHAR fullPath[MAX_PATH + 1]; UString s;
::GetModuleFileName(g_hInstance, fullPath, MAX_PATH); NDLL::MyGetModuleFileName(g_hInstance, s);
return fullPath; return s;
} }
CSysString GetProgramFolderPrefix() UString GetProgramFolderPrefix()
{ {
CSysString path = GetProgramPath(); UString path = GetProgramPath();
int pos = path.ReverseFind(TEXT('\\')); int pos = path.ReverseFind(L'\\');
return path.Left(pos + 1); return path.Left(pos + 1);
} }
@@ -117,12 +124,21 @@ void OnSize(HWND hWnd);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 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) BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{ {
HWND hWnd = NULL; CWindow wnd;
TCHAR windowClass[MAX_LOADSTRING]; // The window class name
lstrcpy(windowClass, TEXT("FM"));
g_hInstance = hInstance; g_hInstance = hInstance;
@@ -131,7 +147,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
// LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING); // LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING);
// LoadString(hInstance, IDS_APP_TITLE, title, 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 //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 = CS_HREDRAW | CS_VREDRAW;
wc.style = 0; wc.style = 0;
@@ -158,10 +174,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
// wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
wc.lpszMenuName = MAKEINTRESOURCE(IDM_MENU); wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
wc.lpszClassName = windowClass; wc.lpszClassName = kWindowClass;
RegisterClass(&wc); MyRegisterClass(&wc);
// RECT rect; // RECT rect;
// GetClientRect(hWnd, &rect); // GetClientRect(hWnd, &rect);
@@ -200,17 +216,14 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
g_App.NumPanels = numPanels; g_App.NumPanels = numPanels;
g_App.LastFocusedPanel = currentPanel; g_App.LastFocusedPanel = currentPanel;
hWnd = CreateWindow(windowClass, GetSystemString(title), style, if (!wnd.Create(kWindowClass, title, style,
x, y, xSize, ySize, NULL, NULL, hInstance, NULL); x, y, xSize, ySize, NULL, NULL, hInstance, NULL))
if (!hWnd) return FALSE;
return FALSE; g_HWND = (HWND)wnd;
g_HWND = hWnd;
CWindow window(hWnd);
WINDOWPLACEMENT placement; WINDOWPLACEMENT placement;
placement.length = sizeof(placement); placement.length = sizeof(placement);
if (window.GetPlacement(&placement)) if (wnd.GetPlacement(&placement))
{ {
if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW || if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
nCmdShow == SW_SHOWDEFAULT) nCmdShow == SW_SHOWDEFAULT)
@@ -224,11 +237,11 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
placement.showCmd = nCmdShow; placement.showCmd = nCmdShow;
if (windowPosIsRead) if (windowPosIsRead)
placement.rcNormalPosition = rect; placement.rcNormalPosition = rect;
window.SetPlacement(&placement); wnd.SetPlacement(&placement);
// window.Show(nCmdShow); // window.Show(nCmdShow);
} }
else else
window.Show(nCmdShow); wnd.Show(nCmdShow);
return TRUE; return TRUE;
} }
@@ -295,11 +308,65 @@ DWORD GetDllVersion(LPCTSTR lpszDllName)
DWORD g_ComCtl32Version; 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, int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, LPSTR lpCmdLine,
int nCmdShow) int nCmdShow)
{ {
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
InitCommonControls(); InitCommonControls();
g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll")); g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
@@ -324,6 +391,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
// MessageBoxW(0, paramString, L"", 0); // MessageBoxW(0, paramString, L"", 0);
} }
SetMemoryLock();
MSG msg; MSG msg;
if (!InitInstance (hInstance, nCmdShow)) if (!InitInstance (hInstance, nCmdShow))
@@ -331,19 +399,34 @@ int WINAPI WinMain( HINSTANCE hInstance,
MyLoadMenu(g_HWND); MyLoadMenu(g_HWND);
HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1)); #ifndef _UNICODE
while (GetMessage(&msg, NULL, 0, 0)) if (g_IsNT)
{ {
if (!TranslateAccelerator(g_HWND, hAccels, &msg)) HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
{ while (GetMessageW(&msg, NULL, 0, 0))
// if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg)) {
// if (!IsDialogMessage(g_Hwnd, &msg)) if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
{ {
TranslateMessage(&msg); 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; g_HWND = 0;
OleUninitialize(); 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) void OnSize(HWND hWnd)

View File

@@ -259,6 +259,14 @@ SOURCE=.\NetFolder.h
# End Source File # End Source File
# Begin 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 SOURCE=.\RootFolder.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -682,6 +690,14 @@ SOURCE=..\..\Windows\Control\Window2.h
# End Group # End Group
# Begin Source File # 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 SOURCE=..\..\Windows\Defs.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -706,6 +722,14 @@ SOURCE=..\..\Windows\Error.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\Windows\FileDir.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -758,6 +782,18 @@ SOURCE=..\..\Windows\Memory.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\Windows\Menu.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -806,6 +842,14 @@ SOURCE=..\..\Windows\ResourceString.h
# End Source File # End Source File
# Begin 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 SOURCE=..\..\Windows\Shell.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -15,6 +15,7 @@
#include "SysIconUtils.h" #include "SysIconUtils.h"
#include "FSFolder.h" #include "FSFolder.h"
#include "PhysDriveFolder.h"
#include "LangUtils.h" #include "LangUtils.h"
using namespace NWindows; using namespace NWindows;
@@ -44,30 +45,26 @@ static const wchar_t *kDriveTypes[] =
L"RAM disk" L"RAM disk"
}; };
static inline UINT GetCurrentFileCodePage()
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
STDMETHODIMP CFSDrives::LoadItems() STDMETHODIMP CFSDrives::LoadItems()
{ {
UINT fileCodePage = GetCurrentFileCodePage();
_drives.Clear(); _drives.Clear();
CSysStringVector driveStrings; UStringVector driveStrings;
MyGetLogicalDriveStrings(driveStrings); MyGetLogicalDriveStrings(driveStrings);
for (int i = 0; i < driveStrings.Size(); i++) for (int i = 0; i < driveStrings.Size(); i++)
{ {
CDriveInfo driveInfo; 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.Name = driveInfo.FullSystemName.Left(
driveInfo.FullSystemName.Length() - 1); driveInfo.FullSystemName.Length() - 1);
driveInfo.ClusterSize = 0; driveInfo.ClusterSize = 0;
driveInfo.DriveSize = 0; driveInfo.DriveSize = 0;
driveInfo.FreeSpace = 0; driveInfo.FreeSpace = 0;
UINT driveType = ::GetDriveType(driveName); UINT driveType = NFile::NSystem::MyGetDriveType(driveName);
if (driveType < sizeof(kDriveTypes) / sizeof(kDriveTypes[0])) if (driveType < sizeof(kDriveTypes) / sizeof(kDriveTypes[0]))
{ {
driveInfo.Type = kDriveTypes[driveType]; driveInfo.Type = kDriveTypes[driveType];
@@ -87,14 +84,14 @@ STDMETHODIMP CFSDrives::LoadItems()
} }
if (needRead) if (needRead)
{ {
CSysString volumeName, fileSystemName; UString volumeName, fileSystemName;
DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags; DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
NFile::NSystem::MyGetVolumeInformation(driveName, NFile::NSystem::MyGetVolumeInformation(driveName,
volumeName, volumeName,
&volumeSerialNumber, &maximumComponentLength, &fileSystemFlags, &volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
fileSystemName); fileSystemName);
driveInfo.VolumeName = GetUnicodeString(volumeName, fileCodePage); driveInfo.VolumeName = volumeName;
driveInfo.FileSystemName = GetUnicodeString(fileSystemName, fileCodePage); driveInfo.FileSystemName = fileSystemName;
NFile::NSystem::MyGetDiskFreeSpace(driveName, NFile::NSystem::MyGetDiskFreeSpace(driveName,
driveInfo.ClusterSize, driveInfo.DriveSize, driveInfo.FreeSpace); driveInfo.ClusterSize, driveInfo.DriveSize, driveInfo.FreeSpace);
@@ -105,15 +102,15 @@ STDMETHODIMP CFSDrives::LoadItems()
return S_OK; return S_OK;
} }
STDMETHODIMP CFSDrives::GetNumberOfItems(UINT32 *numItems) STDMETHODIMP CFSDrives::GetNumberOfItems(UInt32 *numItems)
{ {
*numItems = _drives.Size(); *numItems = _drives.Size();
return S_OK; 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; return E_INVALIDARG;
NCOM::CPropVariant propVariant; NCOM::CPropVariant propVariant;
const CDriveInfo &driveInfo = _drives[itemIndex]; const CDriveInfo &driveInfo = _drives[itemIndex];
@@ -161,12 +158,22 @@ HRESULT CFSDrives::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultF
return S_OK; return S_OK;
} }
STDMETHODIMP CFSDrives::BindToFolder(UINT32 index, IFolderFolder **resultFolder) STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
{ {
*resultFolder = 0; *resultFolder = 0;
if (index >= (UINT32)_drives.Size()) if (index >= (UInt32)_drives.Size())
return E_INVALIDARG; 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) STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
@@ -185,13 +192,13 @@ STDMETHODIMP CFSDrives::GetName(BSTR *name)
return E_NOTIMPL; return E_NOTIMPL;
} }
STDMETHODIMP CFSDrives::GetNumberOfProperties(UINT32 *numProperties) STDMETHODIMP CFSDrives::GetNumberOfProperties(UInt32 *numProperties)
{ {
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]); *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK; return S_OK;
} }
STDMETHODIMP CFSDrives::GetPropertyInfo(UINT32 index, STDMETHODIMP CFSDrives::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType) BSTR *name, PROPID *propID, VARTYPE *varType)
{ {
if (index >= sizeof(kProperties) / sizeof(kProperties[0])) if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -213,18 +220,17 @@ STDMETHODIMP CFSDrives::GetTypeID(BSTR *name)
STDMETHODIMP CFSDrives::GetPath(BSTR *path) STDMETHODIMP CFSDrives::GetPath(BSTR *path)
{ {
CMyComBSTR temp = (LangLoadStringW(IDS_COMPUTER, 0x03020300)) + CMyComBSTR temp = LangString(IDS_COMPUTER, 0x03020300) + UString(L'\\');
UString(L'\\');
*path = temp.Detach(); *path = temp.Detach();
return S_OK; return S_OK;
} }
STDMETHODIMP CFSDrives::GetSystemIconIndex(UINT32 index, INT32 *iconIndex) STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
{ {
*iconIndex = 0; *iconIndex = 0;
const CDriveInfo &driveInfo = _drives[index]; const CDriveInfo &driveInfo = _drives[index];
int iconIndexTemp; int iconIndexTemp;
if (GetRealIconIndex(GetSystemString(driveInfo.FullSystemName), 0, iconIndexTemp) != 0) if (GetRealIconIndex(driveInfo.FullSystemName, 0, iconIndexTemp) != 0)
{ {
*iconIndex = iconIndexTemp; *iconIndex = iconIndexTemp;
return S_OK; return S_OK;

View File

@@ -4,6 +4,7 @@
#define __FSDRIVES_H #define __FSDRIVES_H
#include "Common/String.h" #include "Common/String.h"
#include "Common/Types.h"
#include "Common/MyCom.h" #include "Common/MyCom.h"
#include "Windows/FileFind.h" #include "Windows/FileFind.h"
#include "Windows/PropVariant.h" #include "Windows/PropVariant.h"
@@ -15,9 +16,9 @@ struct CDriveInfo
UString Name; UString Name;
UString FullSystemName; UString FullSystemName;
bool KnownSizes; bool KnownSizes;
UINT64 DriveSize; UInt64 DriveSize;
UINT64 FreeSpace; UInt64 FreeSpace;
UINT64 ClusterSize; UInt64 ClusterSize;
UString Type; UString Type;
UString VolumeName; UString VolumeName;
UString FileSystemName; UString FileSystemName;
@@ -40,25 +41,26 @@ public:
) )
STDMETHOD(LoadItems)(); STDMETHOD(LoadItems)();
STDMETHOD(GetNumberOfItems)(UINT32 *numItems); STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value); STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder); STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder); STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder); STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
STDMETHOD(GetName)(BSTR *name); STDMETHOD(GetName)(BSTR *name);
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties); STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UINT32 index, STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType); BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetTypeID)(BSTR *name); STDMETHOD(GetTypeID)(BSTR *name);
STDMETHOD(GetPath)(BSTR *path); STDMETHOD(GetPath)(BSTR *path);
STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex); STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
private: private:
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder); HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
CObjectVector<CDriveInfo> _drives; CObjectVector<CDriveInfo> _drives;
bool _volumeMode;
public: public:
void Init() {} void Init() { _volumeMode = false;}
}; };
#endif #endif

View File

@@ -37,14 +37,10 @@ static STATPROPSTG kProperties[] =
{ NULL, kpidComment, VT_BSTR} { NULL, kpidComment, VT_BSTR}
}; };
static inline UINT GetCurrentFileCodePage()
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder) HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
{ {
_parentFolder = parentFolder; _parentFolder = parentFolder;
_path = path; _path = path;
_fileCodePage = GetCurrentFileCodePage();
if (_findChangeNotification.FindFirst(_path, false, if (_findChangeNotification.FindFirst(_path, false,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_FILE_NAME |
@@ -70,7 +66,7 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
return S_OK; 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)); RINOK(progress->SetCompleted(NULL));
size = 0; size = 0;
@@ -80,7 +76,7 @@ static HRESULT GetFolderSize(const UString &path, UINT64 &size, IProgress *progr
{ {
if (fileInfo.IsDirectory()) if (fileInfo.IsDirectory())
{ {
UINT64 subSize; UInt64 subSize;
RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name,
subSize, progress)); subSize, progress));
size += subSize; size += subSize;
@@ -137,7 +133,7 @@ bool CFSFolder::LoadComments()
return false; return false;
AString s; AString s;
char *p = s.GetBuffer((size_t)length + 1); char *p = s.GetBuffer((size_t)length + 1);
UINT32 processedSize; UInt32 processedSize;
file.Read(p, (UInt32)length, processedSize); file.Read(p, (UInt32)length, processedSize);
p[length] = 0; p[length] = 0;
s.ReleaseBuffer(); s.ReleaseBuffer();
@@ -168,7 +164,7 @@ bool CFSFolder::SaveComments()
_comments.SaveToString(unicodeString); _comments.SaveToString(unicodeString);
AString utfString; AString utfString;
ConvertUnicodeToUTF8(unicodeString, utfString); ConvertUnicodeToUTF8(unicodeString, utfString);
UINT32 processedSize; UInt32 processedSize;
if (!IsAscii(unicodeString)) if (!IsAscii(unicodeString))
{ {
Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A }; Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A };
@@ -180,28 +176,28 @@ bool CFSFolder::SaveComments()
return true; return true;
} }
STDMETHODIMP CFSFolder::GetNumberOfItems(UINT32 *numItems) STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems)
{ {
*numItems = _files.Size(); *numItems = _files.Size();
return S_OK; 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++) for (int i = 0; i < _files.Size(); i++)
if (_files[i].IsDirectory()) if (_files[i].IsDirectory())
aNumSubFoldersLoc++; numSubFoldersLoc++;
*aNumSubFolders = aNumSubFoldersLoc; *numSubFolders = numSubFoldersLoc;
return S_OK; return S_OK;
} }
*/ */
STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value) STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{ {
NCOM::CPropVariant propVariant; NCOM::CPropVariant propVariant;
if (itemIndex >= (UINT32)_files.Size()) if (itemIndex >= (UInt32)_files.Size())
return E_INVALIDARG; return E_INVALIDARG;
CFileInfoEx &fileInfo = _files[itemIndex]; CFileInfoEx &fileInfo = _files[itemIndex];
switch(propID) switch(propID)
@@ -210,7 +206,7 @@ STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT
propVariant = fileInfo.IsDirectory(); propVariant = fileInfo.IsDirectory();
break; break;
case kpidName: case kpidName:
propVariant = GetUnicodeString(fileInfo.Name); propVariant = fileInfo.Name;
break; break;
case kpidSize: case kpidSize:
propVariant = fileInfo.Size; propVariant = fileInfo.Size;
@@ -227,7 +223,7 @@ STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT
propVariant = fileInfo.CompressedSize; propVariant = fileInfo.CompressedSize;
break; break;
case kpidAttributes: case kpidAttributes:
propVariant = (UINT32)fileInfo.Attributes; propVariant = (UInt32)fileInfo.Attributes;
break; break;
case kpidCreationTime: case kpidCreationTime:
propVariant = fileInfo.CreationTime; propVariant = fileInfo.CreationTime;
@@ -241,7 +237,7 @@ STDMETHODIMP CFSFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT
case kpidComment: case kpidComment:
LoadComments(); LoadComments();
UString comment; UString comment;
if (_comments.GetValue(GetUnicodeString(fileInfo.Name), comment)) if (_comments.GetValue(fileInfo.Name, comment))
propVariant = comment; propVariant = comment;
break; 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; *resultFolder = 0;
const NFind::CFileInfoW &fileInfo = _files[index]; const NFind::CFileInfoW &fileInfo = _files[index];
@@ -285,11 +281,11 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
} }
if (_path.IsEmpty()) if (_path.IsEmpty())
return E_INVALIDARG; return E_INVALIDARG;
int pos = _path.ReverseFind(TEXT('\\')); int pos = _path.ReverseFind(L'\\');
if (pos < 0 || pos != _path.Length() - 1) if (pos < 0 || pos != _path.Length() - 1)
return E_FAIL; return E_FAIL;
UString parentPath = _path.Left(pos); UString parentPath = _path.Left(pos);
pos = parentPath.ReverseFind(TEXT('\\')); pos = parentPath.ReverseFind(L'\\');
if (pos < 0) if (pos < 0)
{ {
parentPath.Empty(); parentPath.Empty();
@@ -301,14 +297,14 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
} }
UString parentPathReduced = parentPath.Left(pos); UString parentPathReduced = parentPath.Left(pos);
parentPath = parentPath.Left(pos + 1); parentPath = parentPath.Left(pos + 1);
pos = parentPathReduced.ReverseFind(TEXT('\\')); pos = parentPathReduced.ReverseFind(L'\\');
if (pos == 1) if (pos == 1)
{ {
if (parentPath[0] != TEXT('\\')) if (parentPath[0] != L'\\')
return E_FAIL; return E_FAIL;
CNetFolder *netFolderSpec = new CNetFolder; CNetFolder *netFolderSpec = new CNetFolder;
CMyComPtr<IFolderFolder> netFolder = netFolderSpec; CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
netFolderSpec->Init(GetUnicodeString(parentPath)); netFolderSpec->Init(parentPath);
*resultFolder = netFolder.Detach(); *resultFolder = netFolder.Detach();
return S_OK; 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]); *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK; return S_OK;
} }
STDMETHODIMP CFSFolder::GetPropertyInfo(UINT32 index, STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType) BSTR *name, PROPID *propID, VARTYPE *varType)
{ {
if (index >= sizeof(kProperties) / sizeof(kProperties[0])) if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -357,7 +353,7 @@ STDMETHODIMP CFSFolder::GetTypeID(BSTR *name)
STDMETHODIMP CFSFolder::GetPath(BSTR *path) STDMETHODIMP CFSFolder::GetPath(BSTR *path)
{ {
CMyComBSTR temp = GetUnicodeString(_path, _fileCodePage); CMyComBSTR temp = _path;
*path = temp.Detach(); *path = temp.Detach();
return S_OK; return S_OK;
} }
@@ -397,7 +393,7 @@ STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
return S_OK; 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]; const CFileInfoW &fileInfo = _files[index];
if (fileInfo.IsDirectory()) if (fileInfo.IsDirectory())
@@ -408,13 +404,13 @@ HRESULT CFSFolder::GetItemFullSize(int index, UINT64 &size, IProgress *progress)
CMyComPtr<IFolderReload> aFolderReload; CMyComPtr<IFolderReload> aFolderReload;
subFolder.QueryInterface(&aFolderReload); subFolder.QueryInterface(&aFolderReload);
aFolderReload->Reload(); aFolderReload->Reload();
UINT32 numItems; UInt32 numItems;
RINOK(subFolder->GetNumberOfItems(&numItems)); RINOK(subFolder->GetNumberOfItems(&numItems));
CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize; CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize;
subFolder.QueryInterface(&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)); RINOK(aGetItemFullSize->GetItemFullSize(i, &size));
*totalSize += size; *totalSize += size;
} }
@@ -425,12 +421,12 @@ HRESULT CFSFolder::GetItemFullSize(int index, UINT64 &size, IProgress *progress)
return S_OK; return S_OK;
} }
STDMETHODIMP CFSFolder::GetItemFullSize(UINT32 index, PROPVARIANT *value, IProgress *progress) STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
{ {
NCOM::CPropVariant propVariant; NCOM::CPropVariant propVariant;
if (index >= (UINT32)_files.Size()) if (index >= (UInt32)_files.Size())
return E_INVALIDARG; return E_INVALIDARG;
UINT64 size = 0; UInt64 size = 0;
HRESULT result = GetItemFullSize(index, size, progress); HRESULT result = GetItemFullSize(index, size, progress);
propVariant = size; propVariant = size;
propVariant.Detach(value); propVariant.Detach(value);
@@ -478,7 +474,7 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress *progress)
return S_OK; 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]; const CFileInfoW &fileInfo = _files[index];
if (!NDirectory::MyMoveFile(_path + fileInfo.Name, _path + newName)) 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; return S_OK;
} }
STDMETHODIMP CFSFolder::Delete(const UINT32 *indices, UINT32 numItems, STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,
IProgress *progress) IProgress *progress)
{ {
RINOK(progress->SetTotal(numItems)); RINOK(progress->SetTotal(numItems));
for (UINT32 i = 0; i < numItems; i++) for (UInt32 i = 0; i < numItems; i++)
{ {
int index = indices[i]; int index = indices[i];
const CFileInfoW &fileInfo = _files[indices[i]]; const CFileInfoW &fileInfo = _files[indices[i]];
@@ -502,57 +498,23 @@ STDMETHODIMP CFSFolder::Delete(const UINT32 *indices, UINT32 numItems,
result = NDirectory::DeleteFileAlways(fullPath); result = NDirectory::DeleteFileAlways(fullPath);
if (!result) if (!result)
return GetLastError(); return GetLastError();
UINT64 completed = i; UInt64 completed = i;
RINOK(progress->SetCompleted(&completed)); RINOK(progress->SetCompleted(&completed));
} }
return S_OK; return S_OK;
} }
/* STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
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,
const PROPVARIANT *value, IProgress *progress) const PROPVARIANT *value, IProgress *progress)
{ {
if (index >= (UINT32)_files.Size()) if (index >= (UInt32)_files.Size())
return E_INVALIDARG; return E_INVALIDARG;
CFileInfoEx &fileInfo = _files[index]; CFileInfoEx &fileInfo = _files[index];
switch(propID) switch(propID)
{ {
case kpidComment: case kpidComment:
{ {
UString filename = GetUnicodeString(fileInfo.Name); UString filename = fileInfo.Name;
filename.Trim(); filename.Trim();
if (value->vt == VT_EMPTY) if (value->vt == VT_EMPTY)
_comments.DeletePair(filename); _comments.DeletePair(filename);
@@ -579,15 +541,14 @@ STDMETHODIMP CFSFolder::SetProperty(UINT32 index, PROPID propID,
return S_OK; 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; return E_INVALIDARG;
const CFileInfoEx &fileInfo = _files[index]; const CFileInfoEx &fileInfo = _files[index];
*iconIndex = 0; *iconIndex = 0;
int iconIndexTemp; int iconIndexTemp;
if (GetRealIconIndex(GetSystemString(_path + fileInfo.Name), if (GetRealIconIndex(_path + fileInfo.Name, fileInfo.Attributes, iconIndexTemp) != 0)
fileInfo.Attributes, iconIndexTemp) != 0)
{ {
*iconIndex = iconIndexTemp; *iconIndex = iconIndexTemp;
return S_OK; return S_OK;

View File

@@ -17,7 +17,7 @@ class CFSFolder;
struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
{ {
bool CompressedSizeIsDefined; bool CompressedSizeIsDefined;
UINT64 CompressedSize; UInt64 CompressedSize;
}; };
@@ -34,7 +34,7 @@ class CFSFolder:
public IFolderGetSystemIconIndex, public IFolderGetSystemIconIndex,
public CMyUnknownImp public CMyUnknownImp
{ {
UINT64 GetSizeOfItem(int anIndex) const; UInt64 GetSizeOfItem(int anIndex) const;
public: public:
MY_QUERYINTERFACE_BEGIN MY_QUERYINTERFACE_BEGIN
MY_QUERYINTERFACE_ENTRY(IEnumProperties) MY_QUERYINTERFACE_ENTRY(IEnumProperties)
@@ -51,41 +51,38 @@ public:
STDMETHOD(LoadItems)(); STDMETHOD(LoadItems)();
STDMETHOD(GetNumberOfItems)(UINT32 *numItems); STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value); STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder); STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder); STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder); STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
STDMETHOD(GetName)(BSTR *name); STDMETHOD(GetName)(BSTR *name);
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties); STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UINT32 index, STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType); BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetTypeID)(BSTR *name); STDMETHOD(GetTypeID)(BSTR *name);
STDMETHOD(GetPath)(BSTR *path); STDMETHOD(GetPath)(BSTR *path);
STDMETHOD(WasChanged)(INT32 *wasChanged); STDMETHOD(WasChanged)(INT32 *wasChanged);
STDMETHOD(Clone)(IFolderFolder **resultFolder); STDMETHOD(Clone)(IFolderFolder **resultFolder);
STDMETHOD(GetItemFullSize)(UINT32 index, PROPVARIANT *value, IProgress *progress); STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
// IFolderOperations // IFolderOperations
STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress); STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress);
STDMETHOD(CreateFile)(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(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress);
STDMETHOD(Delete)(const UINT32 *indices, UINT32 numItems, IProgress *progress); STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress);
STDMETHOD(CopyTo)(const UINT32 *indices, UINT32 numItems, STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback); 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); const wchar_t *path, IFolderOperationsExtractCallback *callback);
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath, STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress); const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress);
STDMETHOD(SetProperty)(UINT32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress); STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex); STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
// STDMETHOD(DeleteToRecycleBin)(const UINT32 *indices, UINT32 numItems, IProgress *progress);
private: private:
UINT _fileCodePage;
UString _path; UString _path;
CObjectVector<CFileInfoEx> _files; CObjectVector<CFileInfoEx> _files;
CMyComPtr<IFolderFolder> _parentFolder; CMyComPtr<IFolderFolder> _parentFolder;
@@ -97,7 +94,7 @@ private:
NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification; 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 GetComplexName(const wchar_t *name, UString &resultPath);
HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder); HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);

View File

@@ -16,17 +16,9 @@ using namespace NWindows;
using namespace NFile; using namespace NFile;
using namespace NFind; using namespace NFind;
static inline UINT GetCurrentCodePage() #ifndef _UNICODE
{ return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; } extern bool g_IsNT;
#endif
static bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
static bool IsItWindows2000orHigher() static bool IsItWindows2000orHigher()
{ {
@@ -81,47 +73,48 @@ typedef BOOL (WINAPI * CopyFileExPointerW)(
IN DWORD dwCopyFlags 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, static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile,
IProgress *progress, UINT64 &completedSize) IProgress *progress, UINT64 &completedSize)
{ {
// if (IsItWindowsNT()) CProgressInfo progressInfo;
// { progressInfo.Progress = progress;
CProgressInfo progressInfo; progressInfo.StartPos = completedSize;
progressInfo.Progress = progress; BOOL CancelFlag = FALSE;
progressInfo.StartPos = completedSize; #ifndef _UNICODE
BOOL CancelFlag = FALSE; if (g_IsNT)
#endif
{
CopyFileExPointerW copyFunctionW = (CopyFileExPointerW) CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"),
"CopyFileExW"); "CopyFileExW");
if (copyFunctionW != 0) if (copyFunctionW == 0)
{ return false;
if (copyFunctionW(existingFile, newFile, CopyProgressRoutine, return BOOLToBool(copyFunctionW(existingFile, newFile, CopyProgressRoutine,
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS)) &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS));
return true; }
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) #ifndef _UNICODE
return false; else
} {
CopyFileExPointer copyFunction = (CopyFileExPointer) CopyFileExPointer copyFunction = (CopyFileExPointer)
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), ::GetProcAddress(::GetModuleHandleA("kernel32.dll"),
"CopyFileExA"); "CopyFileExA");
UINT codePage = GetCurrentCodePage();
if (copyFunction != 0) if (copyFunction != 0)
{ {
if (copyFunction( if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
UnicodeStringToMultiByte(existingFile, codePage), CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
UnicodeStringToMultiByte(newFile, codePage),
CopyProgressRoutine,
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
return true; return true;
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return false; return false;
} }
// } return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
return BOOLToBool(::CopyFile( }
GetSystemString(existingFile, codePage), #endif
GetSystemString(newFile, codePage),
TRUE));
} }
typedef BOOL (WINAPI * MoveFileWithProgressPointer)( typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
@@ -167,14 +160,12 @@ static HRESULT MyCopyFile(
const CFileInfoW &srcFileInfo, const CFileInfoW &srcFileInfo,
const UString &destPathSpec, const UString &destPathSpec,
IFolderOperationsExtractCallback *callback, IFolderOperationsExtractCallback *callback,
UINT fileCodePage,
UINT64 &completedSize) UINT64 &completedSize)
{ {
UString destPath = destPathSpec; UString destPath = destPathSpec;
if (destPath.CompareNoCase(srcPath) == 0) if (destPath.CompareNoCase(srcPath) == 0)
{ {
UString message = UString(L"can not move file \'") + UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
GetUnicodeString(destPath, fileCodePage) + UString(L"\' onto itself");
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
return E_ABORT; return E_ABORT;
} }
@@ -182,10 +173,10 @@ static HRESULT MyCopyFile(
INT32 writeAskResult; INT32 writeAskResult;
CMyComBSTR destPathResult; CMyComBSTR destPathResult;
RINOK(callback->AskWrite( RINOK(callback->AskWrite(
GetUnicodeString(srcPath, fileCodePage), srcPath,
BoolToInt(false), BoolToInt(false),
&srcFileInfo.LastWriteTime, &srcFileInfo.Size, &srcFileInfo.LastWriteTime, &srcFileInfo.Size,
GetUnicodeString(destPath, fileCodePage), destPath,
&destPathResult, &destPathResult,
&writeAskResult)); &writeAskResult));
if (IntToBool(writeAskResult)) if (IntToBool(writeAskResult))
@@ -194,9 +185,9 @@ static HRESULT MyCopyFile(
RINOK(callback->SetCurrentFilePath(srcPath)); RINOK(callback->SetCurrentFilePath(srcPath));
if (!::MyCopyFile(srcPath, destPathNew, callback, completedSize)) if (!::MyCopyFile(srcPath, destPathNew, callback, completedSize))
{ {
UString message = GetUnicodeString(NError::MyFormatMessage(GetLastError())) + UString message = NError::MyFormatMessageW(GetLastError()) +
UString(L" \'") + UString(L" \'") +
GetUnicodeString(destPathNew, fileCodePage)+ UString(destPathNew) +
UString(L"\'"); UString(L"\'");
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
return E_ABORT; return E_ABORT;
@@ -210,7 +201,6 @@ static HRESULT CopyFolder(
const UString &srcPath, const UString &srcPath,
const UString &destPathSpec, const UString &destPathSpec,
IFolderOperationsExtractCallback *callback, IFolderOperationsExtractCallback *callback,
UINT fileCodePage,
UINT64 &completedSize) UINT64 &completedSize)
{ {
RINOK(callback->SetCompleted(&completedSize)); RINOK(callback->SetCompleted(&completedSize));
@@ -222,7 +212,7 @@ static HRESULT CopyFolder(
if (destPath.Length() == len || destPath[len] == L'\\') if (destPath.Length() == len || destPath[len] == L'\\')
{ {
UString message = UString(L"can not copy folder \'") + UString message = UString(L"can not copy folder \'") +
GetUnicodeString(destPath, fileCodePage) + UString(L"\' onto itself"); destPath + UString(L"\' onto itself");
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
return E_ABORT; return E_ABORT;
} }
@@ -230,8 +220,7 @@ static HRESULT CopyFolder(
if (!NDirectory::CreateComplexDirectory(destPath)) if (!NDirectory::CreateComplexDirectory(destPath))
{ {
UString message = UString(L"can not create folder ") + UString message = UString(L"can not create folder ") + destPath;
GetUnicodeString(destPath, fileCodePage);
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
return E_ABORT; return E_ABORT;
} }
@@ -243,25 +232,23 @@ static HRESULT CopyFolder(
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name; const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
if (fileInfo.IsDirectory()) if (fileInfo.IsDirectory())
{ {
RINOK(CopyFolder(srcPath2, destPath2, RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize));
callback, fileCodePage, completedSize));
} }
else else
{ {
RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize));
callback, fileCodePage, completedSize));
} }
} }
return S_OK; 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) const wchar_t *path, IFolderOperationsExtractCallback *callback)
{ {
if (numItems == 0) if (numItems == 0)
return S_OK; return S_OK;
UINT64 totalSize = 0; UINT64 totalSize = 0;
UINT32 i; UInt32 i;
for (i = 0; i < numItems; i++) for (i = 0; i < numItems; i++)
{ {
int index = indices[i]; int index = indices[i];
@@ -285,7 +272,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
/* /*
// doesn't work in network // doesn't work in network
else else
if (!NDirectory::CreateComplexDirectory(GetSystemString(destPath, _fileCodePage))) if (!NDirectory::CreateComplexDirectory(destPath)))
{ {
DWORD lastError = ::GetLastError(); DWORD lastError = ::GetLastError();
UString message = UString(L"can not create folder ") + 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; UString srcPath = _path + fileInfo.Name;
if (fileInfo.IsDirectory()) if (fileInfo.IsDirectory())
{ {
RINOK(CopyFolder(srcPath, destPath2, callback, RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
_fileCodePage, completedSize));
} }
else else
{ {
RINOK(MyCopyFile(srcPath, fileInfo, destPath2, RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize));
callback, _fileCodePage, completedSize));
} }
} }
return S_OK; return S_OK;
@@ -326,14 +311,13 @@ HRESULT MyMoveFile(
const CFileInfoW &srcFileInfo, const CFileInfoW &srcFileInfo,
const UString &destPathSpec, const UString &destPathSpec,
IFolderOperationsExtractCallback *callback, IFolderOperationsExtractCallback *callback,
UINT fileCodePage,
UINT64 &completedSize) UINT64 &completedSize)
{ {
UString destPath = destPathSpec; UString destPath = destPathSpec;
if (destPath.CompareNoCase(srcPath) == 0) if (destPath.CompareNoCase(srcPath) == 0)
{ {
UString message = UString(L"can not move file \'") UString message = UString(L"can not move file \'")
+ GetUnicodeString(destPath, fileCodePage) + + destPath +
UString(L"\' onto itself"); UString(L"\' onto itself");
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
return E_ABORT; return E_ABORT;
@@ -342,10 +326,10 @@ HRESULT MyMoveFile(
INT32 writeAskResult; INT32 writeAskResult;
CMyComBSTR destPathResult; CMyComBSTR destPathResult;
RINOK(callback->AskWrite( RINOK(callback->AskWrite(
GetUnicodeString(srcPath, fileCodePage), srcPath,
BoolToInt(false), BoolToInt(false),
&srcFileInfo.LastWriteTime, &srcFileInfo.Size, &srcFileInfo.LastWriteTime, &srcFileInfo.Size,
GetUnicodeString(destPath, fileCodePage), destPath,
&destPathResult, &destPathResult,
&writeAskResult)); &writeAskResult));
if (IntToBool(writeAskResult)) if (IntToBool(writeAskResult))
@@ -354,8 +338,7 @@ HRESULT MyMoveFile(
RINOK(callback->SetCurrentFilePath(srcPath)); RINOK(callback->SetCurrentFilePath(srcPath));
if (!MyMoveFile(srcPath, destPathNew, callback, completedSize)) if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
{ {
UString message = UString(L"can not move to file ") + UString message = UString(L"can not move to file ") + destPathNew;
GetUnicodeString(destPathNew, fileCodePage);
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
} }
} }
@@ -368,7 +351,6 @@ HRESULT MyMoveFolder(
const UString &srcPath, const UString &srcPath,
const UString &destPathSpec, const UString &destPathSpec,
IFolderOperationsExtractCallback *callback, IFolderOperationsExtractCallback *callback,
UINT fileCodePage,
UINT64 &completedSize) UINT64 &completedSize)
{ {
UString destPath = destPathSpec; UString destPath = destPathSpec;
@@ -377,9 +359,8 @@ HRESULT MyMoveFolder(
{ {
if (destPath.Length() == len || destPath[len] == L'\\') if (destPath.Length() == len || destPath[len] == L'\\')
{ {
UString message = UString(L"can not move folder \'") UString message = UString(L"can not move folder \'") +
+ GetUnicodeString(destPath, fileCodePage) + destPath + UString(L"\' onto itself");
UString(L"\' onto itself");
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
return E_ABORT; return E_ABORT;
} }
@@ -390,8 +371,7 @@ HRESULT MyMoveFolder(
if (!NDirectory::CreateComplexDirectory(destPath)) if (!NDirectory::CreateComplexDirectory(destPath))
{ {
UString message = UString(L"can not create folder ") + UString message = UString(L"can not create folder ") + destPath;
GetUnicodeString(destPath, fileCodePage);
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
return E_ABORT; return E_ABORT;
} }
@@ -404,20 +384,17 @@ HRESULT MyMoveFolder(
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name; const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
if (fileInfo.IsDirectory()) if (fileInfo.IsDirectory())
{ {
RINOK(MyMoveFolder(srcPath2, destPath2, RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
callback, fileCodePage, completedSize));
} }
else else
{ {
RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, callback, completedSize));
callback, fileCodePage, completedSize));
} }
} }
} }
if (!NDirectory::MyRemoveDirectory(srcPath)) if (!NDirectory::MyRemoveDirectory(srcPath))
{ {
UString message = UString(L"can not remove folder") + UString message = UString(L"can not remove folder") + srcPath;
GetUnicodeString(srcPath, fileCodePage);
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
return E_ABORT; return E_ABORT;
} }
@@ -425,8 +402,8 @@ HRESULT MyMoveFolder(
} }
STDMETHODIMP CFSFolder::MoveTo( STDMETHODIMP CFSFolder::MoveTo(
const UINT32 *indices, const UInt32 *indices,
UINT32 numItems, UInt32 numItems,
const wchar_t *path, const wchar_t *path,
IFolderOperationsExtractCallback *callback) IFolderOperationsExtractCallback *callback)
{ {
@@ -434,7 +411,7 @@ STDMETHODIMP CFSFolder::MoveTo(
return S_OK; return S_OK;
UINT64 totalSize = 0; UINT64 totalSize = 0;
UINT32 i; UInt32 i;
for (i = 0; i < numItems; i++) for (i = 0; i < numItems; i++)
{ {
int index = indices[i]; int index = indices[i];
@@ -456,7 +433,7 @@ STDMETHODIMP CFSFolder::MoveTo(
return E_INVALIDARG; return E_INVALIDARG;
} }
else else
if (!NDirectory::CreateComplexDirectory(GetSystemString(destPath, _fileCodePage))) if (!NDirectory::CreateComplexDirectory(destPath))
{ {
UString message = UString(L"can not create folder ") + UString message = UString(L"can not create folder ") +
destPath; destPath;
@@ -475,13 +452,11 @@ STDMETHODIMP CFSFolder::MoveTo(
UString srcPath = _path + fileInfo.Name; UString srcPath = _path + fileInfo.Name;
if (fileInfo.IsDirectory()) if (fileInfo.IsDirectory())
{ {
RINOK(MyMoveFolder(srcPath, destPath2, callback, RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
_fileCodePage, completedSize));
} }
else else
{ {
RINOK(MyMoveFile(srcPath, fileInfo, destPath2, RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize));
callback, _fileCodePage, completedSize));
} }
} }
return S_OK; return S_OK;
@@ -489,7 +464,7 @@ STDMETHODIMP CFSFolder::MoveTo(
STDMETHODIMP CFSFolder::CopyFrom( STDMETHODIMP CFSFolder::CopyFrom(
const wchar_t *fromFolderPath, const wchar_t *fromFolderPath,
const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress) const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress)
{ {
return E_NOTIMPL; return E_NOTIMPL;
} }

View File

@@ -3,49 +3,14 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "FormatUtils.h" #include "FormatUtils.h"
#include "Windows/ResourceString.h"
#include "Common/IntToString.h" #include "Common/IntToString.h"
#include "Common/StringConvert.h" #include "Windows/ResourceString.h"
#ifdef LANG #ifdef LANG
#include "LangUtils.h" #include "LangUtils.h"
#endif #endif
/* UString NumberToString(UInt64 number)
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)
{ {
wchar_t numberString[32]; wchar_t numberString[32];
ConvertUInt64ToString(number, numberString); ConvertUInt64ToString(number, numberString);
@@ -59,16 +24,15 @@ UString MyFormatNew(const UString &format, const UString &argument)
return result; return result;
} }
UString MyFormatNew(UINT resourceID,
UString MyFormatNew(UINT32 resourceID,
#ifdef LANG #ifdef LANG
UINT32 aLangID, UInt32 langID,
#endif #endif
const UString &argument) const UString &argument)
{ {
return MyFormatNew( return MyFormatNew(
#ifdef LANG #ifdef LANG
LangLoadStringW(resourceID, aLangID), LangString(resourceID, langID),
#else #else
NWindows::MyLoadStringW(resourceID), NWindows::MyLoadStringW(resourceID),
#endif #endif

View File

@@ -3,18 +3,15 @@
#ifndef __FORMATUTILS_H #ifndef __FORMATUTILS_H
#define __FORMATUTILS_H #define __FORMATUTILS_H
#include "Common/Types.h"
#include "Common/String.h" #include "Common/String.h"
// CSysString MyFormat(const CSysString &format, const CSysString &argument); UString NumberToString(UInt64 number);
// CSysString NumberToString(UINT64 number);
UString NumberToStringW(UINT64 number);
UString MyFormatNew(const UString &format, const UString &argument); UString MyFormatNew(const UString &format, const UString &argument);
UString MyFormatNew(UINT32 resourceID, UString MyFormatNew(UINT resourceID,
#ifdef LANG #ifdef LANG
UINT32 aLangID, UInt32 langID,
#endif #endif
const UString &argument); const UString &argument);

View File

@@ -14,10 +14,7 @@ void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
{ {
UString path; UString path;
if (!::GetProgramFolderPath(path)) if (!::GetProgramFolderPath(path))
{
// AfxMessageBox(TEXT("App Path Registry Item not found"));
return; return;
}
path += kHelpFileName; path += kHelpFileName;
path += topicFile; path += topicFile;
HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL); HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);

View File

@@ -28,10 +28,10 @@ namespace NPlugin
FOLDER_INTERFACE(IFolderFolder, 0x00) FOLDER_INTERFACE(IFolderFolder, 0x00)
{ {
STDMETHOD(LoadItems)() PURE; STDMETHOD(LoadItems)() PURE;
STDMETHOD(GetNumberOfItems)(UINT32 *numItems) PURE; STDMETHOD(GetNumberOfItems)(UInt32 *numItems) PURE;
// STDMETHOD(GetNumberOfSubFolders)(UINT32 *numSubFolders) PURE; // STDMETHOD(GetNumberOfSubFolders)(UInt32 *numSubFolders) PURE;
STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value) PURE; STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) PURE;
STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder) PURE; STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder) PURE;
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder) PURE; STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder) PURE;
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder) PURE; STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder) PURE;
STDMETHOD(GetName)(BSTR *name) PURE; STDMETHOD(GetName)(BSTR *name) PURE;
@@ -40,8 +40,8 @@ FOLDER_INTERFACE(IFolderFolder, 0x00)
FOLDER_INTERFACE(IEnumProperties, 0x01) FOLDER_INTERFACE(IEnumProperties, 0x01)
{ {
// STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator) PURE; // STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator) PURE;
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties) PURE; STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) PURE;
STDMETHOD(GetPropertyInfo)(UINT32 index, STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType) PURE; BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
}; };
@@ -57,7 +57,7 @@ FOLDER_INTERFACE(IFolderGetPath, 0x03)
FOLDER_INTERFACE(IFolderWasChanged, 0x04) 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)( STDMETHOD(AskWrite)(
const wchar_t *srcPath, const wchar_t *srcPath,
INT32 srcIsFolder, Int32 srcIsFolder,
const FILETIME *srcTime, const FILETIME *srcTime,
const UINT64 *srcSize, const UInt64 *srcSize,
const wchar_t *destPathRequest, const wchar_t *destPathRequest,
BSTR *destPathResult, BSTR *destPathResult,
INT32 *writeAnswer) PURE; Int32 *writeAnswer) PURE;
STDMETHOD(ShowMessage)(const wchar_t *message) PURE; STDMETHOD(ShowMessage)(const wchar_t *message) PURE;
STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE; STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE;
}; };
@@ -86,13 +86,13 @@ FOLDER_INTERFACE_SUB(IFolderOperationsUpdateCallback, IProgress, 0x06, 0x02)
{ {
STDMETHOD(AskOverwrite)( STDMETHOD(AskOverwrite)(
const wchar_t *srcPath, const wchar_t *srcPath,
INT32 destIsFolder, Int32 destIsFolder,
const FILETIME *destTime, const FILETIME *destTime,
const UINT64 *destSize, const UInt64 *destSize,
const wchar_t *aDestPathRequest, const wchar_t *aDestPathRequest,
const wchar_t *aDestName, const wchar_t *aDestName,
BSTR *aDestPathResult, BSTR *aDestPathResult,
INT32 *aResult); Int32 *aResult);
}; };
*/ */
@@ -100,32 +100,32 @@ FOLDER_INTERFACE(IFolderOperations, 0x06)
{ {
STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress) PURE; STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress) PURE;
STDMETHOD(CreateFile)(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(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress) PURE;
STDMETHOD(Delete)(const UINT32 *indices, UINT32 numItems, IProgress *progress) PURE; STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress) PURE;
STDMETHOD(CopyTo)(const UINT32 *indices, UINT32 numItems, STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback) PURE; 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; const wchar_t *path, IFolderOperationsExtractCallback *callback) PURE;
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath, STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress) PURE; const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress) PURE;
STDMETHOD(SetProperty)(UINT32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) PURE; STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) PURE;
}; };
/* /*
FOLDER_INTERFACE2(IFolderOperationsDeleteToRecycleBin, 0x06, 0x03) 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) FOLDER_INTERFACE(IFolderGetSystemIconIndex, 0x07)
{ {
STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex) PURE; STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex) PURE;
}; };
FOLDER_INTERFACE(IFolderGetItemFullSize, 0x08) 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) FOLDER_INTERFACE(IFolderClone, 0x09)

View File

@@ -5,7 +5,6 @@
#include "LangUtils.h" #include "LangUtils.h"
#include "Common/StringConvert.h" #include "Common/StringConvert.h"
#include "Common/StringToInt.h" #include "Common/StringToInt.h"
#include "Windows/ResourceString.h"
#include "Windows/Synchronization.h" #include "Windows/Synchronization.h"
#include "Windows/Window.h" #include "Windows/Window.h"
#include "Windows/FileFind.h" #include "Windows/FileFind.h"
@@ -15,24 +14,28 @@
using namespace NWindows; using namespace NWindows;
static CLang g_Lang; static CLang g_Lang;
CSysString g_LangID; UString g_LangID;
#ifndef _UNICODE
extern bool g_IsNT;
#endif
void ReloadLang() void ReloadLang()
{ {
ReadRegLang(g_LangID); ReadRegLang(g_LangID);
g_Lang.Clear(); 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)
{ {
if (langPath.Find('.') < 0) if (langPath.Find('.') < 0)
langPath += TEXT(".txt"); langPath += L".txt";
UString folderPath; UString folderPath;
if (GetProgramFolderPath(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(); ReloadLang();
} }
/*
class CLangLoader
{
public:
CLangLoader() { ReloadLang(); }
} g_LangLoader;
*/
void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems) void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems)
{ {
for (int i = 0; i < numItems; i++) for (int i = 0; i < numItems; i++)
@@ -74,10 +69,10 @@ void LangSetWindowText(HWND window, UInt32 langID)
{ {
UString message; UString message;
if (g_Lang.GetMessage(langID, message)) if (g_Lang.GetMessage(langID, message))
SetWindowText(window, GetSystemString(message)); MySetWindowText(window, message);
} }
UString LangLoadString(UInt32 langID) UString LangString(UInt32 langID)
{ {
UString message; UString message;
if (g_Lang.GetMessage(langID, message)) if (g_Lang.GetMessage(langID, message))
@@ -85,15 +80,7 @@ UString LangLoadString(UInt32 langID)
return UString(); return UString();
} }
CSysString LangLoadString(UINT resourceID, UInt32 langID) UString LangString(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 message; UString message;
if (g_Lang.GetMessage(langID, message)) if (g_Lang.GetMessage(langID, message))
@@ -180,16 +167,19 @@ void FindMatchLang(UString &shortName)
void ReloadLangSmart() void ReloadLangSmart()
{ {
#ifdef _UNICODE #ifndef _UNICODE
ReadRegLang(g_LangID); if (g_IsNT)
if (g_LangID.IsEmpty())
{
UString shortName;
FindMatchLang(shortName);
if (shortName.IsEmpty())
shortName = L"-";
SaveRegLang(GetSystemString(shortName));
}
#endif #endif
{
ReadRegLang(g_LangID);
if (g_LangID.IsEmpty())
{
UString shortName;
FindMatchLang(shortName);
if (shortName.IsEmpty())
shortName = L"-";
SaveRegLang(shortName);
}
}
ReloadLang(); ReloadLang();
} }

View File

@@ -4,8 +4,9 @@
#define __LANGUTILS_H #define __LANGUTILS_H
#include "Common/Lang.h" #include "Common/Lang.h"
#include "Windows/ResourceString.h"
extern CSysString g_LangID; extern UString g_LangID;
struct CIDLangPair struct CIDLangPair
{ {
@@ -28,9 +29,13 @@ void LoadLangs(CObjectVector<CLangEx> &langs);
void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems); void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems);
void LangSetWindowText(HWND window, UInt32 langID); void LangSetWindowText(HWND window, UInt32 langID);
UString LangLoadString(UInt32 langID); UString LangString(UInt32 langID);
CSysString LangLoadString(UINT resourceID, UInt32 langID); UString LangString(UINT resourceID, UInt32 langID);
UString LangLoadStringW(UINT resourceID, UInt32 langID);
#ifdef LANG
#define LangStringSpec(resourceID, langID) LangString(resourceID, langID)
#else
#define LangStringSpec(resourceID, langID) NWindows::MyLoadStringW(resourceID)
#endif
#endif #endif

View File

@@ -135,61 +135,6 @@ static int FindLangItem(int ControlID)
return -1; 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; static bool g_IsNew_fMask = true;
@@ -241,70 +186,62 @@ static UINT Get_fMaskForFTypeAndString()
return MIIM_TYPE; return MIIM_TYPE;
} }
static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex) static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
{ {
CMenu menu; CMenu menu;
menu.Attach(menuLoc); menu.Attach(menuLoc);
for (int i = 0; i < menu.GetItemCount(); i++) for (int i = 0; i < menu.GetItemCount(); i++)
{ {
MENUITEMINFO menuInfo; CMenuItem item;
ZeroMemory(&menuInfo, sizeof(menuInfo)); item.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID;
menuInfo.cbSize = sizeof(menuInfo); item.fType = MFT_STRING;
menuInfo.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID; if (menu.GetItem(i, true, item))
menuInfo.fType = MFT_STRING;
const int kBufferSize = 1024;
TCHAR buffer[kBufferSize + 1];
menuInfo.dwTypeData = buffer;
menuInfo.cch = kBufferSize;
if (menu.GetItemInfo(i, true, &menuInfo))
{ {
CSysString newString; UString newString;
if (menuInfo.hSubMenu) if (item.hSubMenu)
{ {
if (level == 1 && menuIndex == kBookmarksMenuIndex) if (level == 1 && menuIndex == kBookmarksMenuIndex)
newString = GetSystemString(LangLoadString(kAddToFavoritesLangID)); newString = LangString(kAddToFavoritesLangID);
else else
{ {
MyChangeMenu(menuInfo.hSubMenu, level + 1, i); MyChangeMenu(item.hSubMenu, level + 1, i);
if (level == 1 && menuIndex == kViewMenuIndex) if (level == 1 && menuIndex == kViewMenuIndex)
{ {
newString = GetSystemString(LangLoadString(kToolbarsLangID)); newString = LangString(kToolbarsLangID);
} }
else else
{ {
if (level == 0 && i < sizeof(kStringLangPairs) / if (level == 0 && i < sizeof(kStringLangPairs) /
sizeof(kStringLangPairs[0])) sizeof(kStringLangPairs[0]))
newString = GetSystemString(LangLoadString(kStringLangPairs[i].LangID)); newString = LangString(kStringLangPairs[i].LangID);
else else
continue; continue;
} }
} }
if (newString.IsEmpty()) if (newString.IsEmpty())
continue; continue;
// int langPos = FindStringLangItem(GetUnicodeString(menuInfo.dwTypeData));
// if (langPos >= 0)
// newString = LangLoadString(kStringLangPairs[langPos].LangID);
// else
// newString = menuInfo.dwTypeData;
} }
else else
{ {
int langPos = FindLangItem(menuInfo.wID); int langPos = FindLangItem(item.wID);
if (langPos < 0) if (langPos < 0)
continue; continue;
newString = GetSystemString(LangLoadString(kIDLangPairs[langPos].LangID)); newString = LangString(kIDLangPairs[langPos].LangID);
if (newString.IsEmpty()) if (newString.IsEmpty())
continue; continue;
CSysString shorcutString = menuInfo.dwTypeData; UString shorcutString = item.StringValue;
int tabPos = shorcutString.ReverseFind(wchar_t('\t')); int tabPos = shorcutString.ReverseFind(wchar_t('\t'));
if (tabPos >= 0) if (tabPos >= 0)
newString += shorcutString.Mid(tabPos); newString += shorcutString.Mid(tabPos);
} }
menuInfo.dwTypeData = (LPTSTR)(LPCTSTR)newString; {
menuInfo.fMask = Get_fMaskForString(); item.StringValue = newString;
menuInfo.fType = MFT_STRING; item.fMask = Get_fMaskForString();
menu.SetItemInfo(i, true, &menuInfo); item.fType = MFT_STRING;
menu.SetItem(i, true, item);
}
} }
} }
} }
@@ -353,20 +290,12 @@ static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
int startPos = 0; int startPos = 0;
for (int i = 0; i < srcMenu.GetItemCount(); i++) for (int i = 0; i < srcMenu.GetItemCount(); i++)
{ {
MENUITEMINFO menuInfo; CMenuItem item;
ZeroMemory(&menuInfo, sizeof(menuInfo)); item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
menuInfo.cbSize = sizeof(menuInfo); item.fType = MFT_STRING;
menuInfo.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString(); if (srcMenu.GetItem(i, true, item))
menuInfo.fType = MFT_STRING; if (destMenu.InsertItem(startPos, true, item))
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))
startPos++; startPos++;
}
} }
} }
@@ -422,14 +351,13 @@ void OnMenuActivating(HWND hWnd, HMENU hMenu, int position)
int i; int i;
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
{ {
UString s = LangLoadStringW(IDS_BOOKMARK, 0x03000720); UString s = LangString(IDS_BOOKMARK, 0x03000720);
s += L" "; s += L" ";
wchar_t c = L'0' + i; wchar_t c = L'0' + i;
s += c; s += c;
s += L"\tAlt+Shift+"; s += L"\tAlt+Shift+";
s += c; s += c;
subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s);
GetSystemString(s));
} }
while (menu.GetItemCount() > 2) while (menu.GetItemCount() > 2)
@@ -445,15 +373,13 @@ void OnMenuActivating(HWND hWnd, HMENU hMenu, int position)
path = path.Left(kFirstPartSize) + UString(L" ... ") + path = path.Left(kFirstPartSize) + UString(L" ... ") +
path.Right(kMaxSize - kFirstPartSize); path.Right(kMaxSize - kFirstPartSize);
} }
CSysString s = GetSystemString(path); UString s = path;
if (s.IsEmpty()) if (s.IsEmpty())
s = TEXT("-"); s = L"-";
s += TEXT("\tAlt+"); s += L"\tAlt+";
s += ('0' + i); s += (L'0' + i);
menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s); 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++) for (int i = 0; i < g_FileMenu.GetItemCount(); i++)
{ {
MENUITEMINFO menuInfo; CMenuItem item;
ZeroMemory(&menuInfo, sizeof(menuInfo));
menuInfo.cbSize = sizeof(menuInfo);
/* item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
menuInfo.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE; item.fType = MFT_STRING;
menuInfo.fType = MFT_STRING; if (g_FileMenu.GetItem(i, true, item))
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))
{ {
if (!programMenu) if (!programMenu)
if (menuInfo.wID == IDCLOSE) if (item.wID == IDCLOSE)
continue; continue;
/* /*
bool createItem = (menuInfo.wID == IDM_CREATE_FOLDER || bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE);
menuInfo.wID == IDM_CREATE_FILE);
if (forFileMode) if (forFileMode)
{ {
if (createItem) if (createItem)
@@ -542,21 +438,20 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool forFileMode,
continue; continue;
} }
*/ */
if (destMenu.InsertItem(startPos, true, &menuInfo)) if (destMenu.InsertItem(startPos, true, item))
startPos++; startPos++;
} }
} }
while (destMenu.GetItemCount() > 0) while (destMenu.GetItemCount() > 0)
{ {
MENUITEMINFO menuInfo; CMenuItem item;
ZeroMemory(&menuInfo, sizeof(menuInfo)); item.fMask = MIIM_TYPE;
menuInfo.cbSize = sizeof(menuInfo); item.fType = 0;
menuInfo.fMask = MIIM_TYPE; // item.dwTypeData = 0;
menuInfo.dwTypeData = 0;
int lastIndex = destMenu.GetItemCount() - 1; int lastIndex = destMenu.GetItemCount() - 1;
if (!destMenu.GetItemInfo(lastIndex, true, &menuInfo)) if (!destMenu.GetItem(lastIndex, true, item))
break; break;
if(menuInfo.fType != MFT_SEPARATOR) if(item.fType != MFT_SEPARATOR)
break; break;
if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION)) if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION))
break; break;

View File

@@ -43,9 +43,9 @@ void CNetFolder::Init(const UString &path)
} }
Init(0, 0 , L""); Init(0, 0 , L"");
*/ */
CResource resource; CResourceW resource;
resource.RemoteNameIsDefined = true; resource.RemoteNameIsDefined = true;
resource.RemoteName = GetSystemString(path.Left(path.Length() - 1)); resource.RemoteName = path.Left(path.Length() - 1);
resource.ProviderIsDefined = false; resource.ProviderIsDefined = false;
resource.LocalNameIsDefined = false; resource.LocalNameIsDefined = false;
resource.CommentIsDefined = false; resource.CommentIsDefined = false;
@@ -53,18 +53,17 @@ void CNetFolder::Init(const UString &path)
resource.Scope = RESOURCE_GLOBALNET; resource.Scope = RESOURCE_GLOBALNET;
resource.Usage = 0; resource.Usage = 0;
resource.DisplayType = 0; resource.DisplayType = 0;
CResource aDestResource; CResourceW destResource;
CSysString aSystemPathPart; UString systemPathPart;
DWORD result = GetResourceInformation(resource, aDestResource, DWORD result = GetResourceInformation(resource, destResource, systemPathPart);
aSystemPathPart);
if (result == NO_ERROR) if (result == NO_ERROR)
Init(&aDestResource, 0, path); Init(&destResource, 0, path);
else else
Init(0, 0 , L""); Init(0, 0 , L"");
return; return;
} }
void CNetFolder::Init(const NWindows::NNet::CResource *netResource, void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource,
IFolderFolder *parentFolder, const UString &path) IFolderFolder *parentFolder, const UString &path)
{ {
_path = path; _path = path;
@@ -76,7 +75,7 @@ void CNetFolder::Init(const NWindows::NNet::CResource *netResource,
_netResourcePointer = &_netResource; _netResourcePointer = &_netResource;
// if (_netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER) // if (_netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER)
_path = GetUnicodeString(_netResource.RemoteName) + L'\\'; _path = _netResource.RemoteName + L'\\';
} }
_parentFolder = parentFolder; _parentFolder = parentFolder;
} }
@@ -113,7 +112,7 @@ STDMETHODIMP CNetFolder::LoadItems()
{ {
if (!resource.RemoteNameIsDefined) // For Win 98, I don't know what's wrong if (!resource.RemoteNameIsDefined) // For Win 98, I don't know what's wrong
resource.RemoteName = resource.Comment; resource.RemoteName = resource.Comment;
resource.Name = GetUnicodeString(resource.RemoteName); resource.Name = resource.RemoteName;
int aPos = resource.Name.ReverseFind(L'\\'); int aPos = resource.Name.ReverseFind(L'\\');
if (aPos >= 0) if (aPos >= 0)
{ {
@@ -128,6 +127,8 @@ STDMETHODIMP CNetFolder::LoadItems()
return result; return result;
} }
/*
It's too slow for some systems.
if (_netResourcePointer && _netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER) if (_netResourcePointer && _netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER)
{ {
for (char c = 'a'; c <= 'z'; c++) for (char c = 'a'; c <= 'z'; c++)
@@ -135,11 +136,11 @@ STDMETHODIMP CNetFolder::LoadItems()
CResourceEx resource; CResourceEx resource;
resource.Name = UString(wchar_t(c)) + L'$'; resource.Name = UString(wchar_t(c)) + L'$';
resource.RemoteNameIsDefined = true; resource.RemoteNameIsDefined = true;
resource.RemoteName = GetSystemString(_path + resource.Name); resource.RemoteName = _path + resource.Name;
NFile::NFind::CFindFile aFindFile; NFile::NFind::CFindFile findFile;
NFile::NFind::CFileInfo aFileInfo; NFile::NFind::CFileInfoW fileInfo;
if (!aFindFile.FindFirst(resource.RemoteName + CSysString(TEXT("\\*")), aFileInfo)) if (!findFile.FindFirst(resource.RemoteName + UString(L"\\*"), fileInfo))
continue; continue;
resource.Usage = RESOURCEUSAGE_CONNECTABLE; resource.Usage = RESOURCEUSAGE_CONNECTABLE;
resource.LocalNameIsDefined = false; resource.LocalNameIsDefined = false;
@@ -148,17 +149,18 @@ STDMETHODIMP CNetFolder::LoadItems()
_items.Add(resource); _items.Add(resource);
} }
} }
*/
return S_OK; return S_OK;
} }
STDMETHODIMP CNetFolder::GetNumberOfItems(UINT32 *numItems) STDMETHODIMP CNetFolder::GetNumberOfItems(UInt32 *numItems)
{ {
*numItems = _items.Size(); *numItems = _items.Size();
return S_OK; return S_OK;
} }
STDMETHODIMP CNetFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value) STDMETHODIMP CNetFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{ {
NCOM::CPropVariant propVariant; NCOM::CPropVariant propVariant;
const CResourceEx &item = _items[itemIndex]; const CResourceEx &item = _items[itemIndex];
@@ -173,25 +175,22 @@ STDMETHODIMP CNetFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIAN
break; break;
case kpidLocalName: case kpidLocalName:
if (item.LocalNameIsDefined) if (item.LocalNameIsDefined)
propVariant = GetUnicodeString(item.LocalName); propVariant = item.LocalName;
break; break;
case kpidComment: case kpidComment:
if (item.CommentIsDefined) if (item.CommentIsDefined)
propVariant = GetUnicodeString(item.Comment); propVariant = item.Comment;
break; break;
case kpidProvider: case kpidProvider:
if (item.ProviderIsDefined) if (item.ProviderIsDefined)
propVariant = GetUnicodeString(item.Provider); propVariant = item.Provider;
break; break;
} }
propVariant.Detach(value); propVariant.Detach(value);
return S_OK; return S_OK;
} }
static inline UINT GetCurrentCodePage() STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
{ return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
STDMETHODIMP CNetFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
{ {
*resultFolder = 0; *resultFolder = 0;
const CResourceEx &resource = _items[index]; const CResourceEx &resource = _items[index];
@@ -200,16 +199,14 @@ STDMETHODIMP CNetFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder
{ {
CFSFolder *fsFolderSpec = new CFSFolder; CFSFolder *fsFolderSpec = new CFSFolder;
CMyComPtr<IFolderFolder> subFolder = fsFolderSpec; CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
RINOK(fsFolderSpec->Init( RINOK(fsFolderSpec->Init(resource.RemoteName + L'\\', this));
GetUnicodeString(resource.RemoteName, GetCurrentCodePage())
+ L'\\', this));
*resultFolder = subFolder.Detach(); *resultFolder = subFolder.Detach();
} }
else else
{ {
CNetFolder *netFolder = new CNetFolder; CNetFolder *netFolder = new CNetFolder;
CMyComPtr<IFolderFolder> subFolder = netFolder; CMyComPtr<IFolderFolder> subFolder = netFolder;
netFolder->Init(&resource, this, GetUnicodeString(resource.Name) + L'\\'); netFolder->Init(&resource, this, resource.Name + L'\\');
*resultFolder = subFolder.Detach(); *resultFolder = subFolder.Detach();
} }
return S_OK; return S_OK;
@@ -231,7 +228,7 @@ STDMETHODIMP CNetFolder::BindToParentFolder(IFolderFolder **resultFolder)
} }
if (_netResourcePointer != 0) if (_netResourcePointer != 0)
{ {
CResource resourceParent; CResourceW resourceParent;
DWORD result = GetResourceParent(_netResource, resourceParent); DWORD result = GetResourceParent(_netResource, resourceParent);
if (result != NO_ERROR) if (result != NO_ERROR)
return result; 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]); *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK; return S_OK;
} }
STDMETHODIMP CNetFolder::GetPropertyInfo(UINT32 index, STDMETHODIMP CNetFolder::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType) BSTR *name, PROPID *propID, VARTYPE *varType)
{ {
if (index >= sizeof(kProperties) / sizeof(kProperties[0])) if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -289,12 +286,12 @@ STDMETHODIMP CNetFolder::GetPath(BSTR *path)
return S_OK; 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; return E_INVALIDARG;
*iconIndex = 0; *iconIndex = 0;
const CResource &resource = _items[index]; const CResourceW &resource = _items[index];
int iconIndexTemp; int iconIndexTemp;
if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER || if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER ||
resource.Usage == RESOURCEUSAGE_CONNECTABLE) resource.Usage == RESOURCEUSAGE_CONNECTABLE)

View File

@@ -11,7 +11,7 @@
#include "IFolder.h" #include "IFolder.h"
struct CResourceEx: public NWindows::NNet::CResource struct CResourceEx: public NWindows::NNet::CResourceW
{ {
UString Name; UString Name;
}; };
@@ -33,23 +33,23 @@ public:
) )
STDMETHOD(LoadItems)(); STDMETHOD(LoadItems)();
STDMETHOD(GetNumberOfItems)(UINT32 *numItems); STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value); STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder); STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder); STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder); STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
STDMETHOD(GetName)(BSTR *name); STDMETHOD(GetName)(BSTR *name);
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties); STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UINT32 index, STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType); BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetTypeID)(BSTR *name); STDMETHOD(GetTypeID)(BSTR *name);
STDMETHOD(GetPath)(BSTR *path); STDMETHOD(GetPath)(BSTR *path);
STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex); STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
private: private:
NWindows::NNet::CResource _netResource; NWindows::NNet::CResourceW _netResource;
NWindows::NNet::CResource *_netResourcePointer; NWindows::NNet::CResourceW *_netResourcePointer;
CObjectVector<CResourceEx> _items; CObjectVector<CResourceEx> _items;
@@ -58,7 +58,7 @@ private:
public: public:
void Init(const UString &path); void Init(const UString &path);
void Init(const NWindows::NNet::CResource *netResource, void Init(const NWindows::NNet::CResourceW *netResource,
IFolderFolder *parentFolder, const UString &path); IFolderFolder *parentFolder, const UString &path);
CNetFolder(): _netResourcePointer(0) {} CNetFolder(): _netResourcePointer(0) {}
}; };

View File

@@ -46,7 +46,7 @@ STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value
switch(propID) switch(propID)
{ {
case kpidName: case kpidName:
propVariant = GetUnicodeString(_fileInfo.Name); propVariant = _fileInfo.Name;
break; break;
case kpidIsFolder: case kpidIsFolder:
propVariant = _fileInfo.IsDirectory(); propVariant = _fileInfo.IsDirectory();

View File

@@ -24,33 +24,7 @@
#include "MyLoadMenu.h" #include "MyLoadMenu.h"
#include "App.h" #include "App.h"
void FillInPropertyPage(PROPSHEETPAGE* page, HINSTANCE instance, int dialogID, using namespace NWindows;
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;
}
void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance) void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance)
{ {
@@ -60,54 +34,32 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance)
CSettingsPage settingsPage; CSettingsPage settingsPage;
CLangPage langPage; CLangPage langPage;
CSysStringVector titles; CObjectVector<NControl::CPageInfo> pages;
UINT32 langIDs[] = { 0x03010300, 0x03010100, 0x03010200, 0x03010400, 0x01000400}; 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]); const int kNumPages = sizeof(langIDs) / sizeof(langIDs[0]);
for (int i = 0; i < kNumPages; i++) for (int i = 0; i < kNumPages; i++)
titles.Add(GetSystemString(LangLoadString(langIDs[i]))); {
NControl::CPageInfo page;
PROPSHEETPAGE pages[kNumPages]; 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]); int res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS, 0x03010000));
FillInPropertyPage(&pages[1], hInstance, IDD_PLUGINS, &pluginsPage, titles[1]); if (res != -1 && res != 0)
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)
{ {
if (langPage._langWasChanged) if (langPage._langWasChanged)
{ {
g_App._window.SetText(LangLoadStringW(IDS_APP_TITLE, 0x03000000)); g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000));
MyLoadMenu(); MyLoadMenu();
} }
g_App.SetListSettings(); g_App.SetListSettings();
g_App.SetShowSystemMenu(); g_App.SetShowSystemMenu();
g_App.RefreshAllPanels(); g_App.RefreshAllPanels();
g_App.ReloadToolbars(); g_App.ReloadToolbars();
// ::PostMessage(hwndOwner, kLangWasChangedMessage, 0 , 0); // ::PostMessage(hwndOwner, kLangWasChangedMessage, 0 , 0);
} }
/*
else
MessageBox(0, NWindows::NError::MyFormatMessage(GetLastError()), TEXT("PropertySheet"), 0);
*/
} }

View File

@@ -22,6 +22,10 @@
using namespace NWindows; using namespace NWindows;
#ifndef _UNICODE
extern bool g_IsNT;
#endif
static const UINT_PTR kTimerID = 1; static const UINT_PTR kTimerID = 1;
static const UINT kTimerElapse = 1000; static const UINT kTimerElapse = 1000;
@@ -49,7 +53,7 @@ CPanel::~CPanel()
CloseOpenFolders(); CloseOpenFolders();
} }
static LPCTSTR kClassName = TEXT("7-Zip::Panel"); static LPCWSTR kClassName = L"7-Zip::Panel";
LRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id, 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->_lastFocusedIsList = true;
_panel->_panelCallback->PanelWasFocused(); _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 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) bool CPanel::OnCreate(CREATESTRUCT *createStruct)
@@ -318,11 +332,19 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
HWND(*this), (HMENU)_baseID + 1, g_hInstance, NULL)) HWND(*this), (HMENU)_baseID + 1, g_hInstance, NULL))
return false; return false;
_listView.SetUnicodeFormat(true);
_listView.SetUserDataLongPtr(LONG_PTR(&_listView)); _listView.SetUserDataLongPtr(LONG_PTR(&_listView));
_listView._panel = this; _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; SHFILEINFO shellInfo;
HIMAGELIST imageList = (HIMAGELIST)SHGetFileInfo(TEXT(""), HIMAGELIST imageList = (HIMAGELIST)SHGetFileInfo(TEXT(""),
@@ -401,8 +423,6 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
; ;
} }
_headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle, _headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle,
_baseID + 2, 11, _baseID + 2, 11,
(HINSTANCE)HINST_COMMCTRL, (HINSTANCE)HINST_COMMCTRL,
@@ -414,12 +434,15 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
icex.dwICC = ICC_USEREX_CLASSES; icex.dwICC = ICC_USEREX_CLASSES;
InitCommonControlsEx(&icex); InitCommonControlsEx(&icex);
_headerComboBox.CreateEx(0, WC_COMBOBOXEX, NULL, _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL, WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
0, 0, 100, 20, 0, 0, 100, 20,
((_headerReBar == 0) ? HWND(*this) : _headerToolBar), ((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
(HMENU)(_comboBoxID), (HMENU)(_comboBoxID),
g_hInstance, NULL); g_hInstance, NULL);
// _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
_headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC); _headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
/* /*
@@ -430,11 +453,20 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
LONG_PTR(ComboBoxSubclassProc)); LONG_PTR(ComboBoxSubclassProc));
*/ */
_comboBoxEdit.Attach(_headerComboBox.GetEditControl()); _comboBoxEdit.Attach(_headerComboBox.GetEditControl());
// _comboBoxEdit.SendMessage(CCM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
_comboBoxEdit.SetUserDataLongPtr(LONG_PTR(&_comboBoxEdit)); _comboBoxEdit.SetUserDataLongPtr(LONG_PTR(&_comboBoxEdit));
_comboBoxEdit._panel = this; _comboBoxEdit._panel = this;
_comboBoxEdit._origWindowProc = #ifndef _UNICODE
(WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, if(g_IsNT)
LONG_PTR(ComboBoxEditSubclassProc)); _comboBoxEdit._origWindowProc =
(WNDPROC)_comboBoxEdit.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
else
#endif
_comboBoxEdit._origWindowProc =
(WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
if (_headerReBar) if (_headerReBar)
@@ -472,8 +504,8 @@ bool CPanel::OnCreate(CREATESTRUCT *createStruct)
// _headerReBar.MaximizeBand(1, false); // _headerReBar.MaximizeBand(1, false);
} }
_statusBar.Create(WS_CHILD | WS_VISIBLE, TEXT("Status"), (*this), _statusBarID); _statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
// _statusBar2.Create(WS_CHILD | WS_VISIBLE, TEXT("Status"), (*this), _statusBarID + 1); // _statusBar2.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID + 1);
int sizes[] = {150, 200, 250, -1}; int sizes[] = {150, 200, 250, -1};
_statusBar.SetParts(4, sizes); _statusBar.SetParts(4, sizes);
@@ -607,7 +639,7 @@ void CPanel::MessageBox(LPCWSTR message)
void CPanel::MessageBoxMyError(LPCWSTR message) void CPanel::MessageBoxMyError(LPCWSTR message)
{ MessageBox(message, L"Error"); } { MessageBox(message, L"Error"); }
void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption) void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption)
{ MessageBox(GetUnicodeString(NError::MyFormatMessage(errorCode)), caption); } { MessageBox(NError::MyFormatMessageW(errorCode), caption); }
void CPanel::MessageBoxError(HRESULT errorCode) void CPanel::MessageBoxError(HRESULT errorCode)
{ MessageBoxError(errorCode, L"7-Zip"); } { MessageBoxError(errorCode, L"7-Zip"); }
void CPanel::MessageBoxLastError(LPCWSTR caption) void CPanel::MessageBoxLastError(LPCWSTR caption)
@@ -629,11 +661,6 @@ void CPanel::SetFocusToLastRememberedItem()
_headerComboBox.SetFocus(); _headerComboBox.SetFocus();
} }
CSysString CPanel::GetFileType(UINT32 index)
{
return TEXT("Test type");
}
UString CPanel::GetFolderTypeID() const UString CPanel::GetFolderTypeID() const
{ {
CMyComPtr<IFolderGetTypeID> folderGetTypeID; CMyComPtr<IFolderGetTypeID> folderGetTypeID;

View File

@@ -159,15 +159,18 @@ class CPanel:public NWindows::NControl::CWindow2
virtual void OnDestroy(); virtual void OnDestroy();
virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result); virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result);
void OnComboBoxCommand(UINT code, LPARAM &aParam); void OnComboBoxCommand(UINT code, LPARAM &aParam);
bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
#ifndef _UNICODE
bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result); bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
#endif
bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result); bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result);
bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result); bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result);
void OnItemChanged(NMLISTVIEW *item); void OnItemChanged(NMLISTVIEW *item);
bool OnNotifyList(LPNMHDR lParam, LRESULT &result); bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
void OnDrag(LPNMLISTVIEW nmListView); void OnDrag(LPNMLISTVIEW nmListView);
bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result); bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
BOOL OnBeginLabelEdit(LV_DISPINFO * lpnmh); BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
BOOL OnEndLabelEdit(LV_DISPINFO * lpnmh); BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
void OnColumnClick(LPNMLISTVIEW info); void OnColumnClick(LPNMLISTVIEW info);
bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result); bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
@@ -204,8 +207,8 @@ public:
void InvertSelection(); void InvertSelection();
private: private:
CSysString GetFileType(UInt32 index); // UString GetFileType(UInt32 index);
LRESULT SetItemText(LVITEM &item); LRESULT SetItemText(LVITEMW &item);
// CRecordVector<PROPID> m_ColumnsPropIDs; // CRecordVector<PROPID> m_ColumnsPropIDs;
@@ -231,7 +234,7 @@ public:
UString _focusedName; UString _focusedName;
UInt32 GetRealIndex(const LVITEM &item) const UInt32 GetRealIndex(const LVITEMW &item) const
{ {
/* /*
if (_virtualMode) if (_virtualMode)
@@ -326,7 +329,7 @@ public:
bool _needSaveInfo; bool _needSaveInfo;
CSysString _typeIDString; UString _typeIDString;
CListViewInfo _listViewInfo; CListViewInfo _listViewInfo;
CItemProperties _properties; CItemProperties _properties;
CItemProperties _visibleProperties; CItemProperties _visibleProperties;

View File

@@ -55,7 +55,7 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold
CMyComPtr<IFolderOperations> folderOperations; CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) 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) if (showErrorMessages)
MessageBox(errorMessage); MessageBox(errorMessage);
else if (messages != 0) else if (messages != 0)
@@ -71,9 +71,9 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold
extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages; extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages;
UString title = moveMode ? UString title = moveMode ?
LangLoadStringW(IDS_MOVING, 0x03020206): LangString(IDS_MOVING, 0x03020206):
LangLoadStringW(IDS_COPYING, 0x03020205); LangString(IDS_COPYING, 0x03020205);
UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent(); extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent();
extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle; extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
@@ -133,7 +133,7 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP
CMyComPtr<IFolderOperations> folderOperations; CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) 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) if (showErrorMessages)
MessageBox(errorMessage); MessageBox(errorMessage);
else if (messages != 0) else if (messages != 0)
@@ -145,8 +145,8 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP
updater.UpdateCallbackSpec = new CUpdateCallback100Imp; updater.UpdateCallbackSpec = new CUpdateCallback100Imp;
updater.UpdateCallback = updater.UpdateCallbackSpec; updater.UpdateCallback = updater.UpdateCallbackSpec;
UString title = LangLoadStringW(IDS_COPYING, 0x03020205); UString title = LangString(IDS_COPYING, 0x03020205);
UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
updater.UpdateCallbackSpec->ProgressDialog.MainWindow = GetParent(); updater.UpdateCallbackSpec->ProgressDialog.MainWindow = GetParent();
updater.UpdateCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle; updater.UpdateCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
@@ -176,8 +176,8 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP
void CPanel::CopyFrom(const UStringVector &filePaths) void CPanel::CopyFrom(const UStringVector &filePaths)
{ {
UString title = LangLoadStringW(IDS_CONFIRM_FILE_COPY, 0x03020222); UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222);
UString message = LangLoadStringW(IDS_WANT_TO_COPY_FILES, 0x03020223); UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223);
message += L"\n\'"; message += L"\n\'";
message += _currentFolderPrefix; message += _currentFolderPrefix;
message += L"\' ?"; message += L"\' ?";

View File

@@ -2,21 +2,26 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "Common/StringConvert.h"
#include "Windows/Memory.h" #include "Windows/Memory.h"
#include "Windows/FileDir.h" #include "Windows/FileDir.h"
#include "Windows/Shell.h" #include "Windows/Shell.h"
#include "Common/StringConvert.h"
#include "../UI/Common/ArchiveName.h" #include "../UI/Common/ArchiveName.h"
#include "../UI/Common/CompressCall.h" #include "../UI/Common/CompressCall.h"
#include "Resource/MessagesDialog/MessagesDialog.h" #include "Resource/MessagesDialog/MessagesDialog.h"
using namespace NWindows;
#include "App.h" #include "App.h"
#include "EnumFormatEtc.h" #include "EnumFormatEtc.h"
using namespace NWindows;
#ifndef _UNICODE
extern bool g_IsNT;
#endif
static wchar_t *kTempDirPrefix = L"7zE"; static wchar_t *kTempDirPrefix = L"7zE";
static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder"); static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
@@ -212,39 +217,73 @@ STDMETHODIMP CDropSource::GiveFeedback(DWORD effect)
return DRAGDROP_S_USEDEFAULTCURSORS; 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; 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))) #ifndef _UNICODE
return false; if (!g_IsNT)
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++)
{ {
const CSysString &s = names[i]; AStringVector namesA;
int fullLength = s.Length() + 1; int i;
lstrcpy(p, s); for (i = 0; i < names.Size(); i++)
p += fullLength; namesA.Add(GetSystemString(names[i]));
totalLength -= fullLength; 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; return true;
} }
@@ -278,9 +317,9 @@ void CPanel::OnDrag(LPNMLISTVIEW nmListView)
CMyComPtr<IDataObject> dataObject = dataObjectSpec; CMyComPtr<IDataObject> dataObject = dataObjectSpec;
{ {
CSysStringVector names; UStringVector names;
for (int i = 0; i < indices.Size(); i++) 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)) if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names))
return; return;
} }
@@ -686,15 +725,12 @@ void CPanel::DropObject(IDataObject *dataObject, const UString &folderPath)
/* /*
void CPanel::CompressDropFiles(HDROP dr) void CPanel::CompressDropFiles(HDROP dr)
{ {
CSysStringVector fileNames; UStringVector fileNames;
{ {
NShell::CDrop drop(true); NShell::CDrop drop(true);
drop.Attach(dr); drop.Attach(dr);
drop.QueryFileNames(fileNames); drop.QueryFileNames(fileNames);
} }
UStringVector fileNamesUnicode;
for (int i = 0; i < fileNames.Size(); i++)
fileNamesUnicode.Add(GetUnicodeString(fileNames[i]));
CompressDropFiles(fileNamesUnicode); CompressDropFiles(fileNamesUnicode);
} }
*/ */

View File

@@ -141,12 +141,12 @@ void CPanel::LoadFullPathAndShow()
_appState->FolderHistory.AddString(_currentFolderPrefix); _appState->FolderHistory.AddString(_currentFolderPrefix);
// _headerComboBox.SendMessage(CB_RESETCONTENT, 0, 0); // _headerComboBox.SendMessage(CB_RESETCONTENT, 0, 0);
_headerComboBox.SetText(GetSystemString(_currentFolderPrefix)); _headerComboBox.SetText(_currentFolderPrefix);
/* /*
for (int i = 0; i < g_Folders.m_Strings.Size(); i++) 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; COMBOBOXEXITEM item;
item.mask = CBEIF_TEXT; item.mask = CBEIF_TEXT;
item.iItem = i; 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) bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
{ {
if (info->iWhy == CBENF_ESCAPE) if (info->iWhy == CBENF_ESCAPE)
{ {
_headerComboBox.SetText(GetSystemString(_currentFolderPrefix)); _headerComboBox.SetText(_currentFolderPrefix);
PostMessage(kSetFocusToListView); PostMessage(kSetFocusToListView);
result = FALSE; result = FALSE;
return true; return true;
@@ -175,7 +205,6 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
{ {
if (BindToPathAndRefresh(GetUnicodeString(info->szText)) != S_OK) if (BindToPathAndRefresh(GetUnicodeString(info->szText)) != S_OK)
{ {
// MessageBeep((UINT)-1);
result = TRUE; result = TRUE;
return true; return true;
} }
@@ -185,24 +214,22 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
} }
return false; return false;
} }
#endif
void CPanel::OnComboBoxCommand(UINT code, LPARAM &param) void CPanel::OnComboBoxCommand(UINT code, LPARAM &param)
{ {
/* /*
if (code == CBN_SELENDOK) if (code == CBN_SELENDOK)
{ {
CSysString path; UString path;
if (!_headerComboBox.GetText(path)) if (!_headerComboBox.GetText(path))
return; return;
CRootFolder *rootFolderSpec = new CRootFolder; CRootFolder *rootFolderSpec = new CRootFolder;
CMyComPtr<IFolderFolder> rootFolder = rootFolderSpec; CMyComPtr<IFolderFolder> rootFolder = rootFolderSpec;
rootFolderSpec->Init(); rootFolderSpec->Init();
CMyComPtr<IFolderFolder> newFolder; CMyComPtr<IFolderFolder> newFolder;
if (rootFolder->BindToFolder(GetUnicodeString(path), if (rootFolder->BindToFolder(path, &newFolder) != S_OK)
&newFolder) != S_OK)
{
return; return;
}
_folder = newFolder; _folder = newFolder;
SetCurrentPathText(); SetCurrentPathText();
RefreshListCtrl(UString(), -1, UStringVector()); RefreshListCtrl(UString(), -1, UStringVector());
@@ -220,10 +247,16 @@ bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result)
_lastFocusedIsList = false; _lastFocusedIsList = false;
_panelCallback->PanelWasFocused(); _panelCallback->PanelWasFocused();
} }
#ifndef _UNICODE
case CBEN_ENDEDIT: case CBEN_ENDEDIT:
{ {
return OnNotifyComboBoxEndEdit((PNMCBEENDEDIT)header, result); return OnNotifyComboBoxEndEdit((PNMCBEENDEDIT)header, result);
} }
#endif
case CBEN_ENDEDITW:
{
return OnNotifyComboBoxEndEdit((PNMCBEENDEDITW)header, result);
}
} }
return false; return false;
} }
@@ -233,28 +266,23 @@ void CPanel::FoldersHistory()
{ {
CListViewDialog listViewDialog; CListViewDialog listViewDialog;
listViewDialog.DeleteIsAllowed = true; listViewDialog.DeleteIsAllowed = true;
// listViewDialog.m_Value = TEXT("*"); listViewDialog.Title = LangString(IDS_FOLDERS_HISTORY, 0x03020260);
listViewDialog.Title = LangLoadStringW(IDS_FOLDERS_HISTORY, 0x03020260); _appState->FolderHistory.GetList(listViewDialog.Strings);
UStringVector strings;
_appState->FolderHistory.GetList(strings);
int i;
for(i = 0; i < strings.Size(); i++)
listViewDialog.Strings.Add(GetSystemString(strings[i]));
if (listViewDialog.Create(GetParent()) == IDCANCEL) if (listViewDialog.Create(GetParent()) == IDCANCEL)
return; return;
UString selectString; UString selectString;
if (listViewDialog.StringsWereChanged) if (listViewDialog.StringsWereChanged)
{ {
_appState->FolderHistory.RemoveAll(); _appState->FolderHistory.RemoveAll();
for (i = listViewDialog.Strings.Size() - 1; i >= 0; i--) for (int i = listViewDialog.Strings.Size() - 1; i >= 0; i--)
_appState->FolderHistory.AddString(GetUnicodeString(listViewDialog.Strings[i])); _appState->FolderHistory.AddString(listViewDialog.Strings[i]);
if (listViewDialog.FocusedItemIndex >= 0) if (listViewDialog.FocusedItemIndex >= 0)
selectString = GetUnicodeString(listViewDialog.Strings[listViewDialog.FocusedItemIndex]); selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
} }
else else
{ {
if (listViewDialog.FocusedItemIndex >= 0) if (listViewDialog.FocusedItemIndex >= 0)
selectString = strings[listViewDialog.FocusedItemIndex]; selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
} }
if (listViewDialog.FocusedItemIndex >= 0) if (listViewDialog.FocusedItemIndex >= 0)
BindToPathAndRefresh(selectString); BindToPathAndRefresh(selectString);
@@ -273,7 +301,7 @@ void CPanel::OpenParentFolder()
pos = 0; pos = 0;
else else
pos++; pos++;
focucedName = GetUnicodeString(string.Mid(pos)); focucedName = string.Mid(pos);
} }
CDisableTimerProcessing disableTimerProcessing1(*this); CDisableTimerProcessing disableTimerProcessing1(*this);
@@ -309,7 +337,7 @@ void CPanel::OpenParentFolder()
selectedItems.Add(focucedName); selectedItems.Add(focucedName);
*/ */
LoadFullPath(); LoadFullPath();
::SetCurrentDirectory(::GetSystemString(_currentFolderPrefix)); // ::SetCurrentDirectory(::_currentFolderPrefix);
RefreshListCtrl(focucedName, -1, true, selectedItems); RefreshListCtrl(focucedName, -1, true, selectedItems);
_listView.EnsureVisible(_listView.GetFocusedItem(), false); _listView.EnsureVisible(_listView.GetFocusedItem(), false);
RefreshStatusBar(); RefreshStatusBar();
@@ -337,13 +365,13 @@ void CPanel::OpenRootFolder()
_parentFolders.Clear(); _parentFolders.Clear();
SetToRootFolder(); SetToRootFolder();
RefreshListCtrl(UString(), -1, true, UStringVector()); RefreshListCtrl(UString(), -1, true, UStringVector());
// ::SetCurrentDirectory(::GetSystemString(_currentFolderPrefix)); // ::SetCurrentDirectory(::_currentFolderPrefix);
/* /*
BeforeChangeFolder(); BeforeChangeFolder();
_currentFolderPrefix.Empty(); _currentFolderPrefix.Empty();
AfterChangeFolder(); AfterChangeFolder();
SetCurrentPathText(); SetCurrentPathText();
RefreshListCtrl(CSysString(), 0, CSysStringVector()); RefreshListCtrl(UString(), 0, UStringVector());
_listView.EnsureVisible(_listView.GetFocusedItem(), false); _listView.EnsureVisible(_listView.GetFocusedItem(), false);
*/ */
} }
@@ -370,7 +398,7 @@ void CPanel::OpenFolder(int index)
return; return;
_folder = newFolder; _folder = newFolder;
LoadFullPath(); LoadFullPath();
::SetCurrentDirectory(::GetSystemString(_currentFolderPrefix)); // ::SetCurrentDirectory(::_currentFolderPrefix);
RefreshListCtrl(); RefreshListCtrl();
UINT state = LVIS_SELECTED; UINT state = LVIS_SELECTED;
_listView.SetItemState(_listView.GetFocusedItem(), state, state); _listView.SetItemState(_listView.GetFocusedItem(), state, state);

View File

@@ -29,9 +29,9 @@ using namespace NFile;
using namespace NDirectory; using namespace NDirectory;
extern HWND g_HWND; extern HWND g_HWND;
#ifndef _UNICODE
static inline UINT GetCurrentFileCodePage() extern bool g_IsNT;
{ return AreFileApisANSI() ? CP_ACP : CP_OEMCP;} #endif
static wchar_t *kTempDirPrefix = L"7zO"; static wchar_t *kTempDirPrefix = L"7zO";
@@ -81,8 +81,7 @@ HRESULT CPanel::OpenItemAsArchive(const UString &name,
// _password.Empty(); // _password.Empty();
NDLL::CLibrary library; NDLL::CLibrary library;
RINOK(OpenFileFolderPlugin(GetUnicodeString(filePath), RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent()));
&library, &newFolder, GetParent()));
folderLink.ParentFolder = _folder; folderLink.ParentFolder = _folder;
folderLink.ItemName = name; folderLink.ItemName = name;
@@ -130,7 +129,7 @@ HRESULT CPanel::OpenParentArchiveFolder()
if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName) != S_OK) if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName) != S_OK)
{ {
::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE, ::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; return S_OK;
} }
} }
@@ -151,69 +150,114 @@ static bool DoItemAlwaysStart(const UString &name)
static HANDLE StartEditApplication(const UString &path, HWND window) static HANDLE StartEditApplication(const UString &path, HWND window)
{ {
CSysString command; UString command;
ReadRegEditor(command); ReadRegEditor(command);
if (command.IsEmpty()) if (command.IsEmpty())
{ {
if (!MyGetWindowsDirectory(command)) if (!MyGetWindowsDirectory(command))
return 0; return 0;
NFile::NName::NormalizeDirPathPrefix(command); NFile::NName::NormalizeDirPathPrefix(command);
command += TEXT("notepad.exe"); command += L"notepad.exe";
} }
command = CSysString(TEXT("\"")) + command + CSysString(TEXT("\"")); command = UString(L"\"") + command + UString(L"\"");
command += TEXT(" \""); command += L" \"";
command += GetSystemString(path); command += UString(path);
command += TEXT("\""); 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; 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); 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) if (result != FALSE)
{ {
::CloseHandle(processInformation.hThread); ::CloseHandle(processInformation.hThread);
return processInformation.hProcess; 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); L"7-Zip", MB_OK | MB_ICONSTOP);
return 0; return 0;
} }
static HANDLE StartApplication(const UString &path, HWND window) static HANDLE StartApplication(const UString &path, HWND window)
{ {
SHELLEXECUTEINFO execInfo; UINT32 result;
execInfo.cbSize = sizeof(execInfo); HANDLE hProcess;
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT; #ifndef _UNICODE
execInfo.hwnd = NULL; if (g_IsNT)
execInfo.lpVerb = NULL; {
const CSysString sysPath = GetSystemString(path); SHELLEXECUTEINFOW execInfo;
execInfo.lpFile = sysPath; execInfo.cbSize = sizeof(execInfo);
execInfo.lpParameters = NULL; execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
execInfo.lpDirectory = NULL; execInfo.hwnd = NULL;
execInfo.nShow = SW_SHOWNORMAL; execInfo.lpVerb = NULL;
execInfo.hProcess = 0; execInfo.lpFile = path;
bool success = BOOLToBool(::ShellExecuteEx(&execInfo)); execInfo.lpParameters = NULL;
UINT32 result = (UINT32)execInfo.hInstApp; 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) if(result <= 32)
{ {
switch(result) switch(result)
{ {
case SE_ERR_NOASSOC: case SE_ERR_NOASSOC:
::MessageBox(window, ::MessageBoxW(window,
NError::MyFormatMessage(::GetLastError()), NError::MyFormatMessageW(::GetLastError()),
// TEXT("There is no application associated with the given file name extension"), // L"There is no application associated with the given file name extension",
TEXT("7-Zip"), MB_OK | MB_ICONSTOP); L"7-Zip", MB_OK | MB_ICONSTOP);
} }
} }
return execInfo.hProcess; return hProcess;
} }
void CPanel::EditItem(int index) void CPanel::EditItem(int index)
@@ -268,7 +312,7 @@ LRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item
CMyComPtr<IFolderOperations> folderOperations; CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) 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; return E_FAIL;
} }
UStringVector fileNames; UStringVector fileNames;
@@ -342,7 +386,7 @@ static DWORD WINAPI MyThreadFunction(void *param)
if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1) if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
{ {
::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE, ::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; return 0;
} }
} }
@@ -365,7 +409,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
CMyComPtr<IFolderOperations> folderOperations; CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) 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; return;
} }
@@ -443,7 +487,7 @@ static bool CheckDeleteItem(UINT64 currentFileTime, UINT64 folderFileTime)
void DeleteOldTempFiles() void DeleteOldTempFiles()
{ {
CSysString tempPath; UString tempPath;
if(!NFile::NDirectory::MyGetTempPath(tempPath)) if(!NFile::NDirectory::MyGetTempPath(tempPath))
throw 1; throw 1;
@@ -452,10 +496,10 @@ void DeleteOldTempFiles()
UINT64 currentFileTime; UINT64 currentFileTime;
if(!::SystemTimeToFileTime(&systemTime, (FILETIME *)&currentFileTime)) if(!::SystemTimeToFileTime(&systemTime, (FILETIME *)&currentFileTime))
throw 2; throw 2;
CSysString searchWildCard = tempPath + kTempDirPrefix + TEXT("*.tmp"); UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
searchWildCard += TCHAR(NName::kAnyStringWildcard); searchWildCard += WCHAR(NName::kAnyStringWildcard);
NFind::CEnumerator enumerator(searchWildCard); NFind::CEnumeratorW enumerator(searchWildCard);
NFind::CFileInfo fileInfo; NFind::CFileInfoW fileInfo;
while(enumerator.Next(fileInfo)) while(enumerator.Next(fileInfo))
{ {
if (!fileInfo.IsDirectory()) if (!fileInfo.IsDirectory())

View File

@@ -186,10 +186,8 @@ void CPanel::InitColumns()
void CPanel::InsertColumn(int index) void CPanel::InsertColumn(int index)
{ {
const CItemProperty &property = _visibleProperties[index]; const CItemProperty &property = _visibleProperties[index];
LV_COLUMN column; LV_COLUMNW column;
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER; column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
TCHAR string[1024];
column.pszText = string;
column.cx = property.Width; column.cx = property.Width;
column.fmt = GetColumnAlign(property.ID, property.Type); column.fmt = GetColumnAlign(property.ID, property.Type);
column.iOrder = property.Order; column.iOrder = property.Order;
@@ -197,7 +195,7 @@ void CPanel::InsertColumn(int index)
UString propertyName = GetNameOfProperty(property.ID); UString propertyName = GetNameOfProperty(property.ID);
if (propertyName.IsEmpty()) if (propertyName.IsEmpty())
propertyName = property.Name; propertyName = property.Name;
lstrcpy(string, GetSystemString(propertyName)); column.pszText = (wchar_t *)(const wchar_t *)propertyName;
_listView.InsertColumn(index, &column); _listView.InsertColumn(index, &column);
} }
@@ -223,8 +221,8 @@ void CPanel::GetSelectedNames(UStringVector &selectedNames)
for (int i = 0; i < _listView.GetItemCount(); i++) for (int i = 0; i < _listView.GetItemCount(); i++)
{ {
const int kSize = 1024; const int kSize = 1024;
TCHAR name[kSize + 1]; WCHAR name[kSize + 1];
LVITEM item; LVITEMW item;
item.iItem = i; item.iItem = i;
item.pszText = name; item.pszText = name;
item.cchTextMax = kSize; item.cchTextMax = kSize;
@@ -236,7 +234,7 @@ void CPanel::GetSelectedNames(UStringVector &selectedNames)
if (realIndex == kParentIndex) if (realIndex == kParentIndex)
continue; continue;
if (_selectedStatusVector[realIndex]) if (_selectedStatusVector[realIndex])
selectedNames.Add(GetUnicodeString(item.pszText)); selectedNames.Add(item.pszText);
} }
*/ */
selectedNames.Sort(); selectedNames.Sort();
@@ -262,15 +260,15 @@ void CPanel::SaveSelectedState(CSelectedState &s)
s.FocusedName = GetItemName(realIndex); s.FocusedName = GetItemName(realIndex);
/* /*
const int kSize = 1024; const int kSize = 1024;
TCHAR name[kSize + 1]; WCHAR name[kSize + 1];
LVITEM item; LVITEMW item;
item.iItem = focusedItem; item.iItem = focusedItem;
item.pszText = name; item.pszText = name;
item.cchTextMax = kSize; item.cchTextMax = kSize;
item.iSubItem = 0; item.iSubItem = 0;
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
if (_listView.GetItem(&item)) 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); _listView.SetRedraw(false);
// m_RedrawEnabled = false; // m_RedrawEnabled = false;
LVITEM item; LVITEMW item;
ZeroMemory(&item, sizeof(item)); ZeroMemory(&item, sizeof(item));
_listView.DeleteAllItems(); _listView.DeleteAllItems();
@@ -373,13 +371,9 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
int subItem = 0; int subItem = 0;
item.iSubItem = subItem++; item.iSubItem = subItem++;
item.lParam = kParentIndex; item.lParam = kParentIndex;
const int kMaxNameSize = MAX_PATH * 2; item.pszText = (wchar_t *)(const wchar_t *)itemName;
TCHAR string[kMaxNameSize];
lstrcpyn(string, GetSystemString(itemName), kMaxNameSize);
item.pszText = string;
UINT32 attributes = FILE_ATTRIBUTE_DIRECTORY; UINT32 attributes = FILE_ATTRIBUTE_DIRECTORY;
item.iImage = _extToIconMap.GetIconIndex(attributes, item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
GetSystemString(itemName));
if (item.iImage < 0) if (item.iImage < 0)
item.iImage = 0; item.iImage = 0;
if(_listView.InsertItem(&item) == -1) if(_listView.InsertItem(&item) == -1)
@@ -413,11 +407,9 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
item.iSubItem = subItem++; item.iSubItem = subItem++;
item.lParam = i; item.lParam = i;
const int kMaxNameSize = MAX_PATH * 2; UString correctedName;
TCHAR string[kMaxNameSize + 1];
if (itemName.Find(L" ") >= 0) if (itemName.Find(L" ") >= 0)
{ {
UString correctedName;
int pos = 0; int pos = 0;
while (true) while (true)
{ {
@@ -432,11 +424,10 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
pos = posNew; pos = posNew;
while (itemName[++pos] == ' '); while (itemName[++pos] == ' ');
} }
lstrcpyn(string, GetSystemString(correctedName), kMaxNameSize); item.pszText = (wchar_t *)(const wchar_t *)correctedName;
} }
else else
lstrcpyn(string, GetSystemString(itemName), kMaxNameSize); item.pszText = (wchar_t *)(const wchar_t *)itemName;
item.pszText = string;
NCOM::CPropVariant propVariant; NCOM::CPropVariant propVariant;
_folder->GetProperty(i, kpidAttributes, &propVariant); _folder->GetProperty(i, kpidAttributes, &propVariant);
@@ -461,13 +452,12 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
if (_currentFolderPrefix.IsEmpty()) if (_currentFolderPrefix.IsEmpty())
{ {
int iconIndexTemp; int iconIndexTemp;
GetRealIconIndex(GetSystemString(itemName + L"\\"), attributes, iconIndexTemp); GetRealIconIndex(itemName + L"\\", attributes, iconIndexTemp);
item.iImage = iconIndexTemp; item.iImage = iconIndexTemp;
} }
else else
{ {
item.iImage = _extToIconMap.GetIconIndex(attributes, item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
GetSystemString(itemName));
} }
} }
if (item.iImage < 0) if (item.iImage < 0)
@@ -585,7 +575,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
GetOperatedItemIndices(indices); GetOperatedItemIndices(indices);
if (indices.Size() > 20) if (indices.Size() > 20)
{ {
MessageBox(LangLoadStringW(IDS_TOO_MANY_ITEMS, 0x02000606)); MessageBox(LangString(IDS_TOO_MANY_ITEMS, 0x02000606));
return; return;
} }
@@ -667,7 +657,7 @@ void CPanel::ReadListViewInfo()
return; return;
CMyComBSTR typeID; CMyComBSTR typeID;
folderGetTypeID->GetTypeID(&typeID); folderGetTypeID->GetTypeID(&typeID);
_typeIDString = GetSystemString((const wchar_t *)typeID); _typeIDString = typeID;
::ReadListViewInfo(_typeIDString, _listViewInfo); ::ReadListViewInfo(_typeIDString, _listViewInfo);
} }

View File

@@ -8,7 +8,7 @@
#include "../PropID.h" #include "../PropID.h"
#include "App.h" #include "App.h"
// static LPCTSTR kHelpTopic = _T("FM/index.htm"); // static LPCWSTR kHelpTopic = L"FM/index.htm";
struct CVKeyPropIDPair struct CVKeyPropIDPair
{ {

View File

@@ -41,7 +41,7 @@ static UString ConvertSizeToString(UINT64 value)
return UString(s) + L" G"; return UString(s) + L" G";
} }
LRESULT CPanel::SetItemText(LVITEM &item) LRESULT CPanel::SetItemText(LVITEMW &item)
{ {
UINT32 realIndex = GetRealIndex(item); UINT32 realIndex = GetRealIndex(item);
/* /*
@@ -84,7 +84,7 @@ LRESULT CPanel::SetItemText(LVITEM &item)
if (realIndex == kParentIndex) if (realIndex == kParentIndex)
return 0; return 0;
UString string; UString s;
UINT32 subItemIndex = item.iSubItem; UINT32 subItemIndex = item.iSubItem;
PROPID propID = _visibleProperties[subItemIndex].ID; PROPID propID = _visibleProperties[subItemIndex].ID;
/* /*
@@ -120,6 +120,7 @@ LRESULT CPanel::SetItemText(LVITEM &item)
} }
if (needRead) if (needRead)
*/ */
if (_folder->GetProperty(realIndex, propID, &propVariant) != S_OK) if (_folder->GetProperty(realIndex, propID, &propVariant) != S_OK)
throw 2723407; throw 2723407;
@@ -128,20 +129,16 @@ LRESULT CPanel::SetItemText(LVITEM &item)
propID == kpidClusterSize) propID == kpidClusterSize)
&& &&
(propVariant.vt == VT_UI8 || propVariant.vt == VT_UI4)) (propVariant.vt == VT_UI8 || propVariant.vt == VT_UI4))
{ s = ConvertSizeToString(ConvertPropVariantToUInt64(propVariant));
string = ConvertSizeToString(ConvertPropVariantToUInt64(propVariant));
}
else else
{ s = ConvertPropertyToString(propVariant, propID, false);
string = ConvertPropertyToString(propVariant, propID, false);
}
int size = item.cchTextMax; int size = item.cchTextMax;
if(size > 0) if(size > 0)
{ {
if(string.Length() + 1 > size) if(s.Length() + 1 > size)
string = string.Left(size - 1); s = s.Left(size - 1);
lstrcpy(item.pszText, GetSystemString(string)); wcscpy(item.pszText, s);
} }
return 0; 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? //is the sub-item information being requested?
@@ -268,11 +265,11 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
OnLeftClick((LPNMITEMACTIVATE)header); OnLeftClick((LPNMITEMACTIVATE)header);
return false; return false;
} }
case LVN_BEGINLABELEDIT: case LVN_BEGINLABELEDITW:
result = OnBeginLabelEdit((LV_DISPINFO *)header); result = OnBeginLabelEdit((LV_DISPINFOW *)header);
return true; return true;
case LVN_ENDLABELEDIT: case LVN_ENDLABELEDITW:
result = OnEndLabelEdit((LV_DISPINFO *)header); result = OnEndLabelEdit((LV_DISPINFOW *)header);
return true; return true;
case NM_CUSTOMDRAW: case NM_CUSTOMDRAW:
@@ -354,8 +351,7 @@ void CPanel::OnRefreshStatusBar()
CRecordVector<UINT32> indices; CRecordVector<UINT32> indices;
GetOperatedItemIndices(indices); GetOperatedItemIndices(indices);
_statusBar.SetText(0, GetSystemString(MyFormatNew(IDS_N_SELECTED_ITEMS, _statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, 0x02000301, NumberToString(indices.Size())));
0x02000301, NumberToStringW(indices.Size()))));
UString selectSizeString; UString selectSizeString;
@@ -366,12 +362,11 @@ void CPanel::OnRefreshStatusBar()
totalSize += GetItemSize(indices[i]); totalSize += GetItemSize(indices[i]);
selectSizeString = ConvertSizeToString(totalSize); selectSizeString = ConvertSizeToString(totalSize);
} }
_statusBar.SetText(1, GetSystemString(selectSizeString)); _statusBar.SetText(1, selectSizeString);
int focusedItem = _listView.GetFocusedItem(); int focusedItem = _listView.GetFocusedItem();
UString sizeString; UString sizeString;
UString dateString; UString dateString;
// CSysString nameString;
if (focusedItem >= 0 && _listView.GetSelectedCount() > 0) if (focusedItem >= 0 && _listView.GetSelectedCount() > 0)
{ {
int realIndex = GetRealItemIndex(focusedItem); int realIndex = GetRealItemIndex(focusedItem);
@@ -382,16 +377,9 @@ void CPanel::OnRefreshStatusBar()
if (_folder->GetProperty(realIndex, kpidLastWriteTime, &propVariant) == S_OK) if (_folder->GetProperty(realIndex, kpidLastWriteTime, &propVariant) == S_OK)
dateString = ConvertPropertyToString(propVariant, kpidLastWriteTime, false); dateString = ConvertPropertyToString(propVariant, kpidLastWriteTime, false);
} }
// nameString = GetSystemString(GetItemName(realIndex));
} }
_statusBar.SetText(2, GetSystemString(sizeString)); _statusBar.SetText(2, sizeString);
_statusBar.SetText(3, GetSystemString(dateString)); _statusBar.SetText(3, dateString);
// _statusBar.SetText(4, nameString); // _statusBar.SetText(4, nameString);
// _statusBar2.SetText(1, MyFormatNew(L"{0} bytes", NumberToStringW(totalSize)));
/*
_statusBar2.SetText(1, GetSystemString(MyFormatNew(L"{0} bytes",
NumberToStringW(totalSize))));
*/
// _statusBar.SetText(L"yyy"));
} }

View File

@@ -198,17 +198,17 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, Flags); systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, Flags);
MENUITEMINFO menuItem; {
menuItem.cbSize = sizeof(menuItem); CMenu menu;
menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID; menu.Attach(menuSpec);
menuItem.fType = MFT_STRING; CMenuItem menuItem;
menuItem.hSubMenu = popupMenu.Detach(); menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
// menuDestroyer.Disable(); menuItem.fType = MFT_STRING;
CSysString popupMenuCaption = LangLoadString(IDS_SYSTEM, 0x030202A0); menuItem.hSubMenu = popupMenu.Detach();
menuItem.dwTypeData = (LPTSTR)(LPCTSTR)popupMenuCaption; // menuDestroyer.Disable();
menuItem.StringValue = LangString(IDS_SYSTEM, 0x030202A0);
InsertMenuItem(menuSpec, 0, TRUE, &menuItem); menu.InsertItem(0, true, menuItem);
}
/* /*
if (Cmd < 100 && Cmd != 0) if (Cmd < 100 && Cmd != 0)
{ {
@@ -302,7 +302,7 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
CreateSystemMenu(menu, operatedIndices, systemContextMenu); CreateSystemMenu(menu, operatedIndices, systemContextMenu);
if (menu.GetItemCount() > 0) if (menu.GetItemCount() > 0)
menu.AppendItem(MF_SEPARATOR, 0, 0); menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0);
LoadFileMenu(menu, menu.GetItemCount(), !operatedIndices.IsEmpty(), programMenu); LoadFileMenu(menu, menu.GetItemCount(), !operatedIndices.IsEmpty(), programMenu);
} }

View File

@@ -24,6 +24,10 @@
using namespace NWindows; using namespace NWindows;
using namespace NFile; using namespace NFile;
#ifndef _UNICODE
extern bool g_IsNT;
#endif
struct CThreadDelete struct CThreadDelete
{ {
CMyComPtr<IFolderOperations> FolderOperations; CMyComPtr<IFolderOperations> FolderOperations;
@@ -58,37 +62,68 @@ void CPanel::DeleteItems(bool toRecycleBin)
SaveSelectedState(state); SaveSelectedState(state);
if (IsFSFolder()) if (IsFSFolder())
{ {
CDynamicBuffer<TCHAR> buffer; #ifndef _UNICODE
size_t size = 0; if (!g_IsNT)
for (int i = 0; i < indices.Size(); i++)
{ {
const CSysString path = GetSystemString(GetFsPath() + GetItemName(indices[i])); CDynamicBuffer<CHAR> buffer;
buffer.EnsureCapacity(size + path.Length() + 1); size_t size = 0;
memmove(((TCHAR *)buffer) + size, (const TCHAR *)path, (path.Length() + 1) * sizeof(TCHAR)); for (int i = 0; i < indices.Size(); i++)
size += path.Length() + 1; {
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) 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; CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) 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; return;
} }
@@ -114,20 +149,20 @@ void CPanel::DeleteItems(bool toRecycleBin)
const UString itemName = GetItemName(index); const UString itemName = GetItemName(index);
if (IsItemFolder(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); message = MyFormatNew(IDS_WANT_TO_DELETE_FOLDER, 0x03020214, itemName);
} }
else else
{ {
title = LangLoadStringW(IDS_CONFIRM_FILE_DELETE, 0x03020210); title = LangString(IDS_CONFIRM_FILE_DELETE, 0x03020210);
message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName); message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName);
} }
} }
else else
{ {
title = LangLoadStringW(IDS_CONFIRM_ITEMS_DELETE, 0x03020212); title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215, message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215,
NumberToStringW(indices.Size())); NumberToString(indices.Size()));
} }
if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK) if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK)
return; return;
@@ -137,10 +172,10 @@ void CPanel::DeleteItems(bool toRecycleBin)
deleter.UpdateCallback = deleter.UpdateCallbackSpec; deleter.UpdateCallback = deleter.UpdateCallbackSpec;
deleter.UpdateCallbackSpec->Init(GetParent(), false, L""); 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.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.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
deleter.FolderOperations = folderOperations; deleter.FolderOperations = folderOperations;
@@ -153,13 +188,13 @@ void CPanel::DeleteItems(bool toRecycleBin)
HRESULT result = deleter.Result; HRESULT result = deleter.Result;
if (result != S_OK) if (result != S_OK)
MessageBoxError(result, LangLoadStringW(IDS_ERROR_DELETING, 0x03020217)); MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
} }
RefreshListCtrl(state); RefreshListCtrl(state);
} }
BOOL CPanel::OnBeginLabelEdit(LV_DISPINFO * lpnmh) BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
{ {
int realIndex = GetRealIndex(lpnmh->item); int realIndex = GetRealIndex(lpnmh->item);
if (realIndex == kParentIndex) if (realIndex == kParentIndex)
@@ -170,7 +205,7 @@ BOOL CPanel::OnBeginLabelEdit(LV_DISPINFO * lpnmh)
return FALSE; return FALSE;
} }
BOOL CPanel::OnEndLabelEdit(LV_DISPINFO * lpnmh) BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
{ {
if (lpnmh->item.pszText == NULL) if (lpnmh->item.pszText == NULL)
return FALSE; return FALSE;
@@ -180,7 +215,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFO * lpnmh)
MessageBoxMyError(L"Renaming is not supported"); MessageBoxMyError(L"Renaming is not supported");
return FALSE; return FALSE;
} }
UString newName = GetUnicodeString(lpnmh->item.pszText); UString newName = lpnmh->item.pszText;
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
int realIndex = GetRealIndex(lpnmh->item); int realIndex = GetRealIndex(lpnmh->item);
@@ -189,7 +224,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFO * lpnmh)
HRESULT result = folderOperations->Rename(realIndex, newName, 0); HRESULT result = folderOperations->Rename(realIndex, newName, 0);
if (result != S_OK) if (result != S_OK)
{ {
MessageBoxError(result, LangLoadStringW(IDS_ERROR_RENAMING, 0x03020221)); MessageBoxError(result, LangString(IDS_ERROR_RENAMING, 0x03020221));
return FALSE; return FALSE;
} }
// Can't use RefreshListCtrl here. // Can't use RefreshListCtrl here.
@@ -209,26 +244,26 @@ void CPanel::CreateFolder()
CMyComPtr<IFolderOperations> folderOperations; CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) 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; return;
} }
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
CSelectedState state; CSelectedState state;
SaveSelectedState(state); SaveSelectedState(state);
CComboDialog comboDialog; CComboDialog comboDialog;
comboDialog.Title = LangLoadStringW(IDS_CREATE_FOLDER, 0x03020230); comboDialog.Title = LangString(IDS_CREATE_FOLDER, 0x03020230);
comboDialog.Static = LangLoadStringW(IDS_CREATE_FOLDER_NAME, 0x03020231); comboDialog.Static = LangString(IDS_CREATE_FOLDER_NAME, 0x03020231);
comboDialog.Value = LangLoadStringW(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1); comboDialog.Value = LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
if (comboDialog.Create(GetParent()) == IDCANCEL) if (comboDialog.Create(GetParent()) == IDCANCEL)
return; return;
UString newName = GetUnicodeString(comboDialog.Value); UString newName = comboDialog.Value;
HRESULT result = folderOperations->CreateFolder(newName, 0); HRESULT result = folderOperations->CreateFolder(newName, 0);
if (result != S_OK) if (result != S_OK)
{ {
MessageBoxError(result, LangLoadStringW(IDS_CREATE_FOLDER_ERROR, 0x03020233)); MessageBoxError(result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
return; return;
} }
int pos = newName.Find(TEXT('\\')); int pos = newName.Find(L'\\');
if (pos >= 0) if (pos >= 0)
newName = newName.Left(pos); newName = newName.Left(pos);
if (!_mySelectMode) if (!_mySelectMode)
@@ -243,26 +278,26 @@ void CPanel::CreateFile()
CMyComPtr<IFolderOperations> folderOperations; CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) 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; return;
} }
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
CSelectedState state; CSelectedState state;
SaveSelectedState(state); SaveSelectedState(state);
CComboDialog comboDialog; CComboDialog comboDialog;
comboDialog.Title = LangLoadStringW(IDS_CREATE_FILE, 0x03020240); comboDialog.Title = LangString(IDS_CREATE_FILE, 0x03020240);
comboDialog.Static = LangLoadStringW(IDS_CREATE_FILE_NAME, 0x03020241); comboDialog.Static = LangString(IDS_CREATE_FILE_NAME, 0x03020241);
comboDialog.Value = LangLoadStringW(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1); comboDialog.Value = LangString(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
if (comboDialog.Create(GetParent()) == IDCANCEL) if (comboDialog.Create(GetParent()) == IDCANCEL)
return; return;
UString newName = GetUnicodeString(comboDialog.Value); UString newName = comboDialog.Value;
HRESULT result = folderOperations->CreateFile(newName, 0); HRESULT result = folderOperations->CreateFile(newName, 0);
if (result != S_OK) if (result != S_OK)
{ {
MessageBoxError(result, LangLoadStringW(IDS_CREATE_FILE_ERROR, 0x03020243)); MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243));
return; return;
} }
int pos = newName.Find(TEXT('\\')); int pos = newName.Find(L'\\');
if (pos >= 0) if (pos >= 0)
newName = newName.Left(pos); newName = newName.Left(pos);
if (!_mySelectMode) if (!_mySelectMode)
@@ -293,7 +328,7 @@ void CPanel::ChangeComment()
CMyComPtr<IFolderOperations> folderOperations; CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) 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; return;
} }
@@ -309,12 +344,12 @@ void CPanel::ChangeComment()
} }
UString name = GetItemName(realIndex); UString name = GetItemName(realIndex);
CComboDialog comboDialog; CComboDialog comboDialog;
comboDialog.Title = name + L" " + LangLoadStringW(IDS_COMMENT, 0x03020290); comboDialog.Title = name + L" " + LangString(IDS_COMMENT, 0x03020290);
comboDialog.Value = comment; comboDialog.Value = comment;
comboDialog.Static = LangLoadStringW(IDS_COMMENT2, 0x03020291); comboDialog.Static = LangString(IDS_COMMENT2, 0x03020291);
if (comboDialog.Create(GetParent()) == IDCANCEL) if (comboDialog.Create(GetParent()) == IDCANCEL)
return; return;
NCOM::CPropVariant propVariant = GetUnicodeString(comboDialog.Value); NCOM::CPropVariant propVariant = comboDialog.Value;
HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL); HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);
if (result != S_OK) if (result != S_OK)

View File

@@ -152,9 +152,9 @@ void CPanel::SelectSpec(bool selectMode)
{ {
CComboDialog comboDialog; CComboDialog comboDialog;
comboDialog.Title = selectMode ? comboDialog.Title = selectMode ?
LangLoadStringW(IDS_SELECT, 0x03020250): LangString(IDS_SELECT, 0x03020250):
LangLoadStringW(IDS_DESELECT, 0x03020251); LangString(IDS_DESELECT, 0x03020251);
comboDialog.Static = LangLoadStringW(IDS_SELECT_MASK, 0x03020252); comboDialog.Static = LangString(IDS_SELECT_MASK, 0x03020252);
comboDialog.Value = L"*"; comboDialog.Value = L"*";
if (comboDialog.Create(GetParent()) == IDCANCEL) if (comboDialog.Create(GetParent()) == IDCANCEL)
return; return;

View File

@@ -31,10 +31,10 @@ public:
{ {
if (_data != 0) if (_data != 0)
return false; return false;
_data = BigAlloc(size); _data = ::MidAlloc(size);
return _data != 0; return _data != 0;
} }
~CMyBuffer() { BigFree(_data); } ~CMyBuffer() { ::MidFree(_data); }
}; };
struct CVolSeqName struct CVolSeqName
@@ -184,7 +184,7 @@ void CApp::Split()
CPanel &srcPanel = Panels[srcPanelIndex]; CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder()) if (!srcPanel.IsFSFolder())
{ {
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return; return;
} }
CRecordVector<UInt32> indices; CRecordVector<UInt32> indices;
@@ -223,8 +223,8 @@ void CApp::Split()
CProgressDialog progressDialog; CProgressDialog progressDialog;
spliter.ProgressDialog = &progressDialog; spliter.ProgressDialog = &progressDialog;
UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
UString title = LangLoadStringW(IDS_SPLITTING, 0x03020510); UString title = LangString(IDS_SPLITTING, 0x03020510);
progressDialog.MainWindow = _window; progressDialog.MainWindow = _window;
progressDialog.MainTitle = progressWindowTitle; progressDialog.MainTitle = progressWindowTitle;
@@ -392,7 +392,7 @@ void CApp::Combine()
CPanel &srcPanel = Panels[srcPanelIndex]; CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder()) if (!srcPanel.IsFSFolder())
{ {
srcPanel.MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return; return;
} }
CRecordVector<UInt32> indices; CRecordVector<UInt32> indices;
@@ -421,11 +421,11 @@ void CApp::Combine()
path = destPanel._currentFolderPrefix; path = destPanel._currentFolderPrefix;
CCopyDialog copyDialog; CCopyDialog copyDialog;
copyDialog.Value = path; copyDialog.Value = path;
copyDialog.Title = LangLoadStringW(IDS_COMBINE, 0x03020600); copyDialog.Title = LangString(IDS_COMBINE, 0x03020600);
copyDialog.Title += ' '; copyDialog.Title += ' ';
copyDialog.Title += itemName; copyDialog.Title += itemName;
copyDialog.Static = LangLoadStringW(IDS_COMBINE_TO, 0x03020601);; copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601);;
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL) if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
return; return;
@@ -435,8 +435,8 @@ void CApp::Combine()
CProgressDialog progressDialog; CProgressDialog progressDialog;
combiner.ProgressDialog = &progressDialog; combiner.ProgressDialog = &progressDialog;
UString progressWindowTitle = LangLoadStringW(IDS_APP_TITLE, 0x03000000); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
UString title = LangLoadStringW(IDS_COMBINING, 0x03020610); UString title = LangString(IDS_COMBINING, 0x03020610);
progressDialog.MainWindow = _window; progressDialog.MainWindow = _window;
progressDialog.MainTitle = progressWindowTitle; progressDialog.MainTitle = progressWindowTitle;

View 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;
}

View 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

View File

@@ -21,7 +21,7 @@ public:
return GetLastError(); return GetLastError();
return createObject(&clsID, &IID_IFolderManager, (void **)manager); 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)) if (!Load(filePath))
return GetLastError(); return GetLastError();

View File

@@ -69,5 +69,5 @@ UString GetNameOfProperty(PROPID propID)
if (index < 0) if (index < 0)
return UString(); return UString();
const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index]; const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index];
return LangLoadStringW(pair.ResourceID, pair.LangID); return LangString(pair.ResourceID, pair.LangID);
} }

View File

@@ -25,21 +25,24 @@ static NSynchronization::CCriticalSection g_CriticalSection;
static const TCHAR *kCUKeyPath = TEXT("Software\\7-ZIP\\FM"); static const TCHAR *kCUKeyPath = TEXT("Software\\7-ZIP\\FM");
static const TCHAR *kAssociations = TEXT("Associations"); 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 const TCHAR *kExtEnabled = TEXT("Enabled");
static CSysString GetAssociationsPath()
{
return CSysString(kCUKeyPath) + CSysString('\\') + CSysString(kAssociations);
}
bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo) bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo)
{ {
NSynchronization::CCriticalSectionLock lock(g_CriticalSection); NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CKey key; CKey key;
if(key.Open(HKEY_CURRENT_USER, CSysString(kCUKeyPath) if(key.Open(HKEY_CURRENT_USER, GetAssociationsPath() + CSysString('\\') +
+ CSysString('\\') + CSysString(kAssociations) CSysString(GetSystemString(ext)), KEY_READ) != ERROR_SUCCESS)
+ CSysString('\\') + CSysString(GetSystemString(ext)),
KEY_READ) != ERROR_SUCCESS)
return false; return false;
CSysString pluginsString; UString pluginsString;
key.QueryValue(kExtPlugins, pluginsString); key.QueryValue(kExtPlugins, pluginsString);
SplitString(GetUnicodeString(pluginsString), extInfo.Plugins); SplitString(pluginsString, extInfo.Plugins);
return true; return true;
} }
@@ -48,8 +51,7 @@ void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
items.Clear(); items.Clear();
NSynchronization::CCriticalSectionLock lock(g_CriticalSection); NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CKey associationsKey; CKey associationsKey;
if(associationsKey.Open(HKEY_CURRENT_USER, CSysString(kCUKeyPath) if(associationsKey.Open(HKEY_CURRENT_USER, GetAssociationsPath(), KEY_READ) != ERROR_SUCCESS)
+ CSysString('\\') + CSysString(kAssociations), KEY_READ) != ERROR_SUCCESS)
return; return;
CSysStringVector extNames; CSysStringVector extNames;
associationsKey.EnumKeys(extNames); associationsKey.EnumKeys(extNames);
@@ -62,9 +64,9 @@ void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
CKey key; CKey key;
if(key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS) if(key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS)
return; return;
CSysString pluginsString; UString pluginsString;
key.QueryValue(kExtPlugins, pluginsString); key.QueryValue(kExtPlugins, pluginsString);
SplitString(GetUnicodeString(pluginsString), extInfo.Plugins); SplitString(pluginsString, extInfo.Plugins);
/* /*
if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS) if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS)
extInfo.Enabled = false; extInfo.Enabled = false;
@@ -86,7 +88,7 @@ void WriteInternalAssociations(const CObjectVector<CExtInfo> &items)
const CExtInfo &extInfo = items[i]; const CExtInfo &extInfo = items[i];
CKey key; CKey key;
key.Create(associationsKey, GetSystemString(extInfo.Ext)); key.Create(associationsKey, GetSystemString(extInfo.Ext));
key.SetValue(kExtPlugins, GetSystemString(JoinStrings(extInfo.Plugins))); key.SetValue(kExtPlugins, JoinStrings(extInfo.Plugins));
// key.SetValue(kExtEnabled, extInfo.Enabled); // key.SetValue(kExtEnabled, extInfo.Enabled);
} }
} }
@@ -160,9 +162,9 @@ void DeleteShellExtensionInfo(const CSysString &extension)
} }
void AddShellExtensionInfo(const CSysString &extension, void AddShellExtensionInfo(const CSysString &extension,
const CSysString &programTitle, const UString &programTitle,
const CSysString &programOpenCommand, const UString &programOpenCommand,
const CSysString &iconPath, const UString &iconPath,
const void *shellNewData, int shellNewDataSize) const void *shellNewData, int shellNewDataSize)
{ {
DeleteShellExtensionKey(extension); DeleteShellExtensionKey(extension);
@@ -200,18 +202,7 @@ void AddShellExtensionInfo(const CSysString &extension,
CKey commandKey; CKey commandKey;
commandKey.Create(openKey, kCommandKeyName); commandKey.Create(openKey, kCommandKeyName);
CSysString params; commandKey.SetValue(NULL, programOpenCommand);
/*
if (!NSystem::MyGetWindowsDirectory(aParams))
{
aParams.Empty();
// return;
}
else
NFile::NName::NormalizeDirPathPrefix(aParams);
*/
// aParams += kOpenCommandValue;
HRESULT result = commandKey.SetValue(NULL, programOpenCommand);
} }
/////////////////////////// ///////////////////////////

View File

@@ -24,9 +24,9 @@ namespace NRegistryAssociations {
void DeleteShellExtensionInfo(const CSysString &extension); void DeleteShellExtensionInfo(const CSysString &extension);
void AddShellExtensionInfo(const CSysString &extension, void AddShellExtensionInfo(const CSysString &extension,
const CSysString &programTitle, const UString &programTitle,
const CSysString &programOpenCommand, const UString &programOpenCommand,
const CSysString &iconPath, const UString &iconPath,
const void *shellNewData, int shellNewDataSize); const void *shellNewData, int shellNewDataSize);

View File

@@ -92,40 +92,22 @@ static bool ReadPluginInfo(CPluginInfo &pluginInfo)
return true; return true;
} }
CSysString GetProgramFolderPrefix(); UString 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
void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins) void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
{ {
plugins.Clear(); 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; CPluginInfo pluginInfo;
pluginInfo.FilePath = path; pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll";
if (::ReadPluginInfo(pluginInfo)) if (::ReadPluginInfo(pluginInfo))
plugins.Add(pluginInfo); plugins.Add(pluginInfo);
} }
CSysString folderPath = baseFolderPrefix + TEXT("Plugins\\"); UString folderPath = baseFolderPrefix + L"Plugins\\";
NFind::CEnumerator enumerator(folderPath + TEXT("*")); NFind::CEnumeratorW enumerator(folderPath + L"*");
NFind::CFileInfo fileInfo; NFind::CFileInfoW fileInfo;
while (enumerator.Next(fileInfo)) while (enumerator.Next(fileInfo))
{ {
if (fileInfo.IsDirectory()) if (fileInfo.IsDirectory())

View File

@@ -13,7 +13,7 @@ enum EPluginType
struct CPluginInfo struct CPluginInfo
{ {
CSysString FilePath; UString FilePath;
EPluginType Type; EPluginType Type;
UString Name; UString Name;
CLSID ClassID; CLSID ClassID;

View File

@@ -10,9 +10,10 @@ using namespace NRegistry;
static const TCHAR *kCUBasePath = TEXT("Software\\7-ZIP"); static const TCHAR *kCUBasePath = TEXT("Software\\7-ZIP");
static const TCHAR *kCU_FMPath = TEXT("Software\\7-ZIP\\FM"); 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 WCHAR *kLangValueName = L"Lang";
static const TCHAR *kEditor = TEXT("Editor"); static const WCHAR *kEditor = L"Editor";
static const TCHAR *kShowDots = TEXT("ShowDots"); static const TCHAR *kShowDots = TEXT("ShowDots");
static const TCHAR *kShowRealFileIcons = TEXT("ShowRealFileIcons"); static const TCHAR *kShowRealFileIcons = TEXT("ShowRealFileIcons");
static const TCHAR *kShowSystemMenu = TEXT("ShowSystemMenu"); 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 *kFullRow = TEXT("FullRow");
static const TCHAR *kShowGrid = TEXT("ShowGrid"); static const TCHAR *kShowGrid = TEXT("ShowGrid");
static const TCHAR *kAlternativeSelection = TEXT("AlternativeSelection"); 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 *kSingleClick = TEXT("SingleClick");
// static const TCHAR *kUnderline = TEXT("Underline"); // static const TCHAR *kUnderline = TEXT("Underline");
void SaveRegLang(const CSysString &langFile) void SaveRegLang(const UString &langFile)
{ {
CKey cuKey; CKey key;
cuKey.Create(HKEY_CURRENT_USER, kCUBasePath); key.Create(HKEY_CURRENT_USER, kCUBasePath);
cuKey.SetValue(kLangValueName, langFile); key.SetValue(kLangValueName, langFile);
} }
void ReadRegLang(CSysString &langFile) void ReadRegLang(UString &langFile)
{ {
langFile.Empty(); langFile.Empty();
CKey cuKey; CKey key;
cuKey.Create(HKEY_CURRENT_USER, kCUBasePath); if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
cuKey.QueryValue(kLangValueName, langFile); key.QueryValue(kLangValueName, langFile);
} }
void SaveRegEditor(const CSysString &editorPath) void SaveRegEditor(const UString &editorPath)
{ {
CKey cuKey; CKey key;
cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath); key.Create(HKEY_CURRENT_USER, kCU_FMPath);
cuKey.SetValue(kEditor, editorPath); key.SetValue(kEditor, editorPath);
} }
void ReadRegEditor(CSysString &editorPath) void ReadRegEditor(UString &editorPath)
{ {
editorPath.Empty(); editorPath.Empty();
CKey cuKey; CKey key;
cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath); if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
cuKey.QueryValue(kEditor, editorPath); key.QueryValue(kEditor, editorPath);
/* }
if (editorPath.IsEmpty())
editorPath = TEXT("notepad.exe"); 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) static void SaveOption(const TCHAR *value, bool enabled)
{ {
CKey cuKey; CKey key;
cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath); key.Create(HKEY_CURRENT_USER, kCU_FMPath);
cuKey.SetValue(value, enabled); 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) static bool ReadOption(const TCHAR *value, bool defaultValue)
{ {
CKey cuKey; CKey key;
cuKey.Create(HKEY_CURRENT_USER, kCU_FMPath); if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
bool enabled; {
if (cuKey.QueryValue(value, enabled) != ERROR_SUCCESS) bool enabled;
return defaultValue; if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
return enabled; 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); } void SaveShowDots(bool showDots) { SaveOption(kShowDots, showDots); }
@@ -98,4 +137,12 @@ bool ReadSingleClick(){ return ReadOption(kSingleClick, false); }
void SaveUnderline(bool enable) { SaveOption(kUnderline, enable); } void SaveUnderline(bool enable) { SaveOption(kUnderline, enable); }
bool ReadUnderline(){ return ReadOption(kUnderline, false); } 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); }

View File

@@ -5,11 +5,11 @@
#ifndef __REGISTRYUTILS_H #ifndef __REGISTRYUTILS_H
#define __REGISTRYUTILS_H #define __REGISTRYUTILS_H
void SaveRegLang(const CSysString &langFile); void SaveRegLang(const UString &langFile);
void ReadRegLang(CSysString &langFile); void ReadRegLang(UString &langFile);
void SaveRegEditor(const CSysString &langFile); void SaveRegEditor(const UString &editorPath);
void ReadRegEditor(CSysString &langFile); void ReadRegEditor(UString &editorPath);
void SaveShowDots(bool showDots); void SaveShowDots(bool showDots);
bool ReadShowDots(); bool ReadShowDots();
@@ -29,6 +29,12 @@ bool ReadShowGrid();
void SaveAlternativeSelection(bool enable); void SaveAlternativeSelection(bool enable);
bool ReadAlternativeSelection(); bool ReadAlternativeSelection();
// void SaveLockMemoryAdd(bool enable);
// bool ReadLockMemoryAdd();
bool ReadLockMemoryEnable();
void SaveLockMemoryEnable(bool enable);
/* /*
void SaveSingleClick(bool enable); void SaveSingleClick(bool enable);
bool ReadSingleClick(); bool ReadSingleClick();

View File

@@ -12,8 +12,7 @@ public:
virtual bool OnInit(); virtual bool OnInit();
virtual void OnHelp(); virtual void OnHelp();
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
INT_PTR Create(HWND aWndParent = 0) INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_ABOUT, wndParent); }
{ return CModalDialog::Create(MAKEINTRESOURCE(IDD_ABOUT), aWndParent); }
}; };
#endif #endif

View File

@@ -5,6 +5,7 @@
#include "Common/IntToString.h" #include "Common/IntToString.h"
#include "Common/StringToInt.h" #include "Common/StringToInt.h"
#include "Common/Exception.h" #include "Common/Exception.h"
#include "Common/Alloc.h"
#include "Windows/Thread.h" #include "Windows/Thread.h"
#include "Windows/PropVariant.h" #include "Windows/PropVariant.h"
#include "Windows/Error.h" #include "Windows/Error.h"
@@ -140,15 +141,22 @@ public:
UInt32 BufferSize; UInt32 BufferSize;
Byte *Buffer; Byte *Buffer;
CBenchRandomGenerator(): Buffer(0) {} CBenchRandomGenerator(): Buffer(0) {}
~CBenchRandomGenerator() { delete []Buffer; } ~CBenchRandomGenerator() { Free(); }
void Init() { RG.Init(); } void Free()
void Set(UInt32 bufferSize) {
{ ::MidFree(Buffer);
delete []Buffer;
Buffer = 0; 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; Pos = 0;
BufferSize = bufferSize; BufferSize = bufferSize;
return (Buffer != 0);
} }
UInt32 GetRndBit() { return RG.GetRnd(1); } UInt32 GetRndBit() { return RG.GetRnd(1); }
/* /*
@@ -525,15 +533,29 @@ public:
UInt32 Pos; UInt32 Pos;
Byte *Buffer; Byte *Buffer;
CBenchmarkOutStream(): Buffer(0) {} CBenchmarkOutStream(): Buffer(0) {}
~CBenchmarkOutStream() { delete []Buffer; } ~CBenchmarkOutStream() { Free(); }
void Init(UInt32 bufferSize) void Free()
{ {
delete []Buffer; ::MidFree(Buffer);
Buffer = 0; 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 MY_UNKNOWN_IMP
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
}; };
@@ -691,7 +713,9 @@ DWORD CThreadBenchmark::Process()
writeCoderProperties->WriteCoderProperties(propStream); writeCoderProperties->WriteCoderProperties(propStream);
} }
randomGenerator.Set(kBufferSize); if (!randomGenerator.Alloc(kBufferSize))
return E_OUTOFMEMORY;
randomGenerator.Generate(); randomGenerator.Generate();
CCRC crc; CCRC crc;
@@ -705,11 +729,22 @@ DWORD CThreadBenchmark::Process()
} }
CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream; CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
inStreamSpec->Init(randomGenerator.Buffer, randomGenerator.BufferSize);
CMyComPtr<ISequentialInStream> inStream = inStreamSpec; CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
CBenchmarkOutStream *outStreamSpec = new CBenchmarkOutStream; CBenchmarkOutStream *outStreamSpec = new CBenchmarkOutStream;
outStreamSpec->Init(kCompressedBufferSize);
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec; 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; _approvedStart = dictionarySize;
_startTime = ::GetTimeCount(); _startTime = ::GetTimeCount();
HRESULT result = Encoder->Code(inStream, outStream, 0, 0, this); HRESULT result = Encoder->Code(inStream, outStream, 0, 0, this);

View File

@@ -128,11 +128,7 @@ public:
CProgressSyncInfo _syncInfo; CProgressSyncInfo _syncInfo;
CBenchmarkDialog(): _timer(0) {} CBenchmarkDialog(): _timer(0) {}
INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
INT_PTR Create(HWND wndParent = 0)
{
return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_BENCHMARK), wndParent);
}
}; };
void Benchmark(HWND hwnd); void Benchmark(HWND hwnd);

View File

@@ -17,10 +17,9 @@ public:
UString Title; UString Title;
UString Static; UString Static;
UString Value; UString Value;
CSysStringVector Strings; UStringVector Strings;
// CComboDialog(): Sorted(false) {}; // CComboDialog(): Sorted(false) {};
INT_PTR Create(HWND parentWindow = 0) INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COMBO, parentWindow); }
{ return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_COMBO), parentWindow); }
}; };
#endif #endif

View File

@@ -35,7 +35,7 @@ bool CCopyDialog::OnInit()
staticContol.Attach(GetItem(IDC_COPY_STATIC)); staticContol.Attach(GetItem(IDC_COPY_STATIC));
staticContol.SetText(Static); staticContol.SetText(Static);
for(int i = 0; i < Strings.Size(); i++) for(int i = 0; i < Strings.Size(); i++)
_path.AddString(GetSystemString(Strings[i])); _path.AddString(Strings[i]);
_path.SetText(Value); _path.SetText(Value);
return CModalDialog::OnInit(); return CModalDialog::OnInit();
} }
@@ -53,19 +53,19 @@ bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
void CCopyDialog::OnButtonSetPath() void CCopyDialog::OnButtonSetPath()
{ {
CSysString currentPath; UString currentPath;
_path.GetText(currentPath); _path.GetText(currentPath);
/* /*
#ifdef LANG #ifdef LANG
CSysString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881); UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
#else #else
CSysString title = MyLoadString(IDS_EXTRACT_SET_FOLDER); UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
#endif #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)) if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
return; return;
NFile::NName::NormalizeDirPathPrefix(resultPath); NFile::NName::NormalizeDirPathPrefix(resultPath);

View File

@@ -20,8 +20,7 @@ public:
UString Value; UString Value;
UStringVector Strings; UStringVector Strings;
INT_PTR Create(HWND parentWindow = 0) INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); }
{ return CModalDialog::Create(MAKEINTRESOURCE(IDD_DIALOG_COPY), parentWindow); }
}; };
#endif #endif

View File

@@ -7,6 +7,7 @@
#include "Common/StringConvert.h" #include "Common/StringConvert.h"
#include "Windows/Defs.h" #include "Windows/Defs.h"
#include "Windows/CommonDialog.h"
// #include "Windows/FileFind.h" // #include "Windows/FileFind.h"
// #include "Windows/FileDir.h" // #include "Windows/FileDir.h"
@@ -29,7 +30,7 @@ bool CEditPage::OnInit()
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
_editorEdit.Attach(GetItem(IDC_EDIT_EDIT_EDITOR)); _editorEdit.Attach(GetItem(IDC_EDIT_EDIT_EDITOR));
CSysString editorPath; UString editorPath;
ReadRegEditor(editorPath); ReadRegEditor(editorPath);
_editorEdit.SetText(editorPath); _editorEdit.SetText(editorPath);
return CPropertyPage::OnInit(); return CPropertyPage::OnInit();
@@ -40,7 +41,7 @@ LONG CEditPage::OnApply()
// int selectedIndex = _langCombo.GetCurSel(); // int selectedIndex = _langCombo.GetCurSel();
// int pathIndex = _langCombo.GetItemData(selectedIndex); // int pathIndex = _langCombo.GetItemData(selectedIndex);
// ReloadLang(); // ReloadLang();
CSysString editorPath; UString editorPath;
_editorEdit.GetText(editorPath); _editorEdit.GetText(editorPath);
SaveRegEditor(editorPath); SaveRegEditor(editorPath);
return PSNRET_NOERROR; return PSNRET_NOERROR;
@@ -66,85 +67,14 @@ bool CEditPage::OnButtonClicked(int aButtonID, HWND aButtonHWND)
return CPropertyPage::OnButtonClicked(aButtonID, 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() void CEditPage::OnSetEditorButton()
{ {
OPENFILENAME info; UString editorPath;
info.lStructSize = sizeof(info);
info.hwndOwner = HWND(*this);
info.hInstance = 0;
const int kBufferSize = MAX_PATH * 2;
TCHAR buffer[kBufferSize + 1];
CSysString editorPath;
_editorEdit.GetText(editorPath); _editorEdit.GetText(editorPath);
UString resPath;
lstrcpy(buffer, editorPath); if(!MyGetOpenFileName(HWND(*this), 0, editorPath, L"*.exe", resPath))
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))
return; return;
_editorEdit.SetText(buffer); _editorEdit.SetText(resPath);
// Changed(); // Changed();
} }

View File

@@ -26,13 +26,13 @@ bool CLangPage::OnInit()
_langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG)); _langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG));
CSysString s = NWindows::MyLoadString(IDS_LANG_ENGLISH); UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH);
s += TEXT(" ("); s += L" (";
s += NWindows::MyLoadString(IDS_LANG_NATIVE); s += NWindows::MyLoadStringW(IDS_LANG_NATIVE);
s += TEXT(")"); s += L")";
int index = _langCombo.AddString(s); int index = _langCombo.AddString(s);
_langCombo.SetItemData(index, _paths.Size()); _langCombo.SetItemData(index, _paths.Size());
_paths.Add(TEXT("-")); _paths.Add(L"-");
_langCombo.SetCurSel(0); _langCombo.SetCurSel(0);
CObjectVector<CLangEx> langs; CObjectVector<CLangEx> langs;
@@ -55,10 +55,10 @@ bool CLangPage::OnInit()
name += L")"; name += L")";
} }
} }
index = _langCombo.AddString(GetSystemString(name)); index = _langCombo.AddString(name);
_langCombo.SetItemData(index, _paths.Size()); _langCombo.SetItemData(index, _paths.Size());
_paths.Add(GetSystemString(lang.ShortName)); _paths.Add(lang.ShortName);
if (g_LangID.CompareNoCase(GetSystemString(lang.ShortName)) == 0) if (g_LangID.CompareNoCase(lang.ShortName) == 0)
_langCombo.SetCurSel(index); _langCombo.SetCurSel(index);
} }
return CPropertyPage::OnInit(); return CPropertyPage::OnInit();

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