From c10e6b16f6d5484ed896b2c614cb7fb77f336d24 Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Tue, 19 Aug 2008 00:00:00 +0000 Subject: 4.60 beta --- C/Archive/7z/7zExtract.c | 4 +- C/Archive/7z/7zIn.c | 12 ++-- C/Archive/7z/7zMain.c | 4 +- C/Bcj2.c | 4 +- C/Bra.h | 4 +- C/Bra86.c | 4 +- C/BwtSort.c | 6 +- C/LzFind.c | 10 ++-- C/LzFindMt.c | 8 +-- C/LzmaDec.c | 8 +-- C/LzmaEnc.c | 6 +- C/Sort.c | 6 +- CPP/7zip/Archive/7z/7zDecode.cpp | 2 +- CPP/7zip/Archive/ElfHandler.cpp | 2 +- CPP/7zip/Archive/PeHandler.cpp | 2 +- CPP/7zip/Archive/Rar/RarHandler.cpp | 4 +- CPP/7zip/Archive/Udf/UdfHandler.cpp | 47 ++++++++++----- CPP/7zip/Archive/Udf/UdfIn.cpp | 73 +++++++++++++++-------- CPP/7zip/Archive/Udf/UdfIn.h | 7 +++ CPP/7zip/Archive/Zip/ZipIn.cpp | 4 +- CPP/7zip/Bundles/SFXSetup/Main.cpp | 4 +- CPP/7zip/MyVersion.h | 10 ++-- CPP/7zip/UI/Agent/Agent.cpp | 13 ++-- CPP/7zip/UI/Agent/AgentOut.cpp | 8 +-- CPP/7zip/UI/Agent/AgentProxy.cpp | 4 +- CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp | 17 ++---- CPP/7zip/UI/Client7z/Client7z.cpp | 12 +--- CPP/7zip/UI/Common/ArchiveName.cpp | 2 +- CPP/7zip/UI/Common/EnumDirItems.cpp | 9 ++- CPP/7zip/UI/Common/LoadCodecs.cpp | 4 +- CPP/7zip/UI/Common/OpenArchive.cpp | 2 +- CPP/7zip/UI/Console/ExtractCallbackConsole.cpp | 4 +- CPP/7zip/UI/Console/OpenCallbackConsole.cpp | 4 +- CPP/7zip/UI/Console/UpdateCallbackConsole.cpp | 7 +-- CPP/7zip/UI/Explorer/ContextMenu.cpp | 38 ++++++------ CPP/7zip/UI/Far/ExtractEngine.cpp | 5 +- CPP/7zip/UI/Far/Main.cpp | 4 +- CPP/7zip/UI/Far/Plugin.cpp | 6 +- CPP/7zip/UI/FileManager/App.cpp | 31 +++++----- CPP/7zip/UI/FileManager/AppState.h | 15 +++-- CPP/7zip/UI/FileManager/ExtractCallback.cpp | 17 ++---- CPP/7zip/UI/FileManager/FM.cpp | 2 +- CPP/7zip/UI/FileManager/FM.dsp | 4 ++ CPP/7zip/UI/FileManager/FSDrives.cpp | 2 +- CPP/7zip/UI/FileManager/FSFolder.cpp | 20 +++---- CPP/7zip/UI/FileManager/FSFolderCopy.cpp | 75 +++++++++++++----------- CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp | 2 +- CPP/7zip/UI/FileManager/NetFolder.cpp | 18 +++--- CPP/7zip/UI/FileManager/OpenCallback.cpp | 4 +- CPP/7zip/UI/FileManager/Panel.cpp | 4 +- CPP/7zip/UI/FileManager/PanelCrc.cpp | 2 +- CPP/7zip/UI/FileManager/PanelDrag.cpp | 27 ++++----- CPP/7zip/UI/FileManager/PanelFolderChange.cpp | 24 +++++--- CPP/7zip/UI/FileManager/PanelItems.cpp | 2 +- CPP/7zip/UI/FileManager/PanelMenu.cpp | 4 +- CPP/7zip/UI/FileManager/PanelOperations.cpp | 4 +- CPP/7zip/UI/FileManager/PhysDriveFolder.cpp | 2 +- CPP/7zip/UI/FileManager/PluginsPage.cpp | 16 +++-- CPP/7zip/UI/FileManager/ProgramLocation.cpp | 2 +- CPP/7zip/UI/FileManager/ProgressDialog2.cpp | 2 +- CPP/7zip/UI/FileManager/RegistryAssociations.cpp | 22 +++---- CPP/7zip/UI/FileManager/RegistryPlugins.cpp | 2 +- CPP/7zip/UI/FileManager/RegistryUtils.cpp | 8 ++- CPP/7zip/UI/FileManager/RootFolder.cpp | 20 +++---- CPP/7zip/UI/FileManager/UpdateCallback100.cpp | 9 +-- CPP/7zip/UI/FileManager/ViewSettings.cpp | 15 ++--- CPP/7zip/UI/GUI/CompressDialog.cpp | 4 +- CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp | 8 +-- CPP/7zip/UI/GUI/UpdateGUI.cpp | 2 +- CPP/Common/Buffer.h | 4 +- CPP/Common/C_FileIO.cpp | 2 +- CPP/Common/CommandLineParser.cpp | 14 ++--- CPP/Common/DynamicBuffer.h | 2 +- CPP/Common/IntToString.cpp | 4 +- CPP/Common/ListFileUtils.cpp | 2 +- CPP/Common/MyCom.h | 23 +++++--- CPP/Common/MyString.h | 16 ++--- CPP/Common/MyVector.h | 10 ++-- CPP/Common/MyWindows.cpp | 12 ++-- CPP/Common/StdInStream.cpp | 10 ++-- CPP/Common/StdOutStream.cpp | 2 +- CPP/Common/StringConvert.cpp | 10 ++-- CPP/Common/Wildcard.cpp | 14 ++--- CPP/Windows/COM.h | 2 +- CPP/Windows/Control/ImageList.h | 4 +- CPP/Windows/Control/Window2.cpp | 4 +- CPP/Windows/DLL.cpp | 2 +- CPP/Windows/Error.cpp | 4 +- CPP/Windows/FileDir.cpp | 32 +++++----- CPP/Windows/FileFind.cpp | 4 +- CPP/Windows/FileIO.cpp | 10 ++-- CPP/Windows/FileName.cpp | 4 -- CPP/Windows/FileName.h | 2 - CPP/Windows/Memory.h | 2 +- CPP/Windows/MemoryLock.cpp | 2 +- CPP/Windows/Menu.cpp | 4 +- CPP/Windows/NationalTime.cpp | 4 +- CPP/Windows/Net.cpp | 2 +- CPP/Windows/PropVariant.cpp | 2 +- CPP/Windows/PropVariantConversions.cpp | 13 +--- CPP/Windows/Registry.cpp | 6 +- CPP/Windows/Registry.h | 2 - CPP/Windows/Security.cpp | 2 +- CPP/Windows/Shell.cpp | 14 ++--- CPP/Windows/Window.h | 2 +- DOC/7zip.wxs | 4 +- DOC/lzma.txt | 2 +- 107 files changed, 490 insertions(+), 503 deletions(-) diff --git a/C/Archive/7z/7zExtract.c b/C/Archive/7z/7zExtract.c index da5b57c7..cc727467 100755 --- a/C/Archive/7z/7zExtract.c +++ b/C/Archive/7z/7zExtract.c @@ -1,5 +1,5 @@ /* 7zExtract.c -- Extracting from 7z archive -2008-08-05 +2008-08-17 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov Read 7zExtract.h for license options */ @@ -79,7 +79,7 @@ SRes SzAr_Extract( UInt32 i; CSzFileItem *fileItem = p->db.Files + fileIndex; *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; *outSizeProcessed = (size_t)fileItem->Size; if (*offset + *outSizeProcessed > *outBufferSize) diff --git a/C/Archive/7z/7zIn.c b/C/Archive/7z/7zIn.c index 9a4d6dd1..6592e7f4 100755 --- a/C/Archive/7z/7zIn.c +++ b/C/Archive/7z/7zIn.c @@ -1,5 +1,5 @@ /* 7zIn.c -- 7z Input functions -2008-08-05 +2008-08-17 Igor Pavlov Copyright (c) 1999-2008 Igor Pavlov Read 7zIn.h for license options */ @@ -8,7 +8,7 @@ Read 7zIn.h for license options */ #include "7zDecode.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) { @@ -847,7 +847,7 @@ static SRes SzReadFileNames(CSzData *sd, UInt32 numFiles, CSzFileItem *files, IS UInt32 len = 0; UInt32 pos = 0; CSzFileItem *file = files + i; - while(pos + 2 <= sd->Size) + while (pos + 2 <= sd->Size) { int numAdds; 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); len = 0; - while(2 <= sd->Size) + while (2 <= sd->Size) { int numAdds; 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--; file->Name[len++] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F)); } - while(numAdds > 0); + while (numAdds > 0); len += numAdds; } @@ -1041,7 +1041,7 @@ static SRes SzReadHeader2( file->HasStream = 1; else file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1); - if(file->HasStream) + if (file->HasStream) { file->IsDir = 0; file->Size = (*unpackSizes)[sizeIndex]; diff --git a/C/Archive/7z/7zMain.c b/C/Archive/7z/7zMain.c index 082a2ebd..5bcf0ec8 100755 --- a/C/Archive/7z/7zMain.c +++ b/C/Archive/7z/7zMain.c @@ -1,5 +1,5 @@ /* 7zMain.c - Test application for 7z Decoder -2008-08-05 +2008-08-17 Igor Pavlov Public domain */ @@ -40,7 +40,7 @@ void ConvertNumberToString(CFileSize value, char *s) while (value != 0); do *s++ = temp[--pos]; - while(pos > 0); + while (pos > 0); *s = '\0'; } diff --git a/C/Bcj2.c b/C/Bcj2.c index a4dafac8..d1be3293 100755 --- a/C/Bcj2.c +++ b/C/Bcj2.c @@ -1,5 +1,5 @@ /* Bcj2.c -- Converter for x86 code (BCJ2) -2008-08-05 +2008-08-17 Copyright (c) 1999-2008 Igor Pavlov Read Bra.h for license options */ @@ -24,7 +24,7 @@ Read Bra.h for license options */ #define RC_READ_BYTE (*buffer++) #define RC_TEST { if (buffer == bufferLim) return SZ_ERROR_DATA; } #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; } diff --git a/C/Bra.h b/C/Bra.h index 0ff7b842..129269ae 100755 --- a/C/Bra.h +++ b/C/Bra.h @@ -1,5 +1,5 @@ /* Bra.h -- Branch converters for executables -2008-08-05 +2008-08-17 Copyright (c) 1999-2008 Igor Pavlov Read LzmaDec.h for license options */ @@ -41,7 +41,7 @@ in CALL instructions to increase the compression ratio. Example: UInt32 ip = 0; - for() + for () { // size must be >= Alignment + LookAhead, if it's not last block SizeT processed = Convert(data, size, ip, 1); diff --git a/C/Bra86.c b/C/Bra86.c index 62a1705b..5c1b0923 100755 --- a/C/Bra86.c +++ b/C/Bra86.c @@ -1,5 +1,5 @@ /* Bra86.c -- converter for x86 code (BCJ) -2008-03-19 +2008-08-17 Copyright (c) 1999-2008 Igor Pavlov 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; prevPosT = (SizeT)0 - 1; - for(;;) + for (;;) { Byte *p = data + bufferPos; Byte *limit = data + size - 4; diff --git a/C/BwtSort.c b/C/BwtSort.c index fdac5545..20730507 100755 --- a/C/BwtSort.c +++ b/C/BwtSort.c @@ -1,5 +1,5 @@ /* BwtSort.c -- BWT block sorting -2008-08-05 +2008-08-17 Igor Pavlov Public domain */ @@ -225,7 +225,7 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group break; } } - while(++i < j); + while (++i < j); if (i == 0) { range = range - (mid - left); @@ -438,7 +438,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize) i++; continue; } - for(groupSize = 1; + for (groupSize = 1; (Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0; groupSize++); diff --git a/C/LzFind.c b/C/LzFind.c index d3938548..00c1f5a1 100755 --- a/C/LzFind.c +++ b/C/LzFind.c @@ -1,5 +1,5 @@ /* LzFind.c -- Match finder for LZ algorithms -2008-08-05 +2008-08-17 Copyright (c) 1999-2008 Igor Pavlov Read LzFind.h for license options */ @@ -263,7 +263,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p) void MatchFinder_Init(CMatchFinder *p) { UInt32 i; - for(i = 0; i < p->hashSizeSum; i++) + for (i = 0; i < p->hashSizeSum; i++) p->hash[i] = kEmptyHashValue; p->cyclicBufferPos = 0; 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) { UInt32 len = 0; - while(++len != lenLimit) + while (++len != lenLimit) if (pb[len] != cur[len]) break; if (maxLen < len) @@ -364,7 +364,7 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt if (pb[len] == cur[len]) { if (++len != lenLimit && pb[len] == cur[len]) - while(++len != lenLimit) + while (++len != lenLimit) if (pb[len] != cur[len]) break; if (maxLen < len) @@ -417,7 +417,7 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const UInt32 len = (len0 < len1 ? len0 : len1); if (pb[len] == cur[len]) { - while(++len != lenLimit) + while (++len != lenLimit) if (pb[len] != cur[len]) break; { diff --git a/C/LzFindMt.c b/C/LzFindMt.c index 3df50ac0..82caeb29 100755 --- a/C/LzFindMt.c +++ b/C/LzFindMt.c @@ -1,5 +1,5 @@ /* LzFindMt.c -- multithreaded Match finder for LZ algorithms -2008-08-05 +2008-08-17 Copyright (c) 1999-2008 Igor Pavlov Read LzFind.h for license options */ @@ -97,7 +97,7 @@ void MtSync_Destruct(CMtSync *p) 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) { @@ -262,7 +262,7 @@ Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CL if (pb[len] == cur[len]) { if (++len != lenLimit && pb[len] == cur[len]) - while(++len != lenLimit) + while (++len != lenLimit) if (pb[len] != cur[len]) break; 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_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) { diff --git a/C/LzmaDec.c b/C/LzmaDec.c index 0a782070..724d1c9f 100755 --- a/C/LzmaDec.c +++ b/C/LzmaDec.c @@ -1,5 +1,5 @@ /* LzmaDec.c -- LZMA Decoder -2008-08-05 +2008-08-17 Copyright (c) 1999-2008 Igor Pavlov Read LzmaDec.h for license options */ @@ -56,7 +56,7 @@ Read LzmaDec.h for license options */ { UPDATE_1_CHECK; i = (i + i) + 1; A1; } #define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, 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 @@ -328,7 +328,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte GET_BIT2(prob + i, i, ; , distance |= mask); mask <<= 1; } - while(--numDirectBits != 0); + while (--numDirectBits != 0); } } else @@ -679,7 +679,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS { GET_BIT_CHECK(prob + i, i); } - while(--numDirectBits != 0); + while (--numDirectBits != 0); } } } diff --git a/C/LzmaEnc.c b/C/LzmaEnc.c index 34b976d0..ccbdac97 100755 --- a/C/LzmaEnc.c +++ b/C/LzmaEnc.c @@ -1,5 +1,5 @@ /* LzmaEnc.c -- LZMA Encoder -2008-08-13 +2008-08-17 Copyright (c) 1999-2008 Igor Pavlov Read LzmaEnc.h for license options */ @@ -1966,7 +1966,7 @@ void LzmaEnc_Init(CLzmaEnc *p) { UInt32 i; p->state = 0; - for(i = 0 ; i < LZMA_NUM_REPS; i++) + for (i = 0 ; i < LZMA_NUM_REPS; i++) p->reps[i] = 0; 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; } diff --git a/C/Sort.c b/C/Sort.c index 8438c787..ac772f6f 100755 --- a/C/Sort.c +++ b/C/Sort.c @@ -1,5 +1,5 @@ /* Sort.c -- Sort functions -2008-03-13 +2008-08-17 Igor Pavlov Public domain */ @@ -27,7 +27,7 @@ void HeapSort(UInt32 *p, UInt32 size) UInt32 k = i; HeapSortDown(p, k, size, temp) } - while(--i != 0); + while (--i != 0); } /* do @@ -82,7 +82,7 @@ void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size) UInt32 temp = p[i]; HeapSortRefDown(p, vals, i, size, temp); } - while(--i != 0); + while (--i != 0); } do { diff --git a/CPP/7zip/Archive/7z/7zDecode.cpp b/CPP/7zip/Archive/7z/7zDecode.cpp index 13fe50c8..e630538d 100755 --- a/CPP/7zip/Archive/7z/7zDecode.cpp +++ b/CPP/7zip/Archive/7z/7zDecode.cpp @@ -264,7 +264,7 @@ HRESULT CDecoder::Decode( RINOK(getTextPassword->CryptoGetTextPassword(&passwordBSTR)); CByteBuffer buffer; passwordIsDefined = true; - UString password = passwordBSTR; + const UString password(passwordBSTR); const UInt32 sizeInBytes = password.Length() * 2; buffer.SetCapacity(sizeInBytes); for (int i = 0; i < password.Length(); i++) diff --git a/CPP/7zip/Archive/ElfHandler.cpp b/CPP/7zip/Archive/ElfHandler.cpp index 952f2273..8d498177 100755 --- a/CPP/7zip/Archive/ElfHandler.cpp +++ b/CPP/7zip/Archive/ElfHandler.cpp @@ -1,4 +1,4 @@ -4// ElfHandler.cpp +// ElfHandler.cpp #include "StdAfx.h" diff --git a/CPP/7zip/Archive/PeHandler.cpp b/CPP/7zip/Archive/PeHandler.cpp index 88808b56..245c30c1 100755 --- a/CPP/7zip/Archive/PeHandler.cpp +++ b/CPP/7zip/Archive/PeHandler.cpp @@ -130,7 +130,7 @@ void CDebugEntry::Parse(const Byte *p) Pa = Get32(p + 24); } -static const kNumDirItemsMax = 16; +static const UInt32 kNumDirItemsMax = 16; struct COptHeader { diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp index c8a20643..e81c7967 100755 --- a/CPP/7zip/Archive/Rar/RarHandler.cpp +++ b/CPP/7zip/Archive/Rar/RarHandler.cpp @@ -68,7 +68,7 @@ STATPROPSTG kArcProps[] = { { NULL, kpidSolid, VT_BOOL}, { NULL, kpidNumBlocks, VT_UI4}, - { NULL, kpidEncrypted, VT_BOOL}, + // { NULL, kpidEncrypted, VT_BOOL}, { NULL, kpidIsVolume, VT_BOOL}, { NULL, kpidNumVolumes, VT_UI4}, { NULL, kpidPhySize, VT_UI8} @@ -94,7 +94,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) switch(propID) { 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 kpidNumVolumes: prop = (UInt32)_archives.Size(); break; case kpidOffset: if (_archiveInfo.StartPosition != 0) prop = _archiveInfo.StartPosition; break; diff --git a/CPP/7zip/Archive/Udf/UdfHandler.cpp b/CPP/7zip/Archive/Udf/UdfHandler.cpp index 10a1a900..e503e843 100755 --- a/CPP/7zip/Archive/Udf/UdfHandler.cpp +++ b/CPP/7zip/Archive/Udf/UdfHandler.cpp @@ -236,25 +236,40 @@ STDMETHODIMP CUdfInStream::Read(void *data, UInt32 size, UInt32 *processedSize) const CFile &file = _archive->Files[ref.FileIndex]; const CItem &item = _archive->Items[file.ItemIndex]; - const CMyExtent &extent = item.Extents[_extentIndex]; - UInt32 rem = extent.GetLen() - _offsetInExtent; - if (rem == 0) + HRESULT res = S_OK; + if (item.IsInline) { - _extentIndex++; - _offsetInExtent = 0; - continue; + size_t rem = item.InlineData.GetCapacity() - _offsetInExtent; + if (rem == 0) + return S_OK; + if (rem > _rem) + rem = (size_t)_rem; + memcpy(data, (const Byte *)item.InlineData + _offsetInExtent, rem); } - 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) + + else + { + if (_extentIndex >= item.Extents.Size()) + return S_OK; + const CMyExtent &extent = item.Extents[_extentIndex]; + UInt32 rem = extent.GetLen() - _offsetInExtent; + 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; - - RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL)); - HRESULT res = _stream->Read(data, size, &size); + + RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL)); + res = _stream->Read(data, size, &size); + } _offsetInExtent += size; _rem -= size; if (processedSize) diff --git a/CPP/7zip/Archive/Udf/UdfIn.cpp b/CPP/7zip/Archive/Udf/UdfIn.cpp index 3637bbc6..75a0c333 100755 --- a/CPP/7zip/Archive/Udf/UdfIn.cpp +++ b/CPP/7zip/Archive/Udf/UdfIn.cpp @@ -26,6 +26,7 @@ const int kNumFilesMax = 1 << 28; const int kNumRefsMax = 1 << 28; const UInt32 kNumExtentsMax = (UInt32)1 << 30; const UInt64 kFileNameLengthTotalMax = (UInt64)1 << 33; +const UInt64 kInlineExtentsSizeMax = (UInt64)1 << 33; 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) return S_FALSE; + if (item.IsInline) + { + buf = item.InlineData; + return S_OK; + } buf.SetCapacity((size_t)item.Size); size_t pos = 0; 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; 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) return S_FALSE; - for (UInt32 i = 0; i < allocDescriptorsLen;) + if (desctType == ICB_DESC_TYPE_INLINE) { - CMyExtent e; - if (desctType == ICB_DESC_TYPE_SHORT) - { - if (i + 8 > allocDescriptorsLen) - return S_FALSE; - CShortAllocDesc sad; - sad.Parse(p + pos + i); - e.Pos = sad.Pos; - e.Len = sad.Len; - e.PartitionRef = lad.Location.PartitionRef; - i += 8; - } - else + item.IsInline = true; + 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 + 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; + CMyExtent e; + if (desctType == ICB_DESC_TYPE_SHORT) + { + if (i + 8 > allocDescriptorsLen) + return S_FALSE; + CShortAllocDesc sad; + sad.Parse(p + pos + i); + 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); } - item.Extents.Add(e); } if (item.IcbTag.IsDir()) @@ -489,6 +504,7 @@ HRESULT CInArchive::ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &la RINOK(ReadFromFile(volIndex, item, buf)); item.Size = 0; item.Extents.ClearAndFree(); + item.InlineData.Free(); const Byte *p = buf; size = buf.GetCapacity(); @@ -524,6 +540,10 @@ HRESULT CInArchive::ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &la if ((UInt32)item.Extents.Size() > kNumExtentsMax - _numExtents) return S_FALSE; _numExtents += item.Extents.Size(); + + if (item.InlineData.GetCapacity() > kInlineExtentsSizeMax - _inlineExtentsSize) + return S_FALSE; + _inlineExtentsSize += item.InlineData.GetCapacity(); } return S_OK; @@ -769,6 +789,7 @@ void CInArchive::Clear() _fileNameLengthTotal = 0; _numRefs = 0; _numExtents = 0; + _inlineExtentsSize = 0; _processedProgressBytes = 0; } diff --git a/CPP/7zip/Archive/Udf/UdfIn.h b/CPP/7zip/Archive/Udf/UdfIn.h index f99991a0..46b9a7e8 100755 --- a/CPP/7zip/Archive/Udf/UdfIn.h +++ b/CPP/7zip/Archive/Udf/UdfIn.h @@ -167,6 +167,8 @@ struct CPartitionMap int PartitionIndex; }; +// ECMA 4/14.6 + enum EIcbFileType { ICB_FILE_TYPE_DIR = 4, @@ -243,6 +245,8 @@ struct CItem // CRegId ImplId; // UInt64 UniqueId; + bool IsInline; + CByteBuffer InlineData; CRecordVector Extents; CRecordVector SubFiles; @@ -258,6 +262,8 @@ struct CItem UInt64 GetChunksSumSize() const { + if (IsInline) + return InlineData.GetCapacity(); UInt64 size = 0; for (int i = 0; i < Extents.Size(); i++) size += Extents[i].GetLen(); @@ -343,6 +349,7 @@ class CInArchive UInt64 _fileNameLengthTotal; int _numRefs; UInt32 _numExtents; + UInt64 _inlineExtentsSize; bool CheckExtent(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len) const; public: HRESULT Open(IInStream *inStream, CProgressVirt *progress); diff --git a/CPP/7zip/Archive/Zip/ZipIn.cpp b/CPP/7zip/Archive/Zip/ZipIn.cpp index d67713ce..5fb53ef2 100755 --- a/CPP/7zip/Archive/Zip/ZipIn.cpp +++ b/CPP/7zip/Archive/Zip/ZipIn.cpp @@ -740,8 +740,8 @@ void CEcd64::Parse(const Byte *p) cdStartOffset = Get64(p + 36); } -#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_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; HRESULT CInArchive::ReadHeaders(CObjectVector &items, CProgressVirt *progress) { diff --git a/CPP/7zip/Bundles/SFXSetup/Main.cpp b/CPP/7zip/Bundles/SFXSetup/Main.cpp index 64f0eab1..3f048710 100755 --- a/CPP/7zip/Bundles/SFXSetup/Main.cpp +++ b/CPP/7zip/Bundles/SFXSetup/Main.cpp @@ -168,7 +168,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR / return 1; } - UString dirPrefix = L".\\"; + UString dirPrefix = L"." WSTRING_PATH_SEPARATOR; UString appLaunched; bool showProgress = true; if (!config.IsEmpty()) @@ -298,7 +298,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR / { UString s2 = tempDirPath; NFile::NName::NormalizeDirPathPrefix(s2); - appLaunched.Replace(L"%%T\\", s2); + appLaunched.Replace(L"%%T" WSTRING_PATH_SEPARATOR, s2); } appLaunched.Replace(L"%%T", tempDirPath); diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h index cf6aa5d3..31b8ea3b 100755 --- a/CPP/7zip/MyVersion.h +++ b/CPP/7zip/MyVersion.h @@ -1,8 +1,8 @@ #define MY_VER_MAJOR 4 -#define MY_VER_MINOR 59 -#define MY_VER_BUILD 7 -#define MY_VERSION " 4.59 beta" -#define MY_7ZIP_VERSION "7-Zip 4.59 beta" -#define MY_DATE "2008-08-13" +#define MY_VER_MINOR 60 +#define MY_VER_BUILD 0 +#define MY_VERSION " 4.60 beta" +#define MY_7ZIP_VERSION "7-Zip 4.60 beta" +#define MY_DATE "2008-08-19" #define MY_COPYRIGHT "Copyright (c) 1999-2008 Igor Pavlov" #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE diff --git a/CPP/7zip/UI/Agent/Agent.cpp b/CPP/7zip/UI/Agent/Agent.cpp index b0cb559f..0b57049c 100755 --- a/CPP/7zip/UI/Agent/Agent.cpp +++ b/CPP/7zip/UI/Agent/Agent.cpp @@ -94,9 +94,9 @@ UString CAgentFolder::GetPrefix(UInt32 index) const const CProxyItem &item = _items[index]; const CProxyFolder *folder = item.Folder; 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; } return path; @@ -460,12 +460,9 @@ STDMETHODIMP CAgent::Open( DefaultTime = fileInfo.MTime; DefaultAttrib = fileInfo.Attrib; ArchiveType = ai.Name; - if (archiveType != 0) - { - CMyComBSTR name = ArchiveType; - *archiveType = name.Detach(); - } - return S_OK; + if (archiveType == 0) + return S_OK; + return StringToBstr(ArchiveType, archiveType); COM_TRY_END } diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp index 2e953aed..e4d34a72 100755 --- a/CPP/7zip/UI/Agent/AgentOut.cpp +++ b/CPP/7zip/UI/Agent/AgentOut.cpp @@ -66,10 +66,10 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder) folderItem = newFolder; } - for(int i = 0; i < pathParts.Size(); i++) + for (int i = 0; i < pathParts.Size(); i++) { _archiveNamePrefix += pathParts[i]; - _archiveNamePrefix += L'\\'; + _archiveNamePrefix += WCHAR_PATH_SEPARATOR; } return S_OK; } @@ -138,7 +138,7 @@ static HRESULT EnumerateArchiveItems(CAgent *agent, ai.IndexInServer = dirItem.Index; arcItems.Add(ai); } - RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(L'\\'), arcItems)); + RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(WCHAR_PATH_SEPARATOR), arcItems)); } return S_OK; } @@ -537,5 +537,3 @@ STDMETHODIMP CAgent::SetProperties(const wchar_t **names, } return S_OK; } - - diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp index 704b5d33..0a2de592 100755 --- a/CPP/7zip/UI/Agent/AgentProxy.cpp +++ b/CPP/7zip/UI/Agent/AgentProxy.cpp @@ -98,7 +98,7 @@ UString CProxyFolder::GetFullPathPrefix() const const CProxyFolder *current = this; while (current->Parent != NULL) { - result = current->Name + UString(L'\\') + result; + result = current->Name + UString(WCHAR_PATH_SEPARATOR) + result; current = current->Parent; } return result; @@ -252,7 +252,7 @@ HRESULT CProxyArchive::ReadObjects(IInArchive *archive, IProgress *progress) for (int i = 0; i < len; i++) { wchar_t c = filePath[i]; - if (c == '\\' || c == '/') + if (c == WCHAR_PATH_SEPARATOR || c == L'/') { currentItem = currentItem->AddDirSubItem((UInt32)(Int32)-1, false, fileName); fileName.Empty(); diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp index d983c13a..f339a287 100755 --- a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp +++ b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp @@ -59,9 +59,8 @@ STDMETHODIMP CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *ext int formatIndex = FindFormat(type); if (formatIndex < 0) return E_INVALIDARG; - CMyComBSTR valueTemp = _codecs.Formats[formatIndex].GetAllExtensions(); // Exts[0].Ext; - *extensions = valueTemp.Detach(); - return S_OK; + // Exts[0].Ext; + return StringToBstr(_codecs.Formats[formatIndex].GetAllExtensions(), extensions); } */ STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions) @@ -79,9 +78,7 @@ STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions) res += lib.IconPairs[j].Ext; } } - CMyComBSTR valueTemp = res; - *extensions = valueTemp.Detach(); - return S_OK; + return StringToBstr(res, extensions); } 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); if (ii >= 0) { - CMyComBSTR iconPathTemp = GetUnicodeString(lib.Path, GetCurrentFileCodePage()); *iconIndex = ii; - *iconPath = iconPathTemp.Detach(); - return S_OK; + return StringToBstr(GetUnicodeString(lib.Path, GetCurrentFileCodePage()), iconPath); } } return S_OK; @@ -118,9 +113,7 @@ STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types) typesStrings += L' '; typesStrings += ai.Name; } - CMyComBSTR valueTemp = typesStrings; - *types = valueTemp.Detach(); - return S_OK; + return StringToBstr(typesStrings, types); } STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type, const wchar_t * filePath, IProgress progress) diff --git a/CPP/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp index 82db4f08..0c447479 100755 --- a/CPP/7zip/UI/Client7z/Client7z.cpp +++ b/CPP/7zip/UI/Client7z/Client7z.cpp @@ -151,9 +151,7 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password) PrintError("Password is not defined"); return E_ABORT; } - CMyComBSTR tempName(Password); - *password = tempName.Detach(); - return S_OK; + return StringToBstr(Password, password); } @@ -420,9 +418,7 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password) PrintError("Password is not defined"); return E_ABORT; } - CMyComBSTR tempName(Password); - *password = tempName.Detach(); - return S_OK; + return StringToBstr(Password, password); } @@ -654,9 +650,7 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef } } *passwordIsDefined = BoolToInt(PasswordIsDefined); - CMyComBSTR tempName(Password); - *password = tempName.Detach(); - return S_OK; + return StringToBstr(Password, password); } diff --git a/CPP/7zip/UI/Common/ArchiveName.cpp b/CPP/7zip/UI/Common/ArchiveName.cpp index a2fc6a0f..9b9a4fe6 100755 --- a/CPP/7zip/UI/Common/ArchiveName.cpp +++ b/CPP/7zip/UI/Common/ArchiveName.cpp @@ -16,7 +16,7 @@ UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName) if (NFile::NDirectory::GetOnlyDirPrefix(srcName, dirPrefix)) { if (dirPrefix.Length() > 0) - if (dirPrefix[dirPrefix.Length() - 1] == '\\') + if (dirPrefix[dirPrefix.Length() - 1] == WCHAR_PATH_SEPARATOR) { dirPrefix.Delete(dirPrefix.Length() - 1); NFile::NFind::CFileInfoW fileInfo; diff --git a/CPP/7zip/UI/Common/EnumDirItems.cpp b/CPP/7zip/UI/Common/EnumDirItems.cpp index 3b01b6e8..b83edf2a 100755 --- a/CPP/7zip/UI/Common/EnumDirItems.cpp +++ b/CPP/7zip/UI/Common/EnumDirItems.cpp @@ -129,16 +129,19 @@ void CDirItems::EnumerateDirItems2(const UString &phyPrefix, const UString &logP continue; } int delimiter = filePath.ReverseFind((wchar_t)kDirDelimiter); - + UString phyPrefixCur; int phyParentCur = phyParent; 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); if (fi.IsDir()) { const UString name2 = fi.Name + (wchar_t)kDirDelimiter; int parent = AddPrefix(phyParentCur, logParent, name2); - EnumerateDirectory(parent, parent, phyPrefix + name2, errorPaths, errorCodes); + EnumerateDirectory(parent, parent, phyPrefix + phyPrefixCur + name2, errorPaths, errorCodes); } } ReserveDown(); diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp index 79caf55e..4b5639ee 100755 --- a/CPP/7zip/UI/Common/LoadCodecs.cpp +++ b/CPP/7zip/UI/Common/LoadCodecs.cpp @@ -50,7 +50,7 @@ static CSysString GetLibraryFolderPrefix() static const TCHAR *kMainDll = TEXT("7z.dll"); #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 bool ReadPathFromRegistry(HKEY baseKey, CSysString &path) { @@ -446,7 +446,7 @@ HRESULT CCodecs::Load() 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 dotPos = arcPath.ReverseFind(L'.'); if (dotPos < 0 || dotPos < slashPos1 || dotPos < slashPos2) diff --git a/CPP/7zip/UI/Common/OpenArchive.cpp b/CPP/7zip/UI/Common/OpenArchive.cpp index 7037d876..364ddff5 100755 --- a/CPP/7zip/UI/Common/OpenArchive.cpp +++ b/CPP/7zip/UI/Common/OpenArchive.cpp @@ -175,7 +175,7 @@ HRESULT OpenArchive( processedSize--; 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) break; UInt32 v = buf[pos] | ((UInt32)buf[pos + 1] << 8); diff --git a/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp index 65b74fce..e36b29ee 100755 --- a/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp +++ b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp @@ -152,9 +152,7 @@ STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password) Password = GetPassword(OutStream); PasswordIsDefined = true; } - CMyComBSTR tempName(Password); - *password = tempName.Detach(); - return S_OK; + return StringToBstr(Password, password); } #endif diff --git a/CPP/7zip/UI/Console/OpenCallbackConsole.cpp b/CPP/7zip/UI/Console/OpenCallbackConsole.cpp index 892123d4..7dba2ad5 100755 --- a/CPP/7zip/UI/Console/OpenCallbackConsole.cpp +++ b/CPP/7zip/UI/Console/OpenCallbackConsole.cpp @@ -35,9 +35,7 @@ HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password) Password = GetPassword(OutStream); PasswordIsDefined = true; } - CMyComBSTR temp(Password); - *password = temp.Detach(); - return S_OK; + return StringToBstr(Password, password); } HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(UString &password) diff --git a/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp index f8621567..f81b6491 100755 --- a/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp +++ b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp @@ -199,8 +199,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined, #ifdef _NO_CRYPTO *passwordIsDefined = false; - CMyComBSTR tempName(L""); - *password = tempName.Detach(); + return StringToBstr(L"", password); #else @@ -213,10 +212,8 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined, } } *passwordIsDefined = BoolToInt(PasswordIsDefined); - CMyComBSTR tempName(Password); - *password = tempName.Detach(); + return StringToBstr(Password, password); #endif - return S_OK; } diff --git a/CPP/7zip/UI/Explorer/ContextMenu.cpp b/CPP/7zip/UI/Explorer/ContextMenu.cpp index 0b16bc89..3ba8f3eb 100755 --- a/CPP/7zip/UI/Explorer/ContextMenu.cpp +++ b/CPP/7zip/UI/Explorer/ContextMenu.cpp @@ -309,6 +309,16 @@ static UString GetReducedString(const UString &s) 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[] = { 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; else commandMapItem.Folder = folderPrefix; - commandMapItem.Folder += GetSubFolderNameForExtract(fileInfo.Name) + UString(L'\\'); + commandMapItem.Folder += GetSubFolderNameForExtract(fileInfo.Name) + UString(WCHAR_PATH_SEPARATOR); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString); _commandMap.Add(commandMapItem); } @@ -469,7 +479,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, else commandMapItem.Folder = folderPrefix; 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); _commandMap.Add(commandMapItem); } @@ -525,8 +535,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, commandMapItem.Folder = archivePathPrefix; commandMapItem.Archive = archiveName7z; commandMapItem.ArchiveType = L"7z"; - UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\""); - s = MyFormatNew(s, t); + s = MyFormatNew(s, GetQuotedReducedString(archiveName7z)); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); _commandMap.Add(commandMapItem); } @@ -539,8 +548,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, FillCommand(kCompressTo7zEmail, s, commandMapItem); commandMapItem.Archive = archiveName7z; commandMapItem.ArchiveType = L"7z"; - UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\""); - s = MyFormatNew(s, t); + s = MyFormatNew(s, GetQuotedReducedString(archiveName7z)); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); _commandMap.Add(commandMapItem); } @@ -557,8 +565,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, commandMapItem.Folder = archivePathPrefix; commandMapItem.Archive = archiveNameZip; commandMapItem.ArchiveType = L"zip"; - UString t = UString(L"\"") + GetReducedString(archiveNameZip) + UString(L"\""); - s = MyFormatNew(s, t); + s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip)); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); _commandMap.Add(commandMapItem); } @@ -571,8 +578,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, FillCommand(kCompressToZipEmail, s, commandMapItem); commandMapItem.Archive = archiveNameZip; commandMapItem.ArchiveType = L"zip"; - UString t = UString(L"\"") + GetReducedString(archiveNameZip) + UString(L"\""); - s = MyFormatNew(s, t); + s = MyFormatNew(s, GetQuotedReducedString(archiveNameZip)); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); _commandMap.Add(commandMapItem); } @@ -614,12 +620,11 @@ extern const char *kShellFolderClassIDString; static UString GetProgramCommand() { - UString path = L"\""; + UString path; UString folder; if (GetProgramFolderPath(folder)) - path += folder; - path += L"7zFM.exe\""; - return path; + path = folder; + return GetQuotedString(path + L"7zFM.exe"); } STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo) @@ -658,9 +663,8 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo) { UString params; params = GetProgramCommand(); - params += L" \""; - params += _fileNames[0]; - params += L"\""; + params += L' '; + params += GetQuotedString(_fileNames[0]); MyCreateProcess(params, 0, false, 0); break; } diff --git a/CPP/7zip/UI/Far/ExtractEngine.cpp b/CPP/7zip/UI/Far/ExtractEngine.cpp index 89dacf59..55994ed6 100755 --- a/CPP/7zip/UI/Far/ExtractEngine.cpp +++ b/CPP/7zip/UI/Far/ExtractEngine.cpp @@ -170,8 +170,5 @@ STDMETHODIMP CExtractCallBackImp::CryptoGetTextPassword(BSTR *password) RINOK(GetPassword(m_Password)); m_PasswordIsDefined = true; } - CMyComBSTR tempName = m_Password; - *password = tempName.Detach(); - - return S_OK; + return StringToBstr(m_Password, password); } diff --git a/CPP/7zip/UI/Far/Main.cpp b/CPP/7zip/UI/Far/Main.cpp index 39c84391..f042a785 100755 --- a/CPP/7zip/UI/Far/Main.cpp +++ b/CPP/7zip/UI/Far/Main.cpp @@ -359,9 +359,7 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) RINOK(GetPassword(Password)); PasswordIsDefined = true; } - CMyComBSTR temp = Password; - *password = temp.Detach(); - return S_OK; + return StringToBstr(Password, password); } /* diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp index 65253f01..dc2a3ed1 100755 --- a/CPP/7zip/UI/Far/Plugin.cpp +++ b/CPP/7zip/UI/Far/Plugin.cpp @@ -208,7 +208,7 @@ void CPlugin::EnterToDirectory(const UString &dirName) int CPlugin::SetDirectory(const char *aszDir, int /* opMode */) { UString path = MultiByteToUnicodeString(aszDir, CP_OEMCP); - if (path == L"\\") + if (path == WSTRING_PATH_SEPARATOR) { _folder.Release(); m_ArchiveHandler->BindToRootFolder(&_folder); @@ -225,7 +225,7 @@ int CPlugin::SetDirectory(const char *aszDir, int /* opMode */) EnterToDirectory(path); else { - if (path[0] == L'\\') + if (path[0] == WCHAR_PATH_SEPARATOR) { _folder.Release(); m_ArchiveHandler->BindToRootFolder(&_folder); @@ -265,7 +265,7 @@ void CPlugin::GetCurrentDir() GetPathParts(pathParts); for (int i = 0; i < pathParts.Size(); i++) { - m_CurrentDir += L'\\'; + m_CurrentDir += WCHAR_PATH_SEPARATOR; m_CurrentDir += pathParts[i]; } } diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp index ec1d2df4..db5ef0da 100755 --- a/CPP/7zip/UI/FileManager/App.cpp +++ b/CPP/7zip/UI/FileManager/App.cpp @@ -269,7 +269,7 @@ void CApp::ReloadToolbars() return; HWND parent = _rebar; - while(_rebar.GetBandCount() > 0) + while (_rebar.GetBandCount() > 0) _rebar.DeleteBand(0); _archiveToolBar.Destroy(); @@ -436,14 +436,14 @@ static bool IsThereFolderOfPath(const UString &path) // reduces path to part that exists on disk static void ReducePathToRealFileSystemPath(UString &path) { - while(!path.IsEmpty()) + while (!path.IsEmpty()) { if (IsThereFolderOfPath(path)) { NName::NormalizeDirPathPrefix(path); break; } - int pos = path.ReverseFind('\\'); + int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0) path.Empty(); else @@ -453,8 +453,8 @@ static void ReducePathToRealFileSystemPath(UString &path) break; if (path.Length() > 2 && path[0] == '\\' && path[1] == '\\') { - int nextPos = path.Find('\\', 2); // pos after \\COMPNAME - if (nextPos > 0 && path.Find('\\', nextPos + 1) == pos) + int nextPos = path.Find(WCHAR_PATH_SEPARATOR, 2); // pos after \\COMPNAME + if (nextPos > 0 && path.Find(WCHAR_PATH_SEPARATOR, nextPos + 1) == pos) break; } path = path.Left(pos); @@ -472,9 +472,12 @@ static bool CheckFolderPath(const UString &path) static bool IsPathAbsolute(const UString &path) { - if ((path.Length() >= 1 && path[0] == L'\\') || - (path.Length() >= 3 && path[1] == L':' && path[2] == L'\\')) + if (path.Length() >= 1 && path[0] == WCHAR_PATH_SEPARATOR) return true; + #ifdef _WIN32 + if (path.Length() >= 3 && path[1] == L':' && path[2] == L'\\') + return true; + #endif return false; } @@ -564,7 +567,7 @@ UString CPanel::GetItemsInfoString(const CRecordVector &indices) int index = indices[i]; info += GetItemRelPath(index); if (IsItemFolder(index)) - info += L'\\'; + info += WCHAR_PATH_SEPARATOR; } if (i != indices.Size()) info += L"\n ..."; @@ -656,7 +659,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) 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)) { NDirectory::CreateComplexDirectory(destPath); @@ -673,7 +676,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) } else { - int pos = destPath.ReverseFind('\\'); + int pos = destPath.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos >= 0) { UString prefix = destPath.Left(pos + 1); @@ -734,7 +737,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) else folderPrefix = srcPanel._currentFolderPrefix; 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])); result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0); @@ -789,12 +792,8 @@ void CApp::OnSetSubFolder(int srcPanelIndex) if (!srcPanel.IsItemFolder(realIndex)) return; + // destPanel.BindToFolder(srcPanel._currentFolderPrefix + srcPanel.GetItemName(realIndex) + WCHAR_PATH_SEPARATOR); - /* - UString string = srcPanel._currentFolderPrefix + - srcPanel.GetItemName(realIndex) + L'\\'; - destPanel.BindToFolder(string); - */ CMyComPtr newFolder; if (realIndex == kParentIndex) { diff --git a/CPP/7zip/UI/FileManager/AppState.h b/CPP/7zip/UI/FileManager/AppState.h index 2b2a3e84..5ba0d47f 100755 --- a/CPP/7zip/UI/FileManager/AppState.h +++ b/CPP/7zip/UI/FileManager/AppState.h @@ -51,6 +51,13 @@ class CFolderHistory { NWindows::NSynchronization::CCriticalSection _criticalSection; UStringVector Strings; + void Normalize() + { + const int kMaxSize = 100; + if (Strings.Size() > kMaxSize) + Strings.Delete(kMaxSize, Strings.Size() - kMaxSize); + } + public: void GetList(UStringVector &foldersHistory) @@ -59,14 +66,6 @@ public: 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) { NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp index d5f0e867..b5e70d02 100755 --- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp +++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp @@ -369,9 +369,7 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) Password = dialog.Password; PasswordIsDefined = true; } - CMyComBSTR tempName(Password); - *password = tempName.Detach(); - return S_OK; + return StringToBstr(Password, password); } @@ -384,12 +382,9 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( Int32 *writeAnswer) { UString destPathResultTemp = destPath; - /* - { - CMyComBSTR destPathResultBSTR = destPath; - *destPathResult = destPathResultBSTR.Detach(); - } - */ + + // RINOK(StringToBstr(destPath, destPathResult)); + *destPathResult = 0; *writeAnswer = BoolToInt(false); @@ -476,9 +471,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( return E_ABORT; } } - CMyComBSTR destPathResultBSTR(destPathResultTemp); - *destPathResult = destPathResultBSTR.Detach(); *writeAnswer = BoolToInt(true); - return S_OK; + return StringToBstr(destPathResultTemp, destPathResult); } diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp index 4e5a3724..fc94bcbf 100755 --- a/CPP/7zip/UI/FileManager/FM.cpp +++ b/CPP/7zip/UI/FileManager/FM.cpp @@ -67,7 +67,7 @@ static UString GetProgramPath() UString GetProgramFolderPrefix() { UString path = GetProgramPath(); - int pos = path.ReverseFind(L'\\'); + int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); return path.Left(pos + 1); } diff --git a/CPP/7zip/UI/FileManager/FM.dsp b/CPP/7zip/UI/FileManager/FM.dsp index 8a3ddc83..38e3e19a 100755 --- a/CPP/7zip/UI/FileManager/FM.dsp +++ b/CPP/7zip/UI/FileManager/FM.dsp @@ -767,6 +767,10 @@ SOURCE=..\..\..\Windows\Clipboard.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\COM.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\CommonDialog.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/UI/FileManager/FSDrives.cpp b/CPP/7zip/UI/FileManager/FSDrives.cpp index 6fd8d708..f2d7ac93 100755 --- a/CPP/7zip/UI/FileManager/FSDrives.cpp +++ b/CPP/7zip/UI/FileManager/FSDrives.cpp @@ -195,7 +195,7 @@ STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value) switch(propID) { 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); return S_OK; diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp index a3e4787a..604c9b9c 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.cpp +++ b/CPP/7zip/UI/FileManager/FSFolder.cpp @@ -75,14 +75,14 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, { RINOK(progress->SetCompleted(NULL)); numFiles = numFolders = size = 0; - CEnumeratorW enumerator(path + UString(L"\\*")); + CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*")); CFileInfoW fileInfo; while (enumerator.Next(fileInfo)) { if (fileInfo.IsDir()) { 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++; numFiles += subFiles; @@ -125,7 +125,7 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path) { CDirItem &item = dirItem.Files[i]; if (item.IsDir()) - LoadSubItems(item, path + item.Name + L'\\'); + LoadSubItems(item, path + item.Name + WCHAR_PATH_SEPARATOR); } return S_OK; } @@ -311,7 +311,7 @@ HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultF *resultFolder = 0; CFSFolder *folderSpec = new CFSFolder; CMyComPtr subFolder = folderSpec; - RINOK(folderSpec->Init(_path + name + UString(L'\\'), 0)); + RINOK(folderSpec->Init(_path + name + UString(WCHAR_PATH_SEPARATOR), 0)); *resultFolder = subFolder.Detach(); return S_OK; } @@ -322,7 +322,7 @@ UString CFSFolder::GetPrefix(const CDirItem &item) const CDirItem *cur = item.Parent; while (cur->Parent != 0) { - path = cur->Name + UString('\\') + path; + path = cur->Name + UString(WCHAR_PATH_SEPARATOR) + path; cur = cur->Parent; } return path; @@ -358,11 +358,11 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) } if (_path.IsEmpty()) return E_INVALIDARG; - int pos = _path.ReverseFind(L'\\'); + int pos = _path.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0 || pos != _path.Length() - 1) return E_FAIL; UString parentPath = _path.Left(pos); - pos = parentPath.ReverseFind(L'\\'); + pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0) { parentPath.Empty(); @@ -374,10 +374,10 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) } UString parentPathReduced = parentPath.Left(pos); parentPath = parentPath.Left(pos + 1); - pos = parentPathReduced.ReverseFind(L'\\'); + pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos == 1) { - if (parentPath[0] != L'\\') + if (parentPath[0] != WCHAR_PATH_SEPARATOR) return E_FAIL; CNetFolder *netFolderSpec = new CNetFolder; CMyComPtr netFolder = netFolderSpec; @@ -537,7 +537,7 @@ HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath) resultPath = _path + newName; if (newName.Length() < 1) return S_OK; - if (newName[0] == L'\\') + if (newName[0] == WCHAR_PATH_SEPARATOR) { resultPath = newName; return S_OK; diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp index 8818b6a9..b2d057df 100755 --- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp +++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp @@ -216,6 +216,11 @@ static HRESULT MyCopyFile( return callback->SetCompleted(&completedSize); } +static UString CombinePath(const UString &folderPath, const UString &fileName) +{ + return folderPath + UString(WCHAR_PATH_SEPARATOR) + fileName; +} + static HRESULT CopyFolder( const UString &srcPath, const UString &destPathSpec, @@ -224,11 +229,11 @@ static HRESULT CopyFolder( { RINOK(callback->SetCompleted(&completedSize)); - UString destPath = destPathSpec; + const UString destPath = destPathSpec; int len = srcPath.Length(); 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 \'") + destPath + UString(L"\' onto itself"); @@ -243,19 +248,19 @@ static HRESULT CopyFolder( RINOK(callback->ShowMessage(message)); return E_ABORT; } - CEnumeratorW enumerator(srcPath + UString(L"\\*")); - CFileInfoEx fileInfo; - while (enumerator.Next(fileInfo)) + CEnumeratorW enumerator(CombinePath(srcPath, L"*")); + CFileInfoEx fi; + while (enumerator.Next(fi)) { - const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name; - const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name; - if (fileInfo.IsDir()) + const UString srcPath2 = CombinePath(srcPath, fi.Name); + const UString destPath2 = CombinePath(destPath, fi.Name); + if (fi.IsDir()) { - RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize)); + RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize)) } else { - RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize)); + RINOK(MyCopyFile(srcPath2, fi, destPath2, callback, completedSize)); } } return S_OK; @@ -275,7 +280,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems, UString destPath = path; if (destPath.IsEmpty()) return E_INVALIDARG; - bool directName = (destPath[destPath.Length() - 1] != L'\\'); + bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR); if (directName) { if (numItems > 1) @@ -298,18 +303,18 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems, RINOK(callback->SetCompleted(&completedSize)); for (UInt32 i = 0; i < numItems; i++) { - const CDirItem &fileInfo = *_refs[indices[i]]; + const CDirItem &fi = *_refs[indices[i]]; UString destPath2 = destPath; if (!directName) - destPath2 += fileInfo.Name; - UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name; - if (fileInfo.IsDir()) + destPath2 += fi.Name; + UString srcPath = _path + GetPrefix(fi) + fi.Name; + if (fi.IsDir()) { RINOK(CopyFolder(srcPath, destPath2, callback, completedSize)); } else { - RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize)); + RINOK(MyCopyFile(srcPath, fi, destPath2, callback, completedSize)); } } return S_OK; @@ -369,7 +374,7 @@ HRESULT MyMoveFolder( int len = srcPath.Length(); 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 \'") + destPath + UString(L"\' onto itself"); @@ -388,19 +393,19 @@ HRESULT MyMoveFolder( return E_ABORT; } { - CEnumeratorW enumerator(srcPath + UString(L"\\*")); - CFileInfoEx fileInfo; - while (enumerator.Next(fileInfo)) + CEnumeratorW enumerator(CombinePath(srcPath, L"*")); + CFileInfoEx fi; + while (enumerator.Next(fi)) { - const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name; - const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name; - if (fileInfo.IsDir()) + const UString srcPath2 = CombinePath(srcPath, fi.Name); + const UString destPath2 = CombinePath(destPath, fi.Name); + if (fi.IsDir()) { RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize)); } 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; if (destPath.IsEmpty()) return E_INVALIDARG; - bool directName = (destPath[destPath.Length() - 1] != L'\\'); + bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR); if (directName) { if (numItems > 1) @@ -449,18 +454,18 @@ STDMETHODIMP CFSFolder::MoveTo( RINOK(callback->SetCompleted(&completedSize)); for (UInt32 i = 0; i < numItems; i++) { - const CDirItem &fileInfo = *_refs[indices[i]]; + const CDirItem &fi = *_refs[indices[i]]; UString destPath2 = destPath; if (!directName) - destPath2 += fileInfo.Name; - UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name; - if (fileInfo.IsDir()) + destPath2 += fi.Name; + UString srcPath = _path + GetPrefix(fi) + fi.Name; + if (fi.IsDir()) { RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize)); } else { - RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize)); + RINOK(MyMoveFile(srcPath, fi, destPath2, callback, completedSize)); } } return S_OK; @@ -477,13 +482,13 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */, { UString path = (UString)fromFolderPath + itemsPaths[i]; - CFileInfoW fileInfo; - if (!FindFile(path, fileInfo)) + CFileInfoW fi; + if (!FindFile(path, fi)) return ::GetLastError(); - if (fileInfo.IsDir()) + if (fi.IsDir()) { 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++; numFiles += subFiles; @@ -492,7 +497,7 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */, else { numFiles++; - totalSize += fileInfo.Size; + totalSize += fi.Size; } } RINOK(progress->SetTotal(totalSize)); diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp index f93c0943..3cd79da0 100755 --- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp +++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp @@ -74,7 +74,7 @@ HRESULT OpenFileFolderPlugin( NFile::NName::SplitNameToPureNameAndExtension(name, pureName, dot, extension); - int slashPos = path.ReverseFind(L'\\'); + int slashPos = path.ReverseFind(WCHAR_PATH_SEPARATOR); UString dirPrefix; UString fileName; if (slashPos >= 0) diff --git a/CPP/7zip/UI/FileManager/NetFolder.cpp b/CPP/7zip/UI/FileManager/NetFolder.cpp index e03a06c5..d3298c62 100755 --- a/CPP/7zip/UI/FileManager/NetFolder.cpp +++ b/CPP/7zip/UI/FileManager/NetFolder.cpp @@ -75,7 +75,7 @@ void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource, _netResourcePointer = &_netResource; // if (_netResource.DisplayType == RESOURCEDISPLAYTYPE_SERVER) - _path = _netResource.RemoteName + L'\\'; + _path = _netResource.RemoteName + WCHAR_PATH_SEPARATOR; } _parentFolder = parentFolder; } @@ -113,11 +113,11 @@ STDMETHODIMP CNetFolder::LoadItems() if (!resource.RemoteNameIsDefined) // For Win 98, I don't know what's wrong resource.RemoteName = resource.Comment; resource.Name = resource.RemoteName; - int aPos = resource.Name.ReverseFind(L'\\'); - if (aPos >= 0) + int pos = resource.Name.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos >= 0) { - // _path = resource.Name.Left(aPos + 1); - resource.Name = resource.Name.Mid(aPos + 1); + // _path = resource.Name.Left(pos + 1); + resource.Name = resource.Name.Mid(pos + 1); } _items.Add(resource); } @@ -140,7 +140,7 @@ STDMETHODIMP CNetFolder::LoadItems() NFile::NFind::CFindFile findFile; 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; resource.Usage = RESOURCEUSAGE_CONNECTABLE; resource.LocalNameIsDefined = false; @@ -188,14 +188,14 @@ STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder { NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; CMyComPtr subFolder = fsFolderSpec; - RINOK(fsFolderSpec->Init(resource.RemoteName + L'\\', this)); + RINOK(fsFolderSpec->Init(resource.RemoteName + WCHAR_PATH_SEPARATOR, this)); *resultFolder = subFolder.Detach(); } else { CNetFolder *netFolder = new CNetFolder; CMyComPtr subFolder = netFolder; - netFolder->Init(&resource, this, resource.Name + L'\\'); + netFolder->Init(&resource, this, resource.Name + WCHAR_PATH_SEPARATOR); *resultFolder = subFolder.Detach(); } return S_OK; @@ -226,7 +226,7 @@ STDMETHODIMP CNetFolder::BindToParentFolder(IFolderFolder **resultFolder) CNetFolder *netFolder = new CNetFolder; CMyComPtr subFolder = netFolder; - netFolder->Init(&resourceParent, 0, L'\\'); + netFolder->Init(&resourceParent, 0, WCHAR_PATH_SEPARATOR); *resultFolder = subFolder.Detach(); } return S_OK; diff --git a/CPP/7zip/UI/FileManager/OpenCallback.cpp b/CPP/7zip/UI/FileManager/OpenCallback.cpp index be40fc1c..9c71a291 100755 --- a/CPP/7zip/UI/FileManager/OpenCallback.cpp +++ b/CPP/7zip/UI/FileManager/OpenCallback.cpp @@ -120,7 +120,5 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) Password = dialog.Password; PasswordIsDefined = true; } - CMyComBSTR tempName(Password); - *password = tempName.Detach(); - return S_OK; + return StringToBstr(Password, password); } diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp index e0ed7b50..cdb12ced 100755 --- a/CPP/7zip/UI/FileManager/Panel.cpp +++ b/CPP/7zip/UI/FileManager/Panel.cpp @@ -800,7 +800,7 @@ void CPanel::AddToArchive() static UString GetSubFolderNameForExtract(const UString &archiveName) { - int slashPos = archiveName.ReverseFind(L'\\'); + int slashPos = archiveName.ReverseFind(WCHAR_PATH_SEPARATOR); int dotPos = archiveName.ReverseFind(L'.'); if (dotPos < 0 || slashPos > dotPos) return archiveName + UString(L"~"); @@ -846,7 +846,7 @@ void CPanel::ExtractArchives() folderName = GetSubFolderNameForExtract(GetItemRelPath(indices[0])); else folderName = L"*"; - ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(L"\\"), true); + ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(WCHAR_PATH_SEPARATOR), true); } struct CThreadTest diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp index 61490b57..d6dbd069 100755 --- a/CPP/7zip/UI/FileManager/PanelCrc.cpp +++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp @@ -64,7 +64,7 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr if (Index >= FileNames.Size()) return true; const UString &path = FileNames[Index]; - int pos = path.ReverseFind('\\'); + int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); resPath.Empty(); if (pos >= 0) resPath = path.Left(pos + 1); diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp index 25cbbc38..6cae36fe 100755 --- a/CPP/7zip/UI/FileManager/PanelDrag.cpp +++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp @@ -149,7 +149,7 @@ STDMETHODIMP CDataObject::QueryGetData(LPFORMATETC etc) STDMETHODIMP CDataObject::EnumFormatEtc(DWORD direction, LPENUMFORMATETC FAR* enumFormatEtc) { - if(direction != DATADIR_GET) + if (direction != DATADIR_GET) return E_NOTIMPL; return CreateEnumFormatEtc(1, &m_Etc, enumFormatEtc); } @@ -183,9 +183,9 @@ public: STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState) { - if(escapePressed == TRUE) + if (escapePressed == TRUE) return DRAGDROP_S_CANCEL; - if((keyState & MK_LBUTTON) == 0) + if ((keyState & MK_LBUTTON) == 0) { if (m_Effect == DROPEFFECT_NONE) return DRAGDROP_S_CANCEL; @@ -570,7 +570,7 @@ bool CDropTarget::IsItSameDrive() const return false; } else if (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0) - drive = m_SubFolderName + L'\\'; + drive = m_SubFolderName + WCHAR_PATH_SEPARATOR; else return false; @@ -591,10 +591,7 @@ DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffec if (!m_DropIsAllowed || !m_PanelDropIsAllowed) return DROPEFFECT_NONE; - if (!IsFsFolderPath()) - allowedEffect &= ~DROPEFFECT_MOVE; - - if (!m_SetPathIsOK) + if (!IsFsFolderPath() || !m_SetPathIsOK) allowedEffect &= ~DROPEFFECT_MOVE; DWORD effect = 0; @@ -602,17 +599,17 @@ DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffec effect = allowedEffect & DROPEFFECT_COPY; else if (keyState & MK_SHIFT) effect = allowedEffect & DROPEFFECT_MOVE; - if(effect == 0) + if (effect == 0) { - if(allowedEffect & DROPEFFECT_COPY) + if (allowedEffect & DROPEFFECT_COPY) effect = DROPEFFECT_COPY; - if(allowedEffect & DROPEFFECT_MOVE) + if (allowedEffect & DROPEFFECT_MOVE) { if (IsItSameDrive()) effect = DROPEFFECT_MOVE; } } - if(effect == 0) + if (effect == 0) return DROPEFFECT_NONE; return effect; } @@ -627,7 +624,7 @@ UString CDropTarget::GetTargetPath() const if (m_SubFolderIndex >= 0 && !m_SubFolderName.IsEmpty()) { path += m_SubFolderName; - path += L"\\"; + path += WCHAR_PATH_SEPARATOR; } return path; } @@ -703,11 +700,11 @@ STDMETHODIMP CDropTarget::Drop(IDataObject *dataObject, DWORD keyState, PositionCursor(pt); m_DataObject = dataObject; bool needDrop = true; - if(m_DropIsAllowed && m_PanelDropIsAllowed) + if (m_DropIsAllowed && m_PanelDropIsAllowed) if (IsFsFolderPath()) needDrop = !SetPath(); *effect = GetEffect(keyState, pt, *effect); - if(m_DropIsAllowed && m_PanelDropIsAllowed) + if (m_DropIsAllowed && m_PanelDropIsAllowed) { if (needDrop) { diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp index 47363ef4..f4d024b2 100755 --- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp +++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp @@ -69,11 +69,11 @@ HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool UString sysPath = fullPath; CFileInfoW fileInfo; UStringVector reducedParts; - while(!sysPath.IsEmpty()) + while (!sysPath.IsEmpty()) { if (FindFile(sysPath, fileInfo)) break; - int pos = sysPath.ReverseFind(L'\\'); + int pos = sysPath.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0) sysPath.Empty(); else @@ -175,7 +175,7 @@ void CPanel::LoadFullPath() const CFolderLink &folderLink = _parentFolders[i]; _currentFolderPrefix += GetFolderPath(folderLink.ParentFolder); _currentFolderPrefix += folderLink.ItemName; - _currentFolderPrefix += L'\\'; + _currentFolderPrefix += WCHAR_PATH_SEPARATOR; } if (_folder) _currentFolderPrefix += GetFolderPath(_folder); @@ -199,7 +199,13 @@ void CPanel::LoadFullPathAndShow() item.mask = 0; 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); CFileInfoW info; @@ -334,12 +340,12 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) sumPass += name; UString curName = sumPass; if (i == 0) - curName += L"\\"; + curName += WCHAR_PATH_SEPARATOR; CFileInfoW info; DWORD attrib = FILE_ATTRIBUTE_DIRECTORY; if (NFile::NFind::FindFile(sumPass, info)) attrib = info.Attrib; - sumPass += L"\\"; + sumPass += WCHAR_PATH_SEPARATOR; AddComboBoxItem(name, GetRealIconIndex(curName, attrib), i, false); ComboBoxPaths.Add(sumPass); } @@ -357,7 +363,7 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) UString s = driveStrings[i]; ComboBoxPaths.Add(s); 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); AddComboBoxItem(s, iconIndex, 1, false); } @@ -463,7 +469,7 @@ void CPanel::OpenParentFolder() { UString string = _currentFolderPrefix; string.Delete(string.Length() - 1); - int pos = string.ReverseFind(L'\\'); + int pos = string.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0) pos = 0; else @@ -512,7 +518,7 @@ void CPanel::OpenParentFolder() void CPanel::CloseOpenFolders() { - while(_parentFolders.Size() > 0) + while (_parentFolders.Size() > 0) { _folder.Release(); _library.Free(); diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp index 89b47ec7..3b309d27 100755 --- a/CPP/7zip/UI/FileManager/PanelItems.cpp +++ b/CPP/7zip/UI/FileManager/PanelItems.cpp @@ -425,7 +425,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se if (_currentFolderPrefix.IsEmpty()) { int iconIndexTemp; - GetRealIconIndex(itemName + L"\\", attributes, iconIndexTemp); + GetRealIconIndex(itemName + WCHAR_PATH_SEPARATOR, attributes, iconIndexTemp); item.iImage = iconIndexTemp; } else diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp index c881d8b8..ab48bbc7 100755 --- a/CPP/7zip/UI/FileManager/PanelMenu.cpp +++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp @@ -288,7 +288,7 @@ HRESULT CPanel::CreateShellContextMenu( LPITEMIDLIST pidl; UString fileName = GetItemRelPath(operatedIndices[i]); if (IsFSDrivesFolder()) - fileName += L'\\'; + fileName += WCHAR_PATH_SEPARATOR; RINOK(parentFolder->ParseDisplayName(GetParent(), 0, (wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0)); pidls.Add(pidl); @@ -301,7 +301,7 @@ HRESULT CPanel::CreateShellContextMenu( /* LPITEMIDLIST pidl; HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0, - L".\\", &eaten, &pidl, 0); + L"." WSTRING_PATH_SEPARATOR, &eaten, &pidl, 0); if (result != NOERROR) return; */ diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp index 76de0c1a..c3b5d69d 100755 --- a/CPP/7zip/UI/FileManager/PanelOperations.cpp +++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp @@ -362,7 +362,7 @@ void CPanel::CreateFolder() return; } } - int pos = newName.Find(L'\\'); + int pos = newName.Find(WCHAR_PATH_SEPARATOR); if (pos >= 0) newName = newName.Left(pos); if (!_mySelectMode) @@ -397,7 +397,7 @@ void CPanel::CreateFile() MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243)); return; } - int pos = newName.Find(L'\\'); + int pos = newName.Find(WCHAR_PATH_SEPARATOR); if (pos >= 0) newName = newName.Left(pos); if (!_mySelectMode) diff --git a/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp b/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp index eb6674b3..750f2e02 100755 --- a/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp +++ b/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp @@ -237,7 +237,7 @@ STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numIt UString destPath = path; if (destPath.IsEmpty()) return E_INVALIDARG; - bool directName = (destPath[destPath.Length() - 1] != L'\\'); + bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR); if (directName) { if (numItems > 1) diff --git a/CPP/7zip/UI/FileManager/PluginsPage.cpp b/CPP/7zip/UI/FileManager/PluginsPage.cpp index 3b205ce3..d79e78d8 100755 --- a/CPP/7zip/UI/FileManager/PluginsPage.cpp +++ b/CPP/7zip/UI/FileManager/PluginsPage.cpp @@ -118,9 +118,7 @@ STDMETHODIMP CPluginOptionsCallback::GetProgramFolderPath(BSTR *value) UString folder; if (!::GetProgramFolderPath(folder)) return E_FAIL; - CMyComBSTR valueTemp = folder; - *value = valueTemp.Detach(); - return S_OK; + return StringToBstr(folder, value); } static UString GetDefaultProgramName() @@ -134,16 +132,16 @@ STDMETHODIMP CPluginOptionsCallback::GetProgramPath(BSTR *value) UString folder; if (!::GetProgramFolderPath(folder)) return E_FAIL; - CMyComBSTR valueTemp = folder + GetDefaultProgramName(); - *value = valueTemp.Detach(); - return S_OK; + return StringToBstr(folder + GetDefaultProgramName(), value); } STDMETHODIMP CPluginOptionsCallback::GetRegistryCUPath(BSTR *value) { - CMyComBSTR valueTemp = UString(L"Software\\7-Zip\\FM\\Plugins\\") + _pluginName; - *value = valueTemp.Detach(); - return S_OK; + return StringToBstr(UString(L"Software" + WSTRING_PATH_SEPARATOR L"7-Zip" + WSTRING_PATH_SEPARATOR L"FM" + WSTRING_PATH_SEPARATOR L"Plugins" + WSTRING_PATH_SEPARATOR) + _pluginName, value); } void CPluginsPage::OnButtonOptions() diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.cpp b/CPP/7zip/UI/FileManager/ProgramLocation.cpp index 88c18d5e..fc7b40db 100755 --- a/CPP/7zip/UI/FileManager/ProgramLocation.cpp +++ b/CPP/7zip/UI/FileManager/ProgramLocation.cpp @@ -15,7 +15,7 @@ bool GetProgramFolderPath(UString &folder) { if (!NDLL::MyGetModuleFileName(g_hInstance, folder)) return false; - int pos = folder.ReverseFind(L'\\'); + int pos = folder.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0) return false; folder = folder.Left(pos + 1); diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp index 0e24f187..e8846e68 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp @@ -336,7 +336,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) ProgressSynch.GetCurrentFileName(fileName); if (_prevFileName != fileName) { - int slashPos = fileName.ReverseFind(L'\\'); + int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); UString s1, s2; if (slashPos >= 0) { diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp index 72153f9d..93340c3f 100755 --- a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp +++ b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp @@ -23,22 +23,22 @@ namespace NRegistryAssociations { static NSynchronization::CCriticalSection g_CriticalSection; -static const TCHAR *kCUKeyPath = TEXT("Software\\7-ZIP\\FM"); -static const TCHAR *kAssociations = TEXT("Associations"); +#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") TEXT(STRING_PATH_SEPARATOR) TEXT("FM") + +static const TCHAR *kCUKeyPath = REG_PATH_FM; static const WCHAR *kExtPlugins = L"Plugins"; static const TCHAR *kExtEnabled = TEXT("Enabled"); -static CSysString GetAssociationsPath() -{ - return CSysString(kCUKeyPath) + CSysString('\\') + CSysString(kAssociations); -} +#define kAssociations TEXT("Associations") +#define kAssociationsPath REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) kAssociations bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo) { NSynchronization::CCriticalSectionLock lock(g_CriticalSection); CKey key; - if(key.Open(HKEY_CURRENT_USER, GetAssociationsPath() + CSysString('\\') + - CSysString(GetSystemString(ext)), KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, + CSysString(kAssociationsPath TEXT(STRING_PATH_SEPARATOR)) + + GetSystemString(ext), KEY_READ) != ERROR_SUCCESS) return false; UString pluginsString; key.QueryValue(kExtPlugins, pluginsString); @@ -51,7 +51,7 @@ void ReadInternalAssociations(CObjectVector &items) items.Clear(); NSynchronization::CCriticalSectionLock lock(g_CriticalSection); 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; CSysStringVector extNames; associationsKey.EnumKeys(extNames); @@ -62,7 +62,7 @@ void ReadInternalAssociations(CObjectVector &items) // extInfo.Enabled = false; extInfo.Ext = GetUnicodeString(extName); CKey key; - if(key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS) + if (key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS) return; UString pluginsString; key.QueryValue(kExtPlugins, pluginsString); @@ -129,7 +129,7 @@ static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconP if (programNameValue.CompareNoCase(extProgramKeyName) != 0) return false; 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; UString value; if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS) diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp index a0bfec05..61cceb5f 100755 --- a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp +++ b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp @@ -110,7 +110,7 @@ void ReadPluginInfoList(CObjectVector &plugins) if (::ReadPluginInfo(pluginInfo)) plugins.Add(pluginInfo); } - UString folderPath = baseFolderPrefix + L"Plugins\\"; + UString folderPath = baseFolderPrefix + L"Plugins" WSTRING_PATH_SEPARATOR; NFind::CEnumeratorW enumerator(folderPath + L"*"); NFind::CFileInfoW fileInfo; while (enumerator.Next(fileInfo)) diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.cpp b/CPP/7zip/UI/FileManager/RegistryUtils.cpp index e9c13d19..f071a9c9 100755 --- a/CPP/7zip/UI/FileManager/RegistryUtils.cpp +++ b/CPP/7zip/UI/FileManager/RegistryUtils.cpp @@ -8,9 +8,11 @@ using namespace NWindows; using namespace NRegistry; -static const TCHAR *kCUBasePath = TEXT("Software\\7-ZIP"); -static const TCHAR *kCU_FMPath = TEXT("Software\\7-ZIP\\FM"); -// static const TCHAR *kLM_Path = TEXT("Software\\7-ZIP\\FM"); +#define REG_PATH_7Z TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") + +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 *kEditor = L"Editor"; diff --git a/CPP/7zip/UI/FileManager/RootFolder.cpp b/CPP/7zip/UI/FileManager/RootFolder.cpp index 3f3c67ef..0dec5412 100755 --- a/CPP/7zip/UI/FileManager/RootFolder.cpp +++ b/CPP/7zip/UI/FileManager/RootFolder.cpp @@ -95,8 +95,8 @@ UString GetMyDocsPath() us = GetUnicodeString(s2); } #endif - if (us.Length() > 0 && us[us.Length() - 1] != L'\\') - us += L'\\'; + if (us.Length() > 0 && us[us.Length() - 1] != WCHAR_PATH_SEPARATOR) + us += WCHAR_PATH_SEPARATOR; return us; } @@ -113,7 +113,7 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde { CNetFolder *netFolderSpec = new CNetFolder; CMyComPtr 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(); } 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) { - 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) @@ -159,7 +159,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu if (AreEqualNames(name2, L"My Computer") || AreEqualNames(name2, L"Computer")) return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder); - if (name2 == UString(L'\\')) + if (name2 == UString(WCHAR_PATH_SEPARATOR)) { CMyComPtr subFolder = this; *resultFolder = subFolder.Detach(); @@ -179,13 +179,13 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu } else { - if (name2[name2.Length () - 1] != L'\\') - name2 += L'\\'; + if (name2[name2.Length () - 1] != WCHAR_PATH_SEPARATOR) + name2 += WCHAR_PATH_SEPARATOR; NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; subFolder = fsFolderSpec; if (fsFolderSpec->Init(name2, 0) != S_OK) { - if (name2[0] == L'\\') + if (name2[0] == WCHAR_PATH_SEPARATOR) { CNetFolder *netFolderSpec = new CNetFolder; subFolder = netFolderSpec; @@ -240,7 +240,3 @@ STDMETHODIMP CRootFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex) *iconIndex = _iconIndices[index]; return S_OK; } - - - - diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp index 376e7647..8f6597f4 100755 --- a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp +++ b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp @@ -93,9 +93,7 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefi */ } *passwordIsDefined = BoolToInt(_passwordIsDefined); - CMyComBSTR tempName = _password; - *password = tempName.Detach(); - return S_OK; + return StringToBstr(_password, password); } STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */) @@ -112,8 +110,5 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) { if (!_passwordIsDefined) return S_FALSE; - CMyComBSTR tempName = _password; - *password = tempName.Detach(); - return S_OK; + return StringToBstr(_password, password); } - diff --git a/CPP/7zip/UI/FileManager/ViewSettings.cpp b/CPP/7zip/UI/FileManager/ViewSettings.cpp index 34d01229..6c611dad 100755 --- a/CPP/7zip/UI/FileManager/ViewSettings.cpp +++ b/CPP/7zip/UI/FileManager/ViewSettings.cpp @@ -12,9 +12,10 @@ using namespace NWindows; 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 *kPanelsInfoValueName = TEXT("Panels"); @@ -126,11 +127,8 @@ void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo) } { NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CSysString keyName = kCUBasePath; - keyName += kKeyNameDelimiter; - keyName += kCulumnsKeyName; CKey key; - key.Create(HKEY_CURRENT_USER, keyName); + key.Create(HKEY_CURRENT_USER, kCulumnsKeyName); key.SetValue(GetSystemString(id), (const Byte *)buffer, dataSize); } } @@ -143,11 +141,8 @@ void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo) UInt32 size; { NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CSysString keyName = kCUBasePath; - keyName += kKeyNameDelimiter; - keyName += kCulumnsKeyName; 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; if (key.QueryValue(GetSystemString(id), buffer, size) != ERROR_SUCCESS) return; diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp index 9634ba02..468c87c8 100755 --- a/CPP/7zip/UI/GUI/CompressDialog.cpp +++ b/CPP/7zip/UI/GUI/CompressDialog.cpp @@ -426,7 +426,7 @@ void CCompressDialog::OnButtonSFX() UString fileName; m_ArchivePath.GetText(fileName); int dotPos = fileName.ReverseFind(L'.'); - int slashPos = fileName.ReverseFind(L'\\'); + int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); if (dotPos < 0 || dotPos <= slashPos) dotPos = -1; bool isSFX = IsSFX(); @@ -707,7 +707,7 @@ void CCompressDialog::SetArchiveName(const UString &name) if (!Info.KeepName) { 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) fileName = fileName.Left(dotPos); } diff --git a/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp b/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp index 7cd5df95..8d63ee58 100755 --- a/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp +++ b/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp @@ -167,9 +167,7 @@ HRESULT CUpdateCallbackGUI::CryptoGetTextPassword2(Int32 *passwordIsDefined, BST } } *passwordIsDefined = BoolToInt(PasswordIsDefined); - CMyComBSTR tempName(Password); - *password = tempName.Detach(); - return S_OK; + return StringToBstr(Password, password); } /* @@ -211,9 +209,7 @@ HRESULT CUpdateCallbackGUI::Open_CryptoGetTextPassword(BSTR *password) Password = dialog.Password; PasswordIsDefined = true; } - CMyComBSTR tempName(Password); - *password = tempName.Detach(); - return S_OK; + return StringToBstr(Password, password); } HRESULT CUpdateCallbackGUI::Open_GetPasswordIfAny(UString &password) diff --git a/CPP/7zip/UI/GUI/UpdateGUI.cpp b/CPP/7zip/UI/GUI/UpdateGUI.cpp index 16edc718..ef9a2d70 100755 --- a/CPP/7zip/UI/GUI/UpdateGUI.cpp +++ b/CPP/7zip/UI/GUI/UpdateGUI.cpp @@ -239,7 +239,7 @@ static HRESULT ShowDialog( for (int i = 0; i < item.PathParts.Size(); i++) { if (i > 0) - name += L'\\'; + name += WCHAR_PATH_SEPARATOR; name += item.PathParts[i]; } if (NFind::FindFile(name, fileInfo)) diff --git a/CPP/Common/Buffer.h b/CPP/Common/Buffer.h index cc8b3428..b6960fa8 100755 --- a/CPP/Common/Buffer.h +++ b/CPP/Common/Buffer.h @@ -32,7 +32,7 @@ public: if (newCapacity > 0) { newBuffer = new T[newCapacity]; - if(_capacity > 0) + if (_capacity > 0) memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T)); } else @@ -44,7 +44,7 @@ public: CBuffer& operator=(const CBuffer &buffer) { Free(); - if(buffer._capacity > 0) + if (buffer._capacity > 0) { SetCapacity(buffer._capacity); memmove(_items, buffer._items, buffer._capacity * sizeof(T)); diff --git a/CPP/Common/C_FileIO.cpp b/CPP/Common/C_FileIO.cpp index 3c7f82d9..b4893d65 100755 --- a/CPP/Common/C_FileIO.cpp +++ b/CPP/Common/C_FileIO.cpp @@ -21,7 +21,7 @@ bool CFileBase::OpenBinary(const char *name, int flags) bool CFileBase::Close() { - if(_handle == -1) + if (_handle == -1) return true; if (close(_handle) != 0) return false; diff --git a/CPP/Common/CommandLineParser.cpp b/CPP/Common/CommandLineParser.cpp index 52785d07..6de5e63b 100755 --- a/CPP/Common/CommandLineParser.cpp +++ b/CPP/Common/CommandLineParser.cpp @@ -99,14 +99,14 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms) int pos = 0; if (!IsItSwitchChar(s[pos])) return false; - while(pos < len) + while (pos < len) { if (IsItSwitchChar(s[pos])) pos++; const int kNoLen = -1; int matchedSwitchIndex = 0; // GCC Warning int maxLen = kNoLen; - for(int switchIndex = 0; switchIndex < _numSwitches; switchIndex++) + for (int switchIndex = 0; switchIndex < _numSwitches; switchIndex++) { int switchLen = MyStringLen(switchForms[switchIndex].IDString); if (switchLen <= maxLen || pos + switchLen > len) @@ -114,8 +114,8 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms) UString temp = s + pos; temp = temp.Left(switchLen); - if(temp.CompareNoCase(switchForms[switchIndex].IDString) == 0) - // if(_strnicmp(switchForms[switchIndex].IDString, LPCSTR(s) + pos, switchLen) == 0) + if (temp.CompareNoCase(switchForms[switchIndex].IDString) == 0) + // if (_strnicmp(switchForms[switchIndex].IDString, LPCSTR(s) + pos, switchLen) == 0) { matchedSwitchIndex = switchIndex; maxLen = switchLen; @@ -180,7 +180,7 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms) int maxLen = switchForm.MaxLen; UString stringSwitch = s.Mid(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]; if (IsItSwitchChar(c)) @@ -208,12 +208,12 @@ const CSwitchResult& CParser::operator[](size_t index) const int ParseCommand(int numCommandForms, const CCommandForm *commandForms, 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; if (commandForms[i].PostStringMode) { - if(commandString.Find(id) == 0) + if (commandString.Find(id) == 0) { postString = commandString.Mid(id.Length()); return i; diff --git a/CPP/Common/DynamicBuffer.h b/CPP/Common/DynamicBuffer.h index 9bdbaac8..fd33cec3 100755 --- a/CPP/Common/DynamicBuffer.h +++ b/CPP/Common/DynamicBuffer.h @@ -26,7 +26,7 @@ public: CDynamicBuffer& operator=(const CDynamicBuffer &buffer) { this->Free(); - if(buffer._capacity > 0) + if (buffer._capacity > 0) { SetCapacity(buffer._capacity); memmove(this->_items, buffer._items, buffer._capacity * sizeof(T)); diff --git a/CPP/Common/IntToString.cpp b/CPP/Common/IntToString.cpp index c071daef..beda203d 100755 --- a/CPP/Common/IntToString.cpp +++ b/CPP/Common/IntToString.cpp @@ -22,7 +22,7 @@ void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base) while (value != 0); do *s++ = temp[--pos]; - while(pos > 0); + while (pos > 0); *s = '\0'; } @@ -38,7 +38,7 @@ void ConvertUInt64ToString(UInt64 value, wchar_t *s) while (value != 0); do *s++ = temp[--pos]; - while(pos > 0); + while (pos > 0); *s = L'\0'; } diff --git a/CPP/Common/ListFileUtils.cpp b/CPP/Common/ListFileUtils.cpp index cf03d324..c1c682a2 100755 --- a/CPP/Common/ListFileUtils.cpp +++ b/CPP/Common/ListFileUtils.cpp @@ -53,7 +53,7 @@ bool ReadNamesFromListFile(LPCWSTR fileName, UStringVector &resultStrings, UINT } UString t; - for(int i = 0; i < u.Length(); i++) + for (int i = 0; i < u.Length(); i++) { wchar_t c = u[i]; if (c == L'\n' || c == 0xD) diff --git a/CPP/Common/MyCom.h b/CPP/Common/MyCom.h index 2cd09358..2f00c258 100755 --- a/CPP/Common/MyCom.h +++ b/CPP/Common/MyCom.h @@ -6,7 +6,7 @@ #include "MyWindows.h" #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 template @@ -78,12 +78,18 @@ public: ////////////////////////////////////////////////////////// +inline HRESULT StringToBstr(LPCOLESTR src, BSTR *bstr) +{ + *bstr = ::SysAllocString(src); + return (*bstr != 0) ? S_OK : E_OUTOFMEMORY; +} + class CMyComBSTR { public: BSTR m_str; - CMyComBSTR() { m_str = NULL; } - CMyComBSTR(LPCOLESTR pSrc) { m_str = ::SysAllocString(pSrc); } + CMyComBSTR(): m_str(NULL) {} + CMyComBSTR(LPCOLESTR src) { m_str = ::SysAllocString(src); } // CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); } // CMyComBSTR(int nSize, LPCOLESTR sz) { m_str = ::SysAllocStringLen(sz, nSize); } CMyComBSTR(const CMyComBSTR& src) { m_str = src.MyCopy(); } @@ -107,10 +113,10 @@ public: } return *this; } - CMyComBSTR& operator=(LPCOLESTR pSrc) + CMyComBSTR& operator=(LPCOLESTR src) { ::SysFreeString(m_str); - m_str = ::SysAllocString(pSrc); + m_str = ::SysAllocString(src); return *this; } unsigned int Length() const { return ::SysStringLen(m_str); } @@ -120,16 +126,18 @@ public: { int byteLen = ::SysStringByteLen(m_str); BSTR res = ::SysAllocStringByteLen(NULL, byteLen); - memmove(res, m_str, byteLen); + memcpy(res, m_str, byteLen); return res; } - void Attach(BSTR src) { m_str = src; } + /* + void Attach(BSTR src) { m_str = src; } BSTR Detach() { BSTR s = m_str; m_str = NULL; return s; } + */ void Empty() { ::SysFreeString(m_str); @@ -138,7 +146,6 @@ public: bool operator!() const { return (m_str == NULL); } }; - ////////////////////////////////////////////////////////// class CMyUnknownImp diff --git a/CPP/Common/MyString.h b/CPP/Common/MyString.h index 64095771..82b97618 100755 --- a/CPP/Common/MyString.h +++ b/CPP/Common/MyString.h @@ -24,7 +24,7 @@ template inline T * MyStringCopy(T *dest, const T *src) { T *destStart = dest; - while((*dest++ = *src++) != 0); + while ((*dest++ = *src++) != 0); return destStart; } @@ -131,7 +131,7 @@ class CStringBase pLast = NULL; p = GetNextCharPointer(p); } - if(pLast != NULL) + if (pLast != NULL) { int i = (int)(pLast - _chars); Delete(i, _length - i); @@ -172,7 +172,7 @@ protected: /* const int kMaxStringSize = 0x20000000; #ifndef _WIN32_WCE - if(newCapacity > kMaxStringSize || newCapacity < _length) + if (newCapacity > kMaxStringSize || newCapacity < _length) throw 1052337; #endif */ @@ -250,7 +250,7 @@ public: { /* #ifndef _WIN32_WCE - if(newLength >= _capacity) + if (newLength >= _capacity) throw 282217; #endif */ @@ -278,7 +278,7 @@ public: } CStringBase& operator=(const CStringBase& s) { - if(&s == this) + if (&s == this) return *this; Empty(); SetCapacity(s._length); @@ -414,7 +414,7 @@ public: } 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) return i; return -1; @@ -461,7 +461,7 @@ public: pLast = NULL; p = GetNextCharPointer(p); } - if(pLast != NULL) + if (pLast != NULL) { int i = pLast - _chars; Delete(i, _length - i); @@ -487,7 +487,7 @@ public: return _length; int numInsertChars = s.Length(); InsertSpace(index, numInsertChars); - for(int i = 0; i < numInsertChars; i++) + for (int i = 0; i < numInsertChars; i++) _chars[index + i] = s[i]; _length += numInsertChars; return _length; diff --git a/CPP/Common/MyVector.h b/CPP/Common/MyVector.h index 0ab79d6e..079e8ae4 100755 --- a/CPP/Common/MyVector.h +++ b/CPP/Common/MyVector.h @@ -47,7 +47,7 @@ public: { int size = v.Size(); Reserve(Size() + size); - for(int i = 0; i < size; i++) + for (int i = 0; i < size; i++) Add(v[i]); return *this; } @@ -141,7 +141,7 @@ public: int i = size / 2; do SortRefDown(p, i, size, compare, param); - while(--i != 0); + while (--i != 0); } do { @@ -176,7 +176,7 @@ public: { int size = v.Size(); Reserve(Size() + size); - for(int i = 0; i < size; i++) + for (int i = 0; i < size; i++) Add(v[i]); return *this; } @@ -191,13 +191,13 @@ public: virtual void Delete(int index, int num = 1) { TestIndexAndCorrectNum(index, num); - for(int i = 0; i < num; i++) + for (int i = 0; i < num; i++) delete (T *)(((void **)_items)[index + i]); CPointerVector::Delete(index, num); } int Find(const T& item) const { - for(int i = 0; i < Size(); i++) + for (int i = 0; i < Size(); i++) if (item == (*this)[i]) return i; return -1; diff --git a/CPP/Common/MyWindows.cpp b/CPP/Common/MyWindows.cpp index d9d8327b..1283946c 100755 --- a/CPP/Common/MyWindows.cpp +++ b/CPP/Common/MyWindows.cpp @@ -94,14 +94,10 @@ HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src) LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2) { - if(ft1->dwHighDateTime < ft2->dwHighDateTime) - return -1; - if(ft1->dwHighDateTime > ft2->dwHighDateTime) - return 1; - if(ft1->dwLowDateTime < ft2->dwLowDateTime) - return -1; - if(ft1->dwLowDateTime > ft2->dwLowDateTime) - return 1; + if (ft1->dwHighDateTime < ft2->dwHighDateTime) return -1; + if (ft1->dwHighDateTime > ft2->dwHighDateTime) return 1; + if (ft1->dwLowDateTime < ft2->dwLowDateTime) return -1; + if (ft1->dwLowDateTime > ft2->dwLowDateTime) return 1; return 0; } diff --git a/CPP/Common/StdInStream.cpp b/CPP/Common/StdInStream.cpp index 65aa8dde..b3d00920 100755 --- a/CPP/Common/StdInStream.cpp +++ b/CPP/Common/StdInStream.cpp @@ -31,7 +31,7 @@ bool CStdInStream::Open(LPCTSTR fileName) bool CStdInStream::Close() { - if(!_streamIsOpen) + if (!_streamIsOpen) return true; _streamIsOpen = (fclose(_stream) != 0); return !_streamIsOpen; @@ -48,12 +48,12 @@ AString CStdInStream::ScanStringUntilNewLine() for (;;) { int intChar = GetChar(); - if(intChar == EOF) + if (intChar == EOF) throw kEOFMessage; char c = char(intChar); if (c == kIllegalChar) throw kIllegalCharMessage; - if(c == kNewLineChar) + if (c == kNewLineChar) break; s += c; } @@ -64,7 +64,7 @@ void CStdInStream::ReadToString(AString &resultString) { resultString.Empty(); int c; - while((c = GetChar()) != EOF) + while ((c = GetChar()) != EOF) resultString += char(c); } @@ -76,7 +76,7 @@ bool CStdInStream::Eof() int CStdInStream::GetChar() { int c = fgetc(_stream); // getc() doesn't work in BeOS? - if(c == EOF && !Eof()) + if (c == EOF && !Eof()) throw kReadErrorMessage; return c; } diff --git a/CPP/Common/StdOutStream.cpp b/CPP/Common/StdOutStream.cpp index 084ee95a..b93e255f 100755 --- a/CPP/Common/StdOutStream.cpp +++ b/CPP/Common/StdOutStream.cpp @@ -30,7 +30,7 @@ bool CStdOutStream::Open(const char *fileName) bool CStdOutStream::Close() { - if(!_streamIsOpen) + if (!_streamIsOpen) return true; if (fclose(_stream) != 0) return false; diff --git a/CPP/Common/StringConvert.cpp b/CPP/Common/StringConvert.cpp index cb57467b..9bd47deb 100755 --- a/CPP/Common/StringConvert.cpp +++ b/CPP/Common/StringConvert.cpp @@ -12,13 +12,13 @@ UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) { UString resultString; - if(!srcString.IsEmpty()) + if (!srcString.IsEmpty()) { int numChars = MultiByteToWideChar(codePage, 0, srcString, srcString.Length(), resultString.GetBuffer(srcString.Length()), srcString.Length() + 1); #ifndef _WIN32_WCE - if(numChars == 0) + if (numChars == 0) throw 282228; #endif resultString.ReleaseBuffer(numChars); @@ -39,7 +39,7 @@ AString UnicodeStringToMultiByte(const UString &s, UINT codePage, char defaultCh &defaultChar, &defUsed); defaultCharWasUsed = (defUsed != FALSE); #ifndef _WIN32_WCE - if(numChars == 0) + if (numChars == 0) throw 282229; #endif dest.ReleaseBuffer(numChars); @@ -71,7 +71,7 @@ UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) for (int i = 0; i < srcString.Length(); i++) resultString += wchar_t(srcString[i]); /* - if(!srcString.IsEmpty()) + if (!srcString.IsEmpty()) { int numChars = mbstowcs(resultString.GetBuffer(srcString.Length()), srcString, srcString.Length() + 1); 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++) resultString += char(srcString[i]); /* - if(!srcString.IsEmpty()) + if (!srcString.IsEmpty()) { int numRequiredBytes = srcString.Length() * 6 + 1; int numChars = wcstombs(resultString.GetBuffer(numRequiredBytes), srcString, numRequiredBytes); diff --git a/CPP/Common/Wildcard.cpp b/CPP/Common/Wildcard.cpp index 05a3f5a3..141c5dd6 100755 --- a/CPP/Common/Wildcard.cpp +++ b/CPP/Common/Wildcard.cpp @@ -106,8 +106,8 @@ void SplitPathToParts(const UString &path, UStringVector &pathParts) void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name) { int i; - for(i = path.Length() - 1; i >= 0; i--) - if(IsCharDirLimiter(path[i])) + for (i = path.Length() - 1; i >= 0; i--) + if (IsCharDirLimiter(path[i])) break; dirPrefix = path.Left(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) { int i; - for(i = path.Length() - 1; i >= 0; i--) - if(IsCharDirLimiter(path[i])) + for (i = path.Length() - 1; i >= 0; i--) + if (IsCharDirLimiter(path[i])) break; return path.Left(i + 1); } @@ -125,8 +125,8 @@ UString ExtractDirPrefixFromPath(const UString &path) UString ExtractFileNameFromPath(const UString &path) { int i; - for(i = path.Length() - 1; i >= 0; i--) - if(IsCharDirLimiter(path[i])) + for (i = path.Length() - 1; i >= 0; i--) + if (IsCharDirLimiter(path[i])) break; 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 include; - if(CheckPath(path, isFile, include)) + if (CheckPath(path, isFile, include)) return include; return false; } diff --git a/CPP/Windows/COM.h b/CPP/Windows/COM.h index 06d22ff3..ceffc97f 100755 --- a/CPP/Windows/COM.h +++ b/CPP/Windows/COM.h @@ -26,7 +26,7 @@ public: ~CStgMedium() { Free(); } void Free() { - if(_mustBeReleased) + if (_mustBeReleased) ReleaseStgMedium(&_object); _mustBeReleased = false; } diff --git a/CPP/Windows/Control/ImageList.h b/CPP/Windows/Control/ImageList.h index 8a0862e1..791c96fd 100755 --- a/CPP/Windows/Control/ImageList.h +++ b/CPP/Windows/Control/ImageList.h @@ -16,7 +16,7 @@ public: CImageList(): m_Object(NULL) {} bool Attach(HIMAGELIST imageList) { - if(imageList == NULL) + if (imageList == NULL) return false; m_Object = imageList; return true; @@ -33,7 +33,7 @@ public: { HIMAGELIST a = ImageList_Create(width, height, flags, initialNumber, grow); - if(a == NULL) + if (a == NULL) return false; return Attach(a); } diff --git a/CPP/Windows/Control/Window2.cpp b/CPP/Windows/Control/Window2.cpp index 3fcaa1ab..3900f649 100755 --- a/CPP/Windows/Control/Window2.cpp +++ b/CPP/Windows/Control/Window2.cpp @@ -49,7 +49,7 @@ bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className, HINSTANCE instance) { WNDCLASS windowClass; - if(!::GetClassInfo(instance, className, &windowClass)) + if (!::GetClassInfo(instance, className, &windowClass)) { // windowClass.style = CS_HREDRAW | CS_VREDRAW; windowClass.style = 0; @@ -80,7 +80,7 @@ bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className, HINSTANCE instance) { bool needRegister; - if(g_IsNT) + if (g_IsNT) { WNDCLASSW windowClass; needRegister = ::GetClassInfoW(instance, className, &windowClass) == 0; diff --git a/CPP/Windows/DLL.cpp b/CPP/Windows/DLL.cpp index 8966ed8e..8a95a256 100755 --- a/CPP/Windows/DLL.cpp +++ b/CPP/Windows/DLL.cpp @@ -36,7 +36,7 @@ bool CLibrary::LoadOperations(HMODULE newModule) { if (newModule == NULL) return false; - if(!Free()) + if (!Free()) return false; _module = newModule; return true; diff --git a/CPP/Windows/Error.cpp b/CPP/Windows/Error.cpp index ce5fdb00..7b18c29c 100755 --- a/CPP/Windows/Error.cpp +++ b/CPP/Windows/Error.cpp @@ -17,7 +17,7 @@ namespace NError { bool MyFormatMessage(DWORD messageID, CSysString &message) { LPVOID msgBuf; - if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,messageID, 0, (LPTSTR) &msgBuf,0, NULL) == 0) return false; @@ -32,7 +32,7 @@ bool MyFormatMessage(DWORD messageID, UString &message) if (g_IsNT) { LPVOID msgBuf; - if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | + if (::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, messageID, 0, (LPWSTR) &msgBuf, 0, NULL) == 0) return false; diff --git a/CPP/Windows/FileDir.cpp b/CPP/Windows/FileDir.cpp index 69685b55..4224d6fa 100755 --- a/CPP/Windows/FileDir.cpp +++ b/CPP/Windows/FileDir.cpp @@ -250,12 +250,12 @@ bool CreateComplexDirectory(LPCTSTR pathName) path.ParsePath(pathName); CSysString fullPath = path.Prefix; 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]; - if(string.IsEmpty()) + if (string.IsEmpty()) { - if(i != path.PathParts.Size() - 1) + if (i != path.PathParts.Size() - 1) return false; return true; } @@ -263,7 +263,7 @@ bool CreateComplexDirectory(LPCTSTR pathName) if (!MyCreateDirectory(fullPath)) { DWORD errorCode = GetLastError(); - if(errorCode != ERROR_ALREADY_EXISTS) + if (errorCode != ERROR_ALREADY_EXISTS) return false; } fullPath += NName::kDirDelimiter; @@ -286,7 +286,7 @@ bool CreateComplexDirectory(LPCTSTR _aPathName) pos = pathName.Length(); for (;;) { - if(MyCreateDirectory(pathName)) + if (MyCreateDirectory(pathName)) break; if (::GetLastError() == ERROR_ALREADY_EXISTS) { @@ -305,7 +305,7 @@ bool CreateComplexDirectory(LPCTSTR _aPathName) pathName = pathName.Left(pos); } pathName = pathName2; - while(pos < pathName.Length()) + while (pos < pathName.Length()) { pos = pathName.Find(TEXT(CHAR_PATH_SEPARATOR), pos + 1); if (pos < 0) @@ -332,7 +332,7 @@ bool CreateComplexDirectory(LPCWSTR _aPathName) pos = pathName.Length(); for (;;) { - if(MyCreateDirectory(pathName)) + if (MyCreateDirectory(pathName)) break; if (::GetLastError() == ERROR_ALREADY_EXISTS) { @@ -351,7 +351,7 @@ bool CreateComplexDirectory(LPCWSTR _aPathName) pathName = pathName.Left(pos); } pathName = pathName2; - while(pos < pathName.Length()) + while (pos < pathName.Length()) { pos = pathName.Find(WCHAR_PATH_SEPARATOR, pos + 1); if (pos < 0) @@ -398,7 +398,7 @@ bool DeleteFileAlways(LPCWSTR name) static bool RemoveDirectorySubItems2(const CSysString pathPrefix, const NFind::CFileInfo &fileInfo) { - if(fileInfo.IsDir()) + if (fileInfo.IsDir()) return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name); return DeleteFileAlways(pathPrefix + fileInfo.Name); } @@ -409,7 +409,7 @@ bool RemoveDirectoryWithSubItems(const CSysString &path) CSysString pathPrefix = path + NName::kDirDelimiter; { NFind::CEnumerator enumerator(pathPrefix + TCHAR(NName::kAnyStringWildcard)); - while(enumerator.Next(fileInfo)) + while (enumerator.Next(fileInfo)) if (!RemoveDirectorySubItems2(pathPrefix, fileInfo)) return false; } @@ -421,7 +421,7 @@ bool RemoveDirectoryWithSubItems(const CSysString &path) #ifndef _UNICODE static bool RemoveDirectorySubItems2(const UString pathPrefix, const NFind::CFileInfoW &fileInfo) { - if(fileInfo.IsDir()) + if (fileInfo.IsDir()) return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name); return DeleteFileAlways(pathPrefix + fileInfo.Name); } @@ -431,7 +431,7 @@ bool RemoveDirectoryWithSubItems(const UString &path) UString pathPrefix = path + UString(NName::kDirDelimiter); { NFind::CEnumeratorW enumerator(pathPrefix + UString(NName::kAnyStringWildcard)); - while(enumerator.Next(fileInfo)) + while (enumerator.Next(fileInfo)) if (!RemoveDirectorySubItems2(pathPrefix, fileInfo)) return false; } @@ -700,7 +700,7 @@ UINT CTempFile::Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath) { Remove(); UINT number = MyGetTempFileName(dirPath, prefix, resultPath); - if(number != 0) + if (number != 0) { _fileName = resultPath; _mustBeDeleted = true; @@ -734,7 +734,7 @@ UINT CTempFileW::Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath) { Remove(); UINT number = MyGetTempFileName(dirPath, prefix, resultPath); - if(number != 0) + if (number != 0) { _fileName = resultPath; _mustBeDeleted = true; @@ -784,7 +784,7 @@ bool CreateTempDirectory(LPCTSTR prefix, CSysString &dirName) _stprintf(randomNumberString, _T("%04X"), randomNumber); dirName = prefix + randomNumberString; */ - if(NFind::DoesFileExist(dirName)) + if (NFind::DoesFileExist(dirName)) continue; if (MyCreateDirectory(dirName)) return true; @@ -821,7 +821,7 @@ bool CreateTempDirectory(LPCWSTR prefix, UString &dirName) _stprintf(randomNumberString, _T("%04X"), randomNumber); dirName = prefix + randomNumberString; */ - if(NFind::DoesFileExist(dirName)) + if (NFind::DoesFileExist(dirName)) continue; if (MyCreateDirectory(dirName)) return true; diff --git a/CPP/Windows/FileFind.cpp b/CPP/Windows/FileFind.cpp index c72e1f33..f33ec961 100755 --- a/CPP/Windows/FileFind.cpp +++ b/CPP/Windows/FileFind.cpp @@ -344,7 +344,7 @@ bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings) if (newSize > size) return false; CSysString string; - for(UINT32 i = 0; i < newSize; i++) + for (UINT32 i = 0; i < newSize; i++) { TCHAR c = buffer[i]; if (c == TEXT('\0')) @@ -376,7 +376,7 @@ bool MyGetLogicalDriveStrings(UStringVector &driveStrings) if (newSize > size) return false; UString string; - for(UINT32 i = 0; i < newSize; i++) + for (UINT32 i = 0; i < newSize; i++) { WCHAR c = buffer[i]; if (c == L'\0') diff --git a/CPP/Windows/FileIO.cpp b/CPP/Windows/FileIO.cpp index 02560023..5646d0a3 100755 --- a/CPP/Windows/FileIO.cpp +++ b/CPP/Windows/FileIO.cpp @@ -126,8 +126,8 @@ bool CFileBase::GetLength(UInt64 &length) const { DWORD sizeHigh; DWORD sizeLow = ::GetFileSize(_handle, &sizeHigh); - if(sizeLow == 0xFFFFFFFF) - if(::GetLastError() != NO_ERROR) + if (sizeLow == 0xFFFFFFFF) + if (::GetLastError() != NO_ERROR) return false; length = (((UInt64)sizeHigh) << 32) + sizeLow; return true; @@ -139,7 +139,7 @@ bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition value.QuadPart = distanceToMove; value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod); if (value.LowPart == 0xFFFFFFFF) - if(::GetLastError() != NO_ERROR) + if (::GetLastError() != NO_ERROR) return false; newPosition = value.QuadPart; return true; @@ -307,9 +307,9 @@ bool COutFile::SetEndOfFile() { return BOOLToBool(::SetEndOfFile(_handle)); } bool COutFile::SetLength(UInt64 length) { UInt64 newPosition; - if(!Seek(length, newPosition)) + if (!Seek(length, newPosition)) return false; - if(newPosition != length) + if (newPosition != length) return false; return SetEndOfFile(); } diff --git a/CPP/Windows/FileName.cpp b/CPP/Windows/FileName.cpp index fb146f9f..8443a4af 100755 --- a/CPP/Windows/FileName.cpp +++ b/CPP/Windows/FileName.cpp @@ -27,8 +27,6 @@ void NormalizeDirPathPrefix(UString &dirPath) } #endif -#ifdef _WIN32 - const wchar_t kExtensionDelimiter = L'.'; void SplitNameToPureNameAndExtension(const UString &fullName, @@ -49,6 +47,4 @@ void SplitNameToPureNameAndExtension(const UString &fullName, } } -#endif - }}} diff --git a/CPP/Windows/FileName.h b/CPP/Windows/FileName.h index aac54133..20786e00 100755 --- a/CPP/Windows/FileName.h +++ b/CPP/Windows/FileName.h @@ -17,10 +17,8 @@ void NormalizeDirPathPrefix(CSysString &dirPath); // ensures that it ended with void NormalizeDirPathPrefix(UString &dirPath); // ensures that it ended with '\\' #endif -#ifdef _WIN32 void SplitNameToPureNameAndExtension(const UString &fullName, UString &pureName, UString &extensionDelimiter, UString &extension); -#endif }}} diff --git a/CPP/Windows/Memory.h b/CPP/Windows/Memory.h index aebeab3b..763c9575 100755 --- a/CPP/Windows/Memory.h +++ b/CPP/Windows/Memory.h @@ -35,7 +35,7 @@ public: }; ~CGlobalLock() { - if(m_Pointer != NULL) + if (m_Pointer != NULL) ::GlobalUnlock(m_Global); } }; diff --git a/CPP/Windows/MemoryLock.cpp b/CPP/Windows/MemoryLock.cpp index b468e528..284c832c 100755 --- a/CPP/Windows/MemoryLock.cpp +++ b/CPP/Windows/MemoryLock.cpp @@ -67,7 +67,7 @@ bool enable) bool EnableLockMemoryPrivilege(bool enable) { HMODULE hModule = LoadLibrary(TEXT("Advapi32.dll")); - if(hModule == NULL) + if (hModule == NULL) return false; bool res = EnableLockMemoryPrivilege2(hModule, enable); ::FreeLibrary(hModule); diff --git a/CPP/Windows/Menu.cpp b/CPP/Windows/Menu.cpp index 5869b365..0c16a0e9 100755 --- a/CPP/Windows/Menu.cpp +++ b/CPP/Windows/Menu.cpp @@ -83,7 +83,7 @@ bool CMenu::GetItem(UINT itemIndex, bool byPosition, CMenuItem &item) si.cch = kMaxSize; si.dwTypeData = s; } - if(GetItemInfo(itemIndex, byPosition, &si)) + if (GetItemInfo(itemIndex, byPosition, &si)) { ConvertItemToMyForm(si, item); if (item.IsString()) @@ -102,7 +102,7 @@ bool CMenu::GetItem(UINT itemIndex, bool byPosition, CMenuItem &item) si.cch = kMaxSize; si.dwTypeData = s; } - if(GetItemInfo(itemIndex, byPosition, &si)) + if (GetItemInfo(itemIndex, byPosition, &si)) { ConvertItemToMyForm(si, item); if (item.IsString()) diff --git a/CPP/Windows/NationalTime.cpp b/CPP/Windows/NationalTime.cpp index 12b0334b..c231d3ce 100755 --- a/CPP/Windows/NationalTime.cpp +++ b/CPP/Windows/NationalTime.cpp @@ -13,7 +13,7 @@ bool MyGetTimeFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time, { resultString.Empty(); int numChars = ::GetTimeFormat(locale, flags, time, format, NULL, 0); - if(numChars == 0) + if (numChars == 0) return false; numChars = ::GetTimeFormat(locale, flags, time, format, resultString.GetBuffer(numChars), numChars + 1); @@ -26,7 +26,7 @@ bool MyGetDateFormat(LCID locale, DWORD flags, CONST SYSTEMTIME *time, { resultString.Empty(); int numChars = ::GetDateFormat(locale, flags, time, format, NULL, 0); - if(numChars == 0) + if (numChars == 0) return false; numChars = ::GetDateFormat(locale, flags, time, format, resultString.GetBuffer(numChars), numChars + 1); diff --git a/CPP/Windows/Net.cpp b/CPP/Windows/Net.cpp index 6c71aa38..a5c3f15c 100755 --- a/CPP/Windows/Net.cpp +++ b/CPP/Windows/Net.cpp @@ -181,7 +181,7 @@ DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, const CResourceW *resour DWORD CEnum::Close() { - if(!_handleAllocated) + if (!_handleAllocated) return NO_ERROR; DWORD result = ::WNetCloseEnum(_handle); _handleAllocated = (result != NO_ERROR); diff --git a/CPP/Windows/PropVariant.cpp b/CPP/Windows/PropVariant.cpp index ea2ec27c..ae2e6cd1 100755 --- a/CPP/Windows/PropVariant.cpp +++ b/CPP/Windows/PropVariant.cpp @@ -259,7 +259,7 @@ void CPropVariant::InternalCopy(const PROPVARIANT* pSrc) int CPropVariant::Compare(const CPropVariant &a) { - if(vt != a.vt) + if (vt != a.vt) return 0; // it's mean some bug switch (vt) { diff --git a/CPP/Windows/PropVariantConversions.cpp b/CPP/Windows/PropVariantConversions.cpp index d196d744..df8abfb0 100755 --- a/CPP/Windows/PropVariantConversions.cpp +++ b/CPP/Windows/PropVariantConversions.cpp @@ -2,8 +2,6 @@ #include "StdAfx.h" -// #include - #include "PropVariantConversions.h" #include "Windows/Defs.h" @@ -51,7 +49,7 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool { s[0] = '\0'; SYSTEMTIME st; - if(!BOOLToBool(FileTimeToSystemTime(&ft, &st))) + if (!BOOLToBool(FileTimeToSystemTime(&ft, &st))) return false; s = UIntToStringSpec(0, st.wYear, s, 4); s = UIntToStringSpec('-', st.wMonth, s, 2); @@ -63,15 +61,6 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool if (includeSeconds) 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; } diff --git a/CPP/Windows/Registry.cpp b/CPP/Windows/Registry.cpp index 47ce8912..96cab0c2 100755 --- a/CPP/Windows/Registry.cpp +++ b/CPP/Windows/Registry.cpp @@ -304,7 +304,7 @@ LONG CKey::EnumKeys(CSysStringVector &keyNames) { keyNames.Clear(); CSysString keyName; - for(UInt32 index = 0; ; index++) + for (UInt32 index = 0; ; index++) { const UInt32 kBufferSize = MAX_PATH + 1; // 256 in ATL FILETIME lastWriteTime; @@ -312,9 +312,9 @@ LONG CKey::EnumKeys(CSysStringVector &keyNames) LONG result = ::RegEnumKeyEx(_object, index, keyName.GetBuffer(kBufferSize), (DWORD *)&nameSize, NULL, NULL, NULL, &lastWriteTime); keyName.ReleaseBuffer(); - if(result == ERROR_NO_MORE_ITEMS) + if (result == ERROR_NO_MORE_ITEMS) break; - if(result != ERROR_SUCCESS) + if (result != ERROR_SUCCESS) return result; keyNames.Add(keyName); } diff --git a/CPP/Windows/Registry.h b/CPP/Windows/Registry.h index a590d8ea..c6b14572 100755 --- a/CPP/Windows/Registry.h +++ b/CPP/Windows/Registry.h @@ -10,8 +10,6 @@ namespace NWindows { namespace NRegistry { -const TCHAR kKeyNameDelimiter = TEXT('\\'); - LONG SetValue(HKEY parentKey, LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value); class CKey diff --git a/CPP/Windows/Security.cpp b/CPP/Windows/Security.cpp index 52469979..24001c49 100755 --- a/CPP/Windows/Security.cpp +++ b/CPP/Windows/Security.cpp @@ -86,7 +86,7 @@ static PSID GetSid(LPWSTR accountName) #endif (NULL, accountName, NULL, &sidLen, NULL, &domainLen, &sidNameUse)) { - if(::GetLastError() == ERROR_INSUFFICIENT_BUFFER) + if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) { PSID pSid = ::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sidLen); LPWSTR domainName = (LPWSTR)::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (domainLen + 1) * sizeof(WCHAR)); diff --git a/CPP/Windows/Shell.cpp b/CPP/Windows/Shell.cpp index e605bbee..f2aee286 100755 --- a/CPP/Windows/Shell.cpp +++ b/CPP/Windows/Shell.cpp @@ -21,10 +21,10 @@ namespace NShell { void CItemIDList::Free() { - if(m_Object == NULL) + if (m_Object == NULL) return; CMyComPtr shellMalloc; - if(::SHGetMalloc(&shellMalloc) != NOERROR) + if (::SHGetMalloc(&shellMalloc) != NOERROR) throw 41099; shellMalloc->Free(m_Object); m_Object = NULL; @@ -43,7 +43,7 @@ CItemIDList& CItemIDList::operator=(LPCITEMIDLIST object) { UINT32 size = GetSize(object); m_Object = (LPITEMIDLIST)CoTaskMemAlloc(size); - if(m_Object != NULL) + if (m_Object != NULL) MoveMemory(m_Object, object, size); } return *this; @@ -52,11 +52,11 @@ CItemIDList& CItemIDList::operator=(LPCITEMIDLIST object) CItemIDList& CItemIDList::operator=(const CItemIDList &object) { Free(); - if(object.m_Object != NULL) + if (object.m_Object != NULL) { UINT32 size = GetSize(object.m_Object); m_Object = (LPITEMIDLIST)CoTaskMemAlloc(size); - if(m_Object != NULL) + if (m_Object != NULL) MoveMemory(m_Object, object.m_Object, size); } return *this; @@ -74,7 +74,7 @@ void CDrop::Attach(HDROP object) void CDrop::Free() { - if(m_MustBeFinished && m_Assigned) + if (m_MustBeFinished && m_Assigned) Finish(); m_Assigned = false; } @@ -116,7 +116,7 @@ void CDrop::QueryFileNames(UStringVector &fileNames) fileNames.Clear(); UINT numFiles = QueryCountOfFiles(); fileNames.Reserve(numFiles); - for(UINT i = 0; i < numFiles; i++) + for (UINT i = 0; i < numFiles; i++) fileNames.Add(QueryFileName(i)); } diff --git a/CPP/Windows/Window.h b/CPP/Windows/Window.h index bbe8434a..b7604b8a 100755 --- a/CPP/Windows/Window.h +++ b/CPP/Windows/Window.h @@ -94,7 +94,7 @@ public: if (_window == NULL) return true; bool result = BOOLToBool(::DestroyWindow(_window)); - if(result) + if (result) _window = NULL; return result; } diff --git a/DOC/7zip.wxs b/DOC/7zip.wxs index 74f37c6c..59a2f450 100755 --- a/DOC/7zip.wxs +++ b/DOC/7zip.wxs @@ -1,8 +1,8 @@ - - + + diff --git a/DOC/lzma.txt b/DOC/lzma.txt index 05d1bf13..159b593b 100755 --- a/DOC/lzma.txt +++ b/DOC/lzma.txt @@ -1,4 +1,4 @@ -LZMA SDK 4.59 beta +LZMA SDK 4.60 beta ------------------ LZMA SDK Copyright (C) 1999-2008 Igor Pavlov -- cgit v1.2.3