Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/CPP/7zip
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip')
-rwxr-xr-xCPP/7zip/Archive/7z/7zDecode.cpp2
-rwxr-xr-xCPP/7zip/Archive/ElfHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/PeHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.cpp4
-rwxr-xr-xCPP/7zip/Archive/Udf/UdfHandler.cpp47
-rwxr-xr-xCPP/7zip/Archive/Udf/UdfIn.cpp73
-rwxr-xr-xCPP/7zip/Archive/Udf/UdfIn.h7
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipIn.cpp4
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/Main.cpp4
-rwxr-xr-xCPP/7zip/MyVersion.h10
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.cpp13
-rwxr-xr-xCPP/7zip/UI/Agent/AgentOut.cpp8
-rwxr-xr-xCPP/7zip/UI/Agent/AgentProxy.cpp4
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOpen.cpp17
-rwxr-xr-xCPP/7zip/UI/Client7z/Client7z.cpp12
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveName.cpp2
-rwxr-xr-xCPP/7zip/UI/Common/EnumDirItems.cpp9
-rwxr-xr-xCPP/7zip/UI/Common/LoadCodecs.cpp4
-rwxr-xr-xCPP/7zip/UI/Common/OpenArchive.cpp2
-rwxr-xr-xCPP/7zip/UI/Console/ExtractCallbackConsole.cpp4
-rwxr-xr-xCPP/7zip/UI/Console/OpenCallbackConsole.cpp4
-rwxr-xr-xCPP/7zip/UI/Console/UpdateCallbackConsole.cpp7
-rwxr-xr-xCPP/7zip/UI/Explorer/ContextMenu.cpp38
-rwxr-xr-xCPP/7zip/UI/Far/ExtractEngine.cpp5
-rwxr-xr-xCPP/7zip/UI/Far/Main.cpp4
-rwxr-xr-xCPP/7zip/UI/Far/Plugin.cpp6
-rwxr-xr-xCPP/7zip/UI/FileManager/App.cpp31
-rwxr-xr-xCPP/7zip/UI/FileManager/AppState.h15
-rwxr-xr-xCPP/7zip/UI/FileManager/ExtractCallback.cpp17
-rwxr-xr-xCPP/7zip/UI/FileManager/FM.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/FM.dsp4
-rwxr-xr-xCPP/7zip/UI/FileManager/FSDrives.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolder.cpp20
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolderCopy.cpp75
-rwxr-xr-xCPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/NetFolder.cpp18
-rwxr-xr-xCPP/7zip/UI/FileManager/OpenCallback.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/Panel.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelCrc.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelDrag.cpp27
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelFolderChange.cpp24
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelItems.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelMenu.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelOperations.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/PhysDriveFolder.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/PluginsPage.cpp16
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgramLocation.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryAssociations.cpp22
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryPlugins.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryUtils.cpp8
-rwxr-xr-xCPP/7zip/UI/FileManager/RootFolder.cpp20
-rwxr-xr-xCPP/7zip/UI/FileManager/UpdateCallback100.cpp9
-rwxr-xr-xCPP/7zip/UI/FileManager/ViewSettings.cpp15
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.cpp4
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateCallbackGUI.cpp8
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateGUI.cpp2
57 files changed, 333 insertions, 330 deletions
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<CMyExtent> Extents;
CRecordVector<int> 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<CItemEx> &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<UInt32> &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<IFolderFolder> 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<IFolderFolder> 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<IFolderFolder> 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<IFolderFolder> 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<IFolderFolder> 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<IFolderFolder> 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<CExtInfo> &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<CExtInfo> &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<CPluginInfo> &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<IFolderFolder> subFolder = netFolderSpec;
- netFolderSpec->Init(0, 0, _names[ROOT_INDEX_NETWORK] + L'\\');
+ netFolderSpec->Init(0, 0, _names[ROOT_INDEX_NETWORK] + WCHAR_PATH_SEPARATOR);
*resultFolder = subFolder.Detach();
}
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<IFolderFolder> 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))