4.60 beta

This commit is contained in:
Igor Pavlov
2008-08-19 00:00:00 +00:00
committed by Kornel Lesiński
parent 173c07e166
commit c10e6b16f6
107 changed files with 490 additions and 503 deletions

View File

@@ -1,5 +1,5 @@
/* 7zExtract.c -- Extracting from 7z archive /* 7zExtract.c -- Extracting from 7z archive
2008-08-05 2008-08-17
Igor Pavlov Igor Pavlov
Copyright (c) 1999-2008 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov
Read 7zExtract.h for license options */ Read 7zExtract.h for license options */
@@ -79,7 +79,7 @@ SRes SzAr_Extract(
UInt32 i; UInt32 i;
CSzFileItem *fileItem = p->db.Files + fileIndex; CSzFileItem *fileItem = p->db.Files + fileIndex;
*offset = 0; *offset = 0;
for(i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++)
*offset += (UInt32)p->db.Files[i].Size; *offset += (UInt32)p->db.Files[i].Size;
*outSizeProcessed = (size_t)fileItem->Size; *outSizeProcessed = (size_t)fileItem->Size;
if (*offset + *outSizeProcessed > *outBufferSize) if (*offset + *outSizeProcessed > *outBufferSize)

View File

@@ -1,5 +1,5 @@
/* 7zIn.c -- 7z Input functions /* 7zIn.c -- 7z Input functions
2008-08-05 2008-08-17
Igor Pavlov Igor Pavlov
Copyright (c) 1999-2008 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov
Read 7zIn.h for license options */ Read 7zIn.h for license options */
@@ -8,7 +8,7 @@ Read 7zIn.h for license options */
#include "7zDecode.h" #include "7zDecode.h"
#include "../../7zCrc.h" #include "../../7zCrc.h"
#define RINOM(x) { if((x) == 0) return SZ_ERROR_MEM; } #define RINOM(x) { if ((x) == 0) return SZ_ERROR_MEM; }
void SzArEx_Init(CSzArEx *p) void SzArEx_Init(CSzArEx *p)
{ {
@@ -847,7 +847,7 @@ static SRes SzReadFileNames(CSzData *sd, UInt32 numFiles, CSzFileItem *files, IS
UInt32 len = 0; UInt32 len = 0;
UInt32 pos = 0; UInt32 pos = 0;
CSzFileItem *file = files + i; CSzFileItem *file = files + i;
while(pos + 2 <= sd->Size) while (pos + 2 <= sd->Size)
{ {
int numAdds; int numAdds;
UInt32 value = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8)); UInt32 value = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8));
@@ -879,7 +879,7 @@ static SRes SzReadFileNames(CSzData *sd, UInt32 numFiles, CSzFileItem *files, IS
MY_ALLOC(char, file->Name, (size_t)len, alloc); MY_ALLOC(char, file->Name, (size_t)len, alloc);
len = 0; len = 0;
while(2 <= sd->Size) while (2 <= sd->Size)
{ {
int numAdds; int numAdds;
UInt32 value = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8)); UInt32 value = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8));
@@ -906,7 +906,7 @@ static SRes SzReadFileNames(CSzData *sd, UInt32 numFiles, CSzFileItem *files, IS
numAdds--; numAdds--;
file->Name[len++] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F)); file->Name[len++] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F));
} }
while(numAdds > 0); while (numAdds > 0);
len += numAdds; len += numAdds;
} }
@@ -1041,7 +1041,7 @@ static SRes SzReadHeader2(
file->HasStream = 1; file->HasStream = 1;
else else
file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1); file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1);
if(file->HasStream) if (file->HasStream)
{ {
file->IsDir = 0; file->IsDir = 0;
file->Size = (*unpackSizes)[sizeIndex]; file->Size = (*unpackSizes)[sizeIndex];

View File

@@ -1,5 +1,5 @@
/* 7zMain.c - Test application for 7z Decoder /* 7zMain.c - Test application for 7z Decoder
2008-08-05 2008-08-17
Igor Pavlov Igor Pavlov
Public domain */ Public domain */
@@ -40,7 +40,7 @@ void ConvertNumberToString(CFileSize value, char *s)
while (value != 0); while (value != 0);
do do
*s++ = temp[--pos]; *s++ = temp[--pos];
while(pos > 0); while (pos > 0);
*s = '\0'; *s = '\0';
} }

View File

@@ -1,5 +1,5 @@
/* Bcj2.c -- Converter for x86 code (BCJ2) /* Bcj2.c -- Converter for x86 code (BCJ2)
2008-08-05 2008-08-17
Copyright (c) 1999-2008 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov
Read Bra.h for license options */ Read Bra.h for license options */
@@ -24,7 +24,7 @@ Read Bra.h for license options */
#define RC_READ_BYTE (*buffer++) #define RC_READ_BYTE (*buffer++)
#define RC_TEST { if (buffer == bufferLim) return SZ_ERROR_DATA; } #define RC_TEST { if (buffer == bufferLim) return SZ_ERROR_DATA; }
#define RC_INIT2 code = 0; range = 0xFFFFFFFF; \ #define RC_INIT2 code = 0; range = 0xFFFFFFFF; \
{ int i; for(i = 0; i < 5; i++) { RC_TEST; code = (code << 8) | RC_READ_BYTE; }} { int i; for (i = 0; i < 5; i++) { RC_TEST; code = (code << 8) | RC_READ_BYTE; }}
#define NORMALIZE if (range < kTopValue) { RC_TEST; range <<= 8; code = (code << 8) | RC_READ_BYTE; } #define NORMALIZE if (range < kTopValue) { RC_TEST; range <<= 8; code = (code << 8) | RC_READ_BYTE; }

View File

@@ -1,5 +1,5 @@
/* Bra.h -- Branch converters for executables /* Bra.h -- Branch converters for executables
2008-08-05 2008-08-17
Copyright (c) 1999-2008 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov
Read LzmaDec.h for license options */ Read LzmaDec.h for license options */
@@ -41,7 +41,7 @@ in CALL instructions to increase the compression ratio.
Example: Example:
UInt32 ip = 0; UInt32 ip = 0;
for() for ()
{ {
// size must be >= Alignment + LookAhead, if it's not last block // size must be >= Alignment + LookAhead, if it's not last block
SizeT processed = Convert(data, size, ip, 1); SizeT processed = Convert(data, size, ip, 1);

View File

@@ -1,5 +1,5 @@
/* Bra86.c -- converter for x86 code (BCJ) /* Bra86.c -- converter for x86 code (BCJ)
2008-03-19 2008-08-17
Copyright (c) 1999-2008 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov
Read Bra.h for license options */ Read Bra.h for license options */
@@ -19,7 +19,7 @@ SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding
ip += 5; ip += 5;
prevPosT = (SizeT)0 - 1; prevPosT = (SizeT)0 - 1;
for(;;) for (;;)
{ {
Byte *p = data + bufferPos; Byte *p = data + bufferPos;
Byte *limit = data + size - 4; Byte *limit = data + size - 4;

View File

@@ -1,5 +1,5 @@
/* BwtSort.c -- BWT block sorting /* BwtSort.c -- BWT block sorting
2008-08-05 2008-08-17
Igor Pavlov Igor Pavlov
Public domain */ Public domain */
@@ -225,7 +225,7 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group
break; break;
} }
} }
while(++i < j); while (++i < j);
if (i == 0) if (i == 0)
{ {
range = range - (mid - left); range = range - (mid - left);
@@ -438,7 +438,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
i++; i++;
continue; continue;
} }
for(groupSize = 1; for (groupSize = 1;
(Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0; (Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0;
groupSize++); groupSize++);

View File

@@ -1,5 +1,5 @@
/* LzFind.c -- Match finder for LZ algorithms /* LzFind.c -- Match finder for LZ algorithms
2008-08-05 2008-08-17
Copyright (c) 1999-2008 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov
Read LzFind.h for license options */ Read LzFind.h for license options */
@@ -263,7 +263,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
void MatchFinder_Init(CMatchFinder *p) void MatchFinder_Init(CMatchFinder *p)
{ {
UInt32 i; UInt32 i;
for(i = 0; i < p->hashSizeSum; i++) for (i = 0; i < p->hashSizeSum; i++)
p->hash[i] = kEmptyHashValue; p->hash[i] = kEmptyHashValue;
p->cyclicBufferPos = 0; p->cyclicBufferPos = 0;
p->buffer = p->bufferBase; p->buffer = p->bufferBase;
@@ -327,7 +327,7 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,
if (pb[maxLen] == cur[maxLen] && *pb == *cur) if (pb[maxLen] == cur[maxLen] && *pb == *cur)
{ {
UInt32 len = 0; UInt32 len = 0;
while(++len != lenLimit) while (++len != lenLimit)
if (pb[len] != cur[len]) if (pb[len] != cur[len])
break; break;
if (maxLen < len) if (maxLen < len)
@@ -364,7 +364,7 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
if (pb[len] == cur[len]) if (pb[len] == cur[len])
{ {
if (++len != lenLimit && pb[len] == cur[len]) if (++len != lenLimit && pb[len] == cur[len])
while(++len != lenLimit) while (++len != lenLimit)
if (pb[len] != cur[len]) if (pb[len] != cur[len])
break; break;
if (maxLen < len) if (maxLen < len)
@@ -417,7 +417,7 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
UInt32 len = (len0 < len1 ? len0 : len1); UInt32 len = (len0 < len1 ? len0 : len1);
if (pb[len] == cur[len]) if (pb[len] == cur[len])
{ {
while(++len != lenLimit) while (++len != lenLimit)
if (pb[len] != cur[len]) if (pb[len] != cur[len])
break; break;
{ {

View File

@@ -1,5 +1,5 @@
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms /* LzFindMt.c -- multithreaded Match finder for LZ algorithms
2008-08-05 2008-08-17
Copyright (c) 1999-2008 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov
Read LzFind.h for license options */ Read LzFind.h for license options */
@@ -97,7 +97,7 @@ void MtSync_Destruct(CMtSync *p)
p->wasCreated = False; p->wasCreated = False;
} }
#define RINOK_THREAD(x) { if((x) != 0) return SZ_ERROR_THREAD; } #define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }
static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks) static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
{ {
@@ -262,7 +262,7 @@ Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CL
if (pb[len] == cur[len]) if (pb[len] == cur[len])
{ {
if (++len != lenLimit && pb[len] == cur[len]) if (++len != lenLimit && pb[len] == cur[len])
while(++len != lenLimit) while (++len != lenLimit)
if (pb[len] != cur[len]) if (pb[len] != cur[len])
break; break;
if (maxLen < len) if (maxLen < len)
@@ -715,7 +715,7 @@ UInt32 MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *distances)
#define SKIP_HEADER2 do { GET_NEXT_BLOCK_IF_REQUIRED #define SKIP_HEADER2 do { GET_NEXT_BLOCK_IF_REQUIRED
#define SKIP_HEADER(n) SKIP_HEADER2 if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash; #define SKIP_HEADER(n) SKIP_HEADER2 if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash;
#define SKIP_FOOTER } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while(--num != 0); #define SKIP_FOOTER } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while (--num != 0);
void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num) void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num)
{ {

View File

@@ -1,5 +1,5 @@
/* LzmaDec.c -- LZMA Decoder /* LzmaDec.c -- LZMA Decoder
2008-08-05 2008-08-17
Copyright (c) 1999-2008 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov
Read LzmaDec.h for license options */ Read LzmaDec.h for license options */
@@ -56,7 +56,7 @@ Read LzmaDec.h for license options */
{ UPDATE_1_CHECK; i = (i + i) + 1; A1; } { UPDATE_1_CHECK; i = (i + i) + 1; A1; }
#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) #define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)
#define TREE_DECODE_CHECK(probs, limit, i) \ #define TREE_DECODE_CHECK(probs, limit, i) \
{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while(i < limit); i -= limit; } { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
#define kNumPosBitsMax 4 #define kNumPosBitsMax 4
@@ -328,7 +328,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
GET_BIT2(prob + i, i, ; , distance |= mask); GET_BIT2(prob + i, i, ; , distance |= mask);
mask <<= 1; mask <<= 1;
} }
while(--numDirectBits != 0); while (--numDirectBits != 0);
} }
} }
else else
@@ -679,7 +679,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
{ {
GET_BIT_CHECK(prob + i, i); GET_BIT_CHECK(prob + i, i);
} }
while(--numDirectBits != 0); while (--numDirectBits != 0);
} }
} }
} }

View File

@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder /* LzmaEnc.c -- LZMA Encoder
2008-08-13 2008-08-17
Copyright (c) 1999-2008 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov
Read LzmaEnc.h for license options */ Read LzmaEnc.h for license options */
@@ -1966,7 +1966,7 @@ void LzmaEnc_Init(CLzmaEnc *p)
{ {
UInt32 i; UInt32 i;
p->state = 0; p->state = 0;
for(i = 0 ; i < LZMA_NUM_REPS; i++) for (i = 0 ; i < LZMA_NUM_REPS; i++)
p->reps[i] = 0; p->reps[i] = 0;
RangeEnc_Init(&p->rc); RangeEnc_Init(&p->rc);
@@ -2002,7 +2002,7 @@ void LzmaEnc_Init(CLzmaEnc *p)
} }
} }
{ {
for(i = 0; i < kNumFullDistances - kEndPosModelIndex; i++) for (i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
p->posEncoders[i] = kProbInitValue; p->posEncoders[i] = kProbInitValue;
} }

View File

@@ -1,5 +1,5 @@
/* Sort.c -- Sort functions /* Sort.c -- Sort functions
2008-03-13 2008-08-17
Igor Pavlov Igor Pavlov
Public domain */ Public domain */
@@ -27,7 +27,7 @@ void HeapSort(UInt32 *p, UInt32 size)
UInt32 k = i; UInt32 k = i;
HeapSortDown(p, k, size, temp) HeapSortDown(p, k, size, temp)
} }
while(--i != 0); while (--i != 0);
} }
/* /*
do do
@@ -82,7 +82,7 @@ void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size)
UInt32 temp = p[i]; UInt32 temp = p[i];
HeapSortRefDown(p, vals, i, size, temp); HeapSortRefDown(p, vals, i, size, temp);
} }
while(--i != 0); while (--i != 0);
} }
do do
{ {

View File

@@ -264,7 +264,7 @@ HRESULT CDecoder::Decode(
RINOK(getTextPassword->CryptoGetTextPassword(&passwordBSTR)); RINOK(getTextPassword->CryptoGetTextPassword(&passwordBSTR));
CByteBuffer buffer; CByteBuffer buffer;
passwordIsDefined = true; passwordIsDefined = true;
UString password = passwordBSTR; const UString password(passwordBSTR);
const UInt32 sizeInBytes = password.Length() * 2; const UInt32 sizeInBytes = password.Length() * 2;
buffer.SetCapacity(sizeInBytes); buffer.SetCapacity(sizeInBytes);
for (int i = 0; i < password.Length(); i++) for (int i = 0; i < password.Length(); i++)

View File

@@ -1,4 +1,4 @@
4// ElfHandler.cpp // ElfHandler.cpp
#include "StdAfx.h" #include "StdAfx.h"

View File

@@ -130,7 +130,7 @@ void CDebugEntry::Parse(const Byte *p)
Pa = Get32(p + 24); Pa = Get32(p + 24);
} }
static const kNumDirItemsMax = 16; static const UInt32 kNumDirItemsMax = 16;
struct COptHeader struct COptHeader
{ {

View File

@@ -68,7 +68,7 @@ STATPROPSTG kArcProps[] =
{ {
{ NULL, kpidSolid, VT_BOOL}, { NULL, kpidSolid, VT_BOOL},
{ NULL, kpidNumBlocks, VT_UI4}, { NULL, kpidNumBlocks, VT_UI4},
{ NULL, kpidEncrypted, VT_BOOL}, // { NULL, kpidEncrypted, VT_BOOL},
{ NULL, kpidIsVolume, VT_BOOL}, { NULL, kpidIsVolume, VT_BOOL},
{ NULL, kpidNumVolumes, VT_UI4}, { NULL, kpidNumVolumes, VT_UI4},
{ NULL, kpidPhySize, VT_UI8} { NULL, kpidPhySize, VT_UI8}
@@ -94,7 +94,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
switch(propID) switch(propID)
{ {
case kpidSolid: prop = _archiveInfo.IsSolid(); break; case kpidSolid: prop = _archiveInfo.IsSolid(); break;
case kpidEncrypted: prop = _archiveInfo.IsEncrypted(); break; // case kpidEncrypted: prop = _archiveInfo.IsEncrypted(); break; // it's for encrypted names.
case kpidIsVolume: prop = _archiveInfo.IsVolume(); break; case kpidIsVolume: prop = _archiveInfo.IsVolume(); break;
case kpidNumVolumes: prop = (UInt32)_archives.Size(); break; case kpidNumVolumes: prop = (UInt32)_archives.Size(); break;
case kpidOffset: if (_archiveInfo.StartPosition != 0) prop = _archiveInfo.StartPosition; break; case kpidOffset: if (_archiveInfo.StartPosition != 0) prop = _archiveInfo.StartPosition; break;

View File

@@ -236,25 +236,40 @@ STDMETHODIMP CUdfInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
const CFile &file = _archive->Files[ref.FileIndex]; const CFile &file = _archive->Files[ref.FileIndex];
const CItem &item = _archive->Items[file.ItemIndex]; const CItem &item = _archive->Items[file.ItemIndex];
const CMyExtent &extent = item.Extents[_extentIndex]; HRESULT res = S_OK;
UInt32 rem = extent.GetLen() - _offsetInExtent; if (item.IsInline)
if (rem == 0)
{ {
_extentIndex++; size_t rem = item.InlineData.GetCapacity() - _offsetInExtent;
_offsetInExtent = 0; if (rem == 0)
continue; return S_OK;
if (rem > _rem)
rem = (size_t)_rem;
memcpy(data, (const Byte *)item.InlineData + _offsetInExtent, rem);
} }
if (size > rem) else
size = rem; {
if (_extentIndex >= item.Extents.Size())
int partitionIndex = vol.PartitionMaps[extent.PartitionRef].PartitionIndex; return S_OK;
UInt32 logBlockNumber = extent.Pos; const CMyExtent &extent = item.Extents[_extentIndex];
const CPartition &partition = _archive->Partitions[partitionIndex]; UInt32 rem = extent.GetLen() - _offsetInExtent;
UInt64 offset = ((UInt64)partition.Pos << _archive->SecLogSize) + if (rem == 0)
{
_extentIndex++;
_offsetInExtent = 0;
continue;
}
if (size > rem)
size = rem;
int partitionIndex = vol.PartitionMaps[extent.PartitionRef].PartitionIndex;
UInt32 logBlockNumber = extent.Pos;
const CPartition &partition = _archive->Partitions[partitionIndex];
UInt64 offset = ((UInt64)partition.Pos << _archive->SecLogSize) +
(UInt64)logBlockNumber * vol.BlockSize + _offsetInExtent; (UInt64)logBlockNumber * vol.BlockSize + _offsetInExtent;
RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL)); RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL));
HRESULT res = _stream->Read(data, size, &size); res = _stream->Read(data, size, &size);
}
_offsetInExtent += size; _offsetInExtent += size;
_rem -= size; _rem -= size;
if (processedSize) if (processedSize)

View File

@@ -26,6 +26,7 @@ const int kNumFilesMax = 1 << 28;
const int kNumRefsMax = 1 << 28; const int kNumRefsMax = 1 << 28;
const UInt32 kNumExtentsMax = (UInt32)1 << 30; const UInt32 kNumExtentsMax = (UInt32)1 << 30;
const UInt64 kFileNameLengthTotalMax = (UInt64)1 << 33; const UInt64 kFileNameLengthTotalMax = (UInt64)1 << 33;
const UInt64 kInlineExtentsSizeMax = (UInt64)1 << 33;
void MY_FAST_CALL Crc16GenerateTable(void); void MY_FAST_CALL Crc16GenerateTable(void);
@@ -275,6 +276,11 @@ HRESULT CInArchive::ReadFromFile(int volIndex, const CItem &item, CByteBuffer &b
{ {
if (item.Size >= (UInt32)1 << 30) if (item.Size >= (UInt32)1 << 30)
return S_FALSE; return S_FALSE;
if (item.IsInline)
{
buf = item.InlineData;
return S_OK;
}
buf.SetCapacity((size_t)item.Size); buf.SetCapacity((size_t)item.Size);
size_t pos = 0; size_t pos = 0;
for (int i = 0; i < item.Extents.Size(); i++) for (int i = 0; i < item.Extents.Size(); i++)
@@ -448,37 +454,46 @@ HRESULT CInArchive::ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &la
pos += extendedAttrLen; pos += extendedAttrLen;
int desctType = item.IcbTag.GetDescriptorType(); int desctType = item.IcbTag.GetDescriptorType();
// if (desctType == ICB_DESC_TYPE_INLINE || desctType == ICB_DESC_TYPE_EXTENDED)
if (desctType != ICB_DESC_TYPE_SHORT && desctType != ICB_DESC_TYPE_LONG)
return S_FALSE;
if (allocDescriptorsLen > size - pos) if (allocDescriptorsLen > size - pos)
return S_FALSE; return S_FALSE;
for (UInt32 i = 0; i < allocDescriptorsLen;) if (desctType == ICB_DESC_TYPE_INLINE)
{ {
CMyExtent e; item.IsInline = true;
if (desctType == ICB_DESC_TYPE_SHORT) item.InlineData.SetCapacity(allocDescriptorsLen);
memcpy(item.InlineData, p + pos, allocDescriptorsLen);
}
else
{
item.IsInline = false;
if (desctType != ICB_DESC_TYPE_SHORT && desctType != ICB_DESC_TYPE_LONG)
return S_FALSE;
for (UInt32 i = 0; i < allocDescriptorsLen;)
{ {
if (i + 8 > allocDescriptorsLen) CMyExtent e;
return S_FALSE; if (desctType == ICB_DESC_TYPE_SHORT)
CShortAllocDesc sad; {
sad.Parse(p + pos + i); if (i + 8 > allocDescriptorsLen)
e.Pos = sad.Pos; return S_FALSE;
e.Len = sad.Len; CShortAllocDesc sad;
e.PartitionRef = lad.Location.PartitionRef; sad.Parse(p + pos + i);
i += 8; e.Pos = sad.Pos;
e.Len = sad.Len;
e.PartitionRef = lad.Location.PartitionRef;
i += 8;
}
else
{
if (i + 16 > allocDescriptorsLen)
return S_FALSE;
CLongAllocDesc ladNew;
ladNew.Parse(p + pos + i);
e.Pos = ladNew.Location.Pos;
e.PartitionRef = ladNew.Location.PartitionRef;
e.Len = ladNew.Len;
i += 16;
}
item.Extents.Add(e);
} }
else
{
if (i + 16 > allocDescriptorsLen)
return S_FALSE;
CLongAllocDesc ladNew;
ladNew.Parse(p + pos + i);
e.Pos = ladNew.Location.Pos;
e.PartitionRef = ladNew.Location.PartitionRef;
e.Len = ladNew.Len;
i += 16;
}
item.Extents.Add(e);
} }
if (item.IcbTag.IsDir()) if (item.IcbTag.IsDir())
@@ -489,6 +504,7 @@ HRESULT CInArchive::ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &la
RINOK(ReadFromFile(volIndex, item, buf)); RINOK(ReadFromFile(volIndex, item, buf));
item.Size = 0; item.Size = 0;
item.Extents.ClearAndFree(); item.Extents.ClearAndFree();
item.InlineData.Free();
const Byte *p = buf; const Byte *p = buf;
size = buf.GetCapacity(); size = buf.GetCapacity();
@@ -524,6 +540,10 @@ HRESULT CInArchive::ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &la
if ((UInt32)item.Extents.Size() > kNumExtentsMax - _numExtents) if ((UInt32)item.Extents.Size() > kNumExtentsMax - _numExtents)
return S_FALSE; return S_FALSE;
_numExtents += item.Extents.Size(); _numExtents += item.Extents.Size();
if (item.InlineData.GetCapacity() > kInlineExtentsSizeMax - _inlineExtentsSize)
return S_FALSE;
_inlineExtentsSize += item.InlineData.GetCapacity();
} }
return S_OK; return S_OK;
@@ -769,6 +789,7 @@ void CInArchive::Clear()
_fileNameLengthTotal = 0; _fileNameLengthTotal = 0;
_numRefs = 0; _numRefs = 0;
_numExtents = 0; _numExtents = 0;
_inlineExtentsSize = 0;
_processedProgressBytes = 0; _processedProgressBytes = 0;
} }

View File

@@ -167,6 +167,8 @@ struct CPartitionMap
int PartitionIndex; int PartitionIndex;
}; };
// ECMA 4/14.6
enum EIcbFileType enum EIcbFileType
{ {
ICB_FILE_TYPE_DIR = 4, ICB_FILE_TYPE_DIR = 4,
@@ -243,6 +245,8 @@ struct CItem
// CRegId ImplId; // CRegId ImplId;
// UInt64 UniqueId; // UInt64 UniqueId;
bool IsInline;
CByteBuffer InlineData;
CRecordVector<CMyExtent> Extents; CRecordVector<CMyExtent> Extents;
CRecordVector<int> SubFiles; CRecordVector<int> SubFiles;
@@ -258,6 +262,8 @@ struct CItem
UInt64 GetChunksSumSize() const UInt64 GetChunksSumSize() const
{ {
if (IsInline)
return InlineData.GetCapacity();
UInt64 size = 0; UInt64 size = 0;
for (int i = 0; i < Extents.Size(); i++) for (int i = 0; i < Extents.Size(); i++)
size += Extents[i].GetLen(); size += Extents[i].GetLen();
@@ -343,6 +349,7 @@ class CInArchive
UInt64 _fileNameLengthTotal; UInt64 _fileNameLengthTotal;
int _numRefs; int _numRefs;
UInt32 _numExtents; UInt32 _numExtents;
UInt64 _inlineExtentsSize;
bool CheckExtent(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len) const; bool CheckExtent(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len) const;
public: public:
HRESULT Open(IInStream *inStream, CProgressVirt *progress); HRESULT Open(IInStream *inStream, CProgressVirt *progress);

View File

@@ -740,8 +740,8 @@ void CEcd64::Parse(const Byte *p)
cdStartOffset = Get64(p + 36); cdStartOffset = Get64(p + 36);
} }
#define COPY_ECD_ITEM_16(n) if (!isZip64 || ecd. ## n != 0xFFFF) ecd64. ## n = ecd. ## n; #define COPY_ECD_ITEM_16(n) if (!isZip64 || ecd. n != 0xFFFF) ecd64. n = ecd. n;
#define COPY_ECD_ITEM_32(n) if (!isZip64 || ecd. ## n != 0xFFFFFFFF) ecd64. ## n = ecd. ## n; #define COPY_ECD_ITEM_32(n) if (!isZip64 || ecd. n != 0xFFFFFFFF) ecd64. n = ecd. n;
HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress) HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress)
{ {

View File

@@ -168,7 +168,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
return 1; return 1;
} }
UString dirPrefix = L".\\"; UString dirPrefix = L"." WSTRING_PATH_SEPARATOR;
UString appLaunched; UString appLaunched;
bool showProgress = true; bool showProgress = true;
if (!config.IsEmpty()) if (!config.IsEmpty())
@@ -298,7 +298,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
{ {
UString s2 = tempDirPath; UString s2 = tempDirPath;
NFile::NName::NormalizeDirPathPrefix(s2); NFile::NName::NormalizeDirPathPrefix(s2);
appLaunched.Replace(L"%%T\\", s2); appLaunched.Replace(L"%%T" WSTRING_PATH_SEPARATOR, s2);
} }
appLaunched.Replace(L"%%T", tempDirPath); appLaunched.Replace(L"%%T", tempDirPath);

View File

@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 4 #define MY_VER_MAJOR 4
#define MY_VER_MINOR 59 #define MY_VER_MINOR 60
#define MY_VER_BUILD 7 #define MY_VER_BUILD 0
#define MY_VERSION " 4.59 beta" #define MY_VERSION " 4.60 beta"
#define MY_7ZIP_VERSION "7-Zip 4.59 beta" #define MY_7ZIP_VERSION "7-Zip 4.60 beta"
#define MY_DATE "2008-08-13" #define MY_DATE "2008-08-19"
#define MY_COPYRIGHT "Copyright (c) 1999-2008 Igor Pavlov" #define MY_COPYRIGHT "Copyright (c) 1999-2008 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE

View File

@@ -94,9 +94,9 @@ UString CAgentFolder::GetPrefix(UInt32 index) const
const CProxyItem &item = _items[index]; const CProxyItem &item = _items[index];
const CProxyFolder *folder = item.Folder; const CProxyFolder *folder = item.Folder;
UString path; UString path;
while(folder != _proxyFolderItem) while (folder != _proxyFolderItem)
{ {
path = folder->Name + UString(L"\\") + path; path = folder->Name + UString(WCHAR_PATH_SEPARATOR) + path;
folder = folder->Parent; folder = folder->Parent;
} }
return path; return path;
@@ -460,12 +460,9 @@ STDMETHODIMP CAgent::Open(
DefaultTime = fileInfo.MTime; DefaultTime = fileInfo.MTime;
DefaultAttrib = fileInfo.Attrib; DefaultAttrib = fileInfo.Attrib;
ArchiveType = ai.Name; ArchiveType = ai.Name;
if (archiveType != 0) if (archiveType == 0)
{ return S_OK;
CMyComBSTR name = ArchiveType; return StringToBstr(ArchiveType, archiveType);
*archiveType = name.Detach();
}
return S_OK;
COM_TRY_END COM_TRY_END
} }

View File

@@ -66,10 +66,10 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
folderItem = newFolder; folderItem = newFolder;
} }
for(int i = 0; i < pathParts.Size(); i++) for (int i = 0; i < pathParts.Size(); i++)
{ {
_archiveNamePrefix += pathParts[i]; _archiveNamePrefix += pathParts[i];
_archiveNamePrefix += L'\\'; _archiveNamePrefix += WCHAR_PATH_SEPARATOR;
} }
return S_OK; return S_OK;
} }
@@ -138,7 +138,7 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
ai.IndexInServer = dirItem.Index; ai.IndexInServer = dirItem.Index;
arcItems.Add(ai); arcItems.Add(ai);
} }
RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(L'\\'), arcItems)); RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(WCHAR_PATH_SEPARATOR), arcItems));
} }
return S_OK; return S_OK;
} }
@@ -537,5 +537,3 @@ STDMETHODIMP CAgent::SetProperties(const wchar_t **names,
} }
return S_OK; return S_OK;
} }

View File

@@ -98,7 +98,7 @@ UString CProxyFolder::GetFullPathPrefix() const
const CProxyFolder *current = this; const CProxyFolder *current = this;
while (current->Parent != NULL) while (current->Parent != NULL)
{ {
result = current->Name + UString(L'\\') + result; result = current->Name + UString(WCHAR_PATH_SEPARATOR) + result;
current = current->Parent; current = current->Parent;
} }
return result; return result;
@@ -252,7 +252,7 @@ HRESULT CProxyArchive::ReadObjects(IInArchive *archive, IProgress *progress)
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
{ {
wchar_t c = filePath[i]; wchar_t c = filePath[i];
if (c == '\\' || c == '/') if (c == WCHAR_PATH_SEPARATOR || c == L'/')
{ {
currentItem = currentItem->AddDirSubItem((UInt32)(Int32)-1, false, fileName); currentItem = currentItem->AddDirSubItem((UInt32)(Int32)-1, false, fileName);
fileName.Empty(); fileName.Empty();

View File

@@ -59,9 +59,8 @@ STDMETHODIMP CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *ext
int formatIndex = FindFormat(type); int formatIndex = FindFormat(type);
if (formatIndex < 0) if (formatIndex < 0)
return E_INVALIDARG; return E_INVALIDARG;
CMyComBSTR valueTemp = _codecs.Formats[formatIndex].GetAllExtensions(); // Exts[0].Ext; // Exts[0].Ext;
*extensions = valueTemp.Detach(); return StringToBstr(_codecs.Formats[formatIndex].GetAllExtensions(), extensions);
return S_OK;
} }
*/ */
STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions) STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions)
@@ -79,9 +78,7 @@ STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions)
res += lib.IconPairs[j].Ext; res += lib.IconPairs[j].Ext;
} }
} }
CMyComBSTR valueTemp = res; return StringToBstr(res, extensions);
*extensions = valueTemp.Detach();
return S_OK;
} }
STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex) STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex)
@@ -95,10 +92,8 @@ STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPa
int ii = lib.FindIconIndex(ext); int ii = lib.FindIconIndex(ext);
if (ii >= 0) if (ii >= 0)
{ {
CMyComBSTR iconPathTemp = GetUnicodeString(lib.Path, GetCurrentFileCodePage());
*iconIndex = ii; *iconIndex = ii;
*iconPath = iconPathTemp.Detach(); return StringToBstr(GetUnicodeString(lib.Path, GetCurrentFileCodePage()), iconPath);
return S_OK;
} }
} }
return S_OK; return S_OK;
@@ -118,9 +113,7 @@ STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
typesStrings += L' '; typesStrings += L' ';
typesStrings += ai.Name; typesStrings += ai.Name;
} }
CMyComBSTR valueTemp = typesStrings; return StringToBstr(typesStrings, types);
*types = valueTemp.Detach();
return S_OK;
} }
STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type, STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type,
const wchar_t * filePath, IProgress progress) const wchar_t * filePath, IProgress progress)

View File

@@ -151,9 +151,7 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
PrintError("Password is not defined"); PrintError("Password is not defined");
return E_ABORT; return E_ABORT;
} }
CMyComBSTR tempName(Password); return StringToBstr(Password, password);
*password = tempName.Detach();
return S_OK;
} }
@@ -420,9 +418,7 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
PrintError("Password is not defined"); PrintError("Password is not defined");
return E_ABORT; return E_ABORT;
} }
CMyComBSTR tempName(Password); return StringToBstr(Password, password);
*password = tempName.Detach();
return S_OK;
} }
@@ -654,9 +650,7 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef
} }
} }
*passwordIsDefined = BoolToInt(PasswordIsDefined); *passwordIsDefined = BoolToInt(PasswordIsDefined);
CMyComBSTR tempName(Password); return StringToBstr(Password, password);
*password = tempName.Detach();
return S_OK;
} }

View File

@@ -16,7 +16,7 @@ UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName)
if (NFile::NDirectory::GetOnlyDirPrefix(srcName, dirPrefix)) if (NFile::NDirectory::GetOnlyDirPrefix(srcName, dirPrefix))
{ {
if (dirPrefix.Length() > 0) if (dirPrefix.Length() > 0)
if (dirPrefix[dirPrefix.Length() - 1] == '\\') if (dirPrefix[dirPrefix.Length() - 1] == WCHAR_PATH_SEPARATOR)
{ {
dirPrefix.Delete(dirPrefix.Length() - 1); dirPrefix.Delete(dirPrefix.Length() - 1);
NFile::NFind::CFileInfoW fileInfo; NFile::NFind::CFileInfoW fileInfo;

View File

@@ -129,16 +129,19 @@ void CDirItems::EnumerateDirItems2(const UString &phyPrefix, const UString &logP
continue; continue;
} }
int delimiter = filePath.ReverseFind((wchar_t)kDirDelimiter); int delimiter = filePath.ReverseFind((wchar_t)kDirDelimiter);
UString phyPrefixCur;
int phyParentCur = phyParent; int phyParentCur = phyParent;
if (delimiter >= 0) if (delimiter >= 0)
phyParentCur = AddPrefix(phyParentCur, logParent, filePath.Left(delimiter + 1)); {
phyPrefixCur = filePath.Left(delimiter + 1);
phyParentCur = AddPrefix(phyParent, logParent, phyPrefixCur);
}
AddDirFileInfo(phyParentCur, logParent, fi, Items); AddDirFileInfo(phyParentCur, logParent, fi, Items);
if (fi.IsDir()) if (fi.IsDir())
{ {
const UString name2 = fi.Name + (wchar_t)kDirDelimiter; const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
int parent = AddPrefix(phyParentCur, logParent, name2); int parent = AddPrefix(phyParentCur, logParent, name2);
EnumerateDirectory(parent, parent, phyPrefix + name2, errorPaths, errorCodes); EnumerateDirectory(parent, parent, phyPrefix + phyPrefixCur + name2, errorPaths, errorCodes);
} }
} }
ReserveDown(); ReserveDown();

View File

@@ -50,7 +50,7 @@ static CSysString GetLibraryFolderPrefix()
static const TCHAR *kMainDll = TEXT("7z.dll"); static const TCHAR *kMainDll = TEXT("7z.dll");
#ifdef _WIN32 #ifdef _WIN32
static LPCTSTR kRegistryPath = TEXT("Software\\7-zip"); static LPCTSTR kRegistryPath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-zip");
static LPCTSTR kProgramPathValue = TEXT("Path"); static LPCTSTR kProgramPathValue = TEXT("Path");
static bool ReadPathFromRegistry(HKEY baseKey, CSysString &path) static bool ReadPathFromRegistry(HKEY baseKey, CSysString &path)
{ {
@@ -446,7 +446,7 @@ HRESULT CCodecs::Load()
int CCodecs::FindFormatForArchiveName(const UString &arcPath) const int CCodecs::FindFormatForArchiveName(const UString &arcPath) const
{ {
int slashPos1 = arcPath.ReverseFind(L'\\'); int slashPos1 = arcPath.ReverseFind(WCHAR_PATH_SEPARATOR);
int slashPos2 = arcPath.ReverseFind(L'.'); int slashPos2 = arcPath.ReverseFind(L'.');
int dotPos = arcPath.ReverseFind(L'.'); int dotPos = arcPath.ReverseFind(L'.');
if (dotPos < 0 || dotPos < slashPos1 || dotPos < slashPos2) if (dotPos < 0 || dotPos < slashPos1 || dotPos < slashPos2)

View File

@@ -175,7 +175,7 @@ HRESULT OpenArchive(
processedSize--; processedSize--;
for (UInt32 pos = 0; pos < processedSize; pos++) for (UInt32 pos = 0; pos < processedSize; pos++)
{ {
for (; hash[buf[pos] | ((UInt32)buf[pos + 1] << 8)] == 0xFF && pos < processedSize; pos++); for (; pos < processedSize && hash[buf[pos] | ((UInt32)buf[pos + 1] << 8)] == 0xFF; pos++);
if (pos == processedSize) if (pos == processedSize)
break; break;
UInt32 v = buf[pos] | ((UInt32)buf[pos + 1] << 8); UInt32 v = buf[pos] | ((UInt32)buf[pos + 1] << 8);

View File

@@ -152,9 +152,7 @@ STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
Password = GetPassword(OutStream); Password = GetPassword(OutStream);
PasswordIsDefined = true; PasswordIsDefined = true;
} }
CMyComBSTR tempName(Password); return StringToBstr(Password, password);
*password = tempName.Detach();
return S_OK;
} }
#endif #endif

View File

@@ -35,9 +35,7 @@ HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
Password = GetPassword(OutStream); Password = GetPassword(OutStream);
PasswordIsDefined = true; PasswordIsDefined = true;
} }
CMyComBSTR temp(Password); return StringToBstr(Password, password);
*password = temp.Detach();
return S_OK;
} }
HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(UString &password) HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(UString &password)

View File

@@ -199,8 +199,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined,
#ifdef _NO_CRYPTO #ifdef _NO_CRYPTO
*passwordIsDefined = false; *passwordIsDefined = false;
CMyComBSTR tempName(L""); return StringToBstr(L"", password);
*password = tempName.Detach();
#else #else
@@ -213,10 +212,8 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined,
} }
} }
*passwordIsDefined = BoolToInt(PasswordIsDefined); *passwordIsDefined = BoolToInt(PasswordIsDefined);
CMyComBSTR tempName(Password); return StringToBstr(Password, password);
*password = tempName.Detach();
#endif #endif
return S_OK;
} }

View File

@@ -309,6 +309,16 @@ static UString GetReducedString(const UString &s)
return s.Left(kFirstPartSize) + UString(L" ... ") + s.Right(kMaxSize - kFirstPartSize); return s.Left(kFirstPartSize) + UString(L" ... ") + s.Right(kMaxSize - kFirstPartSize);
} }
static UString GetQuotedString(const UString &s)
{
return UString(L'\"') + s + UString(L'\"');
}
static UString GetQuotedReducedString(const UString &s)
{
return GetQuotedString(GetReducedString(s));
}
static const wchar_t *kExtractExludeExtensions[] = static const wchar_t *kExtractExludeExtensions[] =
{ {
L"txt", L"htm", L"html", L"xml", L"xsd", L"xsl", L"xslt", L"asp", L"aspx", L"css", L"shtml", L"txt", L"htm", L"html", L"xml", L"xsd", L"xsl", L"xslt", L"asp", L"aspx", L"css", L"shtml",
@@ -435,7 +445,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Folder = _dropPath; commandMapItem.Folder = _dropPath;
else else
commandMapItem.Folder = folderPrefix; commandMapItem.Folder = folderPrefix;
commandMapItem.Folder += GetSubFolderNameForExtract(fileInfo.Name) + UString(L'\\'); commandMapItem.Folder += GetSubFolderNameForExtract(fileInfo.Name) + UString(WCHAR_PATH_SEPARATOR);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
} }
@@ -469,7 +479,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
else else
commandMapItem.Folder = folderPrefix; commandMapItem.Folder = folderPrefix;
commandMapItem.Folder += folder; commandMapItem.Folder += folder;
s = MyFormatNew(s, GetReducedString(UString(L"\"") + folder + UString(L"\\\""))); s = MyFormatNew(s, GetQuotedReducedString(folder + UString(WCHAR_PATH_SEPARATOR)));
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
} }
@@ -525,8 +535,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Folder = archivePathPrefix; commandMapItem.Folder = archivePathPrefix;
commandMapItem.Archive = archiveName7z; commandMapItem.Archive = archiveName7z;
commandMapItem.ArchiveType = L"7z"; commandMapItem.ArchiveType = L"7z";
UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\""); s = MyFormatNew(s, GetQuotedReducedString(archiveName7z));
s = MyFormatNew(s, t);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
} }
@@ -539,8 +548,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
FillCommand(kCompressTo7zEmail, s, commandMapItem); FillCommand(kCompressTo7zEmail, s, commandMapItem);
commandMapItem.Archive = archiveName7z; commandMapItem.Archive = archiveName7z;
commandMapItem.ArchiveType = L"7z"; commandMapItem.ArchiveType = L"7z";
UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\""); s = MyFormatNew(s, GetQuotedReducedString(archiveName7z));
s = MyFormatNew(s, t);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
} }
@@ -557,8 +565,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Folder = archivePathPrefix; commandMapItem.Folder = archivePathPrefix;
commandMapItem.Archive = archiveNameZip; commandMapItem.Archive = archiveNameZip;
commandMapItem.ArchiveType = L"zip"; commandMapItem.ArchiveType = L"zip";
UString t = UString(L"\"") + GetReducedString(archiveNameZip) + UString(L"\""); s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip));
s = MyFormatNew(s, t);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
} }
@@ -571,8 +578,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
FillCommand(kCompressToZipEmail, s, commandMapItem); FillCommand(kCompressToZipEmail, s, commandMapItem);
commandMapItem.Archive = archiveNameZip; commandMapItem.Archive = archiveNameZip;
commandMapItem.ArchiveType = L"zip"; commandMapItem.ArchiveType = L"zip";
UString t = UString(L"\"") + GetReducedString(archiveNameZip) + UString(L"\""); s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip));
s = MyFormatNew(s, t);
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem); _commandMap.Add(commandMapItem);
} }
@@ -614,12 +620,11 @@ extern const char *kShellFolderClassIDString;
static UString GetProgramCommand() static UString GetProgramCommand()
{ {
UString path = L"\""; UString path;
UString folder; UString folder;
if (GetProgramFolderPath(folder)) if (GetProgramFolderPath(folder))
path += folder; path = folder;
path += L"7zFM.exe\""; return GetQuotedString(path + L"7zFM.exe");
return path;
} }
STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo) STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
@@ -658,9 +663,8 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
{ {
UString params; UString params;
params = GetProgramCommand(); params = GetProgramCommand();
params += L" \""; params += L' ';
params += _fileNames[0]; params += GetQuotedString(_fileNames[0]);
params += L"\"";
MyCreateProcess(params, 0, false, 0); MyCreateProcess(params, 0, false, 0);
break; break;
} }

View File

@@ -170,8 +170,5 @@ STDMETHODIMP CExtractCallBackImp::CryptoGetTextPassword(BSTR *password)
RINOK(GetPassword(m_Password)); RINOK(GetPassword(m_Password));
m_PasswordIsDefined = true; m_PasswordIsDefined = true;
} }
CMyComBSTR tempName = m_Password; return StringToBstr(m_Password, password);
*password = tempName.Detach();
return S_OK;
} }

View File

@@ -359,9 +359,7 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
RINOK(GetPassword(Password)); RINOK(GetPassword(Password));
PasswordIsDefined = true; PasswordIsDefined = true;
} }
CMyComBSTR temp = Password; return StringToBstr(Password, password);
*password = temp.Detach();
return S_OK;
} }
/* /*

View File

@@ -208,7 +208,7 @@ void CPlugin::EnterToDirectory(const UString &dirName)
int CPlugin::SetDirectory(const char *aszDir, int /* opMode */) int CPlugin::SetDirectory(const char *aszDir, int /* opMode */)
{ {
UString path = MultiByteToUnicodeString(aszDir, CP_OEMCP); UString path = MultiByteToUnicodeString(aszDir, CP_OEMCP);
if (path == L"\\") if (path == WSTRING_PATH_SEPARATOR)
{ {
_folder.Release(); _folder.Release();
m_ArchiveHandler->BindToRootFolder(&_folder); m_ArchiveHandler->BindToRootFolder(&_folder);
@@ -225,7 +225,7 @@ int CPlugin::SetDirectory(const char *aszDir, int /* opMode */)
EnterToDirectory(path); EnterToDirectory(path);
else else
{ {
if (path[0] == L'\\') if (path[0] == WCHAR_PATH_SEPARATOR)
{ {
_folder.Release(); _folder.Release();
m_ArchiveHandler->BindToRootFolder(&_folder); m_ArchiveHandler->BindToRootFolder(&_folder);
@@ -265,7 +265,7 @@ void CPlugin::GetCurrentDir()
GetPathParts(pathParts); GetPathParts(pathParts);
for (int i = 0; i < pathParts.Size(); i++) for (int i = 0; i < pathParts.Size(); i++)
{ {
m_CurrentDir += L'\\'; m_CurrentDir += WCHAR_PATH_SEPARATOR;
m_CurrentDir += pathParts[i]; m_CurrentDir += pathParts[i];
} }
} }

View File

@@ -269,7 +269,7 @@ void CApp::ReloadToolbars()
return; return;
HWND parent = _rebar; HWND parent = _rebar;
while(_rebar.GetBandCount() > 0) while (_rebar.GetBandCount() > 0)
_rebar.DeleteBand(0); _rebar.DeleteBand(0);
_archiveToolBar.Destroy(); _archiveToolBar.Destroy();
@@ -436,14 +436,14 @@ static bool IsThereFolderOfPath(const UString &path)
// reduces path to part that exists on disk // reduces path to part that exists on disk
static void ReducePathToRealFileSystemPath(UString &path) static void ReducePathToRealFileSystemPath(UString &path)
{ {
while(!path.IsEmpty()) while (!path.IsEmpty())
{ {
if (IsThereFolderOfPath(path)) if (IsThereFolderOfPath(path))
{ {
NName::NormalizeDirPathPrefix(path); NName::NormalizeDirPathPrefix(path);
break; break;
} }
int pos = path.ReverseFind('\\'); int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos < 0) if (pos < 0)
path.Empty(); path.Empty();
else else
@@ -453,8 +453,8 @@ static void ReducePathToRealFileSystemPath(UString &path)
break; break;
if (path.Length() > 2 && path[0] == '\\' && path[1] == '\\') if (path.Length() > 2 && path[0] == '\\' && path[1] == '\\')
{ {
int nextPos = path.Find('\\', 2); // pos after \\COMPNAME int nextPos = path.Find(WCHAR_PATH_SEPARATOR, 2); // pos after \\COMPNAME
if (nextPos > 0 && path.Find('\\', nextPos + 1) == pos) if (nextPos > 0 && path.Find(WCHAR_PATH_SEPARATOR, nextPos + 1) == pos)
break; break;
} }
path = path.Left(pos); path = path.Left(pos);
@@ -472,9 +472,12 @@ static bool CheckFolderPath(const UString &path)
static bool IsPathAbsolute(const UString &path) static bool IsPathAbsolute(const UString &path)
{ {
if ((path.Length() >= 1 && path[0] == L'\\') || if (path.Length() >= 1 && path[0] == WCHAR_PATH_SEPARATOR)
(path.Length() >= 3 && path[1] == L':' && path[2] == L'\\'))
return true; return true;
#ifdef _WIN32
if (path.Length() >= 3 && path[1] == L':' && path[2] == L'\\')
return true;
#endif
return false; return false;
} }
@@ -564,7 +567,7 @@ UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
int index = indices[i]; int index = indices[i];
info += GetItemRelPath(index); info += GetItemRelPath(index);
if (IsItemFolder(index)) if (IsItemFolder(index))
info += L'\\'; info += WCHAR_PATH_SEPARATOR;
} }
if (i != indices.Size()) if (i != indices.Size())
info += L"\n ..."; info += L"\n ...";
@@ -656,7 +659,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
return; return;
} }
if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) || if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind(WCHAR_PATH_SEPARATOR) == destPath.Length() - 1) ||
IsThereFolderOfPath(destPath)) IsThereFolderOfPath(destPath))
{ {
NDirectory::CreateComplexDirectory(destPath); NDirectory::CreateComplexDirectory(destPath);
@@ -673,7 +676,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
} }
else else
{ {
int pos = destPath.ReverseFind('\\'); int pos = destPath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos >= 0) if (pos >= 0)
{ {
UString prefix = destPath.Left(pos + 1); UString prefix = destPath.Left(pos + 1);
@@ -734,7 +737,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
else else
folderPrefix = srcPanel._currentFolderPrefix; folderPrefix = srcPanel._currentFolderPrefix;
filePaths.Reserve(indices.Size()); filePaths.Reserve(indices.Size());
for(int i = 0; i < indices.Size(); i++) for (int i = 0; i < indices.Size(); i++)
filePaths.Add(srcPanel.GetItemRelPath(indices[i])); filePaths.Add(srcPanel.GetItemRelPath(indices[i]));
result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0); result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0);
@@ -789,12 +792,8 @@ void CApp::OnSetSubFolder(int srcPanelIndex)
if (!srcPanel.IsItemFolder(realIndex)) if (!srcPanel.IsItemFolder(realIndex))
return; return;
// destPanel.BindToFolder(srcPanel._currentFolderPrefix + srcPanel.GetItemName(realIndex) + WCHAR_PATH_SEPARATOR);
/*
UString string = srcPanel._currentFolderPrefix +
srcPanel.GetItemName(realIndex) + L'\\';
destPanel.BindToFolder(string);
*/
CMyComPtr<IFolderFolder> newFolder; CMyComPtr<IFolderFolder> newFolder;
if (realIndex == kParentIndex) if (realIndex == kParentIndex)
{ {

View File

@@ -51,6 +51,13 @@ class CFolderHistory
{ {
NWindows::NSynchronization::CCriticalSection _criticalSection; NWindows::NSynchronization::CCriticalSection _criticalSection;
UStringVector Strings; UStringVector Strings;
void Normalize()
{
const int kMaxSize = 100;
if (Strings.Size() > kMaxSize)
Strings.Delete(kMaxSize, Strings.Size() - kMaxSize);
}
public: public:
void GetList(UStringVector &foldersHistory) void GetList(UStringVector &foldersHistory)
@@ -59,14 +66,6 @@ public:
foldersHistory = Strings; foldersHistory = Strings;
} }
void Normalize()
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
const int kMaxSize = 100;
if (Strings.Size() > kMaxSize)
Strings.Delete(kMaxSize, Strings.Size() - kMaxSize);
}
void AddString(const UString &string) void AddString(const UString &string)
{ {
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);

View File

@@ -369,9 +369,7 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
Password = dialog.Password; Password = dialog.Password;
PasswordIsDefined = true; PasswordIsDefined = true;
} }
CMyComBSTR tempName(Password); return StringToBstr(Password, password);
*password = tempName.Detach();
return S_OK;
} }
@@ -384,12 +382,9 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
Int32 *writeAnswer) Int32 *writeAnswer)
{ {
UString destPathResultTemp = destPath; UString destPathResultTemp = destPath;
/*
{ // RINOK(StringToBstr(destPath, destPathResult));
CMyComBSTR destPathResultBSTR = destPath;
*destPathResult = destPathResultBSTR.Detach();
}
*/
*destPathResult = 0; *destPathResult = 0;
*writeAnswer = BoolToInt(false); *writeAnswer = BoolToInt(false);
@@ -476,9 +471,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
return E_ABORT; return E_ABORT;
} }
} }
CMyComBSTR destPathResultBSTR(destPathResultTemp);
*destPathResult = destPathResultBSTR.Detach();
*writeAnswer = BoolToInt(true); *writeAnswer = BoolToInt(true);
return S_OK; return StringToBstr(destPathResultTemp, destPathResult);
} }

View File

@@ -67,7 +67,7 @@ static UString GetProgramPath()
UString GetProgramFolderPrefix() UString GetProgramFolderPrefix()
{ {
UString path = GetProgramPath(); UString path = GetProgramPath();
int pos = path.ReverseFind(L'\\'); int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
return path.Left(pos + 1); return path.Left(pos + 1);
} }

View File

@@ -767,6 +767,10 @@ SOURCE=..\..\..\Windows\Clipboard.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\..\Windows\COM.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\CommonDialog.cpp SOURCE=..\..\..\Windows\CommonDialog.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -195,7 +195,7 @@ STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value)
switch(propID) switch(propID)
{ {
case kpidType: prop = L"FSDrives"; break; case kpidType: prop = L"FSDrives"; break;
case kpidPath: prop = LangString(IDS_COMPUTER, 0x03020300) + UString(L'\\'); break; case kpidPath: prop = LangString(IDS_COMPUTER, 0x03020300) + UString(WCHAR_PATH_SEPARATOR); break;
} }
prop.Detach(value); prop.Detach(value);
return S_OK; return S_OK;

View File

@@ -75,14 +75,14 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles,
{ {
RINOK(progress->SetCompleted(NULL)); RINOK(progress->SetCompleted(NULL));
numFiles = numFolders = size = 0; numFiles = numFolders = size = 0;
CEnumeratorW enumerator(path + UString(L"\\*")); CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*"));
CFileInfoW fileInfo; CFileInfoW fileInfo;
while (enumerator.Next(fileInfo)) while (enumerator.Next(fileInfo))
{ {
if (fileInfo.IsDir()) if (fileInfo.IsDir())
{ {
UInt64 subFolders, subFiles, subSize; UInt64 subFolders, subFiles, subSize;
RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subFolders, subFiles, subSize, progress)); RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fileInfo.Name, subFolders, subFiles, subSize, progress));
numFolders += subFolders; numFolders += subFolders;
numFolders++; numFolders++;
numFiles += subFiles; numFiles += subFiles;
@@ -125,7 +125,7 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
{ {
CDirItem &item = dirItem.Files[i]; CDirItem &item = dirItem.Files[i];
if (item.IsDir()) if (item.IsDir())
LoadSubItems(item, path + item.Name + L'\\'); LoadSubItems(item, path + item.Name + WCHAR_PATH_SEPARATOR);
} }
return S_OK; return S_OK;
} }
@@ -311,7 +311,7 @@ HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultF
*resultFolder = 0; *resultFolder = 0;
CFSFolder *folderSpec = new CFSFolder; CFSFolder *folderSpec = new CFSFolder;
CMyComPtr<IFolderFolder> subFolder = folderSpec; CMyComPtr<IFolderFolder> subFolder = folderSpec;
RINOK(folderSpec->Init(_path + name + UString(L'\\'), 0)); RINOK(folderSpec->Init(_path + name + UString(WCHAR_PATH_SEPARATOR), 0));
*resultFolder = subFolder.Detach(); *resultFolder = subFolder.Detach();
return S_OK; return S_OK;
} }
@@ -322,7 +322,7 @@ UString CFSFolder::GetPrefix(const CDirItem &item) const
CDirItem *cur = item.Parent; CDirItem *cur = item.Parent;
while (cur->Parent != 0) while (cur->Parent != 0)
{ {
path = cur->Name + UString('\\') + path; path = cur->Name + UString(WCHAR_PATH_SEPARATOR) + path;
cur = cur->Parent; cur = cur->Parent;
} }
return path; return path;
@@ -358,11 +358,11 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
} }
if (_path.IsEmpty()) if (_path.IsEmpty())
return E_INVALIDARG; return E_INVALIDARG;
int pos = _path.ReverseFind(L'\\'); int pos = _path.ReverseFind(WCHAR_PATH_SEPARATOR);
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(L'\\'); pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos < 0) if (pos < 0)
{ {
parentPath.Empty(); parentPath.Empty();
@@ -374,10 +374,10 @@ 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(L'\\'); pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos == 1) if (pos == 1)
{ {
if (parentPath[0] != L'\\') if (parentPath[0] != WCHAR_PATH_SEPARATOR)
return E_FAIL; return E_FAIL;
CNetFolder *netFolderSpec = new CNetFolder; CNetFolder *netFolderSpec = new CNetFolder;
CMyComPtr<IFolderFolder> netFolder = netFolderSpec; CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
@@ -537,7 +537,7 @@ HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
resultPath = _path + newName; resultPath = _path + newName;
if (newName.Length() < 1) if (newName.Length() < 1)
return S_OK; return S_OK;
if (newName[0] == L'\\') if (newName[0] == WCHAR_PATH_SEPARATOR)
{ {
resultPath = newName; resultPath = newName;
return S_OK; return S_OK;

View File

@@ -216,6 +216,11 @@ static HRESULT MyCopyFile(
return callback->SetCompleted(&completedSize); return callback->SetCompleted(&completedSize);
} }
static UString CombinePath(const UString &folderPath, const UString &fileName)
{
return folderPath + UString(WCHAR_PATH_SEPARATOR) + fileName;
}
static HRESULT CopyFolder( static HRESULT CopyFolder(
const UString &srcPath, const UString &srcPath,
const UString &destPathSpec, const UString &destPathSpec,
@@ -224,11 +229,11 @@ static HRESULT CopyFolder(
{ {
RINOK(callback->SetCompleted(&completedSize)); RINOK(callback->SetCompleted(&completedSize));
UString destPath = destPathSpec; const UString destPath = destPathSpec;
int len = srcPath.Length(); int len = srcPath.Length();
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0) if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
{ {
if (destPath.Length() == len || destPath[len] == L'\\') if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
{ {
UString message = UString(L"can not copy folder \'") + UString message = UString(L"can not copy folder \'") +
destPath + UString(L"\' onto itself"); destPath + UString(L"\' onto itself");
@@ -243,19 +248,19 @@ static HRESULT CopyFolder(
RINOK(callback->ShowMessage(message)); RINOK(callback->ShowMessage(message));
return E_ABORT; return E_ABORT;
} }
CEnumeratorW enumerator(srcPath + UString(L"\\*")); CEnumeratorW enumerator(CombinePath(srcPath, L"*"));
CFileInfoEx fileInfo; CFileInfoEx fi;
while (enumerator.Next(fileInfo)) while (enumerator.Next(fi))
{ {
const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name; const UString srcPath2 = CombinePath(srcPath, fi.Name);
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name; const UString destPath2 = CombinePath(destPath, fi.Name);
if (fileInfo.IsDir()) if (fi.IsDir())
{ {
RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize)); RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize))
} }
else else
{ {
RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize)); RINOK(MyCopyFile(srcPath2, fi, destPath2, callback, completedSize));
} }
} }
return S_OK; return S_OK;
@@ -275,7 +280,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
UString destPath = path; UString destPath = path;
if (destPath.IsEmpty()) if (destPath.IsEmpty())
return E_INVALIDARG; return E_INVALIDARG;
bool directName = (destPath[destPath.Length() - 1] != L'\\'); bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
if (directName) if (directName)
{ {
if (numItems > 1) if (numItems > 1)
@@ -298,18 +303,18 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
RINOK(callback->SetCompleted(&completedSize)); RINOK(callback->SetCompleted(&completedSize));
for (UInt32 i = 0; i < numItems; i++) for (UInt32 i = 0; i < numItems; i++)
{ {
const CDirItem &fileInfo = *_refs[indices[i]]; const CDirItem &fi = *_refs[indices[i]];
UString destPath2 = destPath; UString destPath2 = destPath;
if (!directName) if (!directName)
destPath2 += fileInfo.Name; destPath2 += fi.Name;
UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name; UString srcPath = _path + GetPrefix(fi) + fi.Name;
if (fileInfo.IsDir()) if (fi.IsDir())
{ {
RINOK(CopyFolder(srcPath, destPath2, callback, completedSize)); RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
} }
else else
{ {
RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize)); RINOK(MyCopyFile(srcPath, fi, destPath2, callback, completedSize));
} }
} }
return S_OK; return S_OK;
@@ -369,7 +374,7 @@ HRESULT MyMoveFolder(
int len = srcPath.Length(); int len = srcPath.Length();
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0) if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
{ {
if (destPath.Length() == len || destPath[len] == L'\\') if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
{ {
UString message = UString(L"can not move folder \'") + UString message = UString(L"can not move folder \'") +
destPath + UString(L"\' onto itself"); destPath + UString(L"\' onto itself");
@@ -388,19 +393,19 @@ HRESULT MyMoveFolder(
return E_ABORT; return E_ABORT;
} }
{ {
CEnumeratorW enumerator(srcPath + UString(L"\\*")); CEnumeratorW enumerator(CombinePath(srcPath, L"*"));
CFileInfoEx fileInfo; CFileInfoEx fi;
while (enumerator.Next(fileInfo)) while (enumerator.Next(fi))
{ {
const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name; const UString srcPath2 = CombinePath(srcPath, fi.Name);
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name; const UString destPath2 = CombinePath(destPath, fi.Name);
if (fileInfo.IsDir()) if (fi.IsDir())
{ {
RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize)); RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
} }
else else
{ {
RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, callback, completedSize)); RINOK(MyMoveFile(srcPath2, fi, destPath2, callback, completedSize));
} }
} }
} }
@@ -430,7 +435,7 @@ STDMETHODIMP CFSFolder::MoveTo(
UString destPath = path; UString destPath = path;
if (destPath.IsEmpty()) if (destPath.IsEmpty())
return E_INVALIDARG; return E_INVALIDARG;
bool directName = (destPath[destPath.Length() - 1] != L'\\'); bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
if (directName) if (directName)
{ {
if (numItems > 1) if (numItems > 1)
@@ -449,18 +454,18 @@ STDMETHODIMP CFSFolder::MoveTo(
RINOK(callback->SetCompleted(&completedSize)); RINOK(callback->SetCompleted(&completedSize));
for (UInt32 i = 0; i < numItems; i++) for (UInt32 i = 0; i < numItems; i++)
{ {
const CDirItem &fileInfo = *_refs[indices[i]]; const CDirItem &fi = *_refs[indices[i]];
UString destPath2 = destPath; UString destPath2 = destPath;
if (!directName) if (!directName)
destPath2 += fileInfo.Name; destPath2 += fi.Name;
UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name; UString srcPath = _path + GetPrefix(fi) + fi.Name;
if (fileInfo.IsDir()) if (fi.IsDir())
{ {
RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize)); RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
} }
else else
{ {
RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize)); RINOK(MyMoveFile(srcPath, fi, destPath2, callback, completedSize));
} }
} }
return S_OK; return S_OK;
@@ -477,13 +482,13 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
{ {
UString path = (UString)fromFolderPath + itemsPaths[i]; UString path = (UString)fromFolderPath + itemsPaths[i];
CFileInfoW fileInfo; CFileInfoW fi;
if (!FindFile(path, fileInfo)) if (!FindFile(path, fi))
return ::GetLastError(); return ::GetLastError();
if (fileInfo.IsDir()) if (fi.IsDir())
{ {
UInt64 subFolders, subFiles, subSize; UInt64 subFolders, subFiles, subSize;
RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subFolders, subFiles, subSize, progress)); RINOK(GetFolderSize(CombinePath(path, fi.Name), subFolders, subFiles, subSize, progress));
numFolders += subFolders; numFolders += subFolders;
numFolders++; numFolders++;
numFiles += subFiles; numFiles += subFiles;
@@ -492,7 +497,7 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
else else
{ {
numFiles++; numFiles++;
totalSize += fileInfo.Size; totalSize += fi.Size;
} }
} }
RINOK(progress->SetTotal(totalSize)); RINOK(progress->SetTotal(totalSize));

View File

@@ -74,7 +74,7 @@ HRESULT OpenFileFolderPlugin(
NFile::NName::SplitNameToPureNameAndExtension(name, pureName, dot, extension); NFile::NName::SplitNameToPureNameAndExtension(name, pureName, dot, extension);
int slashPos = path.ReverseFind(L'\\'); int slashPos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
UString dirPrefix; UString dirPrefix;
UString fileName; UString fileName;
if (slashPos >= 0) if (slashPos >= 0)

View File

@@ -75,7 +75,7 @@ void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource,
_netResourcePointer = &_netResource; _netResourcePointer = &_netResource;
// if (_netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER) // if (_netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER)
_path = _netResource.RemoteName + L'\\'; _path = _netResource.RemoteName + WCHAR_PATH_SEPARATOR;
} }
_parentFolder = parentFolder; _parentFolder = parentFolder;
} }
@@ -113,11 +113,11 @@ 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 = resource.RemoteName; resource.Name = resource.RemoteName;
int aPos = resource.Name.ReverseFind(L'\\'); int pos = resource.Name.ReverseFind(WCHAR_PATH_SEPARATOR);
if (aPos >= 0) if (pos >= 0)
{ {
// _path = resource.Name.Left(aPos + 1); // _path = resource.Name.Left(pos + 1);
resource.Name = resource.Name.Mid(aPos + 1); resource.Name = resource.Name.Mid(pos + 1);
} }
_items.Add(resource); _items.Add(resource);
} }
@@ -140,7 +140,7 @@ STDMETHODIMP CNetFolder::LoadItems()
NFile::NFind::CFindFile findFile; NFile::NFind::CFindFile findFile;
NFile::NFind::CFileInfoW fileInfo; NFile::NFind::CFileInfoW fileInfo;
if (!findFile.FindFirst(resource.RemoteName + UString(L"\\*"), fileInfo)) if (!findFile.FindFirst(resource.RemoteName + UString(WCHAR_PATH_SEPARATOR) + UString(L"*"), fileInfo))
continue; continue;
resource.Usage = RESOURCEUSAGE_CONNECTABLE; resource.Usage = RESOURCEUSAGE_CONNECTABLE;
resource.LocalNameIsDefined = false; resource.LocalNameIsDefined = false;
@@ -188,14 +188,14 @@ STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder
{ {
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
CMyComPtr<IFolderFolder> subFolder = fsFolderSpec; CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
RINOK(fsFolderSpec->Init(resource.RemoteName + L'\\', this)); RINOK(fsFolderSpec->Init(resource.RemoteName + WCHAR_PATH_SEPARATOR, 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, resource.Name + L'\\'); netFolder->Init(&resource, this, resource.Name + WCHAR_PATH_SEPARATOR);
*resultFolder = subFolder.Detach(); *resultFolder = subFolder.Detach();
} }
return S_OK; return S_OK;
@@ -226,7 +226,7 @@ STDMETHODIMP CNetFolder::BindToParentFolder(IFolderFolder **resultFolder)
CNetFolder *netFolder = new CNetFolder; CNetFolder *netFolder = new CNetFolder;
CMyComPtr<IFolderFolder> subFolder = netFolder; CMyComPtr<IFolderFolder> subFolder = netFolder;
netFolder->Init(&resourceParent, 0, L'\\'); netFolder->Init(&resourceParent, 0, WCHAR_PATH_SEPARATOR);
*resultFolder = subFolder.Detach(); *resultFolder = subFolder.Detach();
} }
return S_OK; return S_OK;

View File

@@ -120,7 +120,5 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
Password = dialog.Password; Password = dialog.Password;
PasswordIsDefined = true; PasswordIsDefined = true;
} }
CMyComBSTR tempName(Password); return StringToBstr(Password, password);
*password = tempName.Detach();
return S_OK;
} }

View File

@@ -800,7 +800,7 @@ void CPanel::AddToArchive()
static UString GetSubFolderNameForExtract(const UString &archiveName) static UString GetSubFolderNameForExtract(const UString &archiveName)
{ {
int slashPos = archiveName.ReverseFind(L'\\'); int slashPos = archiveName.ReverseFind(WCHAR_PATH_SEPARATOR);
int dotPos = archiveName.ReverseFind(L'.'); int dotPos = archiveName.ReverseFind(L'.');
if (dotPos < 0 || slashPos > dotPos) if (dotPos < 0 || slashPos > dotPos)
return archiveName + UString(L"~"); return archiveName + UString(L"~");
@@ -846,7 +846,7 @@ void CPanel::ExtractArchives()
folderName = GetSubFolderNameForExtract(GetItemRelPath(indices[0])); folderName = GetSubFolderNameForExtract(GetItemRelPath(indices[0]));
else else
folderName = L"*"; folderName = L"*";
::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(L"\\"), true); ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(WCHAR_PATH_SEPARATOR), true);
} }
struct CThreadTest struct CThreadTest

View File

@@ -64,7 +64,7 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr
if (Index >= FileNames.Size()) if (Index >= FileNames.Size())
return true; return true;
const UString &path = FileNames[Index]; const UString &path = FileNames[Index];
int pos = path.ReverseFind('\\'); int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
resPath.Empty(); resPath.Empty();
if (pos >= 0) if (pos >= 0)
resPath = path.Left(pos + 1); resPath = path.Left(pos + 1);

View File

@@ -149,7 +149,7 @@ STDMETHODIMP CDataObject::QueryGetData(LPFORMATETC etc)
STDMETHODIMP CDataObject::EnumFormatEtc(DWORD direction, LPENUMFORMATETC FAR* enumFormatEtc) STDMETHODIMP CDataObject::EnumFormatEtc(DWORD direction, LPENUMFORMATETC FAR* enumFormatEtc)
{ {
if(direction != DATADIR_GET) if (direction != DATADIR_GET)
return E_NOTIMPL; return E_NOTIMPL;
return CreateEnumFormatEtc(1, &m_Etc, enumFormatEtc); return CreateEnumFormatEtc(1, &m_Etc, enumFormatEtc);
} }
@@ -183,9 +183,9 @@ public:
STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState) STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState)
{ {
if(escapePressed == TRUE) if (escapePressed == TRUE)
return DRAGDROP_S_CANCEL; return DRAGDROP_S_CANCEL;
if((keyState & MK_LBUTTON) == 0) if ((keyState & MK_LBUTTON) == 0)
{ {
if (m_Effect == DROPEFFECT_NONE) if (m_Effect == DROPEFFECT_NONE)
return DRAGDROP_S_CANCEL; return DRAGDROP_S_CANCEL;
@@ -570,7 +570,7 @@ bool CDropTarget::IsItSameDrive() const
return false; return false;
} }
else if (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0) else if (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0)
drive = m_SubFolderName + L'\\'; drive = m_SubFolderName + WCHAR_PATH_SEPARATOR;
else else
return false; return false;
@@ -591,10 +591,7 @@ DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffec
if (!m_DropIsAllowed || !m_PanelDropIsAllowed) if (!m_DropIsAllowed || !m_PanelDropIsAllowed)
return DROPEFFECT_NONE; return DROPEFFECT_NONE;
if (!IsFsFolderPath()) if (!IsFsFolderPath() || !m_SetPathIsOK)
allowedEffect &= ~DROPEFFECT_MOVE;
if (!m_SetPathIsOK)
allowedEffect &= ~DROPEFFECT_MOVE; allowedEffect &= ~DROPEFFECT_MOVE;
DWORD effect = 0; DWORD effect = 0;
@@ -602,17 +599,17 @@ DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffec
effect = allowedEffect & DROPEFFECT_COPY; effect = allowedEffect & DROPEFFECT_COPY;
else if (keyState & MK_SHIFT) else if (keyState & MK_SHIFT)
effect = allowedEffect & DROPEFFECT_MOVE; effect = allowedEffect & DROPEFFECT_MOVE;
if(effect == 0) if (effect == 0)
{ {
if(allowedEffect & DROPEFFECT_COPY) if (allowedEffect & DROPEFFECT_COPY)
effect = DROPEFFECT_COPY; effect = DROPEFFECT_COPY;
if(allowedEffect & DROPEFFECT_MOVE) if (allowedEffect & DROPEFFECT_MOVE)
{ {
if (IsItSameDrive()) if (IsItSameDrive())
effect = DROPEFFECT_MOVE; effect = DROPEFFECT_MOVE;
} }
} }
if(effect == 0) if (effect == 0)
return DROPEFFECT_NONE; return DROPEFFECT_NONE;
return effect; return effect;
} }
@@ -627,7 +624,7 @@ UString CDropTarget::GetTargetPath() const
if (m_SubFolderIndex >= 0 && !m_SubFolderName.IsEmpty()) if (m_SubFolderIndex >= 0 && !m_SubFolderName.IsEmpty())
{ {
path += m_SubFolderName; path += m_SubFolderName;
path += L"\\"; path += WCHAR_PATH_SEPARATOR;
} }
return path; return path;
} }
@@ -703,11 +700,11 @@ STDMETHODIMP CDropTarget::Drop(IDataObject *dataObject, DWORD keyState,
PositionCursor(pt); PositionCursor(pt);
m_DataObject = dataObject; m_DataObject = dataObject;
bool needDrop = true; bool needDrop = true;
if(m_DropIsAllowed && m_PanelDropIsAllowed) if (m_DropIsAllowed && m_PanelDropIsAllowed)
if (IsFsFolderPath()) if (IsFsFolderPath())
needDrop = !SetPath(); needDrop = !SetPath();
*effect = GetEffect(keyState, pt, *effect); *effect = GetEffect(keyState, pt, *effect);
if(m_DropIsAllowed && m_PanelDropIsAllowed) if (m_DropIsAllowed && m_PanelDropIsAllowed)
{ {
if (needDrop) if (needDrop)
{ {

View File

@@ -69,11 +69,11 @@ HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool
UString sysPath = fullPath; UString sysPath = fullPath;
CFileInfoW fileInfo; CFileInfoW fileInfo;
UStringVector reducedParts; UStringVector reducedParts;
while(!sysPath.IsEmpty()) while (!sysPath.IsEmpty())
{ {
if (FindFile(sysPath, fileInfo)) if (FindFile(sysPath, fileInfo))
break; break;
int pos = sysPath.ReverseFind(L'\\'); int pos = sysPath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos < 0) if (pos < 0)
sysPath.Empty(); sysPath.Empty();
else else
@@ -175,7 +175,7 @@ void CPanel::LoadFullPath()
const CFolderLink &folderLink = _parentFolders[i]; const CFolderLink &folderLink = _parentFolders[i];
_currentFolderPrefix += GetFolderPath(folderLink.ParentFolder); _currentFolderPrefix += GetFolderPath(folderLink.ParentFolder);
_currentFolderPrefix += folderLink.ItemName; _currentFolderPrefix += folderLink.ItemName;
_currentFolderPrefix += L'\\'; _currentFolderPrefix += WCHAR_PATH_SEPARATOR;
} }
if (_folder) if (_folder)
_currentFolderPrefix += GetFolderPath(_folder); _currentFolderPrefix += GetFolderPath(_folder);
@@ -199,7 +199,13 @@ void CPanel::LoadFullPathAndShow()
item.mask = 0; item.mask = 0;
UString path = _currentFolderPrefix; UString path = _currentFolderPrefix;
if (path.Length() > 3 && path[path.Length() - 1] == L'\\') if (path.Length() >
#ifdef _WIN32
3
#else
1
#endif
&& path[path.Length() - 1] == WCHAR_PATH_SEPARATOR)
path.Delete(path.Length() - 1); path.Delete(path.Length() - 1);
CFileInfoW info; CFileInfoW info;
@@ -334,12 +340,12 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
sumPass += name; sumPass += name;
UString curName = sumPass; UString curName = sumPass;
if (i == 0) if (i == 0)
curName += L"\\"; curName += WCHAR_PATH_SEPARATOR;
CFileInfoW info; CFileInfoW info;
DWORD attrib = FILE_ATTRIBUTE_DIRECTORY; DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
if (NFile::NFind::FindFile(sumPass, info)) if (NFile::NFind::FindFile(sumPass, info))
attrib = info.Attrib; attrib = info.Attrib;
sumPass += L"\\"; sumPass += WCHAR_PATH_SEPARATOR;
AddComboBoxItem(name, GetRealIconIndex(curName, attrib), i, false); AddComboBoxItem(name, GetRealIconIndex(curName, attrib), i, false);
ComboBoxPaths.Add(sumPass); ComboBoxPaths.Add(sumPass);
} }
@@ -357,7 +363,7 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
UString s = driveStrings[i]; UString s = driveStrings[i];
ComboBoxPaths.Add(s); ComboBoxPaths.Add(s);
int iconIndex = GetRealIconIndex(s, 0); int iconIndex = GetRealIconIndex(s, 0);
if (s.Length() > 0 && s[s.Length() - 1] == '\\') if (s.Length() > 0 && s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
s.Delete(s.Length() - 1); s.Delete(s.Length() - 1);
AddComboBoxItem(s, iconIndex, 1, false); AddComboBoxItem(s, iconIndex, 1, false);
} }
@@ -463,7 +469,7 @@ void CPanel::OpenParentFolder()
{ {
UString string = _currentFolderPrefix; UString string = _currentFolderPrefix;
string.Delete(string.Length() - 1); string.Delete(string.Length() - 1);
int pos = string.ReverseFind(L'\\'); int pos = string.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos < 0) if (pos < 0)
pos = 0; pos = 0;
else else
@@ -512,7 +518,7 @@ void CPanel::OpenParentFolder()
void CPanel::CloseOpenFolders() void CPanel::CloseOpenFolders()
{ {
while(_parentFolders.Size() > 0) while (_parentFolders.Size() > 0)
{ {
_folder.Release(); _folder.Release();
_library.Free(); _library.Free();

View File

@@ -425,7 +425,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
if (_currentFolderPrefix.IsEmpty()) if (_currentFolderPrefix.IsEmpty())
{ {
int iconIndexTemp; int iconIndexTemp;
GetRealIconIndex(itemName + L"\\", attributes, iconIndexTemp); GetRealIconIndex(itemName + WCHAR_PATH_SEPARATOR, attributes, iconIndexTemp);
item.iImage = iconIndexTemp; item.iImage = iconIndexTemp;
} }
else else

View File

@@ -288,7 +288,7 @@ HRESULT CPanel::CreateShellContextMenu(
LPITEMIDLIST pidl; LPITEMIDLIST pidl;
UString fileName = GetItemRelPath(operatedIndices[i]); UString fileName = GetItemRelPath(operatedIndices[i]);
if (IsFSDrivesFolder()) if (IsFSDrivesFolder())
fileName += L'\\'; fileName += WCHAR_PATH_SEPARATOR;
RINOK(parentFolder->ParseDisplayName(GetParent(), 0, RINOK(parentFolder->ParseDisplayName(GetParent(), 0,
(wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0)); (wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0));
pidls.Add(pidl); pidls.Add(pidl);
@@ -301,7 +301,7 @@ HRESULT CPanel::CreateShellContextMenu(
/* /*
LPITEMIDLIST pidl; LPITEMIDLIST pidl;
HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0, HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0,
L".\\", &eaten, &pidl, 0); L"." WSTRING_PATH_SEPARATOR, &eaten, &pidl, 0);
if (result != NOERROR) if (result != NOERROR)
return; return;
*/ */

View File

@@ -362,7 +362,7 @@ void CPanel::CreateFolder()
return; return;
} }
} }
int pos = newName.Find(L'\\'); int pos = newName.Find(WCHAR_PATH_SEPARATOR);
if (pos >= 0) if (pos >= 0)
newName = newName.Left(pos); newName = newName.Left(pos);
if (!_mySelectMode) if (!_mySelectMode)
@@ -397,7 +397,7 @@ void CPanel::CreateFile()
MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243)); MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243));
return; return;
} }
int pos = newName.Find(L'\\'); int pos = newName.Find(WCHAR_PATH_SEPARATOR);
if (pos >= 0) if (pos >= 0)
newName = newName.Left(pos); newName = newName.Left(pos);
if (!_mySelectMode) if (!_mySelectMode)

View File

@@ -237,7 +237,7 @@ STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numIt
UString destPath = path; UString destPath = path;
if (destPath.IsEmpty()) if (destPath.IsEmpty())
return E_INVALIDARG; return E_INVALIDARG;
bool directName = (destPath[destPath.Length() - 1] != L'\\'); bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
if (directName) if (directName)
{ {
if (numItems > 1) if (numItems > 1)

View File

@@ -118,9 +118,7 @@ STDMETHODIMP CPluginOptionsCallback::GetProgramFolderPath(BSTR *value)
UString folder; UString folder;
if (!::GetProgramFolderPath(folder)) if (!::GetProgramFolderPath(folder))
return E_FAIL; return E_FAIL;
CMyComBSTR valueTemp = folder; return StringToBstr(folder, value);
*value = valueTemp.Detach();
return S_OK;
} }
static UString GetDefaultProgramName() static UString GetDefaultProgramName()
@@ -134,16 +132,16 @@ STDMETHODIMP CPluginOptionsCallback::GetProgramPath(BSTR *value)
UString folder; UString folder;
if (!::GetProgramFolderPath(folder)) if (!::GetProgramFolderPath(folder))
return E_FAIL; return E_FAIL;
CMyComBSTR valueTemp = folder + GetDefaultProgramName(); return StringToBstr(folder + GetDefaultProgramName(), value);
*value = valueTemp.Detach();
return S_OK;
} }
STDMETHODIMP CPluginOptionsCallback::GetRegistryCUPath(BSTR *value) STDMETHODIMP CPluginOptionsCallback::GetRegistryCUPath(BSTR *value)
{ {
CMyComBSTR valueTemp = UString(L"Software\\7-Zip\\FM\\Plugins\\") + _pluginName; return StringToBstr(UString(L"Software"
*value = valueTemp.Detach(); WSTRING_PATH_SEPARATOR L"7-Zip"
return S_OK; WSTRING_PATH_SEPARATOR L"FM"
WSTRING_PATH_SEPARATOR L"Plugins"
WSTRING_PATH_SEPARATOR) + _pluginName, value);
} }
void CPluginsPage::OnButtonOptions() void CPluginsPage::OnButtonOptions()

View File

@@ -15,7 +15,7 @@ bool GetProgramFolderPath(UString &folder)
{ {
if (!NDLL::MyGetModuleFileName(g_hInstance, folder)) if (!NDLL::MyGetModuleFileName(g_hInstance, folder))
return false; return false;
int pos = folder.ReverseFind(L'\\'); int pos = folder.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos < 0) if (pos < 0)
return false; return false;
folder = folder.Left(pos + 1); folder = folder.Left(pos + 1);

View File

@@ -336,7 +336,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
ProgressSynch.GetCurrentFileName(fileName); ProgressSynch.GetCurrentFileName(fileName);
if (_prevFileName != fileName) if (_prevFileName != fileName)
{ {
int slashPos = fileName.ReverseFind(L'\\'); int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR);
UString s1, s2; UString s1, s2;
if (slashPos >= 0) if (slashPos >= 0)
{ {

View File

@@ -23,22 +23,22 @@ namespace NRegistryAssociations {
static NSynchronization::CCriticalSection g_CriticalSection; static NSynchronization::CCriticalSection g_CriticalSection;
static const TCHAR *kCUKeyPath = TEXT("Software\\7-ZIP\\FM"); #define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") TEXT(STRING_PATH_SEPARATOR) TEXT("FM")
static const TCHAR *kAssociations = TEXT("Associations");
static const TCHAR *kCUKeyPath = REG_PATH_FM;
static const WCHAR *kExtPlugins = L"Plugins"; static const WCHAR *kExtPlugins = L"Plugins";
static const TCHAR *kExtEnabled = TEXT("Enabled"); static const TCHAR *kExtEnabled = TEXT("Enabled");
static CSysString GetAssociationsPath() #define kAssociations TEXT("Associations")
{ #define kAssociationsPath REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) kAssociations
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, GetAssociationsPath() + CSysString('\\') + if (key.Open(HKEY_CURRENT_USER,
CSysString(GetSystemString(ext)), KEY_READ) != ERROR_SUCCESS) CSysString(kAssociationsPath TEXT(STRING_PATH_SEPARATOR)) +
GetSystemString(ext), KEY_READ) != ERROR_SUCCESS)
return false; return false;
UString pluginsString; UString pluginsString;
key.QueryValue(kExtPlugins, pluginsString); key.QueryValue(kExtPlugins, pluginsString);
@@ -51,7 +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, GetAssociationsPath(), KEY_READ) != ERROR_SUCCESS) if (associationsKey.Open(HKEY_CURRENT_USER, kAssociationsPath, KEY_READ) != ERROR_SUCCESS)
return; return;
CSysStringVector extNames; CSysStringVector extNames;
associationsKey.EnumKeys(extNames); associationsKey.EnumKeys(extNames);
@@ -62,7 +62,7 @@ void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
// extInfo.Enabled = false; // extInfo.Enabled = false;
extInfo.Ext = GetUnicodeString(extName); extInfo.Ext = GetUnicodeString(extName);
CKey key; CKey key;
if(key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS) if (key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS)
return; return;
UString pluginsString; UString pluginsString;
key.QueryValue(kExtPlugins, pluginsString); key.QueryValue(kExtPlugins, pluginsString);
@@ -129,7 +129,7 @@ static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconP
if (programNameValue.CompareNoCase(extProgramKeyName) != 0) if (programNameValue.CompareNoCase(extProgramKeyName) != 0)
return false; return false;
CKey iconKey; CKey iconKey;
if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT('\\')) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS) if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS)
return false; return false;
UString value; UString value;
if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS) if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS)

View File

@@ -110,7 +110,7 @@ void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
if (::ReadPluginInfo(pluginInfo)) if (::ReadPluginInfo(pluginInfo))
plugins.Add(pluginInfo); plugins.Add(pluginInfo);
} }
UString folderPath = baseFolderPrefix + L"Plugins\\"; UString folderPath = baseFolderPrefix + L"Plugins" WSTRING_PATH_SEPARATOR;
NFind::CEnumeratorW enumerator(folderPath + L"*"); NFind::CEnumeratorW enumerator(folderPath + L"*");
NFind::CFileInfoW fileInfo; NFind::CFileInfoW fileInfo;
while (enumerator.Next(fileInfo)) while (enumerator.Next(fileInfo))

View File

@@ -8,9 +8,11 @@
using namespace NWindows; using namespace NWindows;
using namespace NRegistry; using namespace NRegistry;
static const TCHAR *kCUBasePath = TEXT("Software\\7-ZIP"); #define REG_PATH_7Z TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP")
static const TCHAR *kCU_FMPath = TEXT("Software\\7-ZIP\\FM");
// static const TCHAR *kLM_Path = TEXT("Software\\7-ZIP\\FM"); static const TCHAR *kCUBasePath = REG_PATH_7Z;
static const TCHAR *kCU_FMPath = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM");
// static const TCHAR *kLM_Path = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM");
static const WCHAR *kLangValueName = L"Lang"; static const WCHAR *kLangValueName = L"Lang";
static const WCHAR *kEditor = L"Editor"; static const WCHAR *kEditor = L"Editor";

View File

@@ -95,8 +95,8 @@ UString GetMyDocsPath()
us = GetUnicodeString(s2); us = GetUnicodeString(s2);
} }
#endif #endif
if (us.Length() > 0 && us[us.Length() - 1] != L'\\') if (us.Length() > 0 && us[us.Length() - 1] != WCHAR_PATH_SEPARATOR)
us += L'\\'; us += WCHAR_PATH_SEPARATOR;
return us; return us;
} }
@@ -113,7 +113,7 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde
{ {
CNetFolder *netFolderSpec = new CNetFolder; CNetFolder *netFolderSpec = new CNetFolder;
CMyComPtr<IFolderFolder> subFolder = netFolderSpec; CMyComPtr<IFolderFolder> subFolder = netFolderSpec;
netFolderSpec->Init(0, 0, _names[ROOT_INDEX_NETWORK] + L'\\'); netFolderSpec->Init(0, 0, _names[ROOT_INDEX_NETWORK] + WCHAR_PATH_SEPARATOR);
*resultFolder = subFolder.Detach(); *resultFolder = subFolder.Detach();
} }
else if (index == ROOT_INDEX_DOCUMENTS) else if (index == ROOT_INDEX_DOCUMENTS)
@@ -134,7 +134,7 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde
static bool AreEqualNames(const UString &name1, const UString &name2) static bool AreEqualNames(const UString &name1, const UString &name2)
{ {
return (name1 == name2 || name1 == (name2 + UString(L'\\'))); return (name1 == name2 || name1 == (name2 + UString(WCHAR_PATH_SEPARATOR)));
} }
STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
@@ -159,7 +159,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu
if (AreEqualNames(name2, L"My Computer") || if (AreEqualNames(name2, L"My Computer") ||
AreEqualNames(name2, L"Computer")) AreEqualNames(name2, L"Computer"))
return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder); return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder);
if (name2 == UString(L'\\')) if (name2 == UString(WCHAR_PATH_SEPARATOR))
{ {
CMyComPtr<IFolderFolder> subFolder = this; CMyComPtr<IFolderFolder> subFolder = this;
*resultFolder = subFolder.Detach(); *resultFolder = subFolder.Detach();
@@ -179,13 +179,13 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu
} }
else else
{ {
if (name2[name2.Length () - 1] != L'\\') if (name2[name2.Length () - 1] != WCHAR_PATH_SEPARATOR)
name2 += L'\\'; name2 += WCHAR_PATH_SEPARATOR;
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
subFolder = fsFolderSpec; subFolder = fsFolderSpec;
if (fsFolderSpec->Init(name2, 0) != S_OK) if (fsFolderSpec->Init(name2, 0) != S_OK)
{ {
if (name2[0] == L'\\') if (name2[0] == WCHAR_PATH_SEPARATOR)
{ {
CNetFolder *netFolderSpec = new CNetFolder; CNetFolder *netFolderSpec = new CNetFolder;
subFolder = netFolderSpec; subFolder = netFolderSpec;
@@ -240,7 +240,3 @@ STDMETHODIMP CRootFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
*iconIndex = _iconIndices[index]; *iconIndex = _iconIndices[index];
return S_OK; return S_OK;
} }

View File

@@ -93,9 +93,7 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefi
*/ */
} }
*passwordIsDefined = BoolToInt(_passwordIsDefined); *passwordIsDefined = BoolToInt(_passwordIsDefined);
CMyComBSTR tempName = _password; return StringToBstr(_password, password);
*password = tempName.Detach();
return S_OK;
} }
STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */) STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
@@ -112,8 +110,5 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password)
{ {
if (!_passwordIsDefined) if (!_passwordIsDefined)
return S_FALSE; return S_FALSE;
CMyComBSTR tempName = _password; return StringToBstr(_password, password);
*password = tempName.Detach();
return S_OK;
} }

View File

@@ -12,9 +12,10 @@
using namespace NWindows; using namespace NWindows;
using namespace NRegistry; using namespace NRegistry;
static const TCHAR *kCUBasePath = TEXT("Software\\7-Zip\\FM"); #define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") TEXT(STRING_PATH_SEPARATOR) TEXT("FM")
static const TCHAR *kCulumnsKeyName = TEXT("Columns"); static const TCHAR *kCUBasePath = REG_PATH_FM;
static const TCHAR *kCulumnsKeyName = REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) TEXT("Columns");
static const TCHAR *kPositionValueName = TEXT("Position"); static const TCHAR *kPositionValueName = TEXT("Position");
static const TCHAR *kPanelsInfoValueName = TEXT("Panels"); static const TCHAR *kPanelsInfoValueName = TEXT("Panels");
@@ -126,11 +127,8 @@ void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo)
} }
{ {
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
CSysString keyName = kCUBasePath;
keyName += kKeyNameDelimiter;
keyName += kCulumnsKeyName;
CKey key; CKey key;
key.Create(HKEY_CURRENT_USER, keyName); key.Create(HKEY_CURRENT_USER, kCulumnsKeyName);
key.SetValue(GetSystemString(id), (const Byte *)buffer, dataSize); key.SetValue(GetSystemString(id), (const Byte *)buffer, dataSize);
} }
} }
@@ -143,11 +141,8 @@ void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo)
UInt32 size; UInt32 size;
{ {
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
CSysString keyName = kCUBasePath;
keyName += kKeyNameDelimiter;
keyName += kCulumnsKeyName;
CKey key; CKey key;
if(key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) if(key.Open(HKEY_CURRENT_USER, kCulumnsKeyName, KEY_READ) != ERROR_SUCCESS)
return; return;
if (key.QueryValue(GetSystemString(id), buffer, size) != ERROR_SUCCESS) if (key.QueryValue(GetSystemString(id), buffer, size) != ERROR_SUCCESS)
return; return;

View File

@@ -426,7 +426,7 @@ void CCompressDialog::OnButtonSFX()
UString fileName; UString fileName;
m_ArchivePath.GetText(fileName); m_ArchivePath.GetText(fileName);
int dotPos = fileName.ReverseFind(L'.'); int dotPos = fileName.ReverseFind(L'.');
int slashPos = fileName.ReverseFind(L'\\'); int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR);
if (dotPos < 0 || dotPos <= slashPos) if (dotPos < 0 || dotPos <= slashPos)
dotPos = -1; dotPos = -1;
bool isSFX = IsSFX(); bool isSFX = IsSFX();
@@ -707,7 +707,7 @@ void CCompressDialog::SetArchiveName(const UString &name)
if (!Info.KeepName) if (!Info.KeepName)
{ {
int dotPos = fileName.ReverseFind('.'); int dotPos = fileName.ReverseFind('.');
int slashPos = MyMax(fileName.ReverseFind('\\'), fileName.ReverseFind('/')); int slashPos = MyMax(fileName.ReverseFind(WCHAR_PATH_SEPARATOR), fileName.ReverseFind('/'));
if (dotPos >= 0 && dotPos > slashPos + 1) if (dotPos >= 0 && dotPos > slashPos + 1)
fileName = fileName.Left(dotPos); fileName = fileName.Left(dotPos);
} }

View File

@@ -167,9 +167,7 @@ HRESULT CUpdateCallbackGUI::CryptoGetTextPassword2(Int32 *passwordIsDefined, BST
} }
} }
*passwordIsDefined = BoolToInt(PasswordIsDefined); *passwordIsDefined = BoolToInt(PasswordIsDefined);
CMyComBSTR tempName(Password); return StringToBstr(Password, password);
*password = tempName.Detach();
return S_OK;
} }
/* /*
@@ -211,9 +209,7 @@ HRESULT CUpdateCallbackGUI::Open_CryptoGetTextPassword(BSTR *password)
Password = dialog.Password; Password = dialog.Password;
PasswordIsDefined = true; PasswordIsDefined = true;
} }
CMyComBSTR tempName(Password); return StringToBstr(Password, password);
*password = tempName.Detach();
return S_OK;
} }
HRESULT CUpdateCallbackGUI::Open_GetPasswordIfAny(UString &password) HRESULT CUpdateCallbackGUI::Open_GetPasswordIfAny(UString &password)

View File

@@ -239,7 +239,7 @@ static HRESULT ShowDialog(
for (int i = 0; i < item.PathParts.Size(); i++) for (int i = 0; i < item.PathParts.Size(); i++)
{ {
if (i > 0) if (i > 0)
name += L'\\'; name += WCHAR_PATH_SEPARATOR;
name += item.PathParts[i]; name += item.PathParts[i];
} }
if (NFind::FindFile(name, fileInfo)) if (NFind::FindFile(name, fileInfo))

View File

@@ -32,7 +32,7 @@ public:
if (newCapacity > 0) if (newCapacity > 0)
{ {
newBuffer = new T[newCapacity]; newBuffer = new T[newCapacity];
if(_capacity > 0) if (_capacity > 0)
memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T)); memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T));
} }
else else
@@ -44,7 +44,7 @@ public:
CBuffer& operator=(const CBuffer &buffer) CBuffer& operator=(const CBuffer &buffer)
{ {
Free(); Free();
if(buffer._capacity > 0) if (buffer._capacity > 0)
{ {
SetCapacity(buffer._capacity); SetCapacity(buffer._capacity);
memmove(_items, buffer._items, buffer._capacity * sizeof(T)); memmove(_items, buffer._items, buffer._capacity * sizeof(T));

View File

@@ -21,7 +21,7 @@ bool CFileBase::OpenBinary(const char *name, int flags)
bool CFileBase::Close() bool CFileBase::Close()
{ {
if(_handle == -1) if (_handle == -1)
return true; return true;
if (close(_handle) != 0) if (close(_handle) != 0)
return false; return false;

View File

@@ -99,14 +99,14 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
int pos = 0; int pos = 0;
if (!IsItSwitchChar(s[pos])) if (!IsItSwitchChar(s[pos]))
return false; return false;
while(pos < len) while (pos < len)
{ {
if (IsItSwitchChar(s[pos])) if (IsItSwitchChar(s[pos]))
pos++; pos++;
const int kNoLen = -1; const int kNoLen = -1;
int matchedSwitchIndex = 0; // GCC Warning int matchedSwitchIndex = 0; // GCC Warning
int maxLen = kNoLen; int maxLen = kNoLen;
for(int switchIndex = 0; switchIndex < _numSwitches; switchIndex++) for (int switchIndex = 0; switchIndex < _numSwitches; switchIndex++)
{ {
int switchLen = MyStringLen(switchForms[switchIndex].IDString); int switchLen = MyStringLen(switchForms[switchIndex].IDString);
if (switchLen <= maxLen || pos + switchLen > len) if (switchLen <= maxLen || pos + switchLen > len)
@@ -114,8 +114,8 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
UString temp = s + pos; UString temp = s + pos;
temp = temp.Left(switchLen); temp = temp.Left(switchLen);
if(temp.CompareNoCase(switchForms[switchIndex].IDString) == 0) if (temp.CompareNoCase(switchForms[switchIndex].IDString) == 0)
// if(_strnicmp(switchForms[switchIndex].IDString, LPCSTR(s) + pos, switchLen) == 0) // if (_strnicmp(switchForms[switchIndex].IDString, LPCSTR(s) + pos, switchLen) == 0)
{ {
matchedSwitchIndex = switchIndex; matchedSwitchIndex = switchIndex;
maxLen = switchLen; maxLen = switchLen;
@@ -180,7 +180,7 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
int maxLen = switchForm.MaxLen; int maxLen = switchForm.MaxLen;
UString stringSwitch = s.Mid(pos, minLen); UString stringSwitch = s.Mid(pos, minLen);
pos += minLen; pos += minLen;
for(int i = minLen; i < maxLen && pos < len; i++, pos++) for (int i = minLen; i < maxLen && pos < len; i++, pos++)
{ {
wchar_t c = s[pos]; wchar_t c = s[pos];
if (IsItSwitchChar(c)) if (IsItSwitchChar(c))
@@ -208,12 +208,12 @@ const CSwitchResult& CParser::operator[](size_t index) const
int ParseCommand(int numCommandForms, const CCommandForm *commandForms, int ParseCommand(int numCommandForms, const CCommandForm *commandForms,
const UString &commandString, UString &postString) const UString &commandString, UString &postString)
{ {
for(int i = 0; i < numCommandForms; i++) for (int i = 0; i < numCommandForms; i++)
{ {
const UString id = commandForms[i].IDString; const UString id = commandForms[i].IDString;
if (commandForms[i].PostStringMode) if (commandForms[i].PostStringMode)
{ {
if(commandString.Find(id) == 0) if (commandString.Find(id) == 0)
{ {
postString = commandString.Mid(id.Length()); postString = commandString.Mid(id.Length());
return i; return i;

View File

@@ -26,7 +26,7 @@ public:
CDynamicBuffer& operator=(const CDynamicBuffer &buffer) CDynamicBuffer& operator=(const CDynamicBuffer &buffer)
{ {
this->Free(); this->Free();
if(buffer._capacity > 0) if (buffer._capacity > 0)
{ {
SetCapacity(buffer._capacity); SetCapacity(buffer._capacity);
memmove(this->_items, buffer._items, buffer._capacity * sizeof(T)); memmove(this->_items, buffer._items, buffer._capacity * sizeof(T));

View File

@@ -22,7 +22,7 @@ void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base)
while (value != 0); while (value != 0);
do do
*s++ = temp[--pos]; *s++ = temp[--pos];
while(pos > 0); while (pos > 0);
*s = '\0'; *s = '\0';
} }
@@ -38,7 +38,7 @@ void ConvertUInt64ToString(UInt64 value, wchar_t *s)
while (value != 0); while (value != 0);
do do
*s++ = temp[--pos]; *s++ = temp[--pos];
while(pos > 0); while (pos > 0);
*s = L'\0'; *s = L'\0';
} }

View File

@@ -53,7 +53,7 @@ bool ReadNamesFromListFile(LPCWSTR fileName, UStringVector &resultStrings, UINT
} }
UString t; UString t;
for(int i = 0; i < u.Length(); i++) for (int i = 0; i < u.Length(); i++)
{ {
wchar_t c = u[i]; wchar_t c = u[i];
if (c == L'\n' || c == 0xD) if (c == L'\n' || c == 0xD)

View File

@@ -6,7 +6,7 @@
#include "MyWindows.h" #include "MyWindows.h"
#ifndef RINOK #ifndef RINOK
#define RINOK(x) { HRESULT __result_ = (x); if(__result_ != S_OK) return __result_; } #define RINOK(x) { HRESULT __result_ = (x); if (__result_ != S_OK) return __result_; }
#endif #endif
template <class T> template <class T>
@@ -78,12 +78,18 @@ public:
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
inline HRESULT StringToBstr(LPCOLESTR src, BSTR *bstr)
{
*bstr = ::SysAllocString(src);
return (*bstr != 0) ? S_OK : E_OUTOFMEMORY;
}
class CMyComBSTR class CMyComBSTR
{ {
public: public:
BSTR m_str; BSTR m_str;
CMyComBSTR() { m_str = NULL; } CMyComBSTR(): m_str(NULL) {}
CMyComBSTR(LPCOLESTR pSrc) { m_str = ::SysAllocString(pSrc); } CMyComBSTR(LPCOLESTR src) { m_str = ::SysAllocString(src); }
// CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); } // CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); }
// CMyComBSTR(int nSize, LPCOLESTR sz) { m_str = ::SysAllocStringLen(sz, nSize); } // CMyComBSTR(int nSize, LPCOLESTR sz) { m_str = ::SysAllocStringLen(sz, nSize); }
CMyComBSTR(const CMyComBSTR& src) { m_str = src.MyCopy(); } CMyComBSTR(const CMyComBSTR& src) { m_str = src.MyCopy(); }
@@ -107,10 +113,10 @@ public:
} }
return *this; return *this;
} }
CMyComBSTR& operator=(LPCOLESTR pSrc) CMyComBSTR& operator=(LPCOLESTR src)
{ {
::SysFreeString(m_str); ::SysFreeString(m_str);
m_str = ::SysAllocString(pSrc); m_str = ::SysAllocString(src);
return *this; return *this;
} }
unsigned int Length() const { return ::SysStringLen(m_str); } unsigned int Length() const { return ::SysStringLen(m_str); }
@@ -120,16 +126,18 @@ public:
{ {
int byteLen = ::SysStringByteLen(m_str); int byteLen = ::SysStringByteLen(m_str);
BSTR res = ::SysAllocStringByteLen(NULL, byteLen); BSTR res = ::SysAllocStringByteLen(NULL, byteLen);
memmove(res, m_str, byteLen); memcpy(res, m_str, byteLen);
return res; return res;
} }
void Attach(BSTR src) { m_str = src; } /*
void Attach(BSTR src) { m_str = src; }
BSTR Detach() BSTR Detach()
{ {
BSTR s = m_str; BSTR s = m_str;
m_str = NULL; m_str = NULL;
return s; return s;
} }
*/
void Empty() void Empty()
{ {
::SysFreeString(m_str); ::SysFreeString(m_str);
@@ -138,7 +146,6 @@ public:
bool operator!() const { return (m_str == NULL); } bool operator!() const { return (m_str == NULL); }
}; };
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
class CMyUnknownImp class CMyUnknownImp

View File

@@ -24,7 +24,7 @@ template <class T>
inline T * MyStringCopy(T *dest, const T *src) inline T * MyStringCopy(T *dest, const T *src)
{ {
T *destStart = dest; T *destStart = dest;
while((*dest++ = *src++) != 0); while ((*dest++ = *src++) != 0);
return destStart; return destStart;
} }
@@ -131,7 +131,7 @@ class CStringBase
pLast = NULL; pLast = NULL;
p = GetNextCharPointer(p); p = GetNextCharPointer(p);
} }
if(pLast != NULL) if (pLast != NULL)
{ {
int i = (int)(pLast - _chars); int i = (int)(pLast - _chars);
Delete(i, _length - i); Delete(i, _length - i);
@@ -172,7 +172,7 @@ protected:
/* /*
const int kMaxStringSize = 0x20000000; const int kMaxStringSize = 0x20000000;
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
if(newCapacity > kMaxStringSize || newCapacity < _length) if (newCapacity > kMaxStringSize || newCapacity < _length)
throw 1052337; throw 1052337;
#endif #endif
*/ */
@@ -250,7 +250,7 @@ public:
{ {
/* /*
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
if(newLength >= _capacity) if (newLength >= _capacity)
throw 282217; throw 282217;
#endif #endif
*/ */
@@ -278,7 +278,7 @@ public:
} }
CStringBase& operator=(const CStringBase& s) CStringBase& operator=(const CStringBase& s)
{ {
if(&s == this) if (&s == this)
return *this; return *this;
Empty(); Empty();
SetCapacity(s._length); SetCapacity(s._length);
@@ -414,7 +414,7 @@ public:
} }
int FindOneOf(const CStringBase &s) const int FindOneOf(const CStringBase &s) const
{ {
for(int i = 0; i < _length; i++) for (int i = 0; i < _length; i++)
if (s.Find(_chars[i]) >= 0) if (s.Find(_chars[i]) >= 0)
return i; return i;
return -1; return -1;
@@ -461,7 +461,7 @@ public:
pLast = NULL; pLast = NULL;
p = GetNextCharPointer(p); p = GetNextCharPointer(p);
} }
if(pLast != NULL) if (pLast != NULL)
{ {
int i = pLast - _chars; int i = pLast - _chars;
Delete(i, _length - i); Delete(i, _length - i);
@@ -487,7 +487,7 @@ public:
return _length; return _length;
int numInsertChars = s.Length(); int numInsertChars = s.Length();
InsertSpace(index, numInsertChars); InsertSpace(index, numInsertChars);
for(int i = 0; i < numInsertChars; i++) for (int i = 0; i < numInsertChars; i++)
_chars[index + i] = s[i]; _chars[index + i] = s[i];
_length += numInsertChars; _length += numInsertChars;
return _length; return _length;

View File

@@ -47,7 +47,7 @@ public:
{ {
int size = v.Size(); int size = v.Size();
Reserve(Size() + size); Reserve(Size() + size);
for(int i = 0; i < size; i++) for (int i = 0; i < size; i++)
Add(v[i]); Add(v[i]);
return *this; return *this;
} }
@@ -141,7 +141,7 @@ public:
int i = size / 2; int i = size / 2;
do do
SortRefDown(p, i, size, compare, param); SortRefDown(p, i, size, compare, param);
while(--i != 0); while (--i != 0);
} }
do do
{ {
@@ -176,7 +176,7 @@ public:
{ {
int size = v.Size(); int size = v.Size();
Reserve(Size() + size); Reserve(Size() + size);
for(int i = 0; i < size; i++) for (int i = 0; i < size; i++)
Add(v[i]); Add(v[i]);
return *this; return *this;
} }
@@ -191,13 +191,13 @@ public:
virtual void Delete(int index, int num = 1) virtual void Delete(int index, int num = 1)
{ {
TestIndexAndCorrectNum(index, num); TestIndexAndCorrectNum(index, num);
for(int i = 0; i < num; i++) for (int i = 0; i < num; i++)
delete (T *)(((void **)_items)[index + i]); delete (T *)(((void **)_items)[index + i]);
CPointerVector::Delete(index, num); CPointerVector::Delete(index, num);
} }
int Find(const T& item) const int Find(const T& item) const
{ {
for(int i = 0; i < Size(); i++) for (int i = 0; i < Size(); i++)
if (item == (*this)[i]) if (item == (*this)[i])
return i; return i;
return -1; return -1;

View File

@@ -94,14 +94,10 @@ HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src)
LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2) LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2)
{ {
if(ft1->dwHighDateTime < ft2->dwHighDateTime) if (ft1->dwHighDateTime < ft2->dwHighDateTime) return -1;
return -1; if (ft1->dwHighDateTime > ft2->dwHighDateTime) return 1;
if(ft1->dwHighDateTime > ft2->dwHighDateTime) if (ft1->dwLowDateTime < ft2->dwLowDateTime) return -1;
return 1; if (ft1->dwLowDateTime > ft2->dwLowDateTime) return 1;
if(ft1->dwLowDateTime < ft2->dwLowDateTime)
return -1;
if(ft1->dwLowDateTime > ft2->dwLowDateTime)
return 1;
return 0; return 0;
} }

View File

@@ -31,7 +31,7 @@ bool CStdInStream::Open(LPCTSTR fileName)
bool CStdInStream::Close() bool CStdInStream::Close()
{ {
if(!_streamIsOpen) if (!_streamIsOpen)
return true; return true;
_streamIsOpen = (fclose(_stream) != 0); _streamIsOpen = (fclose(_stream) != 0);
return !_streamIsOpen; return !_streamIsOpen;
@@ -48,12 +48,12 @@ AString CStdInStream::ScanStringUntilNewLine()
for (;;) for (;;)
{ {
int intChar = GetChar(); int intChar = GetChar();
if(intChar == EOF) if (intChar == EOF)
throw kEOFMessage; throw kEOFMessage;
char c = char(intChar); char c = char(intChar);
if (c == kIllegalChar) if (c == kIllegalChar)
throw kIllegalCharMessage; throw kIllegalCharMessage;
if(c == kNewLineChar) if (c == kNewLineChar)
break; break;
s += c; s += c;
} }
@@ -64,7 +64,7 @@ void CStdInStream::ReadToString(AString &resultString)
{ {
resultString.Empty(); resultString.Empty();
int c; int c;
while((c = GetChar()) != EOF) while ((c = GetChar()) != EOF)
resultString += char(c); resultString += char(c);
} }
@@ -76,7 +76,7 @@ bool CStdInStream::Eof()
int CStdInStream::GetChar() int CStdInStream::GetChar()
{ {
int c = fgetc(_stream); // getc() doesn't work in BeOS? int c = fgetc(_stream); // getc() doesn't work in BeOS?
if(c == EOF && !Eof()) if (c == EOF && !Eof())
throw kReadErrorMessage; throw kReadErrorMessage;
return c; return c;
} }

View File

@@ -30,7 +30,7 @@ bool CStdOutStream::Open(const char *fileName)
bool CStdOutStream::Close() bool CStdOutStream::Close()
{ {
if(!_streamIsOpen) if (!_streamIsOpen)
return true; return true;
if (fclose(_stream) != 0) if (fclose(_stream) != 0)
return false; return false;

View File

@@ -12,13 +12,13 @@
UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
{ {
UString resultString; UString resultString;
if(!srcString.IsEmpty()) if (!srcString.IsEmpty())
{ {
int numChars = MultiByteToWideChar(codePage, 0, srcString, int numChars = MultiByteToWideChar(codePage, 0, srcString,
srcString.Length(), resultString.GetBuffer(srcString.Length()), srcString.Length(), resultString.GetBuffer(srcString.Length()),
srcString.Length() + 1); srcString.Length() + 1);
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
if(numChars == 0) if (numChars == 0)
throw 282228; throw 282228;
#endif #endif
resultString.ReleaseBuffer(numChars); resultString.ReleaseBuffer(numChars);
@@ -39,7 +39,7 @@ AString UnicodeStringToMultiByte(const UString &s, UINT codePage, char defaultCh
&defaultChar, &defUsed); &defaultChar, &defUsed);
defaultCharWasUsed = (defUsed != FALSE); defaultCharWasUsed = (defUsed != FALSE);
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
if(numChars == 0) if (numChars == 0)
throw 282229; throw 282229;
#endif #endif
dest.ReleaseBuffer(numChars); dest.ReleaseBuffer(numChars);
@@ -71,7 +71,7 @@ UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
for (int i = 0; i < srcString.Length(); i++) for (int i = 0; i < srcString.Length(); i++)
resultString += wchar_t(srcString[i]); resultString += wchar_t(srcString[i]);
/* /*
if(!srcString.IsEmpty()) if (!srcString.IsEmpty())
{ {
int numChars = mbstowcs(resultString.GetBuffer(srcString.Length()), srcString, srcString.Length() + 1); int numChars = mbstowcs(resultString.GetBuffer(srcString.Length()), srcString, srcString.Length() + 1);
if (numChars < 0) throw "Your environment does not support UNICODE"; if (numChars < 0) throw "Your environment does not support UNICODE";
@@ -87,7 +87,7 @@ AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
for (int i = 0; i < srcString.Length(); i++) for (int i = 0; i < srcString.Length(); i++)
resultString += char(srcString[i]); resultString += char(srcString[i]);
/* /*
if(!srcString.IsEmpty()) if (!srcString.IsEmpty())
{ {
int numRequiredBytes = srcString.Length() * 6 + 1; int numRequiredBytes = srcString.Length() * 6 + 1;
int numChars = wcstombs(resultString.GetBuffer(numRequiredBytes), srcString, numRequiredBytes); int numChars = wcstombs(resultString.GetBuffer(numRequiredBytes), srcString, numRequiredBytes);

View File

@@ -106,8 +106,8 @@ void SplitPathToParts(const UString &path, UStringVector &pathParts)
void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name) void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name)
{ {
int i; int i;
for(i = path.Length() - 1; i >= 0; i--) for (i = path.Length() - 1; i >= 0; i--)
if(IsCharDirLimiter(path[i])) if (IsCharDirLimiter(path[i]))
break; break;
dirPrefix = path.Left(i + 1); dirPrefix = path.Left(i + 1);
name = path.Mid(i + 1); name = path.Mid(i + 1);
@@ -116,8 +116,8 @@ void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name)
UString ExtractDirPrefixFromPath(const UString &path) UString ExtractDirPrefixFromPath(const UString &path)
{ {
int i; int i;
for(i = path.Length() - 1; i >= 0; i--) for (i = path.Length() - 1; i >= 0; i--)
if(IsCharDirLimiter(path[i])) if (IsCharDirLimiter(path[i]))
break; break;
return path.Left(i + 1); return path.Left(i + 1);
} }
@@ -125,8 +125,8 @@ UString ExtractDirPrefixFromPath(const UString &path)
UString ExtractFileNameFromPath(const UString &path) UString ExtractFileNameFromPath(const UString &path)
{ {
int i; int i;
for(i = path.Length() - 1; i >= 0; i--) for (i = path.Length() - 1; i >= 0; i--)
if(IsCharDirLimiter(path[i])) if (IsCharDirLimiter(path[i]))
break; break;
return path.Mid(i + 1); return path.Mid(i + 1);
} }
@@ -309,7 +309,7 @@ bool CCensorNode::CheckPath(const UString &path, bool isFile, bool &include) con
bool CCensorNode::CheckPath(const UString &path, bool isFile) const bool CCensorNode::CheckPath(const UString &path, bool isFile) const
{ {
bool include; bool include;
if(CheckPath(path, isFile, include)) if (CheckPath(path, isFile, include))
return include; return include;
return false; return false;
} }

View File

@@ -26,7 +26,7 @@ public:
~CStgMedium() { Free(); } ~CStgMedium() { Free(); }
void Free() void Free()
{ {
if(_mustBeReleased) if (_mustBeReleased)
ReleaseStgMedium(&_object); ReleaseStgMedium(&_object);
_mustBeReleased = false; _mustBeReleased = false;
} }

View File

@@ -16,7 +16,7 @@ public:
CImageList(): m_Object(NULL) {} CImageList(): m_Object(NULL) {}
bool Attach(HIMAGELIST imageList) bool Attach(HIMAGELIST imageList)
{ {
if(imageList == NULL) if (imageList == NULL)
return false; return false;
m_Object = imageList; m_Object = imageList;
return true; return true;
@@ -33,7 +33,7 @@ public:
{ {
HIMAGELIST a = ImageList_Create(width, height, flags, HIMAGELIST a = ImageList_Create(width, height, flags,
initialNumber, grow); initialNumber, grow);
if(a == NULL) if (a == NULL)
return false; return false;
return Attach(a); return Attach(a);
} }

View File

@@ -49,7 +49,7 @@ bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className,
HINSTANCE instance) HINSTANCE instance)
{ {
WNDCLASS windowClass; WNDCLASS windowClass;
if(!::GetClassInfo(instance, className, &windowClass)) if (!::GetClassInfo(instance, className, &windowClass))
{ {
// windowClass.style = CS_HREDRAW | CS_VREDRAW; // windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.style = 0; windowClass.style = 0;
@@ -80,7 +80,7 @@ bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className,
HINSTANCE instance) HINSTANCE instance)
{ {
bool needRegister; bool needRegister;
if(g_IsNT) if (g_IsNT)
{ {
WNDCLASSW windowClass; WNDCLASSW windowClass;
needRegister = ::GetClassInfoW(instance, className, &windowClass) == 0; needRegister = ::GetClassInfoW(instance, className, &windowClass) == 0;

View File

@@ -36,7 +36,7 @@ bool CLibrary::LoadOperations(HMODULE newModule)
{ {
if (newModule == NULL) if (newModule == NULL)
return false; return false;
if(!Free()) if (!Free())
return false; return false;
_module = newModule; _module = newModule;
return true; return true;

View File

@@ -17,7 +17,7 @@ namespace NError {
bool MyFormatMessage(DWORD messageID, CSysString &message) bool MyFormatMessage(DWORD messageID, CSysString &message)
{ {
LPVOID msgBuf; LPVOID msgBuf;
if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,messageID, 0, (LPTSTR) &msgBuf,0, NULL) == 0) NULL,messageID, 0, (LPTSTR) &msgBuf,0, NULL) == 0)
return false; return false;
@@ -32,7 +32,7 @@ bool MyFormatMessage(DWORD messageID, UString &message)
if (g_IsNT) if (g_IsNT)
{ {
LPVOID msgBuf; LPVOID msgBuf;
if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | if (::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, messageID, 0, (LPWSTR) &msgBuf, 0, NULL) == 0) NULL, messageID, 0, (LPWSTR) &msgBuf, 0, NULL) == 0)
return false; return false;

View File

@@ -250,12 +250,12 @@ bool CreateComplexDirectory(LPCTSTR pathName)
path.ParsePath(pathName); path.ParsePath(pathName);
CSysString fullPath = path.Prefix; CSysString fullPath = path.Prefix;
DWORD errorCode = ERROR_SUCCESS; DWORD errorCode = ERROR_SUCCESS;
for(int i = 0; i < path.PathParts.Size(); i++) for (int i = 0; i < path.PathParts.Size(); i++)
{ {
const CSysString &string = path.PathParts[i]; const CSysString &string = path.PathParts[i];
if(string.IsEmpty()) if (string.IsEmpty())
{ {
if(i != path.PathParts.Size() - 1) if (i != path.PathParts.Size() - 1)
return false; return false;
return true; return true;
} }
@@ -263,7 +263,7 @@ bool CreateComplexDirectory(LPCTSTR pathName)
if (!MyCreateDirectory(fullPath)) if (!MyCreateDirectory(fullPath))
{ {
DWORD errorCode = GetLastError(); DWORD errorCode = GetLastError();
if(errorCode != ERROR_ALREADY_EXISTS) if (errorCode != ERROR_ALREADY_EXISTS)
return false; return false;
} }
fullPath += NName::kDirDelimiter; fullPath += NName::kDirDelimiter;
@@ -286,7 +286,7 @@ bool CreateComplexDirectory(LPCTSTR _aPathName)
pos = pathName.Length(); pos = pathName.Length();
for (;;) for (;;)
{ {
if(MyCreateDirectory(pathName)) if (MyCreateDirectory(pathName))
break; break;
if (::GetLastError() == ERROR_ALREADY_EXISTS) if (::GetLastError() == ERROR_ALREADY_EXISTS)
{ {
@@ -305,7 +305,7 @@ bool CreateComplexDirectory(LPCTSTR _aPathName)
pathName = pathName.Left(pos); pathName = pathName.Left(pos);
} }
pathName = pathName2; pathName = pathName2;
while(pos < pathName.Length()) while (pos < pathName.Length())
{ {
pos = pathName.Find(TEXT(CHAR_PATH_SEPARATOR), pos + 1); pos = pathName.Find(TEXT(CHAR_PATH_SEPARATOR), pos + 1);
if (pos < 0) if (pos < 0)
@@ -332,7 +332,7 @@ bool CreateComplexDirectory(LPCWSTR _aPathName)
pos = pathName.Length(); pos = pathName.Length();
for (;;) for (;;)
{ {
if(MyCreateDirectory(pathName)) if (MyCreateDirectory(pathName))
break; break;
if (::GetLastError() == ERROR_ALREADY_EXISTS) if (::GetLastError() == ERROR_ALREADY_EXISTS)
{ {
@@ -351,7 +351,7 @@ bool CreateComplexDirectory(LPCWSTR _aPathName)
pathName = pathName.Left(pos); pathName = pathName.Left(pos);
} }
pathName = pathName2; pathName = pathName2;
while(pos < pathName.Length()) while (pos < pathName.Length())
{ {
pos = pathName.Find(WCHAR_PATH_SEPARATOR, pos + 1); pos = pathName.Find(WCHAR_PATH_SEPARATOR, pos + 1);
if (pos < 0) if (pos < 0)
@@ -398,7 +398,7 @@ bool DeleteFileAlways(LPCWSTR name)
static bool RemoveDirectorySubItems2(const CSysString pathPrefix, const NFind::CFileInfo &fileInfo) static bool RemoveDirectorySubItems2(const CSysString pathPrefix, const NFind::CFileInfo &fileInfo)
{ {
if(fileInfo.IsDir()) if (fileInfo.IsDir())
return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name); return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
return DeleteFileAlways(pathPrefix + fileInfo.Name); return DeleteFileAlways(pathPrefix + fileInfo.Name);
} }
@@ -409,7 +409,7 @@ bool RemoveDirectoryWithSubItems(const CSysString &path)
CSysString pathPrefix = path + NName::kDirDelimiter; CSysString pathPrefix = path + NName::kDirDelimiter;
{ {
NFind::CEnumerator enumerator(pathPrefix + TCHAR(NName::kAnyStringWildcard)); NFind::CEnumerator enumerator(pathPrefix + TCHAR(NName::kAnyStringWildcard));
while(enumerator.Next(fileInfo)) while (enumerator.Next(fileInfo))
if (!RemoveDirectorySubItems2(pathPrefix, fileInfo)) if (!RemoveDirectorySubItems2(pathPrefix, fileInfo))
return false; return false;
} }
@@ -421,7 +421,7 @@ bool RemoveDirectoryWithSubItems(const CSysString &path)
#ifndef _UNICODE #ifndef _UNICODE
static bool RemoveDirectorySubItems2(const UString pathPrefix, const NFind::CFileInfoW &fileInfo) static bool RemoveDirectorySubItems2(const UString pathPrefix, const NFind::CFileInfoW &fileInfo)
{ {
if(fileInfo.IsDir()) if (fileInfo.IsDir())
return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name); return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
return DeleteFileAlways(pathPrefix + fileInfo.Name); return DeleteFileAlways(pathPrefix + fileInfo.Name);
} }
@@ -431,7 +431,7 @@ bool RemoveDirectoryWithSubItems(const UString &path)
UString pathPrefix = path + UString(NName::kDirDelimiter); UString pathPrefix = path + UString(NName::kDirDelimiter);
{ {
NFind::CEnumeratorW enumerator(pathPrefix + UString(NName::kAnyStringWildcard)); NFind::CEnumeratorW enumerator(pathPrefix + UString(NName::kAnyStringWildcard));
while(enumerator.Next(fileInfo)) while (enumerator.Next(fileInfo))
if (!RemoveDirectorySubItems2(pathPrefix, fileInfo)) if (!RemoveDirectorySubItems2(pathPrefix, fileInfo))
return false; return false;
} }
@@ -700,7 +700,7 @@ UINT CTempFile::Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath)
{ {
Remove(); Remove();
UINT number = MyGetTempFileName(dirPath, prefix, resultPath); UINT number = MyGetTempFileName(dirPath, prefix, resultPath);
if(number != 0) if (number != 0)
{ {
_fileName = resultPath; _fileName = resultPath;
_mustBeDeleted = true; _mustBeDeleted = true;
@@ -734,7 +734,7 @@ UINT CTempFileW::Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath)
{ {
Remove(); Remove();
UINT number = MyGetTempFileName(dirPath, prefix, resultPath); UINT number = MyGetTempFileName(dirPath, prefix, resultPath);
if(number != 0) if (number != 0)
{ {
_fileName = resultPath; _fileName = resultPath;
_mustBeDeleted = true; _mustBeDeleted = true;
@@ -784,7 +784,7 @@ bool CreateTempDirectory(LPCTSTR prefix, CSysString &dirName)
_stprintf(randomNumberString, _T("%04X"), randomNumber); _stprintf(randomNumberString, _T("%04X"), randomNumber);
dirName = prefix + randomNumberString; dirName = prefix + randomNumberString;
*/ */
if(NFind::DoesFileExist(dirName)) if (NFind::DoesFileExist(dirName))
continue; continue;
if (MyCreateDirectory(dirName)) if (MyCreateDirectory(dirName))
return true; return true;
@@ -821,7 +821,7 @@ bool CreateTempDirectory(LPCWSTR prefix, UString &dirName)
_stprintf(randomNumberString, _T("%04X"), randomNumber); _stprintf(randomNumberString, _T("%04X"), randomNumber);
dirName = prefix + randomNumberString; dirName = prefix + randomNumberString;
*/ */
if(NFind::DoesFileExist(dirName)) if (NFind::DoesFileExist(dirName))
continue; continue;
if (MyCreateDirectory(dirName)) if (MyCreateDirectory(dirName))
return true; return true;

View File

@@ -344,7 +344,7 @@ bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings)
if (newSize > size) if (newSize > size)
return false; return false;
CSysString string; CSysString string;
for(UINT32 i = 0; i < newSize; i++) for (UINT32 i = 0; i < newSize; i++)
{ {
TCHAR c = buffer[i]; TCHAR c = buffer[i];
if (c == TEXT('\0')) if (c == TEXT('\0'))
@@ -376,7 +376,7 @@ bool MyGetLogicalDriveStrings(UStringVector &driveStrings)
if (newSize > size) if (newSize > size)
return false; return false;
UString string; UString string;
for(UINT32 i = 0; i < newSize; i++) for (UINT32 i = 0; i < newSize; i++)
{ {
WCHAR c = buffer[i]; WCHAR c = buffer[i];
if (c == L'\0') if (c == L'\0')

View File

@@ -126,8 +126,8 @@ bool CFileBase::GetLength(UInt64 &length) const
{ {
DWORD sizeHigh; DWORD sizeHigh;
DWORD sizeLow = ::GetFileSize(_handle, &sizeHigh); DWORD sizeLow = ::GetFileSize(_handle, &sizeHigh);
if(sizeLow == 0xFFFFFFFF) if (sizeLow == 0xFFFFFFFF)
if(::GetLastError() != NO_ERROR) if (::GetLastError() != NO_ERROR)
return false; return false;
length = (((UInt64)sizeHigh) << 32) + sizeLow; length = (((UInt64)sizeHigh) << 32) + sizeLow;
return true; return true;
@@ -139,7 +139,7 @@ bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition
value.QuadPart = distanceToMove; value.QuadPart = distanceToMove;
value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod); value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod);
if (value.LowPart == 0xFFFFFFFF) if (value.LowPart == 0xFFFFFFFF)
if(::GetLastError() != NO_ERROR) if (::GetLastError() != NO_ERROR)
return false; return false;
newPosition = value.QuadPart; newPosition = value.QuadPart;
return true; return true;
@@ -307,9 +307,9 @@ bool COutFile::SetEndOfFile() { return BOOLToBool(::SetEndOfFile(_handle)); }
bool COutFile::SetLength(UInt64 length) bool COutFile::SetLength(UInt64 length)
{ {
UInt64 newPosition; UInt64 newPosition;
if(!Seek(length, newPosition)) if (!Seek(length, newPosition))
return false; return false;
if(newPosition != length) if (newPosition != length)
return false; return false;
return SetEndOfFile(); return SetEndOfFile();
} }

View File

@@ -27,8 +27,6 @@ void NormalizeDirPathPrefix(UString &dirPath)
} }
#endif #endif
#ifdef _WIN32
const wchar_t kExtensionDelimiter = L'.'; const wchar_t kExtensionDelimiter = L'.';
void SplitNameToPureNameAndExtension(const UString &fullName, void SplitNameToPureNameAndExtension(const UString &fullName,
@@ -49,6 +47,4 @@ void SplitNameToPureNameAndExtension(const UString &fullName,
} }
} }
#endif
}}} }}}

View File

@@ -17,10 +17,8 @@ void NormalizeDirPathPrefix(CSysString &dirPath); // ensures that it ended with
void NormalizeDirPathPrefix(UString &dirPath); // ensures that it ended with '\\' void NormalizeDirPathPrefix(UString &dirPath); // ensures that it ended with '\\'
#endif #endif
#ifdef _WIN32
void SplitNameToPureNameAndExtension(const UString &fullName, void SplitNameToPureNameAndExtension(const UString &fullName,
UString &pureName, UString &extensionDelimiter, UString &extension); UString &pureName, UString &extensionDelimiter, UString &extension);
#endif
}}} }}}

View File

@@ -35,7 +35,7 @@ public:
}; };
~CGlobalLock() ~CGlobalLock()
{ {
if(m_Pointer != NULL) if (m_Pointer != NULL)
::GlobalUnlock(m_Global); ::GlobalUnlock(m_Global);
} }
}; };

View File

@@ -67,7 +67,7 @@ bool enable)
bool EnableLockMemoryPrivilege(bool enable) bool EnableLockMemoryPrivilege(bool enable)
{ {
HMODULE hModule = LoadLibrary(TEXT("Advapi32.dll")); HMODULE hModule = LoadLibrary(TEXT("Advapi32.dll"));
if(hModule == NULL) if (hModule == NULL)
return false; return false;
bool res = EnableLockMemoryPrivilege2(hModule, enable); bool res = EnableLockMemoryPrivilege2(hModule, enable);
::FreeLibrary(hModule); ::FreeLibrary(hModule);

View File

@@ -83,7 +83,7 @@ bool CMenu::GetItem(UINT itemIndex, bool byPosition, CMenuItem &item)
si.cch = kMaxSize; si.cch = kMaxSize;
si.dwTypeData = s; si.dwTypeData = s;
} }
if(GetItemInfo(itemIndex, byPosition, &si)) if (GetItemInfo(itemIndex, byPosition, &si))
{ {
ConvertItemToMyForm(si, item); ConvertItemToMyForm(si, item);
if (item.IsString()) if (item.IsString())
@@ -102,7 +102,7 @@ bool CMenu::GetItem(UINT itemIndex, bool byPosition, CMenuItem &item)
si.cch = kMaxSize; si.cch = kMaxSize;
si.dwTypeData = s; si.dwTypeData = s;
} }
if(GetItemInfo(itemIndex, byPosition, &si)) if (GetItemInfo(itemIndex, byPosition, &si))
{ {
ConvertItemToMyForm(si, item); ConvertItemToMyForm(si, item);
if (item.IsString()) if (item.IsString())

View File

@@ -13,7 +13,7 @@ bool MyGetTimeFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
{ {
resultString.Empty(); resultString.Empty();
int numChars = ::GetTimeFormat(locale, flags, time, format, NULL, 0); int numChars = ::GetTimeFormat(locale, flags, time, format, NULL, 0);
if(numChars == 0) if (numChars == 0)
return false; return false;
numChars = ::GetTimeFormat(locale, flags, time, format, numChars = ::GetTimeFormat(locale, flags, time, format,
resultString.GetBuffer(numChars), numChars + 1); resultString.GetBuffer(numChars), numChars + 1);
@@ -26,7 +26,7 @@ bool MyGetDateFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time,
{ {
resultString.Empty(); resultString.Empty();
int numChars = ::GetDateFormat(locale, flags, time, format, NULL, 0); int numChars = ::GetDateFormat(locale, flags, time, format, NULL, 0);
if(numChars == 0) if (numChars == 0)
return false; return false;
numChars = ::GetDateFormat(locale, flags, time, format, numChars = ::GetDateFormat(locale, flags, time, format,
resultString.GetBuffer(numChars), numChars + 1); resultString.GetBuffer(numChars), numChars + 1);

View File

@@ -181,7 +181,7 @@ DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, const CResourceW *resour
DWORD CEnum::Close() DWORD CEnum::Close()
{ {
if(!_handleAllocated) if (!_handleAllocated)
return NO_ERROR; return NO_ERROR;
DWORD result = ::WNetCloseEnum(_handle); DWORD result = ::WNetCloseEnum(_handle);
_handleAllocated = (result != NO_ERROR); _handleAllocated = (result != NO_ERROR);

View File

@@ -259,7 +259,7 @@ void CPropVariant::InternalCopy(const PROPVARIANT* pSrc)
int CPropVariant::Compare(const CPropVariant &a) int CPropVariant::Compare(const CPropVariant &a)
{ {
if(vt != a.vt) if (vt != a.vt)
return 0; // it's mean some bug return 0; // it's mean some bug
switch (vt) switch (vt)
{ {

View File

@@ -2,8 +2,6 @@
#include "StdAfx.h" #include "StdAfx.h"
// #include <stdio.h>
#include "PropVariantConversions.h" #include "PropVariantConversions.h"
#include "Windows/Defs.h" #include "Windows/Defs.h"
@@ -51,7 +49,7 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool
{ {
s[0] = '\0'; s[0] = '\0';
SYSTEMTIME st; SYSTEMTIME st;
if(!BOOLToBool(FileTimeToSystemTime(&ft, &st))) if (!BOOLToBool(FileTimeToSystemTime(&ft, &st)))
return false; return false;
s = UIntToStringSpec(0, st.wYear, s, 4); s = UIntToStringSpec(0, st.wYear, s, 4);
s = UIntToStringSpec('-', st.wMonth, s, 2); s = UIntToStringSpec('-', st.wMonth, s, 2);
@@ -63,15 +61,6 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool
if (includeSeconds) if (includeSeconds)
UIntToStringSpec(':', st.wSecond, s, 2); UIntToStringSpec(':', st.wSecond, s, 2);
} }
/*
sprintf(s, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay);
if (includeTime)
{
sprintf(s + strlen(s), " %02d:%02d", st.wHour, st.wMinute);
if (includeSeconds)
sprintf(s + strlen(s), ":%02d", st.wSecond);
}
*/
return true; return true;
} }

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