summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/Windows
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/lzma/CPP/Windows')
-rw-r--r--3rdparty/lzma/CPP/Windows/COM.h32
-rw-r--r--3rdparty/lzma/CPP/Windows/Clipboard.h6
-rw-r--r--3rdparty/lzma/CPP/Windows/CommonDialog.cpp291
-rw-r--r--3rdparty/lzma/CPP/Windows/CommonDialog.h44
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/ComboBox.cpp8
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/ComboBox.h22
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/CommandBar.h12
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/Dialog.cpp51
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/Dialog.h114
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/Edit.h4
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/ImageList.h6
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/ListView.cpp47
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/ListView.h51
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/ProgressBar.h24
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/PropertyPage.cpp90
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/PropertyPage.h20
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/ReBar.h6
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/Static.h4
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/StatusBar.h10
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/StdAfx.h7
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/ToolBar.h6
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/Trackbar.h4
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/Window2.cpp14
-rw-r--r--3rdparty/lzma/CPP/Windows/Control/Window2.h16
-rw-r--r--3rdparty/lzma/CPP/Windows/DLL.cpp50
-rw-r--r--3rdparty/lzma/CPP/Windows/DLL.h49
-rw-r--r--3rdparty/lzma/CPP/Windows/Defs.h5
-rw-r--r--3rdparty/lzma/CPP/Windows/ErrorMsg.cpp8
-rw-r--r--3rdparty/lzma/CPP/Windows/ErrorMsg.h4
-rw-r--r--3rdparty/lzma/CPP/Windows/FileDir.cpp235
-rw-r--r--3rdparty/lzma/CPP/Windows/FileDir.h6
-rw-r--r--3rdparty/lzma/CPP/Windows/FileFind.cpp36
-rw-r--r--3rdparty/lzma/CPP/Windows/FileFind.h14
-rw-r--r--3rdparty/lzma/CPP/Windows/FileIO.cpp38
-rw-r--r--3rdparty/lzma/CPP/Windows/FileIO.h51
-rw-r--r--3rdparty/lzma/CPP/Windows/FileLink.cpp79
-rw-r--r--3rdparty/lzma/CPP/Windows/FileMapping.h6
-rw-r--r--3rdparty/lzma/CPP/Windows/FileName.cpp171
-rw-r--r--3rdparty/lzma/CPP/Windows/FileName.h38
-rw-r--r--3rdparty/lzma/CPP/Windows/FileSystem.cpp24
-rw-r--r--3rdparty/lzma/CPP/Windows/FileSystem.h4
-rw-r--r--3rdparty/lzma/CPP/Windows/Handle.h8
-rw-r--r--3rdparty/lzma/CPP/Windows/MemoryGlobal.h12
-rw-r--r--3rdparty/lzma/CPP/Windows/MemoryLock.cpp28
-rw-r--r--3rdparty/lzma/CPP/Windows/MemoryLock.h4
-rw-r--r--3rdparty/lzma/CPP/Windows/NtCheck.h14
-rw-r--r--3rdparty/lzma/CPP/Windows/PropVariant.cpp8
-rw-r--r--3rdparty/lzma/CPP/Windows/PropVariant.h10
-rw-r--r--3rdparty/lzma/CPP/Windows/PropVariantConv.cpp10
-rw-r--r--3rdparty/lzma/CPP/Windows/PropVariantConv.h4
-rw-r--r--3rdparty/lzma/CPP/Windows/Registry.h4
-rw-r--r--3rdparty/lzma/CPP/Windows/ResourceString.h5
-rw-r--r--3rdparty/lzma/CPP/Windows/SecurityUtils.cpp38
-rw-r--r--3rdparty/lzma/CPP/Windows/SecurityUtils.h12
-rw-r--r--3rdparty/lzma/CPP/Windows/Shell.cpp574
-rw-r--r--3rdparty/lzma/CPP/Windows/Shell.h62
-rw-r--r--3rdparty/lzma/CPP/Windows/StdAfx.h8
-rw-r--r--3rdparty/lzma/CPP/Windows/Synchronization.cpp24
-rw-r--r--3rdparty/lzma/CPP/Windows/Synchronization.h50
-rw-r--r--3rdparty/lzma/CPP/Windows/System.cpp58
-rw-r--r--3rdparty/lzma/CPP/Windows/System.h17
-rw-r--r--3rdparty/lzma/CPP/Windows/SystemInfo.cpp291
-rw-r--r--3rdparty/lzma/CPP/Windows/SystemInfo.h5
-rw-r--r--3rdparty/lzma/CPP/Windows/Thread.h6
-rw-r--r--3rdparty/lzma/CPP/Windows/TimeUtils.cpp4
-rw-r--r--3rdparty/lzma/CPP/Windows/TimeUtils.h4
-rw-r--r--3rdparty/lzma/CPP/Windows/Window.cpp10
-rw-r--r--3rdparty/lzma/CPP/Windows/Window.h113
68 files changed, 2092 insertions, 998 deletions
diff --git a/3rdparty/lzma/CPP/Windows/COM.h b/3rdparty/lzma/CPP/Windows/COM.h
index cee7f702d6f..a8780cacb30 100644
--- a/3rdparty/lzma/CPP/Windows/COM.h
+++ b/3rdparty/lzma/CPP/Windows/COM.h
@@ -1,9 +1,9 @@
// Windows/COM.h
-#ifndef __WINDOWS_COM_H
-#define __WINDOWS_COM_H
+#ifndef ZIP7_INC_WINDOWS_COM_H
+#define ZIP7_INC_WINDOWS_COM_H
-#include "../Common/MyString.h"
+// #include "../Common/MyString.h"
namespace NWindows {
namespace NCOM {
@@ -21,17 +21,18 @@ public:
// it's single thread. Do we need multithread?
CoInitialize(NULL);
#endif
- };
+ }
~CComInitializer() { CoUninitialize(); }
};
-class CStgMedium
+/*
+class CStgMedium2
{
STGMEDIUM _object;
-public:
bool _mustBeReleased;
- CStgMedium(): _mustBeReleased(false) {}
- ~CStgMedium() { Free(); }
+public:
+ CStgMedium2(): _mustBeReleased(false) {}
+ ~CStgMedium2() { Free(); }
void Free()
{
if (_mustBeReleased)
@@ -42,6 +43,21 @@ public:
STGMEDIUM* operator->() { return &_object;}
STGMEDIUM* operator&() { return &_object; }
};
+*/
+
+struct CStgMedium: public STGMEDIUM
+{
+ CStgMedium()
+ {
+ tymed = TYMED_NULL; // 0
+ hGlobal = NULL;
+ pUnkForRelease = NULL;
+ }
+ ~CStgMedium()
+ {
+ ReleaseStgMedium(this);
+ }
+};
#endif
diff --git a/3rdparty/lzma/CPP/Windows/Clipboard.h b/3rdparty/lzma/CPP/Windows/Clipboard.h
index 60fedc13b14..3b4f2fe5ee3 100644
--- a/3rdparty/lzma/CPP/Windows/Clipboard.h
+++ b/3rdparty/lzma/CPP/Windows/Clipboard.h
@@ -1,7 +1,7 @@
// Windows/Clipboard.h
-#ifndef __CLIPBOARD_H
-#define __CLIPBOARD_H
+#ifndef ZIP7_INC_CLIPBOARD_H
+#define ZIP7_INC_CLIPBOARD_H
#include "../Common/MyString.h"
@@ -11,7 +11,7 @@ class CClipboard
{
bool m_Open;
public:
- CClipboard(): m_Open(false) {};
+ CClipboard(): m_Open(false) {}
~CClipboard() { Close(); }
bool Open(HWND wndNewOwner) throw();
bool Close() throw();
diff --git a/3rdparty/lzma/CPP/Windows/CommonDialog.cpp b/3rdparty/lzma/CPP/Windows/CommonDialog.cpp
index eaaecada727..7a92d5f9b65 100644
--- a/3rdparty/lzma/CPP/Windows/CommonDialog.cpp
+++ b/3rdparty/lzma/CPP/Windows/CommonDialog.cpp
@@ -2,7 +2,7 @@
#include "StdAfx.h"
-#include "../Common/MyWindows.h"
+#include "../Common/MyBuffer.h"
#ifdef UNDER_CE
#include <commdlg.h>
@@ -14,6 +14,7 @@
#include "CommonDialog.h"
#include "Defs.h"
+// #include "FileDir.h"
#ifndef _UNICODE
extern bool g_IsNT;
@@ -21,61 +22,46 @@ extern bool g_IsNT;
namespace NWindows {
-#ifndef _UNICODE
+/*
+ GetSaveFileName()
+ GetOpenFileName()
+ OPENFILENAME
-class CDoubleZeroStringListA
-{
- LPTSTR Buf;
- unsigned Size;
-public:
- CDoubleZeroStringListA(LPSTR buf, unsigned size): Buf(buf), Size(size) {}
- bool Add(LPCSTR s) throw();
- void Finish() { *Buf = 0; }
-};
-
-bool CDoubleZeroStringListA::Add(LPCSTR s) throw()
+(lpstrInitialDir) : the initial directory.
+DOCs: the algorithm for selecting the initial directory varies on different platforms:
{
- unsigned len = MyStringLen(s) + 1;
- if (len >= Size)
- return false;
- MyStringCopy(Buf, s);
- Buf += len;
- Size -= len;
- return true;
+ Win2000/XP/Vista:
+ 1. If lpstrFile contains a path, that path is the initial directory.
+ 2. Otherwise, lpstrInitialDir specifies the initial directory.
+
+ Win7:
+ If lpstrInitialDir has the same value as was passed the first time
+ the application used an Open or Save As dialog box, the path
+ most recently selected by the user is used as the initial directory.
}
-#endif
+Win10:
+ in:
+ function supports (lpstrInitialDir) path with super prefix "\\\\?\\"
+ function supports (lpstrInitialDir) path with long path
+ function doesn't support absolute (lpstrFile) path with super prefix "\\\\?\\"
+ function doesn't support absolute (lpstrFile) path with long path
+ out: the path with super prefix "\\\\?\\" will be returned, if selected path is long
-class CDoubleZeroStringListW
-{
- LPWSTR Buf;
- unsigned Size;
-public:
- CDoubleZeroStringListW(LPWSTR buf, unsigned size): Buf(buf), Size(size) {}
- bool Add(LPCWSTR s) throw();
- void Finish() { *Buf = 0; }
-};
-
-bool CDoubleZeroStringListW::Add(LPCWSTR s) throw()
-{
- unsigned len = MyStringLen(s) + 1;
- if (len >= Size)
- return false;
- MyStringCopy(Buf, s);
- Buf += len;
- Size -= len;
- return true;
-}
+WinXP-64 and Win10: if no filters, the system shows all files.
+ but DOCs say: If all three members are zero or NULL,
+ the system does not use any filters and does not
+ show any files in the file list control of the dialog box.
+in Win7+: GetOpenFileName() and GetSaveFileName()
+ do not support pstrCustomFilter feature anymore
+*/
#ifdef UNDER_CE
-#define MY__OFN_PROJECT 0x00400000
-#define MY__OFN_SHOW_ALL 0x01000000
+#define MY_OFN_PROJECT 0x00400000
+#define MY_OFN_SHOW_ALL 0x01000000
#endif
-/* if (lpstrFilter == NULL && nFilterIndex == 0)
- MSDN : "the system doesn't show any files",
- but WinXP-64 shows all files. Why ??? */
/*
structures
@@ -89,16 +75,16 @@ contain additional members:
#endif
If we compile the source code with (_WIN32_WINNT >= 0x0500), some functions
-will not work at NT 4.0, if we use sizeof(OPENFILENAME*).
-So we use size of old version of structure. */
+will not work at NT 4.0, if we use sizeof(OPENFILENAME).
+We try to use reduced structure OPENFILENAME_NT4.
+*/
-#if defined(UNDER_CE) || defined(_WIN64) || (_WIN32_WINNT < 0x0500)
-// || !defined(WINVER)
+// #if defined(_WIN64) || (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500)
+#if defined(__GNUC__) && (__GNUC__ <= 9) || defined(Z7_OLD_WIN_SDK)
#ifndef _UNICODE
- #define my_compatib_OPENFILENAMEA_size sizeof(OPENFILENAMEA)
+ #define my_compatib_OPENFILENAMEA OPENFILENAMEA
#endif
- #define my_compatib_OPENFILENAMEW_size sizeof(OPENFILENAMEW)
-#else
+ #define my_compatib_OPENFILENAMEW OPENFILENAMEW
// MinGW doesn't support some required macros. So we define them here:
#ifndef CDSIZEOF_STRUCT
@@ -117,91 +103,166 @@ So we use size of old version of structure. */
#define my_compatib_OPENFILENAMEA_size OPENFILENAME_SIZE_VERSION_400A
#endif
#define my_compatib_OPENFILENAMEW_size OPENFILENAME_SIZE_VERSION_400W
+#else
+ #ifndef _UNICODE
+ #define my_compatib_OPENFILENAMEA OPENFILENAME_NT4A
+ #define my_compatib_OPENFILENAMEA_size sizeof(my_compatib_OPENFILENAMEA)
+ #endif
+ #define my_compatib_OPENFILENAMEW OPENFILENAME_NT4W
+ #define my_compatib_OPENFILENAMEW_size sizeof(my_compatib_OPENFILENAMEW)
+#endif
+/*
+#elif defined(UNDER_CE) || defined(_WIN64) || (_WIN32_WINNT < 0x0500)
+// || !defined(WINVER)
+ #ifndef _UNICODE
+ #define my_compatib_OPENFILENAMEA OPENFILENAMEA
+ #define my_compatib_OPENFILENAMEA_size sizeof(OPENFILENAMEA)
+ #endif
+ #define my_compatib_OPENFILENAMEW OPENFILENAMEW
+ #define my_compatib_OPENFILENAMEW_size sizeof(OPENFILENAMEW)
+#else
+
#endif
+*/
#ifndef _UNICODE
#define CONV_U_To_A(dest, src, temp) AString temp; if (src) { temp = GetSystemString(src); dest = temp; }
#endif
-bool MyGetOpenFileName(HWND hwnd, LPCWSTR title,
- LPCWSTR initialDir,
- LPCWSTR filePath,
- LPCWSTR filterDescription,
- LPCWSTR filter,
- UString &resPath
- #ifdef UNDER_CE
- , bool openFolder
- #endif
- )
+bool CCommonDialogInfo::CommonDlg_BrowseForFile(LPCWSTR lpstrInitialDir, const UStringVector &filters)
{
- const unsigned kBufSize = MAX_PATH * 2;
- const unsigned kFilterBufSize = MAX_PATH;
- if (!filter)
- filter = L"*.*";
- #ifndef _UNICODE
+ /* GetSaveFileName() and GetOpenFileName() could change current dir,
+ if OFN_NOCHANGEDIR is not used.
+ We can restore current dir manually, if it's required.
+ 22.02: we use OFN_NOCHANGEDIR. So we don't need to restore current dir manually. */
+ // NFile::NDir::CCurrentDirRestorer curDirRestorer;
+
+#ifndef _UNICODE
if (!g_IsNT)
{
- CHAR buf[kBufSize];
- MyStringCopy(buf, (const char *)GetSystemString(filePath));
- // OPENFILENAME_NT4A
- OPENFILENAMEA p;
+ AString tempPath;
+ AStringVector f;
+ unsigned i;
+ for (i = 0; i < filters.Size(); i++)
+ f.Add(GetSystemString(filters[i]));
+ unsigned size = f.Size() + 1;
+ for (i = 0; i < f.Size(); i++)
+ size += f[i].Len();
+ CObjArray<char> filterBuf(size);
+ // memset(filterBuf, 0, size * sizeof(char));
+ {
+ char *dest = filterBuf;
+ for (i = 0; i < f.Size(); i++)
+ {
+ const AString &s = f[i];
+ MyStringCopy(dest, s);
+ dest += s.Len() + 1;
+ }
+ *dest = 0;
+ }
+ my_compatib_OPENFILENAMEA p;
memset(&p, 0, sizeof(p));
p.lStructSize = my_compatib_OPENFILENAMEA_size;
- p.hwndOwner = hwnd;
- CHAR filterBuf[kFilterBufSize];
+ p.hwndOwner = hwndOwner;
+ if (size > 1)
{
- CDoubleZeroStringListA dz(filterBuf, kFilterBufSize);
- dz.Add(GetSystemString(filterDescription ? filterDescription : filter));
- dz.Add(GetSystemString(filter));
- dz.Finish();
p.lpstrFilter = filterBuf;
- p.nFilterIndex = 1;
+ p.nFilterIndex = (DWORD)(FilterIndex + 1);
+ }
+
+ CONV_U_To_A(p.lpstrInitialDir, lpstrInitialDir, initialDir_a)
+ CONV_U_To_A(p.lpstrTitle, lpstrTitle, title_a)
+
+ const AString filePath_a = GetSystemString(FilePath);
+ const unsigned bufSize = MAX_PATH * 8
+ + filePath_a.Len()
+ + initialDir_a.Len();
+ p.nMaxFile = bufSize;
+ p.lpstrFile = tempPath.GetBuf(bufSize);
+ MyStringCopy(p.lpstrFile, filePath_a);
+ p.Flags =
+ OFN_EXPLORER
+ | OFN_HIDEREADONLY
+ | OFN_NOCHANGEDIR;
+ const BOOL b = SaveMode ?
+ ::GetSaveFileNameA((LPOPENFILENAMEA)(void *)&p) :
+ ::GetOpenFileNameA((LPOPENFILENAMEA)(void *)&p);
+ if (!b)
+ return false;
+ {
+ tempPath.ReleaseBuf_CalcLen(bufSize);
+ FilePath = GetUnicodeString(tempPath);
+ FilterIndex = (int)p.nFilterIndex - 1;
+ return true;
}
-
- p.lpstrFile = buf;
- p.nMaxFile = kBufSize;
- CONV_U_To_A(p.lpstrInitialDir, initialDir, initialDirA);
- CONV_U_To_A(p.lpstrTitle, title, titleA);
- p.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
-
- bool res = BOOLToBool(::GetOpenFileNameA(&p));
- resPath = GetUnicodeString(buf);
- return res;
}
else
- #endif
+#endif
{
- WCHAR buf[kBufSize];
- MyStringCopy(buf, filePath);
- // OPENFILENAME_NT4W
- OPENFILENAMEW p;
+ UString tempPath;
+ unsigned size = filters.Size() + 1;
+ unsigned i;
+ for (i = 0; i < filters.Size(); i++)
+ size += filters[i].Len();
+ CObjArray<wchar_t> filterBuf(size);
+ // memset(filterBuf, 0, size * sizeof(wchar_t));
+ {
+ wchar_t *dest = filterBuf;
+ for (i = 0; i < filters.Size(); i++)
+ {
+ const UString &s = filters[i];
+ MyStringCopy(dest, s);
+ dest += s.Len() + 1;
+ }
+ *dest = 0;
+ // if ((unsigned)(dest + 1 - filterBuf) != size) return false;
+ }
+ my_compatib_OPENFILENAMEW p;
memset(&p, 0, sizeof(p));
p.lStructSize = my_compatib_OPENFILENAMEW_size;
- p.hwndOwner = hwnd;
-
- WCHAR filterBuf[kFilterBufSize];
+ p.hwndOwner = hwndOwner;
+ if (size > 1)
{
- CDoubleZeroStringListW dz(filterBuf, kFilterBufSize);
- dz.Add(filterDescription ? filterDescription : filter);
- dz.Add(filter);
- dz.Finish();
p.lpstrFilter = filterBuf;
- p.nFilterIndex = 1;
+ p.nFilterIndex = (DWORD)(FilterIndex + 1);
}
-
- p.lpstrFile = buf;
- p.nMaxFile = kBufSize;
- p.lpstrInitialDir = initialDir;
- p.lpstrTitle = title;
- p.Flags = OFN_EXPLORER | OFN_HIDEREADONLY
- #ifdef UNDER_CE
- | (openFolder ? (MY__OFN_PROJECT | MY__OFN_SHOW_ALL) : 0)
- #endif
+ unsigned bufSize = MAX_PATH * 8 + FilePath.Len();
+ if (lpstrInitialDir)
+ {
+ p.lpstrInitialDir = lpstrInitialDir;
+ bufSize += MyStringLen(lpstrInitialDir);
+ }
+ p.nMaxFile = bufSize;
+ p.lpstrFile = tempPath.GetBuf(bufSize);
+ MyStringCopy(p.lpstrFile, FilePath);
+ p.lpstrTitle = lpstrTitle;
+ p.Flags =
+ OFN_EXPLORER
+ | OFN_HIDEREADONLY
+ | OFN_NOCHANGEDIR
+ // | OFN_FORCESHOWHIDDEN // Win10 shows hidden items even without this flag
+ // | OFN_PATHMUSTEXIST
+ #ifdef UNDER_CE
+ | (OpenFolderMode ? (MY_OFN_PROJECT | MY_OFN_SHOW_ALL) : 0)
+ #endif
;
-
- bool res = BOOLToBool(::GetOpenFileNameW(&p));
- resPath = buf;
- return res;
+ const BOOL b = SaveMode ?
+ ::GetSaveFileNameW((LPOPENFILENAMEW)(void *)&p) :
+ ::GetOpenFileNameW((LPOPENFILENAMEW)(void *)&p);
+ /* DOCs: lpstrFile :
+ if the buffer is too small, then:
+ - the function returns FALSE
+ - the CommDlgExtendedError() returns FNERR_BUFFERTOOSMALL
+ - the first two bytes of the lpstrFile buffer contain the
+ required size, in bytes or characters. */
+ if (!b)
+ return false;
+ {
+ tempPath.ReleaseBuf_CalcLen(bufSize);
+ FilePath = tempPath;
+ FilterIndex = (int)p.nFilterIndex - 1;
+ return true;
+ }
}
}
diff --git a/3rdparty/lzma/CPP/Windows/CommonDialog.h b/3rdparty/lzma/CPP/Windows/CommonDialog.h
index aaf17ac57ce..85b071f0ce2 100644
--- a/3rdparty/lzma/CPP/Windows/CommonDialog.h
+++ b/3rdparty/lzma/CPP/Windows/CommonDialog.h
@@ -1,22 +1,42 @@
// Windows/CommonDialog.h
-#ifndef __WINDOWS_COMMON_DIALOG_H
-#define __WINDOWS_COMMON_DIALOG_H
+#ifndef ZIP7_INC_WINDOWS_COMMON_DIALOG_H
+#define ZIP7_INC_WINDOWS_COMMON_DIALOG_H
#include "../Common/MyString.h"
namespace NWindows {
-bool MyGetOpenFileName(HWND hwnd, LPCWSTR title,
- LPCWSTR initialDir, // can be NULL, so dir prefix in filePath will be used
- LPCWSTR filePath, // full path
- LPCWSTR filterDescription, // like "All files (*.*)"
- LPCWSTR filter, // like "*.exe"
- UString &resPath
- #ifdef UNDER_CE
- , bool openFolder = false
- #endif
-);
+struct CCommonDialogInfo
+{
+ /* (FilterIndex == -1) means no selected filter.
+ and (-1) also is reserved for unsupported custom filter.
+ if (FilterIndex >= 0), then FilterIndex is index of filter */
+ int FilterIndex; // [in / out]
+ bool SaveMode;
+ #ifdef UNDER_CE
+ bool OpenFolderMode;
+ #endif
+ HWND hwndOwner;
+ // LPCWSTR lpstrInitialDir;
+ LPCWSTR lpstrTitle;
+ UString FilePath; // [in / out]
+
+ CCommonDialogInfo()
+ {
+ FilterIndex = -1;
+ SaveMode = false;
+ #ifdef UNDER_CE
+ OpenFolderMode = false;
+ #endif
+ hwndOwner = NULL;
+ // lpstrInitialDir = NULL;
+ lpstrTitle = NULL;
+ }
+
+ /* (filters) : 2 sequential vector strings (Description, Masks) represent each filter */
+ bool CommonDlg_BrowseForFile(LPCWSTR lpstrInitialDir, const UStringVector &filters);
+};
}
diff --git a/3rdparty/lzma/CPP/Windows/Control/ComboBox.cpp b/3rdparty/lzma/CPP/Windows/Control/ComboBox.cpp
index f6ed8d346e4..8da487d490a 100644
--- a/3rdparty/lzma/CPP/Windows/Control/ComboBox.cpp
+++ b/3rdparty/lzma/CPP/Windows/Control/ComboBox.cpp
@@ -43,10 +43,10 @@ LRESULT CComboBox::GetLBText(int index, UString &s)
s.Empty();
if (g_IsNT)
{
- LRESULT len = SendMsgW(CB_GETLBTEXTLEN, MY__int_TO_WPARAM(index), 0);
+ LRESULT len = SendMsgW(CB_GETLBTEXTLEN, MY_int_TO_WPARAM(index), 0);
if (len == CB_ERR)
return len;
- LRESULT len2 = SendMsgW(CB_GETLBTEXT, MY__int_TO_WPARAM(index), (LPARAM)s.GetBuf((unsigned)len));
+ LRESULT len2 = SendMsgW(CB_GETLBTEXT, MY_int_TO_WPARAM(index), (LPARAM)s.GetBuf((unsigned)len));
if (len2 == CB_ERR)
return len;
if (len > len2)
@@ -55,11 +55,11 @@ LRESULT CComboBox::GetLBText(int index, UString &s)
return len;
}
AString sa;
- LRESULT len = GetLBText(index, sa);
+ const LRESULT len = GetLBText(index, sa);
if (len == CB_ERR)
return len;
s = GetUnicodeString(sa);
- return s.Len();
+ return (LRESULT)s.Len();
}
#endif
diff --git a/3rdparty/lzma/CPP/Windows/Control/ComboBox.h b/3rdparty/lzma/CPP/Windows/Control/ComboBox.h
index f08b1f7ce28..2a60b8aac96 100644
--- a/3rdparty/lzma/CPP/Windows/Control/ComboBox.h
+++ b/3rdparty/lzma/CPP/Windows/Control/ComboBox.h
@@ -1,7 +1,7 @@
// Windows/Control/ComboBox.h
-#ifndef __WINDOWS_CONTROL_COMBOBOX_H
-#define __WINDOWS_CONTROL_COMBOBOX_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_COMBOBOX_H
+#define ZIP7_INC_WINDOWS_CONTROL_COMBOBOX_H
#include "../../Common/MyWindows.h"
@@ -12,8 +12,6 @@
namespace NWindows {
namespace NControl {
-#define MY__int_TO_WPARAM(i) ((WPARAM)(INT_PTR)(i))
-
class CComboBox: public CWindow
{
public:
@@ -24,7 +22,8 @@ public:
#endif
/* If this parameter is -1, any current selection in the list is removed and the edit control is cleared.*/
- LRESULT SetCurSel(int index) { return SendMsg(CB_SETCURSEL, MY__int_TO_WPARAM(index), 0); }
+ LRESULT SetCurSel(int index) { return SendMsg(CB_SETCURSEL, MY_int_TO_WPARAM(index), 0); }
+ LRESULT SetCurSel(unsigned index) { return SendMsg(CB_SETCURSEL, index, 0); }
/* If no item is selected, it returns CB_ERR (-1) */
int GetCurSel() { return (int)SendMsg(CB_GETCURSEL, 0, 0); }
@@ -32,15 +31,16 @@ public:
/* If an error occurs, it is CB_ERR (-1) */
int GetCount() { return (int)SendMsg(CB_GETCOUNT, 0, 0); }
- LRESULT GetLBTextLen(int index) { return SendMsg(CB_GETLBTEXTLEN, MY__int_TO_WPARAM(index), 0); }
- LRESULT GetLBText(int index, LPTSTR s) { return SendMsg(CB_GETLBTEXT, MY__int_TO_WPARAM(index), (LPARAM)s); }
+ LRESULT GetLBTextLen(int index) { return SendMsg(CB_GETLBTEXTLEN, MY_int_TO_WPARAM(index), 0); }
+ LRESULT GetLBText(int index, LPTSTR s) { return SendMsg(CB_GETLBTEXT, MY_int_TO_WPARAM(index), (LPARAM)s); }
LRESULT GetLBText(int index, CSysString &s);
#ifndef _UNICODE
LRESULT GetLBText(int index, UString &s);
#endif
- LRESULT SetItemData(int index, LPARAM lParam) { return SendMsg(CB_SETITEMDATA, MY__int_TO_WPARAM(index), lParam); }
- LRESULT GetItemData(int index) { return SendMsg(CB_GETITEMDATA, MY__int_TO_WPARAM(index), 0); }
+ LRESULT SetItemData(int index, LPARAM lParam) { return SendMsg(CB_SETITEMDATA, MY_int_TO_WPARAM(index), lParam); }
+ LRESULT GetItemData(int index) { return SendMsg(CB_GETITEMDATA, MY_int_TO_WPARAM(index), 0); }
+ LRESULT GetItemData(unsigned index) { return SendMsg(CB_GETITEMDATA, index, 0); }
LRESULT GetItemData_of_CurSel() { return GetItemData(GetCurSel()); }
@@ -57,7 +57,7 @@ public:
/* Returns:
an INT value that represents the number of items remaining in the control.
If (index) is invalid, the message returns CB_ERR. */
- LRESULT DeleteItem(int index) { return SendMsg(CBEM_DELETEITEM, MY__int_TO_WPARAM(index), 0); }
+ LRESULT DeleteItem(int index) { return SendMsg(CBEM_DELETEITEM, MY_int_TO_WPARAM(index), 0); }
LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_INSERTITEM, 0, (LPARAM)item); }
#ifndef _UNICODE
@@ -65,7 +65,7 @@ public:
#endif
LRESULT SetItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_SETITEM, 0, (LPARAM)item); }
- DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMsg(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); }
+ DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMsg(CBEM_SETEXTENDEDSTYLE, exMask, (LPARAM)exStyle); }
HWND GetEditControl() { return (HWND)SendMsg(CBEM_GETEDITCONTROL, 0, 0); }
HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMsg(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); }
};
diff --git a/3rdparty/lzma/CPP/Windows/Control/CommandBar.h b/3rdparty/lzma/CPP/Windows/Control/CommandBar.h
index a6197447a40..d1b2f17861d 100644
--- a/3rdparty/lzma/CPP/Windows/Control/CommandBar.h
+++ b/3rdparty/lzma/CPP/Windows/Control/CommandBar.h
@@ -1,7 +1,7 @@
// Windows/Control/CommandBar.h
-#ifndef __WINDOWS_CONTROL_COMMANDBAR_H
-#define __WINDOWS_CONTROL_COMMANDBAR_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_COMMANDBAR_H
+#define ZIP7_INC_WINDOWS_CONTROL_COMMANDBAR_H
#ifdef UNDER_CE
@@ -26,12 +26,12 @@ public:
// Macros
// void Destroy() { CommandBar_Destroy(_window); }
// bool AddButtons(UINT numButtons, LPTBBUTTON buttons) { return BOOLToBool(SendMsg(TB_ADDBUTTONS, (WPARAM)numButtons, (LPARAM)buttons)); }
- bool InsertButton(int iButton, LPTBBUTTON button) { return BOOLToBool(SendMsg(TB_INSERTBUTTON, (WPARAM)iButton, (LPARAM)button)); }
- BOOL AddToolTips(UINT numToolTips, LPTSTR toolTips) { return BOOLToBool(SendMsg(TB_SETTOOLTIPS, (WPARAM)numToolTips, (LPARAM)toolTips)); }
+ // bool InsertButton(unsigned iButton, LPTBBUTTON button) { return BOOLToBool(SendMsg(TB_INSERTBUTTON, (WPARAM)iButton, (LPARAM)button)); }
+ // BOOL AddToolTips(UINT numToolTips, LPTSTR toolTips) { return BOOLToBool(SendMsg(TB_SETTOOLTIPS, (WPARAM)numToolTips, (LPARAM)toolTips)); }
void AutoSize() { SendMsg(TB_AUTOSIZE, 0, 0); }
- bool AddAdornments(DWORD dwFlags) { return BOOLToBool(::CommandBar_AddAdornments(_window, dwFlags, 0)); }
- int AddBitmap(HINSTANCE hInst, int idBitmap, int iNumImages, int iImageWidth, int iImageHeight) { return ::CommandBar_AddBitmap(_window, hInst, idBitmap, iNumImages, iImageWidth, iImageHeight); }
+ // bool AddAdornments(DWORD dwFlags) { return BOOLToBool(::CommandBar_AddAdornments(_window, dwFlags, 0)); }
+ // int AddBitmap(HINSTANCE hInst, int idBitmap, int iNumImages, int iImageWidth, int iImageHeight) { return ::CommandBar_AddBitmap(_window, hInst, idBitmap, iNumImages, iImageWidth, iImageHeight); }
bool DrawMenuBar(WORD iButton) { return BOOLToBool(::CommandBar_DrawMenuBar(_window, iButton)); }
HMENU GetMenu(WORD iButton) { return ::CommandBar_GetMenu(_window, iButton); }
int Height() { return CommandBar_Height(_window); }
diff --git a/3rdparty/lzma/CPP/Windows/Control/Dialog.cpp b/3rdparty/lzma/CPP/Windows/Control/Dialog.cpp
index 9ddd23427d8..c8f1bd27c79 100644
--- a/3rdparty/lzma/CPP/Windows/Control/Dialog.cpp
+++ b/3rdparty/lzma/CPP/Windows/Control/Dialog.cpp
@@ -18,7 +18,14 @@ extern bool g_IsNT;
namespace NWindows {
namespace NControl {
-static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
+static
+#ifdef Z7_OLD_WIN_SDK
+ BOOL
+#else
+ INT_PTR
+#endif
+APIENTRY
+DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
{
CWindow tempDialog(dialogHWND);
if (message == WM_INITDIALOG)
@@ -45,7 +52,7 @@ bool CDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
switch (message)
{
case WM_INITDIALOG: return OnInit();
- case WM_COMMAND: return OnCommand(wParam, lParam);
+ case WM_COMMAND: return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam);
case WM_NOTIFY: return OnNotify((UINT)wParam, (LPNMHDR) lParam);
case WM_TIMER: return OnTimer(wParam, lParam);
case WM_SIZE: return OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
@@ -65,19 +72,21 @@ bool CDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
}
}
-bool CDialog::OnCommand(WPARAM wParam, LPARAM lParam)
+/*
+bool CDialog::OnCommand2(WPARAM wParam, LPARAM lParam)
{
return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam);
}
+*/
-bool CDialog::OnCommand(int code, int itemID, LPARAM lParam)
+bool CDialog::OnCommand(unsigned code, unsigned itemID, LPARAM lParam)
{
if (code == BN_CLICKED)
return OnButtonClicked(itemID, (HWND)lParam);
return false;
}
-bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */)
+bool CDialog::OnButtonClicked(unsigned buttonID, HWND /* buttonHWND */)
{
switch (buttonID)
{
@@ -90,6 +99,28 @@ bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */)
return true;
}
+#ifndef UNDER_CE
+/* in win2000/win98 : monitor functions are supported.
+ We need dynamic linking, if we want nt4/win95 support in program.
+ Even if we compile the code with low (WINVER) value, we still
+ want to use monitor functions. So we declare missing functions here */
+// #if (WINVER < 0x0500)
+#ifndef MONITOR_DEFAULTTOPRIMARY
+extern "C" {
+DECLARE_HANDLE(HMONITOR);
+#define MONITOR_DEFAULTTOPRIMARY 0x00000001
+typedef struct tagMONITORINFO
+{
+ DWORD cbSize;
+ RECT rcMonitor;
+ RECT rcWork;
+ DWORD dwFlags;
+} MONITORINFO, *LPMONITORINFO;
+WINUSERAPI HMONITOR WINAPI MonitorFromWindow(HWND hwnd, DWORD dwFlags);
+WINUSERAPI BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpmi);
+}
+#endif
+#endif
static bool GetWorkAreaRect(RECT *rect, HWND hwnd)
{
@@ -172,7 +203,7 @@ int CDialog::Units_To_Pixels_X(int units)
return rect.right - rect.left;
}
-bool CDialog::GetItemSizes(int id, int &x, int &y)
+bool CDialog::GetItemSizes(unsigned id, int &x, int &y)
{
RECT rect;
if (!::GetWindowRect(GetItem(id), &rect))
@@ -182,13 +213,13 @@ bool CDialog::GetItemSizes(int id, int &x, int &y)
return true;
}
-void CDialog::GetClientRectOfItem(int id, RECT &rect)
+void CDialog::GetClientRectOfItem(unsigned id, RECT &rect)
{
::GetWindowRect(GetItem(id), &rect);
ScreenToClient(&rect);
}
-bool CDialog::MoveItem(int id, int x, int y, int width, int height, bool repaint)
+bool CDialog::MoveItem(unsigned id, int x, int y, int width, int height, bool repaint)
{
return BOOLToBool(::MoveWindow(GetItem(id), x, y, width, height, BoolToBOOL(repaint)));
}
@@ -356,8 +387,8 @@ void CDialog::NormalizePosition()
bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow)
{
- HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
- if (aHWND == 0)
+ const HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
+ if (!aHWND)
return false;
Attach(aHWND);
return true;
diff --git a/3rdparty/lzma/CPP/Windows/Control/Dialog.h b/3rdparty/lzma/CPP/Windows/Control/Dialog.h
index 8a39e996fa0..06be4bf938b 100644
--- a/3rdparty/lzma/CPP/Windows/Control/Dialog.h
+++ b/3rdparty/lzma/CPP/Windows/Control/Dialog.h
@@ -1,7 +1,7 @@
// Windows/Control/Dialog.h
-#ifndef __WINDOWS_CONTROL_DIALOG_H
-#define __WINDOWS_CONTROL_DIALOG_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_DIALOG_H
+#define ZIP7_INC_WINDOWS_CONTROL_DIALOG_H
#include "../Window.h"
@@ -10,65 +10,66 @@ namespace NControl {
class CDialog: public CWindow
{
+ // Z7_CLASS_NO_COPY(CDialog)
public:
- CDialog(HWND wnd = NULL): CWindow(wnd){};
- virtual ~CDialog() {};
+ CDialog(HWND wnd = NULL): CWindow(wnd) {}
+ virtual ~CDialog() {}
- HWND GetItem(int itemID) const
- { return GetDlgItem(_window, itemID); }
+ HWND GetItem(unsigned itemID) const
+ { return GetDlgItem(_window, (int)itemID); }
- bool EnableItem(int itemID, bool enable) const
+ bool EnableItem(unsigned itemID, bool enable) const
{ return BOOLToBool(::EnableWindow(GetItem(itemID), BoolToBOOL(enable))); }
- bool ShowItem(int itemID, int cmdShow) const
+ bool ShowItem(unsigned itemID, int cmdShow) const
{ return BOOLToBool(::ShowWindow(GetItem(itemID), cmdShow)); }
- bool ShowItem_Bool(int itemID, bool show) const
+ bool ShowItem_Bool(unsigned itemID, bool show) const
{ return ShowItem(itemID, show ? SW_SHOW: SW_HIDE); }
- bool HideItem(int itemID) const { return ShowItem(itemID, SW_HIDE); }
+ bool HideItem(unsigned itemID) const { return ShowItem(itemID, SW_HIDE); }
- bool SetItemText(int itemID, LPCTSTR s)
- { return BOOLToBool(SetDlgItemText(_window, itemID, s)); }
+ bool SetItemText(unsigned itemID, LPCTSTR s)
+ { return BOOLToBool(SetDlgItemText(_window, (int)itemID, s)); }
- bool SetItemTextA(int itemID, LPCSTR s)
- { return BOOLToBool(SetDlgItemTextA(_window, itemID, s)); }
+ bool SetItemTextA(unsigned itemID, LPCSTR s)
+ { return BOOLToBool(SetDlgItemTextA(_window, (int)itemID, s)); }
- bool SetItemText_Empty(int itemID)
+ bool SetItemText_Empty(unsigned itemID)
{ return SetItemText(itemID, TEXT("")); }
#ifndef _UNICODE
- bool SetItemText(int itemID, LPCWSTR s)
+ bool SetItemText(unsigned itemID, LPCWSTR s)
{
CWindow window(GetItem(itemID));
return window.SetText(s);
}
#endif
- UINT GetItemText(int itemID, LPTSTR string, int maxCount)
- { return GetDlgItemText(_window, itemID, string, maxCount); }
+ UINT GetItemText(unsigned itemID, LPTSTR string, unsigned maxCount)
+ { return GetDlgItemText(_window, (int)itemID, string, (int)maxCount); }
#ifndef _UNICODE
/*
- bool GetItemText(int itemID, LPWSTR string, int maxCount)
+ bool GetItemText(unsigned itemID, LPWSTR string, int maxCount)
{
- CWindow window(GetItem(itemID));
+ CWindow window(GetItem(unsigned));
return window.GetText(string, maxCount);
}
*/
#endif
- bool GetItemText(int itemID, UString &s)
+ bool GetItemText(unsigned itemID, UString &s)
{
CWindow window(GetItem(itemID));
return window.GetText(s);
}
- bool SetItemInt(int itemID, UINT value, bool isSigned)
- { return BOOLToBool(SetDlgItemInt(_window, itemID, value, BoolToBOOL(isSigned))); }
- bool GetItemInt(int itemID, bool isSigned, UINT &value)
+ bool SetItemInt(unsigned itemID, UINT value, bool isSigned)
+ { return BOOLToBool(SetDlgItemInt(_window, (int)itemID, value, BoolToBOOL(isSigned))); }
+ bool GetItemInt(unsigned itemID, bool isSigned, UINT &value)
{
BOOL result;
- value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned));
+ value = GetDlgItemInt(_window, (int)itemID, &result, BoolToBOOL(isSigned));
return BOOLToBool(result);
}
@@ -80,7 +81,7 @@ public:
LRESULT SendMsg_NextDlgCtl(WPARAM wParam, LPARAM lParam)
{ return SendMsg(WM_NEXTDLGCTL, wParam, lParam); }
LRESULT SendMsg_NextDlgCtl_HWND(HWND hwnd) { return SendMsg_NextDlgCtl((WPARAM)hwnd, TRUE); }
- LRESULT SendMsg_NextDlgCtl_CtlId(int id) { return SendMsg_NextDlgCtl_HWND(GetItem(id)); }
+ LRESULT SendMsg_NextDlgCtl_CtlId(unsigned id) { return SendMsg_NextDlgCtl_HWND(GetItem(id)); }
LRESULT SendMsg_NextDlgCtl_Next() { return SendMsg_NextDlgCtl(0, FALSE); }
LRESULT SendMsg_NextDlgCtl_Prev() { return SendMsg_NextDlgCtl(1, FALSE); }
@@ -90,26 +91,27 @@ public:
bool IsMessage(LPMSG message)
{ return BOOLToBool(IsDialogMessage(_window, message)); }
- LRESULT SendItemMessage(int itemID, UINT message, WPARAM wParam, LPARAM lParam)
- { return SendDlgItemMessage(_window, itemID, message, wParam, lParam); }
+ LRESULT SendItemMessage(unsigned itemID, UINT message, WPARAM wParam, LPARAM lParam)
+ { return SendDlgItemMessage(_window, (int)itemID, message, wParam, lParam); }
- bool CheckButton(int buttonID, UINT checkState)
- { return BOOLToBool(CheckDlgButton(_window, buttonID, checkState)); }
- bool CheckButton(int buttonID, bool checkState)
+ bool CheckButton(unsigned buttonID, UINT checkState)
+ { return BOOLToBool(CheckDlgButton(_window, (int)buttonID, checkState)); }
+ bool CheckButton(unsigned buttonID, bool checkState)
{ return CheckButton(buttonID, UINT(checkState ? BST_CHECKED : BST_UNCHECKED)); }
- UINT IsButtonChecked(int buttonID) const
- { return IsDlgButtonChecked(_window, buttonID); }
- bool IsButtonCheckedBool(int buttonID) const
- { return (IsButtonChecked(buttonID) == BST_CHECKED); }
+ UINT IsButtonChecked_BST(unsigned buttonID) const
+ { return IsDlgButtonChecked(_window, (int)buttonID); }
+ bool IsButtonCheckedBool(unsigned buttonID) const
+ { return (IsButtonChecked_BST(buttonID) == BST_CHECKED); }
- bool CheckRadioButton(int firstButtonID, int lastButtonID, int checkButtonID)
- { return BOOLToBool(::CheckRadioButton(_window, firstButtonID, lastButtonID, checkButtonID)); }
+ bool CheckRadioButton(unsigned firstButtonID, unsigned lastButtonID, unsigned checkButtonID)
+ { return BOOLToBool(::CheckRadioButton(_window,
+ (int)firstButtonID, (int)lastButtonID, (int)checkButtonID)); }
virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
virtual bool OnInit() { return true; }
- virtual bool OnCommand(WPARAM wParam, LPARAM lParam);
- virtual bool OnCommand(int code, int itemID, LPARAM lParam);
+ // virtual bool OnCommand2(WPARAM wParam, LPARAM lParam);
+ virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam);
virtual bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; }
virtual bool OnDestroy() { return false; }
@@ -120,11 +122,11 @@ public:
virtual void OnHelp(LPHELPINFO) { OnHelp(); }
#endif
*/
- virtual void OnHelp() {};
+ virtual void OnHelp() {}
- virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
- virtual void OnOK() {};
- virtual void OnCancel() {};
+ virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND);
+ virtual void OnOK() {}
+ virtual void OnCancel() {}
virtual void OnClose() {}
virtual bool OnNotify(UINT /* controlID */, LPNMHDR /* lParam */) { return false; }
virtual bool OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { return false; }
@@ -136,9 +138,11 @@ public:
bool GetMargins(int margin, int &x, int &y);
int Units_To_Pixels_X(int units);
- bool GetItemSizes(int id, int &x, int &y);
- void GetClientRectOfItem(int id, RECT &rect);
- bool MoveItem(int id, int x, int y, int width, int height, bool repaint = true);
+ bool GetItemSizes(unsigned id, int &x, int &y);
+ void GetClientRectOfItem(unsigned id, RECT &rect);
+ bool MoveItem(unsigned id, int x, int y, int width, int height, bool repaint = true);
+ bool MoveItem_RECT(unsigned id, const RECT &r, bool repaint = true)
+ { return MoveItem(id, r.left, r.top, RECT_SIZE_X(r), RECT_SIZE_Y(r), repaint); }
void NormalizeSize(bool fullNormalize = false);
void NormalizePosition();
@@ -152,9 +156,9 @@ public:
#ifndef _UNICODE
bool Create(LPCWSTR templateName, HWND parentWindow);
#endif
- virtual void OnOK() { Destroy(); }
- virtual void OnCancel() { Destroy(); }
- virtual void OnClose() { Destroy(); }
+ virtual void OnOK() Z7_override { Destroy(); }
+ virtual void OnCancel() Z7_override { Destroy(); }
+ virtual void OnClose() Z7_override { Destroy(); }
};
class CModalDialog: public CDialog
@@ -167,18 +171,18 @@ public:
#endif
bool End(INT_PTR result) { return BOOLToBool(::EndDialog(_window, result)); }
- virtual void OnOK() { End(IDOK); }
- virtual void OnCancel() { End(IDCANCEL); }
- virtual void OnClose() { End(IDCLOSE); }
+ virtual void OnOK() Z7_override { End(IDOK); }
+ virtual void OnCancel() Z7_override { End(IDCANCEL); }
+ virtual void OnClose() Z7_override { End(IDCLOSE); }
};
class CDialogChildControl: public NWindows::CWindow
{
- int m_ID;
+ // unsigned m_ID;
public:
- void Init(const NWindows::NControl::CDialog &parentDialog, int id)
+ void Init(const NWindows::NControl::CDialog &parentDialog, unsigned id)
{
- m_ID = id;
+ // m_ID = id;
Attach(parentDialog.GetItem(id));
}
};
diff --git a/3rdparty/lzma/CPP/Windows/Control/Edit.h b/3rdparty/lzma/CPP/Windows/Control/Edit.h
index 51a22c53740..963470d78bc 100644
--- a/3rdparty/lzma/CPP/Windows/Control/Edit.h
+++ b/3rdparty/lzma/CPP/Windows/Control/Edit.h
@@ -1,7 +1,7 @@
// Windows/Control/Edit.h
-#ifndef __WINDOWS_CONTROL_EDIT_H
-#define __WINDOWS_CONTROL_EDIT_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_EDIT_H
+#define ZIP7_INC_WINDOWS_CONTROL_EDIT_H
#include "../Window.h"
diff --git a/3rdparty/lzma/CPP/Windows/Control/ImageList.h b/3rdparty/lzma/CPP/Windows/Control/ImageList.h
index 19feb117d66..688f1777c1c 100644
--- a/3rdparty/lzma/CPP/Windows/Control/ImageList.h
+++ b/3rdparty/lzma/CPP/Windows/Control/ImageList.h
@@ -1,7 +1,7 @@
// Windows/Control/ImageList.h
-#ifndef __WINDOWS_CONTROL_IMAGE_LIST_H
-#define __WINDOWS_CONTROL_IMAGE_LIST_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_IMAGE_LIST_H
+#define ZIP7_INC_WINDOWS_CONTROL_IMAGE_LIST_H
#include <CommCtrl.h>
@@ -56,7 +56,7 @@ public:
bool GetImageInfo(int index, IMAGEINFO* imageInfo) const
{ return BOOLToBool(ImageList_GetImageInfo(m_Object, index, imageInfo)); }
- int Add(HBITMAP hbmImage, HBITMAP hbmMask = 0)
+ int Add(HBITMAP hbmImage, HBITMAP hbmMask = NULL)
{ return ImageList_Add(m_Object, hbmImage, hbmMask); }
int AddMasked(HBITMAP hbmImage, COLORREF mask)
{ return ImageList_AddMasked(m_Object, hbmImage, mask); }
diff --git a/3rdparty/lzma/CPP/Windows/Control/ListView.cpp b/3rdparty/lzma/CPP/Windows/Control/ListView.cpp
index 16cfd396ede..3e8786a1d95 100644
--- a/3rdparty/lzma/CPP/Windows/Control/ListView.cpp
+++ b/3rdparty/lzma/CPP/Windows/Control/ListView.cpp
@@ -20,78 +20,85 @@ bool CListView::CreateEx(DWORD exStyle, DWORD style,
height, parentWindow, idOrHMenu, instance, createParam);
}
-bool CListView::GetItemParam(int index, LPARAM &param) const
+/* note: LVITEM and LVCOLUMN structures contain optional fields
+ depending from preprocessor macros:
+ #if (_WIN32_IE >= 0x0300)
+ #if (_WIN32_WINNT >= 0x0501)
+ #if (_WIN32_WINNT >= 0x0600)
+*/
+
+bool CListView::GetItemParam(unsigned index, LPARAM &param) const
{
LVITEM item;
- item.iItem = index;
+ item.iItem = (int)index;
item.iSubItem = 0;
item.mask = LVIF_PARAM;
- bool aResult = GetItem(&item);
+ const bool res = GetItem(&item);
param = item.lParam;
- return aResult;
+ return res;
}
-int CListView::InsertColumn(int columnIndex, LPCTSTR text, int width)
+int CListView::InsertColumn(unsigned columnIndex, LPCTSTR text, int width)
{
LVCOLUMN ci;
ci.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
ci.pszText = (LPTSTR)(void *)text;
- ci.iSubItem = columnIndex;
+ ci.iSubItem = (int)columnIndex;
ci.cx = width;
return InsertColumn(columnIndex, &ci);
}
-int CListView::InsertItem(int index, LPCTSTR text)
+int CListView::InsertItem(unsigned index, LPCTSTR text)
{
LVITEM item;
item.mask = LVIF_TEXT | LVIF_PARAM;
- item.iItem = index;
- item.lParam = index;
+ item.iItem = (int)index;
+ item.lParam = (LPARAM)index;
item.pszText = (LPTSTR)(void *)text;
item.iSubItem = 0;
return InsertItem(&item);
}
-int CListView::SetSubItem(int index, int subIndex, LPCTSTR text)
+int CListView::SetSubItem(unsigned index, unsigned subIndex, LPCTSTR text)
{
LVITEM item;
item.mask = LVIF_TEXT;
- item.iItem = index;
+ item.iItem = (int)index;
item.pszText = (LPTSTR)(void *)text;
- item.iSubItem = subIndex;
+ item.iSubItem = (int)subIndex;
return SetItem(&item);
}
#ifndef _UNICODE
-int CListView::InsertColumn(int columnIndex, LPCWSTR text, int width)
+int CListView::InsertColumn(unsigned columnIndex, LPCWSTR text, int width)
{
LVCOLUMNW ci;
ci.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
ci.pszText = (LPWSTR)(void *)text;
- ci.iSubItem = columnIndex;
+ ci.iSubItem = (int)columnIndex;
ci.cx = width;
return InsertColumn(columnIndex, &ci);
}
-int CListView::InsertItem(int index, LPCWSTR text)
+int CListView::InsertItem(unsigned index, LPCWSTR text)
{
LVITEMW item;
item.mask = LVIF_TEXT | LVIF_PARAM;
- item.iItem = index;
- item.lParam = index;
+ item.iItem = (int)index;
+ item.lParam = (LPARAM)index;
item.pszText = (LPWSTR)(void *)text;
item.iSubItem = 0;
return InsertItem(&item);
}
-int CListView::SetSubItem(int index, int subIndex, LPCWSTR text)
+int CListView::SetSubItem(unsigned index, unsigned subIndex, LPCWSTR text)
{
LVITEMW item;
item.mask = LVIF_TEXT;
- item.iItem = index;
+ item.iItem = (int)index;
item.pszText = (LPWSTR)(void *)text;
- item.iSubItem = subIndex;
+ item.iSubItem = (int)subIndex;
return SetItem(&item);
}
diff --git a/3rdparty/lzma/CPP/Windows/Control/ListView.h b/3rdparty/lzma/CPP/Windows/Control/ListView.h
index a13b1041fd9..11a33a07d07 100644
--- a/3rdparty/lzma/CPP/Windows/Control/ListView.h
+++ b/3rdparty/lzma/CPP/Windows/Control/ListView.h
@@ -1,7 +1,7 @@
// Windows/Control/ListView.h
-#ifndef __WINDOWS_CONTROL_LISTVIEW_H
-#define __WINDOWS_CONTROL_LISTVIEW_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
+#define ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
#include "../../Common/MyWindows.h"
@@ -28,11 +28,11 @@ public:
}
bool DeleteAllItems() { return BOOLToBool(ListView_DeleteAllItems(_window)); }
- bool DeleteColumn(int columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
+ bool DeleteColumn(unsigned columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
- int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
- int InsertColumn(int columnIndex, LPCTSTR text, int width);
- bool SetColumnOrderArray(int count, const int *columns)
+ int InsertColumn(unsigned columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
+ int InsertColumn(unsigned columnIndex, LPCTSTR text, int width);
+ bool SetColumnOrderArray(unsigned count, const int *columns)
{ return BOOLToBool(ListView_SetColumnOrderArray(_window, count, (int *)(void *)columns)); }
/*
@@ -46,43 +46,49 @@ public:
*/
int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
- int InsertItem(int index, LPCTSTR text);
+ int InsertItem(unsigned index, LPCTSTR text);
bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }
- int SetSubItem(int index, int subIndex, LPCTSTR text);
+ int SetSubItem(unsigned index, unsigned subIndex, LPCTSTR text);
#ifndef _UNICODE
- int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMsg(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
- int InsertColumn(int columnIndex, LPCWSTR text, int width);
+ int InsertColumn(unsigned columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMsg(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
+ int InsertColumn(unsigned columnIndex, LPCWSTR text, int width);
int InsertItem(const LV_ITEMW* item) { return (int)SendMsg(LVM_INSERTITEMW, 0, (LPARAM)item); }
- int InsertItem(int index, LPCWSTR text);
+ int InsertItem(unsigned index, LPCWSTR text);
bool SetItem(const LV_ITEMW* item) { return BOOLToBool((BOOL)SendMsg(LVM_SETITEMW, 0, (LPARAM)item)); }
- int SetSubItem(int index, int subIndex, LPCWSTR text);
+ int SetSubItem(unsigned index, unsigned subIndex, LPCWSTR text);
#endif
- bool DeleteItem(int itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
+ bool DeleteItem(unsigned itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
UINT GetSelectedCount() const { return ListView_GetSelectedCount(_window); }
int GetItemCount() const { return ListView_GetItemCount(_window); }
INT GetSelectionMark() const { return ListView_GetSelectionMark(_window); }
- void SetItemCount(int numItems) { ListView_SetItemCount(_window, numItems); }
- void SetItemCountEx(int numItems, DWORD flags) { ListView_SetItemCountEx(_window, numItems, flags); }
+ void SetItemCount(unsigned numItems) { ListView_SetItemCount(_window, numItems); }
+ void SetItemCountEx(unsigned numItems, DWORD flags) { ListView_SetItemCountEx(_window, numItems, flags); }
+ /* startIndex : The index of the item with which to begin the search,
+ or -1 to find the first item that matches the specified flags.
+ The specified item itself is excluded from the search. */
int GetNextItem(int startIndex, UINT flags) const { return ListView_GetNextItem(_window, startIndex, flags); }
int GetNextSelectedItem(int startIndex) const { return GetNextItem(startIndex, LVNI_SELECTED); }
int GetFocusedItem() const { return GetNextItem(-1, LVNI_FOCUSED); }
bool GetItem(LVITEM* item) const { return BOOLToBool(ListView_GetItem(_window, item)); }
- bool GetItemParam(int itemIndex, LPARAM &param) const;
- void GetItemText(int itemIndex, int subItemIndex, LPTSTR text, int textSizeMax) const
- { ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax); }
+ bool GetItemParam(unsigned itemIndex, LPARAM &param) const;
+ /*
+ void GetItemText(unsigned itemIndex, unsigned subItemIndex, LPTSTR text, unsigned textSizeMax) const
+ { ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax) }
+ */
bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
{ return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
- void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask); }
+ // If (index == -1), then the state change is applied to all items.
+ void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask) }
void SetItemState_Selected(int index, bool select) { SetItemState(index, select ? LVIS_SELECTED : 0, LVIS_SELECTED); }
void SetItemState_Selected(int index) { SetItemState(index, LVIS_SELECTED, LVIS_SELECTED); }
void SelectAll() { SetItemState_Selected(-1); }
@@ -90,7 +96,7 @@ public:
UINT GetItemState(int index, UINT mask) const { return ListView_GetItemState(_window, index, mask); }
bool IsItemSelected(int index) const { return GetItemState(index, LVIS_SELECTED) == LVIS_SELECTED; }
- bool GetColumn(int columnIndex, LVCOLUMN* columnInfo) const
+ bool GetColumn(unsigned columnIndex, LVCOLUMN* columnInfo) const
{ return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
HIMAGELIST SetImageList(HIMAGELIST imageList, int imageListType)
@@ -101,7 +107,7 @@ public:
void SetExtendedListViewStyle(DWORD exStyle) { ListView_SetExtendedListViewStyle(_window, exStyle); }
void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle) { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
- void SetCheckState(UINT index, bool checkState) { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); }
+ void SetCheckState(UINT index, bool checkState) { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)) }
bool GetCheckState(UINT index) { return BOOLToBool(ListView_GetCheckState(_window, index)); }
bool EnsureVisible(int index, bool partialOK) { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
@@ -129,7 +135,10 @@ public:
class CListView2: public CListView
{
WNDPROC _origWindowProc;
+ // ~CListView2() ZIP7_eq_delete;
public:
+ virtual ~CListView2() {}
+ CListView2() {}
void SetWindowProc();
virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
};
diff --git a/3rdparty/lzma/CPP/Windows/Control/ProgressBar.h b/3rdparty/lzma/CPP/Windows/Control/ProgressBar.h
index 03743067448..2256aa9e912 100644
--- a/3rdparty/lzma/CPP/Windows/Control/ProgressBar.h
+++ b/3rdparty/lzma/CPP/Windows/Control/ProgressBar.h
@@ -1,7 +1,7 @@
// Windows/Control/ProgressBar.h
-#ifndef __WINDOWS_CONTROL_PROGRESSBAR_H
-#define __WINDOWS_CONTROL_PROGRESSBAR_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_PROGRESSBAR_H
+#define ZIP7_INC_WINDOWS_CONTROL_PROGRESSBAR_H
#include "../../Common/MyWindows.h"
@@ -15,18 +15,18 @@ namespace NControl {
class CProgressBar: public CWindow
{
public:
- LRESULT SetPos(int pos) { return SendMsg(PBM_SETPOS, pos, 0); }
- LRESULT DeltaPos(int increment) { return SendMsg(PBM_DELTAPOS, increment, 0); }
- UINT GetPos() { return (UINT)SendMsg(PBM_GETPOS, 0, 0); }
- LRESULT SetRange(unsigned short minValue, unsigned short maxValue) { return SendMsg(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); }
- DWORD SetRange32(int minValue, int maxValue) { return (DWORD)SendMsg(PBM_SETRANGE32, minValue, maxValue); }
- int SetStep(int step) { return (int)SendMsg(PBM_SETSTEP, step, 0); }
- LRESULT StepIt() { return SendMsg(PBM_STEPIT, 0, 0); }
- INT GetRange(bool minValue, PPBRANGE range) { return (INT)SendMsg(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); }
+ LRESULT SetPos(int pos) { return SendMsg(PBM_SETPOS, (unsigned)pos, 0); }
+ // LRESULT DeltaPos(int increment) { return SendMsg(PBM_DELTAPOS, increment, 0); }
+ // UINT GetPos() { return (UINT)SendMsg(PBM_GETPOS, 0, 0); }
+ // LRESULT SetRange(unsigned short minValue, unsigned short maxValue) { return SendMsg(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); }
+ DWORD SetRange32(int minValue, int maxValue) { return (DWORD)SendMsg(PBM_SETRANGE32, (unsigned)minValue, (LPARAM)(unsigned)maxValue); }
+ // int SetStep(int step) { return (int)SendMsg(PBM_SETSTEP, step, 0); }
+ // LRESULT StepIt() { return SendMsg(PBM_STEPIT, 0, 0); }
+ // INT GetRange(bool minValue, PPBRANGE range) { return (INT)SendMsg(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); }
#ifndef UNDER_CE
- COLORREF SetBarColor(COLORREF color) { return (COLORREF)SendMsg(PBM_SETBARCOLOR, 0, color); }
- COLORREF SetBackgroundColor(COLORREF color) { return (COLORREF)SendMsg(PBM_SETBKCOLOR, 0, color); }
+ COLORREF SetBarColor(COLORREF color) { return (COLORREF)SendMsg(PBM_SETBARCOLOR, 0, (LPARAM)color); }
+ COLORREF SetBackgroundColor(COLORREF color) { return (COLORREF)SendMsg(PBM_SETBKCOLOR, 0, (LPARAM)color); }
#endif
};
diff --git a/3rdparty/lzma/CPP/Windows/Control/PropertyPage.cpp b/3rdparty/lzma/CPP/Windows/Control/PropertyPage.cpp
index ce8696d4018..f8effe607bb 100644
--- a/3rdparty/lzma/CPP/Windows/Control/PropertyPage.cpp
+++ b/3rdparty/lzma/CPP/Windows/Control/PropertyPage.cpp
@@ -16,7 +16,13 @@ extern bool g_IsNT;
namespace NWindows {
namespace NControl {
-static INT_PTR APIENTRY MyProperyPageProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
+static
+#ifdef Z7_OLD_WIN_SDK
+ BOOL
+#else
+ INT_PTR
+#endif
+APIENTRY MyProperyPageProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
{
CWindow tempDialog(dialogHWND);
if (message == WM_INITDIALOG)
@@ -34,75 +40,91 @@ bool CPropertyPage::OnNotify(UINT /* controlID */, LPNMHDR lParam)
{
switch (lParam->code)
{
- case PSN_APPLY: SetMsgResult(OnApply(LPPSHNOTIFY(lParam))); break;
- case PSN_KILLACTIVE: SetMsgResult(BoolToBOOL(OnKillActive(LPPSHNOTIFY(lParam)))); break;
- case PSN_SETACTIVE: SetMsgResult(OnSetActive(LPPSHNOTIFY(lParam))); break;
- case PSN_RESET: OnReset(LPPSHNOTIFY(lParam)); break;
- case PSN_HELP: OnNotifyHelp(LPPSHNOTIFY(lParam)); break;
+ case PSN_APPLY: SetMsgResult(OnApply2(LPPSHNOTIFY(lParam))); break;
+ case PSN_KILLACTIVE: SetMsgResult(BoolToBOOL(OnKillActive2(LPPSHNOTIFY(lParam)))); break;
+ case PSN_SETACTIVE: SetMsgResult(OnSetActive2(LPPSHNOTIFY(lParam))); break;
+ case PSN_RESET: OnReset2(LPPSHNOTIFY(lParam)); break;
+ case PSN_HELP: OnNotifyHelp2(LPPSHNOTIFY(lParam)); break;
default: return false;
}
return true;
}
+/*
+PROPSHEETPAGE fields depend from
+#if (_WIN32_WINNT >= 0x0600)
+#elif (_WIN32_WINNT >= 0x0501)
+#elif (_WIN32_IE >= 0x0400)
+PROPSHEETHEADER fields depend from
+#if (_WIN32_IE >= 0x0400)
+*/
+#if defined(PROPSHEETPAGEA_V1_SIZE) && !defined(Z7_OLD_WIN_SDK)
+#ifndef _UNICODE
+#define my_compatib_PROPSHEETPAGEA PROPSHEETPAGEA_V1
+#endif
+#define my_compatib_PROPSHEETPAGEW PROPSHEETPAGEW_V1
+#else
+// for old mingw:
+#ifndef _UNICODE
+#define my_compatib_PROPSHEETPAGEA PROPSHEETPAGEA
+#endif
+#define my_compatib_PROPSHEETPAGEW PROPSHEETPAGEW
+#endif
+
INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndParent, const UString &title)
{
- #ifndef _UNICODE
- AStringVector titles;
- #endif
- #ifndef _UNICODE
- CRecordVector<PROPSHEETPAGEA> pagesA;
- #endif
- CRecordVector<PROPSHEETPAGEW> pagesW;
-
unsigned i;
#ifndef _UNICODE
+ AStringVector titles;
for (i = 0; i < pagesInfo.Size(); i++)
titles.Add(GetSystemString(pagesInfo[i].Title));
+ CRecordVector<my_compatib_PROPSHEETPAGEA> pagesA;
#endif
+ CRecordVector<my_compatib_PROPSHEETPAGEW> pagesW;
for (i = 0; i < pagesInfo.Size(); i++)
{
const CPageInfo &pageInfo = pagesInfo[i];
#ifndef _UNICODE
{
- PROPSHEETPAGE page;
+ my_compatib_PROPSHEETPAGEA page;
+ memset(&page, 0, sizeof(page));
page.dwSize = sizeof(page);
page.dwFlags = PSP_HASHELP;
page.hInstance = g_hInstance;
- page.pszTemplate = MAKEINTRESOURCE(pageInfo.ID);
- page.pszIcon = NULL;
+ page.pszTemplate = MAKEINTRESOURCEA(pageInfo.ID);
+ // page.pszIcon = NULL;
page.pfnDlgProc = NWindows::NControl::MyProperyPageProcedure;
- if (titles[i].IsEmpty())
- page.pszTitle = NULL;
- else
+ if (!titles[i].IsEmpty())
{
- page.dwFlags |= PSP_USETITLE;
page.pszTitle = titles[i];
+ page.dwFlags |= PSP_USETITLE;
}
+ // else page.pszTitle = NULL;
page.lParam = (LPARAM)pageInfo.Page;
- page.pfnCallback = NULL;
+ // page.pfnCallback = NULL;
pagesA.Add(page);
}
#endif
{
- PROPSHEETPAGEW page;
+ my_compatib_PROPSHEETPAGEW page;
+ memset(&page, 0, sizeof(page));
page.dwSize = sizeof(page);
page.dwFlags = PSP_HASHELP;
page.hInstance = g_hInstance;
page.pszTemplate = MAKEINTRESOURCEW(pageInfo.ID);
- page.pszIcon = NULL;
+ // page.pszIcon = NULL;
page.pfnDlgProc = NWindows::NControl::MyProperyPageProcedure;
- if (pageInfo.Title.IsEmpty())
- page.pszTitle = NULL;
- else
+ if (!pageInfo.Title.IsEmpty())
{
- page.dwFlags |= PSP_USETITLE;
page.pszTitle = pageInfo.Title;
+ page.dwFlags |= PSP_USETITLE;
}
+ // else page.pszTitle = NULL;
page.lParam = (LPARAM)pageInfo.Page;
- page.pfnCallback = NULL;
+ // page.pfnCallback = NULL;
pagesW.Add(page);
}
}
@@ -110,16 +132,16 @@ INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndPare
#ifndef _UNICODE
if (!g_IsNT)
{
- PROPSHEETHEADER sheet;
+ PROPSHEETHEADERA sheet;
sheet.dwSize = sizeof(sheet);
sheet.dwFlags = PSH_PROPSHEETPAGE;
sheet.hwndParent = hwndParent;
sheet.hInstance = g_hInstance;
AString titleA (GetSystemString(title));
sheet.pszCaption = titleA;
- sheet.nPages = pagesInfo.Size();
+ sheet.nPages = pagesA.Size();
sheet.nStartPage = 0;
- sheet.ppsp = &pagesA.Front();
+ sheet.ppsp = (LPCPROPSHEETPAGEA)(const void *)&pagesA.Front();
sheet.pfnCallback = NULL;
return ::PropertySheetA(&sheet);
}
@@ -132,9 +154,9 @@ INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndPare
sheet.hwndParent = hwndParent;
sheet.hInstance = g_hInstance;
sheet.pszCaption = title;
- sheet.nPages = pagesInfo.Size();
+ sheet.nPages = pagesW.Size();
sheet.nStartPage = 0;
- sheet.ppsp = &pagesW.Front();
+ sheet.ppsp = (LPCPROPSHEETPAGEW)(const void *)&pagesW.Front();
sheet.pfnCallback = NULL;
return ::PropertySheetW(&sheet);
}
diff --git a/3rdparty/lzma/CPP/Windows/Control/PropertyPage.h b/3rdparty/lzma/CPP/Windows/Control/PropertyPage.h
index b68fd8fee24..264a5d29cac 100644
--- a/3rdparty/lzma/CPP/Windows/Control/PropertyPage.h
+++ b/3rdparty/lzma/CPP/Windows/Control/PropertyPage.h
@@ -1,11 +1,11 @@
// Windows/Control/PropertyPage.h
-#ifndef __WINDOWS_CONTROL_PROPERTYPAGE_H
-#define __WINDOWS_CONTROL_PROPERTYPAGE_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_PROPERTYPAGE_H
+#define ZIP7_INC_WINDOWS_CONTROL_PROPERTYPAGE_H
#include "../../Common/MyWindows.h"
-#include <PrSht.h>
+#include <prsht.h>
#include "Dialog.h"
@@ -17,23 +17,23 @@ INT_PTR APIENTRY ProperyPageProcedure(HWND dialogHWND, UINT message, WPARAM wPar
class CPropertyPage: public CDialog
{
public:
- CPropertyPage(HWND window = NULL): CDialog(window){};
+ CPropertyPage(HWND window = NULL): CDialog(window) {}
void Changed() { PropSheet_Changed(GetParent(), (HWND)*this); }
void UnChanged() { PropSheet_UnChanged(GetParent(), (HWND)*this); }
- virtual bool OnNotify(UINT controlID, LPNMHDR lParam);
+ virtual bool OnNotify(UINT controlID, LPNMHDR lParam) Z7_override;
virtual bool OnKillActive() { return false; } // false = OK
- virtual bool OnKillActive(const PSHNOTIFY *) { return OnKillActive(); }
+ virtual bool OnKillActive2(const PSHNOTIFY *) { return OnKillActive(); }
virtual LONG OnSetActive() { return false; } // false = OK
- virtual LONG OnSetActive(const PSHNOTIFY *) { return OnSetActive(); }
+ virtual LONG OnSetActive2(const PSHNOTIFY *) { return OnSetActive(); }
virtual LONG OnApply() { return PSNRET_NOERROR; }
- virtual LONG OnApply(const PSHNOTIFY *) { return OnApply(); }
+ virtual LONG OnApply2(const PSHNOTIFY *) { return OnApply(); }
virtual void OnNotifyHelp() {}
- virtual void OnNotifyHelp(const PSHNOTIFY *) { OnNotifyHelp(); }
+ virtual void OnNotifyHelp2(const PSHNOTIFY *) { OnNotifyHelp(); }
virtual void OnReset() {}
- virtual void OnReset(const PSHNOTIFY *) { OnReset(); }
+ virtual void OnReset2(const PSHNOTIFY *) { OnReset(); }
};
struct CPageInfo
diff --git a/3rdparty/lzma/CPP/Windows/Control/ReBar.h b/3rdparty/lzma/CPP/Windows/Control/ReBar.h
index c2d58dbe80d..b56f018cb05 100644
--- a/3rdparty/lzma/CPP/Windows/Control/ReBar.h
+++ b/3rdparty/lzma/CPP/Windows/Control/ReBar.h
@@ -1,7 +1,7 @@
// Windows/Control/ReBar.h
-#ifndef __WINDOWS_CONTROL_REBAR_H
-#define __WINDOWS_CONTROL_REBAR_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_REBAR_H
+#define ZIP7_INC_WINDOWS_CONTROL_REBAR_H
#include "../Window.h"
@@ -14,7 +14,7 @@ public:
bool SetBarInfo(LPREBARINFO barInfo)
{ return LRESULTToBool(SendMsg(RB_SETBARINFO, 0, (LPARAM)barInfo)); }
bool InsertBand(int index, LPREBARBANDINFO bandInfo)
- { return LRESULTToBool(SendMsg(RB_INSERTBAND, index, (LPARAM)bandInfo)); }
+ { return LRESULTToBool(SendMsg(RB_INSERTBAND, MY_int_TO_WPARAM(index), (LPARAM)bandInfo)); }
bool SetBandInfo(unsigned index, LPREBARBANDINFO bandInfo)
{ return LRESULTToBool(SendMsg(RB_SETBANDINFO, index, (LPARAM)bandInfo)); }
void MaximizeBand(unsigned index, bool ideal)
diff --git a/3rdparty/lzma/CPP/Windows/Control/Static.h b/3rdparty/lzma/CPP/Windows/Control/Static.h
index 5523b2e633e..ceeedf96695 100644
--- a/3rdparty/lzma/CPP/Windows/Control/Static.h
+++ b/3rdparty/lzma/CPP/Windows/Control/Static.h
@@ -1,7 +1,7 @@
// Windows/Control/Static.h
-#ifndef __WINDOWS_CONTROL_STATIC_H
-#define __WINDOWS_CONTROL_STATIC_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_STATIC_H
+#define ZIP7_INC_WINDOWS_CONTROL_STATIC_H
#include "../Window.h"
diff --git a/3rdparty/lzma/CPP/Windows/Control/StatusBar.h b/3rdparty/lzma/CPP/Windows/Control/StatusBar.h
index 988b84700b4..38aca478821 100644
--- a/3rdparty/lzma/CPP/Windows/Control/StatusBar.h
+++ b/3rdparty/lzma/CPP/Windows/Control/StatusBar.h
@@ -1,7 +1,7 @@
// Windows/Control/StatusBar.h
-#ifndef __WINDOWS_CONTROL_STATUSBAR_H
-#define __WINDOWS_CONTROL_STATUSBAR_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_STATUSBAR_H
+#define ZIP7_INC_WINDOWS_CONTROL_STATUSBAR_H
#include "../Window.h"
@@ -12,7 +12,7 @@ class CStatusBar: public NWindows::CWindow
{
public:
bool Create(LONG style, LPCTSTR text, HWND hwndParent, UINT id)
- { return (_window = ::CreateStatusWindow(style, text, hwndParent, id)) != 0; }
+ { return (_window = ::CreateStatusWindow(style, text, hwndParent, id)) != NULL; }
bool SetText(LPCTSTR text)
{ return CWindow::SetText(text); }
bool SetText(unsigned index, LPCTSTR text, UINT type)
@@ -22,7 +22,7 @@ public:
#ifndef _UNICODE
bool Create(LONG style, LPCWSTR text, HWND hwndParent, UINT id)
- { return (_window = ::CreateStatusWindowW(style, text, hwndParent, id)) != 0; }
+ { return (_window = ::CreateStatusWindowW(style, text, hwndParent, id)) != NULL; }
bool SetText(LPCWSTR text)
{ return CWindow::SetText(text); }
bool SetText(unsigned index, LPCWSTR text, UINT type)
@@ -34,7 +34,7 @@ public:
bool SetParts(unsigned numParts, const int *edgePostions)
{ return LRESULTToBool(SendMsg(SB_SETPARTS, numParts, (LPARAM)edgePostions)); }
void Simple(bool simple)
- { SendMsg(SB_SIMPLE, BoolToBOOL(simple), 0); }
+ { SendMsg(SB_SIMPLE, (WPARAM)BoolToBOOL(simple), 0); }
};
}}
diff --git a/3rdparty/lzma/CPP/Windows/Control/StdAfx.h b/3rdparty/lzma/CPP/Windows/Control/StdAfx.h
index 1cbd7feaeec..80866550d1f 100644
--- a/3rdparty/lzma/CPP/Windows/Control/StdAfx.h
+++ b/3rdparty/lzma/CPP/Windows/Control/StdAfx.h
@@ -1,8 +1,11 @@
// StdAfx.h
-#ifndef __STDAFX_H
-#define __STDAFX_H
+#ifndef ZIP7_INC_STDAFX_H
+#define ZIP7_INC_STDAFX_H
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+#pragma warning(disable : 4464) // relative include path contains '..'
+#endif
#include "../../Common/Common.h"
#endif
diff --git a/3rdparty/lzma/CPP/Windows/Control/ToolBar.h b/3rdparty/lzma/CPP/Windows/Control/ToolBar.h
index 7bc93a24170..2bf20a592e3 100644
--- a/3rdparty/lzma/CPP/Windows/Control/ToolBar.h
+++ b/3rdparty/lzma/CPP/Windows/Control/ToolBar.h
@@ -1,7 +1,7 @@
// Windows/Control/ToolBar.h
-#ifndef __WINDOWS_CONTROL_TOOLBAR_H
-#define __WINDOWS_CONTROL_TOOLBAR_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_TOOLBAR_H
+#define ZIP7_INC_WINDOWS_CONTROL_TOOLBAR_H
#include "../Window.h"
@@ -18,7 +18,7 @@ public:
#ifdef UNDER_CE
{
// maybe it must be fixed for more than 1 buttons
- DWORD val = GetButtonSize();
+ const DWORD val = GetButtonSize();
size->cx = LOWORD(val);
size->cy = HIWORD(val);
return true;
diff --git a/3rdparty/lzma/CPP/Windows/Control/Trackbar.h b/3rdparty/lzma/CPP/Windows/Control/Trackbar.h
index 313e0c851b6..18d1b29186a 100644
--- a/3rdparty/lzma/CPP/Windows/Control/Trackbar.h
+++ b/3rdparty/lzma/CPP/Windows/Control/Trackbar.h
@@ -1,7 +1,7 @@
// Windows/Control/Trackbar.h
-#ifndef __WINDOWS_CONTROL_TRACKBAR_H
-#define __WINDOWS_CONTROL_TRACKBAR_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_TRACKBAR_H
+#define ZIP7_INC_WINDOWS_CONTROL_TRACKBAR_H
#include "../Window.h"
diff --git a/3rdparty/lzma/CPP/Windows/Control/Window2.cpp b/3rdparty/lzma/CPP/Windows/Control/Window2.cpp
index 994d96e080a..8fe908e0813 100644
--- a/3rdparty/lzma/CPP/Windows/Control/Window2.cpp
+++ b/3rdparty/lzma/CPP/Windows/Control/Window2.cpp
@@ -32,9 +32,9 @@ static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message, WPARAM wParam,
if (message == MY_START_WM_CREATE)
tempWindow.SetUserDataLongPtr((LONG_PTR)(((LPCREATESTRUCT)lParam)->lpCreateParams));
CWindow2 *window = (CWindow2 *)(tempWindow.GetUserDataLongPtr());
- if (window != NULL && message == MY_START_WM_CREATE)
+ if (window && message == MY_START_WM_CREATE)
window->Attach(aHWND);
- if (window == 0)
+ if (!window)
{
#ifndef _UNICODE
if (g_IsNT)
@@ -140,7 +140,7 @@ LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return -1;
break;
case WM_COMMAND:
- if (OnCommand(wParam, lParam, result))
+ if (OnCommand(HIWORD(wParam), LOWORD(wParam), lParam, result))
return result;
break;
case WM_NOTIFY:
@@ -160,12 +160,14 @@ LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return DefProc(message, wParam, lParam);
}
-bool CWindow2::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result)
+/*
+bool CWindow2::OnCommand2(WPARAM wParam, LPARAM lParam, LRESULT &result)
{
return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam, result);
}
+*/
-bool CWindow2::OnCommand(int /* code */, int /* itemID */, LPARAM /* lParam */, LRESULT & /* result */)
+bool CWindow2::OnCommand(unsigned /* code */, unsigned /* itemID */, LPARAM /* lParam */, LRESULT & /* result */)
{
return false;
// return DefProc(message, wParam, lParam);
@@ -176,7 +178,7 @@ bool CWindow2::OnCommand(int /* code */, int /* itemID */, LPARAM /* lParam */,
}
/*
-bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+bool CDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
switch (buttonID)
{
diff --git a/3rdparty/lzma/CPP/Windows/Control/Window2.h b/3rdparty/lzma/CPP/Windows/Control/Window2.h
index 7ac580cb071..ebb59793567 100644
--- a/3rdparty/lzma/CPP/Windows/Control/Window2.h
+++ b/3rdparty/lzma/CPP/Windows/Control/Window2.h
@@ -1,7 +1,7 @@
// Windows/Control/Window2.h
-#ifndef __WINDOWS_CONTROL_WINDOW2_H
-#define __WINDOWS_CONTROL_WINDOW2_H
+#ifndef ZIP7_INC_WINDOWS_CONTROL_WINDOW2_H
+#define ZIP7_INC_WINDOWS_CONTROL_WINDOW2_H
#include "../Window.h"
@@ -10,10 +10,12 @@ namespace NControl {
class CWindow2: public CWindow
{
+ // Z7_CLASS_NO_COPY(CWindow2)
+
LRESULT DefProc(UINT message, WPARAM wParam, LPARAM lParam);
public:
- CWindow2(HWND newWindow = NULL): CWindow(newWindow){};
- virtual ~CWindow2() {};
+ CWindow2(HWND newWindow = NULL): CWindow(newWindow) {}
+ virtual ~CWindow2() {}
bool CreateEx(DWORD exStyle, LPCTSTR className, LPCTSTR windowName,
DWORD style, int x, int y, int width, int height,
@@ -28,8 +30,8 @@ public:
virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
virtual bool OnCreate(CREATESTRUCT * /* createStruct */) { return true; }
// virtual LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
- virtual bool OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result);
- virtual bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result);
+ // bool OnCommand2(WPARAM wParam, LPARAM lParam, LRESULT &result);
+ virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam, LRESULT &result);
virtual bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; }
virtual bool OnNotify(UINT /* controlID */, LPNMHDR /* lParam */, LRESULT & /* result */) { return false; }
virtual void OnDestroy() { PostQuitMessage(0); }
@@ -37,7 +39,7 @@ public:
/*
virtual LRESULT OnHelp(LPHELPINFO helpInfo) { OnHelp(); }
virtual LRESULT OnHelp() {};
- virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND);
virtual void OnOK() {};
virtual void OnCancel() {};
*/
diff --git a/3rdparty/lzma/CPP/Windows/DLL.cpp b/3rdparty/lzma/CPP/Windows/DLL.cpp
index cf5d01a302c..b2499ecdc0e 100644
--- a/3rdparty/lzma/CPP/Windows/DLL.cpp
+++ b/3rdparty/lzma/CPP/Windows/DLL.cpp
@@ -17,11 +17,11 @@ namespace NDLL {
bool CLibrary::Free() throw()
{
- if (_module == 0)
+ if (_module == NULL)
return true;
if (!::FreeLibrary(_module))
return false;
- _module = 0;
+ _module = NULL;
return true;
}
@@ -90,7 +90,7 @@ bool MyGetModuleFileName(FString &path)
return false;
}
-#ifndef _SFX
+#ifndef Z7_SFX
FString GetModuleDirPrefix()
{
@@ -110,38 +110,35 @@ FString GetModuleDirPrefix()
}}
-#else
+#else // _WIN32
#include <dlfcn.h>
#include <stdlib.h>
+#include "../Common/Common.h"
+
+// FARPROC
+void *GetProcAddress(HMODULE module, LPCSTR procName)
+{
+ void *ptr = NULL;
+ if (module)
+ ptr = dlsym(module, procName);
+ return ptr;
+}
namespace NWindows {
namespace NDLL {
bool CLibrary::Free() throw()
{
- if (_module == NULL)
+ if (!_module)
return true;
- int ret = dlclose(_module);
+ const int ret = dlclose(_module);
if (ret != 0)
return false;
_module = NULL;
return true;
}
-static
-// FARPROC
-void *
-local_GetProcAddress(HMODULE module, LPCSTR procName)
-{
- void *ptr = NULL;
- if (module)
- {
- ptr = dlsym(module, procName);
- }
- return ptr;
-}
-
bool CLibrary::Load(CFSTR path) throw()
{
if (!Free())
@@ -163,21 +160,11 @@ bool CLibrary::Load(CFSTR path) throw()
#endif
#endif
- void *handler = dlopen(path, options);
-
- if (handler)
- {
- // here we can transfer some settings to DLL
- }
- else
- {
- }
-
- _module = handler;
-
+ _module = dlopen(path, options);
return (_module != NULL);
}
+/*
// FARPROC
void * CLibrary::GetProc(LPCSTR procName) const
{
@@ -185,6 +172,7 @@ void * CLibrary::GetProc(LPCSTR procName) const
return local_GetProcAddress(_module, procName);
// return NULL;
}
+*/
}}
diff --git a/3rdparty/lzma/CPP/Windows/DLL.h b/3rdparty/lzma/CPP/Windows/DLL.h
index 0c093eeddb6..19a82b33b89 100644
--- a/3rdparty/lzma/CPP/Windows/DLL.h
+++ b/3rdparty/lzma/CPP/Windows/DLL.h
@@ -1,20 +1,29 @@
// Windows/DLL.h
-#ifndef __WINDOWS_DLL_H
-#define __WINDOWS_DLL_H
+#ifndef ZIP7_INC_WINDOWS_DLL_H
+#define ZIP7_INC_WINDOWS_DLL_H
#include "../Common/MyString.h"
+#ifndef _WIN32
+typedef void * HMODULE;
+// typedef int (*FARPROC)();
+// typedef void *FARPROC;
+void *GetProcAddress(HMODULE module, LPCSTR procName);
+#endif
+
namespace NWindows {
namespace NDLL {
#ifdef _WIN32
+/*
#ifdef UNDER_CE
#define My_GetProcAddress(module, procName) (void *)::GetProcAddressA(module, procName)
#else
#define My_GetProcAddress(module, procName) (void *)::GetProcAddress(module, procName)
#endif
+*/
/* Win32: Don't call CLibrary::Free() and FreeLibrary() from another
FreeLibrary() code: detaching code in DLL entry-point or in
@@ -24,13 +33,25 @@ class CLibrary
{
HMODULE _module;
- // CLASS_NO_COPY(CLibrary);
+ // Z7_CLASS_NO_COPY(CLibrary);
+ // copy constructor is required here
public:
- CLibrary(): _module(NULL) {};
+ CLibrary(): _module(NULL) {}
~CLibrary() { Free(); }
- operator HMODULE() const { return _module; }
- HMODULE* operator&() { return &_module; }
+ CLibrary(const CLibrary &c): _module(NULL)
+ {
+ if (c._module)
+ {
+ // we need non const to reference from original item
+ // c._module = NULL;
+ throw 20230102;
+ }
+ }
+
+ HMODULE Get_HMODULE() const { return _module; }
+ // operator HMODULE() const { return _module; }
+ // HMODULE* operator&() { return &_module; }
bool IsLoaded() const { return (_module != NULL); }
void Attach(HMODULE m)
@@ -40,7 +61,7 @@ public:
}
HMODULE Detach()
{
- HMODULE m = _module;
+ const HMODULE m = _module;
_module = NULL;
return m;
}
@@ -49,28 +70,26 @@ public:
bool LoadEx(CFSTR path, DWORD flags = LOAD_LIBRARY_AS_DATAFILE) throw();
bool Load(CFSTR path) throw();
// FARPROC
- void *GetProc(LPCSTR procName) const { return My_GetProcAddress(_module, procName); }
+ // void *GetProc(LPCSTR procName) const { return My_GetProcAddress(_module, procName); }
};
#else
-typedef void * HMODULE;
-// typedef int (*FARPROC)();
-// typedef void *FARPROC;
-
class CLibrary
{
HMODULE _module;
- // CLASS_NO_COPY(CLibrary);
+ // Z7_CLASS_NO_COPY(CLibrary);
public:
- CLibrary(): _module(NULL) {};
+ CLibrary(): _module(NULL) {}
~CLibrary() { Free(); }
+ HMODULE Get_HMODULE() const { return _module; }
+
bool Free() throw();
bool Load(CFSTR path) throw();
// FARPROC
- void *GetProc(LPCSTR procName) const; // { return My_GetProcAddress(_module, procName); }
+ // void *GetProc(LPCSTR procName) const; // { return My_GetProcAddress(_module, procName); }
};
#endif
diff --git a/3rdparty/lzma/CPP/Windows/Defs.h b/3rdparty/lzma/CPP/Windows/Defs.h
index 1d96078dd60..8ab9cf5ea79 100644
--- a/3rdparty/lzma/CPP/Windows/Defs.h
+++ b/3rdparty/lzma/CPP/Windows/Defs.h
@@ -1,12 +1,11 @@
// Windows/Defs.h
-#ifndef __WINDOWS_DEFS_H
-#define __WINDOWS_DEFS_H
+#ifndef ZIP7_INC_WINDOWS_DEFS_H
+#define ZIP7_INC_WINDOWS_DEFS_H
#include "../Common/MyWindows.h"
#ifdef _WIN32
-inline bool LRESULTToBool(LRESULT v) { return (v != FALSE); }
inline BOOL BoolToBOOL(bool v) { return (v ? TRUE: FALSE); }
#endif
diff --git a/3rdparty/lzma/CPP/Windows/ErrorMsg.cpp b/3rdparty/lzma/CPP/Windows/ErrorMsg.cpp
index f6343a5cf3b..5acf3adb613 100644
--- a/3rdparty/lzma/CPP/Windows/ErrorMsg.cpp
+++ b/3rdparty/lzma/CPP/Windows/ErrorMsg.cpp
@@ -19,8 +19,8 @@ namespace NError {
static bool MyFormatMessage(DWORD errorCode, UString &message)
{
- #ifndef _SFX
- if ((HRESULT)errorCode == MY_HRES_ERROR__INTERNAL_ERROR)
+ #ifndef Z7_SFX
+ if ((HRESULT)errorCode == MY_HRES_ERROR_INTERNAL_ERROR)
{
message = "Internal Error: The failure in hardware (RAM or CPU), OS or program";
return true;
@@ -72,7 +72,7 @@ static bool MyFormatMessage(DWORD errorCode, UString &message)
case E_OUTOFMEMORY : s = "E_OUTOFMEMORY : Can't allocate required memory"; break;
case E_INVALIDARG : s = "E_INVALIDARG : One or more arguments are invalid"; break;
- // case MY__E_ERROR_NEGATIVE_SEEK : s = "MY__E_ERROR_NEGATIVE_SEEK"; break;
+ // case MY_E_ERROR_NEGATIVE_SEEK : s = "MY_E_ERROR_NEGATIVE_SEEK"; break;
default:
break;
}
@@ -81,7 +81,7 @@ static bool MyFormatMessage(DWORD errorCode, UString &message)
So we must transfer error codes before strerror() */
if (!s)
{
- if ((errorCode & 0xFFFF0000) == (UInt32)((MY__FACILITY__WRes << 16) | 0x80000000))
+ if ((errorCode & 0xFFFF0000) == (UInt32)((MY_FACILITY_WRes << 16) | 0x80000000))
errorCode &= 0xFFFF;
else if ((errorCode & ((UInt32)1 << 31)))
return false; // we will show hex error later for that case
diff --git a/3rdparty/lzma/CPP/Windows/ErrorMsg.h b/3rdparty/lzma/CPP/Windows/ErrorMsg.h
index 01204eb9567..6142b4ebe64 100644
--- a/3rdparty/lzma/CPP/Windows/ErrorMsg.h
+++ b/3rdparty/lzma/CPP/Windows/ErrorMsg.h
@@ -1,7 +1,7 @@
// Windows/ErrorMsg.h
-#ifndef __WINDOWS_ERROR_MSG_H
-#define __WINDOWS_ERROR_MSG_H
+#ifndef ZIP7_INC_WINDOWS_ERROR_MSG_H
+#define ZIP7_INC_WINDOWS_ERROR_MSG_H
#include "../Common/MyString.h"
diff --git a/3rdparty/lzma/CPP/Windows/FileDir.cpp b/3rdparty/lzma/CPP/Windows/FileDir.cpp
index cce2638587e..5b1f340b5c7 100644
--- a/3rdparty/lzma/CPP/Windows/FileDir.cpp
+++ b/3rdparty/lzma/CPP/Windows/FileDir.cpp
@@ -65,46 +65,55 @@ namespace NDir {
bool GetWindowsDir(FString &path)
{
- UINT needLength;
+ const unsigned kBufSize = MAX_PATH + 16;
+ UINT len;
#ifndef _UNICODE
if (!g_IsNT)
{
- TCHAR s[MAX_PATH + 2];
+ TCHAR s[kBufSize + 1];
s[0] = 0;
- needLength = ::GetWindowsDirectory(s, MAX_PATH + 1);
+ len = ::GetWindowsDirectory(s, kBufSize);
path = fas2fs(s);
}
else
#endif
{
- WCHAR s[MAX_PATH + 2];
+ WCHAR s[kBufSize + 1];
s[0] = 0;
- needLength = ::GetWindowsDirectoryW(s, MAX_PATH + 1);
+ len = ::GetWindowsDirectoryW(s, kBufSize);
path = us2fs(s);
}
- return (needLength > 0 && needLength <= MAX_PATH);
+ return (len != 0 && len < kBufSize);
}
+
+/*
+new DOCs for GetSystemDirectory:
+ returned path does not end with a backslash unless the
+ system directory is the root directory.
+*/
+
bool GetSystemDir(FString &path)
{
- UINT needLength;
+ const unsigned kBufSize = MAX_PATH + 16;
+ UINT len;
#ifndef _UNICODE
if (!g_IsNT)
{
- TCHAR s[MAX_PATH + 2];
+ TCHAR s[kBufSize + 1];
s[0] = 0;
- needLength = ::GetSystemDirectory(s, MAX_PATH + 1);
+ len = ::GetSystemDirectory(s, kBufSize);
path = fas2fs(s);
}
else
#endif
{
- WCHAR s[MAX_PATH + 2];
+ WCHAR s[kBufSize + 1];
s[0] = 0;
- needLength = ::GetSystemDirectoryW(s, MAX_PATH + 1);
+ len = ::GetSystemDirectoryW(s, kBufSize);
path = us2fs(s);
}
- return (needLength > 0 && needLength <= MAX_PATH);
+ return (len != 0 && len < kBufSize);
}
#endif // UNDER_CE
@@ -123,7 +132,7 @@ bool SetDirTime(CFSTR path, const CFiTime *cTime, const CFiTime *aTime, const CF
IF_USE_MAIN_PATH
hDir = ::CreateFileW(fs2us(path), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (hDir == INVALID_HANDLE_VALUE && USE_SUPER_PATH)
{
UString superPath;
@@ -158,7 +167,7 @@ bool SetFileAttrib(CFSTR path, DWORD attrib)
IF_USE_MAIN_PATH
if (::SetFileAttributesW(fs2us(path), attrib))
return true;
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (USE_SUPER_PATH)
{
UString superPath;
@@ -195,7 +204,7 @@ bool RemoveDir(CFSTR path)
IF_USE_MAIN_PATH
if (::RemoveDirectoryW(fs2us(path)))
return true;
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (USE_SUPER_PATH)
{
UString superPath;
@@ -224,7 +233,7 @@ bool MyMoveFile(CFSTR oldFile, CFSTR newFile)
if (::MoveFileW(fs2us(oldFile), fs2us(newFile)))
return true;
}
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (USE_SUPER_PATH_2)
{
UString d1, d2;
@@ -261,8 +270,11 @@ bool MyCreateHardLink(CFSTR newFileName, CFSTR existFileName)
else
#endif
{
- Func_CreateHardLinkW my_CreateHardLinkW = (Func_CreateHardLinkW)
- (void *)::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), "CreateHardLinkW");
+ const
+ Func_CreateHardLinkW
+ my_CreateHardLinkW = Z7_GET_PROC_ADDRESS(
+ Func_CreateHardLinkW, ::GetModuleHandleW(L"kernel32.dll"),
+ "CreateHardLinkW");
if (!my_CreateHardLinkW)
return false;
IF_USE_MAIN_PATH_2(newFileName, existFileName)
@@ -270,7 +282,7 @@ bool MyCreateHardLink(CFSTR newFileName, CFSTR existFileName)
if (my_CreateHardLinkW(fs2us(newFileName), fs2us(existFileName), NULL))
return true;
}
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (USE_SUPER_PATH_2)
{
UString d1, d2;
@@ -320,7 +332,7 @@ bool CreateDir(CFSTR path)
IF_USE_MAIN_PATH
if (::CreateDirectoryW(fs2us(path), NULL))
return true;
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if ((!USE_MAIN_PATH || ::GetLastError() != ERROR_ALREADY_EXISTS) && USE_SUPER_PATH)
{
UString superPath;
@@ -355,7 +367,7 @@ static bool CreateDir2(CFSTR path)
IF_USE_MAIN_PATH
if (::CreateDirectoryW(fs2us(path), NULL))
return true;
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if ((!USE_MAIN_PATH || ::GetLastError() != ERROR_ALREADY_EXISTS) && USE_SUPER_PATH)
{
UString superPath;
@@ -390,7 +402,7 @@ bool CreateComplexDir(CFSTR _path)
#ifdef _WIN32
{
- DWORD attrib = NFind::GetFileAttrib(_path);
+ const DWORD attrib = NFind::GetFileAttrib(_path);
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
return true;
}
@@ -496,7 +508,7 @@ bool DeleteFileAlways(CFSTR path)
IF_USE_MAIN_PATH
if (::DeleteFileW(fs2us(path)))
return true;
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (USE_SUPER_PATH)
{
UString superPath;
@@ -586,9 +598,12 @@ bool MyGetFullPathName(CFSTR path, FString &resFullPath)
#ifdef _WIN32
+/* Win10: SetCurrentDirectory() doesn't support long paths and
+ doesn't support super prefix "\\?\", if long path behavior is not
+ enabled in registry (LongPathsEnabled) and in manifest (longPathAware). */
+
bool SetCurrentDir(CFSTR path)
{
- // SetCurrentDirectory doesn't support \\?\ prefix
#ifndef _UNICODE
if (!g_IsNT)
{
@@ -602,28 +617,74 @@ bool SetCurrentDir(CFSTR path)
}
+/*
+we use system function GetCurrentDirectory()
+new GetCurrentDirectory() DOCs:
+ - If the function fails, the return value is zero.
+ - If the function succeeds, the return value specifies
+ the number of characters that are written to the buffer,
+ not including the terminating null character.
+ - If the buffer is not large enough, the return value specifies
+ the required size of the buffer, in characters,
+ including the null-terminating character.
+
+GetCurrentDir() calls GetCurrentDirectory().
+GetCurrentDirectory() in win10 in tests:
+ the returned (path) does not end with a backslash, if
+ current directory is not root directory of drive.
+ But that behavior is not guarantied in specification docs.
+*/
+
bool GetCurrentDir(FString &path)
{
+ const unsigned kBufSize = MAX_PATH + 16;
path.Empty();
- DWORD needLength;
#ifndef _UNICODE
if (!g_IsNT)
{
- TCHAR s[MAX_PATH + 2];
+ TCHAR s[kBufSize + 1];
s[0] = 0;
- needLength = ::GetCurrentDirectory(MAX_PATH + 1, s);
+ const DWORD len = ::GetCurrentDirectory(kBufSize, s);
+ if (len == 0 || len >= kBufSize)
+ return false;
+ s[kBufSize] = 0; // optional guard
path = fas2fs(s);
+ return true;
}
else
#endif
{
- WCHAR s[MAX_PATH + 2];
- s[0] = 0;
- needLength = ::GetCurrentDirectoryW(MAX_PATH + 1, s);
- path = us2fs(s);
+ DWORD len;
+ {
+ WCHAR s[kBufSize + 1];
+ s[0] = 0;
+ len = ::GetCurrentDirectoryW(kBufSize, s);
+ if (len == 0)
+ return false;
+ if (len < kBufSize)
+ {
+ s[kBufSize] = 0; // optional guard
+ path = us2fs(s);
+ return true;
+ }
+ }
+ UString temp;
+ const DWORD len2 = ::GetCurrentDirectoryW(len, temp.GetBuf(len));
+ if (len2 == 0)
+ return false;
+ temp.ReleaseBuf_CalcLen(len);
+ if (temp.Len() != len2 || len - 1 != len2)
+ {
+ /* it's unexpected case, if current dir of process
+ was changed between two function calls,
+ or some unexpected function implementation */
+ // SetLastError((DWORD)E_FAIL); // we can set some error code
+ return false;
+ }
+ path = us2fs(temp);
+ return true;
}
- return (needLength > 0 && needLength <= MAX_PATH);
}
#endif // _WIN32
@@ -648,41 +709,59 @@ bool GetOnlyDirPrefix(CFSTR path, FString &resDirPrefix)
return GetFullPathAndSplit(path, resDirPrefix, resFileName);
}
+
+
bool MyGetTempPath(FString &path)
{
#ifdef _WIN32
- path.Empty();
- DWORD needLength;
+
+ /*
+ new DOCs for GetTempPathW():
+ - The returned string ends with a backslash.
+ - The maximum possible return value is MAX_PATH+1 (261).
+ */
+
+ const unsigned kBufSize = MAX_PATH + 16;
+ DWORD len;
#ifndef _UNICODE
if (!g_IsNT)
{
- TCHAR s[MAX_PATH + 2];
+ TCHAR s[kBufSize + 1];
s[0] = 0;
- needLength = ::GetTempPath(MAX_PATH + 1, s);
+ len = ::GetTempPath(kBufSize, s);
path = fas2fs(s);
}
else
#endif
{
- WCHAR s[MAX_PATH + 2];
+ WCHAR s[kBufSize + 1];
s[0] = 0;
- needLength = ::GetTempPathW(MAX_PATH + 1, s);;
+ len = ::GetTempPathW(kBufSize, s);
path = us2fs(s);
}
- return (needLength > 0 && needLength <= MAX_PATH);
+ /* win10: GetTempPathW() doesn't set backslash at the end of path,
+ if (buffer_size == len_of(path_with_backslash)).
+ So we normalize path here: */
+ NormalizeDirPathPrefix(path);
+ return (len != 0 && len < kBufSize);
- #else
+ #else // !_WIN32
// FIXME: improve that code
- path = "/tmp/";
- if (!NFind::DoesDirExist_FollowLink(path))
- path = "./";
+ path = STRING_PATH_SEPARATOR "tmp";
+ const char *s;
+ if (NFind::DoesDirExist_FollowLink(path))
+ s = STRING_PATH_SEPARATOR "tmp" STRING_PATH_SEPARATOR;
+ else
+ s = "." STRING_PATH_SEPARATOR;
+ path = s;
return true;
+
#endif
}
-static bool CreateTempFile(CFSTR prefix, bool addRandom, FString &path, NIO::COutFile *outFile)
+bool CreateTempFile2(CFSTR prefix, bool addRandom, AString &postfix, NIO::COutFile *outFile)
{
UInt32 d =
#ifdef _WIN32
@@ -693,7 +772,7 @@ static bool CreateTempFile(CFSTR prefix, bool addRandom, FString &path, NIO::COu
for (unsigned i = 0; i < 100; i++)
{
- path = prefix;
+ postfix.Empty();
if (addRandom)
{
char s[16];
@@ -701,14 +780,14 @@ static bool CreateTempFile(CFSTR prefix, bool addRandom, FString &path, NIO::COu
unsigned k;
for (k = 0; k < 8; k++)
{
- unsigned t = val & 0xF;
+ const unsigned t = val & 0xF;
val >>= 4;
s[k] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
}
s[k] = '\0';
if (outFile)
- path += '.';
- path += s;
+ postfix.Add_Dot();
+ postfix += s;
UInt32 step = GetTickCount() + 2;
if (step == 0)
step = 1;
@@ -716,7 +795,9 @@ static bool CreateTempFile(CFSTR prefix, bool addRandom, FString &path, NIO::COu
}
addRandom = true;
if (outFile)
- path += ".tmp";
+ postfix += ".tmp";
+ FString path (prefix);
+ path += postfix;
if (NFind::DoesFileOrDirExist(path))
{
SetLastError(ERROR_ALREADY_EXISTS);
@@ -732,12 +813,12 @@ static bool CreateTempFile(CFSTR prefix, bool addRandom, FString &path, NIO::COu
if (CreateDir(path))
return true;
}
- DWORD error = GetLastError();
+ const DWORD error = GetLastError();
if (error != ERROR_FILE_EXISTS &&
error != ERROR_ALREADY_EXISTS)
break;
}
- path.Empty();
+ postfix.Empty();
return false;
}
@@ -745,8 +826,12 @@ bool CTempFile::Create(CFSTR prefix, NIO::COutFile *outFile)
{
if (!Remove())
return false;
- if (!CreateTempFile(prefix, false, _path, outFile))
+ _path.Empty();
+ AString postfix;
+ if (!CreateTempFile2(prefix, false, postfix, outFile))
return false;
+ _path = prefix;
+ _path += postfix;
_mustBeDeleted = true;
return true;
}
@@ -755,11 +840,16 @@ bool CTempFile::CreateRandomInTempFolder(CFSTR namePrefix, NIO::COutFile *outFil
{
if (!Remove())
return false;
+ _path.Empty();
FString tempPath;
if (!MyGetTempPath(tempPath))
return false;
- if (!CreateTempFile(tempPath + namePrefix, true, _path, outFile))
+ AString postfix;
+ tempPath += namePrefix;
+ if (!CreateTempFile2(tempPath, true, postfix, outFile))
return false;
+ _path = tempPath;
+ _path += postfix;
_mustBeDeleted = true;
return true;
}
@@ -802,11 +892,16 @@ bool CTempDir::Create(CFSTR prefix)
{
if (!Remove())
return false;
+ _path.Empty();
FString tempPath;
if (!MyGetTempPath(tempPath))
return false;
- if (!CreateTempFile(tempPath + prefix, true, _path, NULL))
+ tempPath += prefix;
+ AString postfix;
+ if (!CreateTempFile2(tempPath, true, postfix, NULL))
return false;
+ _path = tempPath;
+ _path += postfix;
_mustBeDeleted = true;
return true;
}
@@ -830,7 +925,7 @@ bool RemoveDir(CFSTR path)
}
-static BOOL My__CopyFile(CFSTR oldFile, CFSTR newFile)
+static BOOL My_CopyFile(CFSTR oldFile, CFSTR newFile)
{
NWindows::NFile::NIO::COutFile outFile;
if (!outFile.Create(newFile, false))
@@ -865,7 +960,7 @@ bool MyMoveFile(CFSTR oldFile, CFSTR newFile)
if (errno != EXDEV) // (oldFile and newFile are not on the same mounted filesystem)
return false;
- if (My__CopyFile(oldFile, newFile) == FALSE)
+ if (My_CopyFile(oldFile, newFile) == FALSE)
return false;
struct stat info_file;
@@ -906,11 +1001,11 @@ bool GetCurrentDir(FString &path)
{
path.Empty();
- #define MY__PATH_MAX PATH_MAX
- // #define MY__PATH_MAX 1024
+ #define MY_PATH_MAX PATH_MAX
+ // #define MY_PATH_MAX 1024
- char s[MY__PATH_MAX + 1];
- char *res = getcwd(s, MY__PATH_MAX);
+ char s[MY_PATH_MAX + 1];
+ char *res = getcwd(s, MY_PATH_MAX);
if (res)
{
path = fas2fs(s);
@@ -1035,10 +1130,10 @@ static C_umask g_umask;
#define PRF(x)
#define TRACE_SetFileAttrib(msg) \
- PRF(printf("\nSetFileAttrib(%s, %x) : %s\n", (const char *)path, attrib, msg));
+ PRF(printf("\nSetFileAttrib(%s, %x) : %s\n", (const char *)path, attrib, msg);)
#define TRACE_chmod(s, mode) \
- PRF(printf("\n chmod(%s, %o)\n", (const char *)path, (unsigned)(mode)));
+ PRF(printf("\n chmod(%s, %o)\n", (const char *)path, (unsigned)(mode));)
int my_chown(CFSTR path, uid_t owner, gid_t group)
{
@@ -1047,7 +1142,7 @@ int my_chown(CFSTR path, uid_t owner, gid_t group)
bool SetFileAttrib_PosixHighDetect(CFSTR path, DWORD attrib)
{
- TRACE_SetFileAttrib("");
+ TRACE_SetFileAttrib("")
struct stat st;
@@ -1056,7 +1151,7 @@ bool SetFileAttrib_PosixHighDetect(CFSTR path, DWORD attrib)
{
if (lstat(path, &st) != 0)
{
- TRACE_SetFileAttrib("bad lstat()");
+ TRACE_SetFileAttrib("bad lstat()")
return false;
}
// TRACE_chmod("lstat", st.st_mode);
@@ -1065,14 +1160,14 @@ bool SetFileAttrib_PosixHighDetect(CFSTR path, DWORD attrib)
{
if (stat(path, &st) != 0)
{
- TRACE_SetFileAttrib("bad stat()");
+ TRACE_SetFileAttrib("bad stat()")
return false;
}
}
if (attrib & FILE_ATTRIBUTE_UNIX_EXTENSION)
{
- TRACE_SetFileAttrib("attrib & FILE_ATTRIBUTE_UNIX_EXTENSION");
+ TRACE_SetFileAttrib("attrib & FILE_ATTRIBUTE_UNIX_EXTENSION")
st.st_mode = attrib >> 16;
if (S_ISDIR(st.st_mode))
{
@@ -1092,7 +1187,7 @@ bool SetFileAttrib_PosixHighDetect(CFSTR path, DWORD attrib)
}
else
{
- TRACE_SetFileAttrib("Only Windows Attributes");
+ TRACE_SetFileAttrib("Only Windows Attributes")
// Only Windows Attributes
if (S_ISDIR(st.st_mode)
|| (attrib & FILE_ATTRIBUTE_READONLY) == 0)
@@ -1105,7 +1200,7 @@ bool SetFileAttrib_PosixHighDetect(CFSTR path, DWORD attrib)
if (S_ISLNK(st.st_mode))
{
printf("\nfchmodat()\n");
- TRACE_chmod(path, (st.st_mode) & g_umask.mask);
+ TRACE_chmod(path, (st.st_mode) & g_umask.mask)
// AT_SYMLINK_NOFOLLOW is not implemted still in Linux.
res = fchmodat(AT_FDCWD, path, (st.st_mode) & g_umask.mask,
S_ISLNK(st.st_mode) ? AT_SYMLINK_NOFOLLOW : 0);
@@ -1113,7 +1208,7 @@ bool SetFileAttrib_PosixHighDetect(CFSTR path, DWORD attrib)
else
*/
{
- TRACE_chmod(path, (st.st_mode) & g_umask.mask);
+ TRACE_chmod(path, (st.st_mode) & g_umask.mask)
res = chmod(path, (st.st_mode) & g_umask.mask);
}
// TRACE_SetFileAttrib("End")
@@ -1123,7 +1218,7 @@ bool SetFileAttrib_PosixHighDetect(CFSTR path, DWORD attrib)
bool MyCreateHardLink(CFSTR newFileName, CFSTR existFileName)
{
- PRF(printf("\nhard link() %s -> %s\n", newFileName, existFileName));
+ PRF(printf("\nhard link() %s -> %s\n", newFileName, existFileName);)
return (link(existFileName, newFileName) == 0);
}
diff --git a/3rdparty/lzma/CPP/Windows/FileDir.h b/3rdparty/lzma/CPP/Windows/FileDir.h
index 08281aaa986..573ffa23329 100644
--- a/3rdparty/lzma/CPP/Windows/FileDir.h
+++ b/3rdparty/lzma/CPP/Windows/FileDir.h
@@ -1,7 +1,7 @@
// Windows/FileDir.h
-#ifndef __WINDOWS_FILE_DIR_H
-#define __WINDOWS_FILE_DIR_H
+#ifndef ZIP7_INC_WINDOWS_FILE_DIR_H
+#define ZIP7_INC_WINDOWS_FILE_DIR_H
#include "../Common/MyString.h"
@@ -73,6 +73,8 @@ bool GetCurrentDir(FString &resultPath);
bool MyGetTempPath(FString &resultPath);
+bool CreateTempFile2(CFSTR prefix, bool addRandom, AString &postfix, NIO::COutFile *outFile);
+
class CTempFile MY_UNCOPYABLE
{
bool _mustBeDeleted;
diff --git a/3rdparty/lzma/CPP/Windows/FileFind.cpp b/3rdparty/lzma/CPP/Windows/FileFind.cpp
index c6557599a2e..c562a909ce3 100644
--- a/3rdparty/lzma/CPP/Windows/FileFind.cpp
+++ b/3rdparty/lzma/CPP/Windows/FileFind.cpp
@@ -39,10 +39,10 @@ typedef struct
WCHAR cStreamName[MAX_PATH + 36];
} MY_WIN32_FIND_STREAM_DATA, *MY_PWIN32_FIND_STREAM_DATA;
-typedef HANDLE (WINAPI *FindFirstStreamW_Ptr)(LPCWSTR fileName, MY_STREAM_INFO_LEVELS infoLevel,
+typedef HANDLE (WINAPI *Func_FindFirstStreamW)(LPCWSTR fileName, MY_STREAM_INFO_LEVELS infoLevel,
LPVOID findStreamData, DWORD flags);
-typedef BOOL (APIENTRY *FindNextStreamW_Ptr)(HANDLE findStream, LPVOID findStreamData);
+typedef BOOL (APIENTRY *Func_FindNextStreamW)(HANDLE findStream, LPVOID findStreamData);
EXTERN_C_END
@@ -54,7 +54,7 @@ namespace NFile {
#ifdef _WIN32
-#ifdef SUPPORT_DEVICE_FILE
+#ifdef Z7_DEVICE_FILE
namespace NSystem
{
bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize);
@@ -128,7 +128,7 @@ bool CFileInfo::IsDots() const throw()
static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATAW &fd, CFileInfo &fi)
{
- WIN_FD_TO_MY_FI(fi, fd);
+ WIN_FD_TO_MY_FI(fi, fd)
fi.Name = us2fs(fd.cFileName);
#if defined(_WIN32) && !defined(UNDER_CE)
// fi.ShortName = us2fs(fd.cAlternateFileName);
@@ -138,7 +138,7 @@ static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATAW &fd, CFil
#ifndef _UNICODE
static void Convert_WIN32_FIND_DATA_to_FileInfo(const WIN32_FIND_DATA &fd, CFileInfo &fi)
{
- WIN_FD_TO_MY_FI(fi, fd);
+ WIN_FD_TO_MY_FI(fi, fd)
fi.Name = fas2fs(fd.cFileName);
#if defined(_WIN32) && !defined(UNDER_CE)
// fi.ShortName = fas2fs(fd.cAlternateFileName);
@@ -211,7 +211,7 @@ bool CFindFile::FindFirst(CFSTR path, CFileInfo &fi)
IF_USE_MAIN_PATH
_handle = ::FindFirstFileW(fs2us(path), &fd);
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (_handle == INVALID_HANDLE_VALUE && USE_SUPER_PATH)
{
UString superPath;
@@ -252,23 +252,27 @@ bool CFindFile::FindNext(CFileInfo &fi)
////////////////////////////////
// AltStreams
-static FindFirstStreamW_Ptr g_FindFirstStreamW;
-static FindNextStreamW_Ptr g_FindNextStreamW;
+static Func_FindFirstStreamW g_FindFirstStreamW;
+static Func_FindNextStreamW g_FindNextStreamW;
static struct CFindStreamLoader
{
CFindStreamLoader()
{
- HMODULE hm = ::GetModuleHandleA("kernel32.dll");
- g_FindFirstStreamW = (FindFirstStreamW_Ptr)(void *)::GetProcAddress(hm, "FindFirstStreamW");
- g_FindNextStreamW = (FindNextStreamW_Ptr)(void *)::GetProcAddress(hm, "FindNextStreamW");
+ const HMODULE hm = ::GetModuleHandleA("kernel32.dll");
+ g_FindFirstStreamW = Z7_GET_PROC_ADDRESS(
+ Func_FindFirstStreamW, hm,
+ "FindFirstStreamW");
+ g_FindNextStreamW = Z7_GET_PROC_ADDRESS(
+ Func_FindNextStreamW, hm,
+ "FindNextStreamW");
}
} g_FindStreamLoader;
bool CStreamInfo::IsMainStream() const throw()
{
return StringsAreEqualNoCase_Ascii(Name, "::$DATA");
-};
+}
UString CStreamInfo::GetReducedName() const
{
@@ -331,7 +335,7 @@ bool CFindStream::FindFirst(CFSTR path, CStreamInfo &si)
if (::GetLastError() == ERROR_HANDLE_EOF)
return false;
// long name can be tricky for path like ".\dirName".
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (USE_SUPER_PATH)
{
UString superPath;
@@ -414,7 +418,7 @@ DWORD GetFileAttrib(CFSTR path)
if (dw != INVALID_FILE_ATTRIBUTES)
return dw;
}
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (USE_SUPER_PATH)
{
UString superPath;
@@ -451,7 +455,7 @@ also we support paths that are not supported by FindFirstFile:
bool CFileInfo::Find(CFSTR path, bool followLink)
{
- #ifdef SUPPORT_DEVICE_FILE
+ #ifdef Z7_DEVICE_FILE
if (IS_PATH_SEPAR(path[0]) &&
IS_PATH_SEPAR(path[1]) &&
@@ -847,7 +851,7 @@ HANDLE CFindChangeNotification::FindFirst(CFSTR path, bool watchSubtree, DWORD n
{
IF_USE_MAIN_PATH
_handle = ::FindFirstChangeNotificationW(fs2us(path), BoolToBOOL(watchSubtree), notifyFilter);
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (!IsHandleAllocated())
{
UString superPath;
diff --git a/3rdparty/lzma/CPP/Windows/FileFind.h b/3rdparty/lzma/CPP/Windows/FileFind.h
index fcfe02c7e64..11408d05958 100644
--- a/3rdparty/lzma/CPP/Windows/FileFind.h
+++ b/3rdparty/lzma/CPP/Windows/FileFind.h
@@ -1,7 +1,7 @@
// Windows/FileFind.h
-#ifndef __WINDOWS_FILE_FIND_H
-#define __WINDOWS_FILE_FIND_H
+#ifndef ZIP7_INC_WINDOWS_FILE_FIND_H
+#define ZIP7_INC_WINDOWS_FILE_FIND_H
#ifndef _WIN32
#include <sys/stat.h>
@@ -249,7 +249,15 @@ class CFindChangeNotification MY_UNCOPYABLE
HANDLE _handle;
public:
operator HANDLE () { return _handle; }
- bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE && _handle != 0; }
+ bool IsHandleAllocated() const
+ {
+ /* at least on win2000/XP (undocumented):
+ if pathName is "" or NULL,
+ FindFirstChangeNotification() could return NULL.
+ So we check for INVALID_HANDLE_VALUE and NULL.
+ */
+ return _handle != INVALID_HANDLE_VALUE && _handle != NULL;
+ }
CFindChangeNotification(): _handle(INVALID_HANDLE_VALUE) {}
~CFindChangeNotification() { Close(); }
bool Close() throw();
diff --git a/3rdparty/lzma/CPP/Windows/FileIO.cpp b/3rdparty/lzma/CPP/Windows/FileIO.cpp
index e51b0eb31b8..4ecbb7ed213 100644
--- a/3rdparty/lzma/CPP/Windows/FileIO.cpp
+++ b/3rdparty/lzma/CPP/Windows/FileIO.cpp
@@ -2,7 +2,7 @@
#include "StdAfx.h"
-#ifdef SUPPORT_DEVICE_FILE
+#ifdef Z7_DEVICE_FILE
#include "../../C/Alloc.h"
#endif
@@ -21,7 +21,7 @@
HRESULT GetLastError_noZero_HRESULT()
{
- DWORD res = ::GetLastError();
+ const DWORD res = ::GetLastError();
if (res == 0)
return E_FAIL;
return HRESULT_FROM_WIN32(res);
@@ -40,7 +40,7 @@ using namespace NName;
namespace NWindows {
namespace NFile {
-#ifdef SUPPORT_DEVICE_FILE
+#ifdef Z7_DEVICE_FILE
namespace NSystem
{
@@ -72,7 +72,7 @@ bool CFileBase::Create(CFSTR path, DWORD desiredAccess,
if (!Close())
return false;
- #ifdef SUPPORT_DEVICE_FILE
+ #ifdef Z7_DEVICE_FILE
IsDeviceFile = false;
#endif
@@ -88,7 +88,7 @@ bool CFileBase::Create(CFSTR path, DWORD desiredAccess,
IF_USE_MAIN_PATH
_handle = ::CreateFileW(fs2us(path), desiredAccess, shareMode,
(LPSECURITY_ATTRIBUTES)NULL, creationDisposition, flagsAndAttributes, (HANDLE)NULL);
- #ifdef WIN_LONG_PATH
+ #ifdef Z7_LONG_PATH
if (_handle == INVALID_HANDLE_VALUE && USE_SUPER_PATH)
{
UString superPath;
@@ -101,7 +101,7 @@ bool CFileBase::Create(CFSTR path, DWORD desiredAccess,
/*
#ifndef UNDER_CE
- #ifndef _SFX
+ #ifndef Z7_SFX
if (_handle == INVALID_HANDLE_VALUE)
{
// it's debug hack to open symbolic links in Windows XP and WSL links in Windows 10
@@ -149,7 +149,7 @@ bool CFileBase::Close() throw()
bool CFileBase::GetLength(UInt64 &length) const throw()
{
- #ifdef SUPPORT_DEVICE_FILE
+ #ifdef Z7_DEVICE_FILE
if (IsDeviceFile && SizeDefined)
{
length = Size;
@@ -219,7 +219,7 @@ bool CFileBase::GetPosition(UInt64 &position) const throw()
bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const throw()
{
- #ifdef SUPPORT_DEVICE_FILE
+ #ifdef Z7_DEVICE_FILE
if (IsDeviceFile && SizeDefined && moveMethod == FILE_END)
{
distanceToMove += Size;
@@ -262,12 +262,12 @@ bool CFileBase::SeekToEnd(UInt64 &newPosition) const throw()
// ---------- CInFile ---------
-#ifdef SUPPORT_DEVICE_FILE
+#ifdef Z7_DEVICE_FILE
void CInFile::CorrectDeviceSize()
{
// maybe we must decrease kClusterSize to 1 << 12, if we want correct size at tail
- static const UInt32 kClusterSize = 1 << 14;
+ const UInt32 kClusterSize = 1 << 14;
UInt64 pos = Size & ~(UInt64)(kClusterSize - 1);
UInt64 realNewPosition;
if (!Seek(pos, realNewPosition))
@@ -462,7 +462,7 @@ static const UInt32 kChunkSizeMax = (1 << 22);
bool CInFile::Read1(void *data, UInt32 size, UInt32 &processedSize) throw()
{
DWORD processedLoc = 0;
- bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL));
+ const bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL));
processedSize = (UInt32)processedLoc;
return res;
}
@@ -480,7 +480,7 @@ bool CInFile::Read(void *data, UInt32 size, UInt32 &processedSize) throw()
do
{
UInt32 processedLoc = 0;
- bool res = ReadPart(data, size, processedLoc);
+ const bool res = ReadPart(data, size, processedLoc);
processedSize += processedLoc;
if (!res)
return false;
@@ -551,7 +551,7 @@ bool COutFile::Write(const void *data, UInt32 size, UInt32 &processedSize) throw
do
{
UInt32 processedLoc = 0;
- bool res = WritePart(data, size, processedLoc);
+ const bool res = WritePart(data, size, processedLoc);
processedSize += processedLoc;
if (!res)
return false;
@@ -628,14 +628,14 @@ bool SetDirTime(CFSTR path, const CFiTime *cTime, const CFiTime *aTime, const CF
namespace NIO {
-bool CFileBase::OpenBinary(const char *name, int flags)
+bool CFileBase::OpenBinary(const char *name, int flags, mode_t mode)
{
#ifdef O_BINARY
flags |= O_BINARY;
#endif
Close();
- _handle = ::open(name, flags, 0666);
+ _handle = ::open(name, flags, mode);
return _handle != -1;
/*
@@ -804,10 +804,10 @@ bool COutFile::Create(const char *name, bool createAlways)
if (createAlways)
{
Close();
- _handle = ::creat(name, 0666);
+ _handle = ::creat(name, mode_for_Create);
return _handle != -1;
}
- return OpenBinary(name, O_CREAT | O_EXCL | O_WRONLY);
+ return OpenBinary(name, O_CREAT | O_EXCL | O_WRONLY, mode_for_Create);
}
bool COutFile::Open(const char *name, DWORD creationDisposition)
@@ -850,13 +850,13 @@ bool COutFile::SetLength(UInt64 length) throw()
return false;
}
// The value of the seek pointer shall not be modified by a call to ftruncate().
- int iret = ftruncate(_handle, len2);
+ const int iret = ftruncate(_handle, len2);
return (iret == 0);
}
bool COutFile::Close()
{
- bool res = CFileBase::Close();
+ const bool res = CFileBase::Close();
if (!res)
return res;
if (CTime_defined || ATime_defined || MTime_defined)
diff --git a/3rdparty/lzma/CPP/Windows/FileIO.h b/3rdparty/lzma/CPP/Windows/FileIO.h
index 80509653e99..03e061a980b 100644
--- a/3rdparty/lzma/CPP/Windows/FileIO.h
+++ b/3rdparty/lzma/CPP/Windows/FileIO.h
@@ -1,23 +1,23 @@
// Windows/FileIO.h
-#ifndef __WINDOWS_FILE_IO_H
-#define __WINDOWS_FILE_IO_H
+#ifndef ZIP7_INC_WINDOWS_FILE_IO_H
+#define ZIP7_INC_WINDOWS_FILE_IO_H
#include "../Common/MyWindows.h"
-#define _my_IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L)
-#define _my_IO_REPARSE_TAG_SYMLINK (0xA000000CL)
-#define _my_IO_REPARSE_TAG_LX_SYMLINK (0xA000001DL)
+#define Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L)
+#define Z7_WIN_IO_REPARSE_TAG_SYMLINK (0xA000000CL)
+#define Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK (0xA000001DL)
-#define _my_SYMLINK_FLAG_RELATIVE 1
+#define Z7_WIN_SYMLINK_FLAG_RELATIVE 1
// what the meaning of that FLAG or field (2)?
-#define _my_LX_SYMLINK_FLAG 2
+#define Z7_WIN_LX_SYMLINK_FLAG 2
#ifdef _WIN32
#if defined(_WIN32) && !defined(UNDER_CE)
-#include <WinIoCtl.h>
+#include <winioctl.h>
#endif
#else
@@ -76,11 +76,11 @@ struct CReparseAttr
// returns (false) and (ErrorCode = ERROR_REPARSE_TAG_INVALID), if unknown tag
bool Parse(const Byte *p, size_t size);
- bool IsMountPoint() const { return Tag == _my_IO_REPARSE_TAG_MOUNT_POINT; } // it's Junction
- bool IsSymLink_Win() const { return Tag == _my_IO_REPARSE_TAG_SYMLINK; }
- bool IsSymLink_WSL() const { return Tag == _my_IO_REPARSE_TAG_LX_SYMLINK; }
+ bool IsMountPoint() const { return Tag == Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT; } // it's Junction
+ bool IsSymLink_Win() const { return Tag == Z7_WIN_IO_REPARSE_TAG_SYMLINK; }
+ bool IsSymLink_WSL() const { return Tag == Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK; }
- bool IsRelative_Win() const { return Flags == _my_SYMLINK_FLAG_RELATIVE; }
+ bool IsRelative_Win() const { return Flags == Z7_WIN_SYMLINK_FLAG_RELATIVE; }
bool IsRelative_WSL() const
{
@@ -141,17 +141,19 @@ public:
public:
bool PreserveATime;
- #ifdef SUPPORT_DEVICE_FILE
+ #ifdef Z7_DEVICE_FILE
bool IsDeviceFile;
bool SizeDefined;
UInt64 Size; // it can be larger than real available size
#endif
- CFileBase(): _handle(INVALID_HANDLE_VALUE), PreserveATime(false) {};
+ CFileBase(): _handle(INVALID_HANDLE_VALUE), PreserveATime(false) {}
~CFileBase() { Close(); }
HANDLE GetHandle() const { return _handle; }
+ // void Detach() { _handle = INVALID_HANDLE_VALUE; }
+
bool Close() throw();
bool GetPosition(UInt64 &position) const throw();
@@ -193,7 +195,7 @@ struct my_DISK_GEOMETRY_EX
class CInFile: public CFileBase
{
- #ifdef SUPPORT_DEVICE_FILE
+ #ifdef Z7_DEVICE_FILE
#ifndef UNDER_CE
@@ -232,6 +234,14 @@ public:
// we must use (FILE_FLAG_BACKUP_SEMANTICS) to open handle of directory.
}
+ bool Open_for_FileRenameInformation(CFSTR fileName)
+ {
+ return Create(fileName, DELETE | SYNCHRONIZE | GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL);
+ // we must use (FILE_FLAG_BACKUP_SEMANTICS) to open handle of directory.
+ }
+
bool OpenReparse(CFSTR fileName)
{
// 17.02 fix: to support Windows XP compatibility junctions:
@@ -295,12 +305,13 @@ protected:
UInt64 Size; // it can be larger than real available size
*/
- bool OpenBinary(const char *name, int flags);
+ bool OpenBinary(const char *name, int flags, mode_t mode = 0666);
public:
bool PreserveATime;
- CFileBase(): _handle(-1), PreserveATime(false) {};
+ CFileBase(): _handle(-1), PreserveATime(false) {}
~CFileBase() { Close(); }
+ // void Detach() { _handle = -1; }
bool Close();
bool GetLength(UInt64 &length) const;
off_t seek(off_t distanceToMove, int moveMethod) const;
@@ -330,7 +341,6 @@ class COutFile: public CFileBase
bool CTime_defined;
bool ATime_defined;
bool MTime_defined;
-
CFiTime CTime;
CFiTime ATime;
CFiTime MTime;
@@ -338,10 +348,13 @@ class COutFile: public CFileBase
AString Path;
ssize_t write_part(const void *data, size_t size) throw();
public:
+ mode_t mode_for_Create;
+
COutFile():
CTime_defined(false),
ATime_defined(false),
- MTime_defined(false)
+ MTime_defined(false),
+ mode_for_Create(0666)
{}
bool Close();
diff --git a/3rdparty/lzma/CPP/Windows/FileLink.cpp b/3rdparty/lzma/CPP/Windows/FileLink.cpp
index 8ce634fd01a..2b9fa1a0930 100644
--- a/3rdparty/lzma/CPP/Windows/FileLink.cpp
+++ b/3rdparty/lzma/CPP/Windows/FileLink.cpp
@@ -8,7 +8,7 @@
#include <unistd.h>
#endif
-#ifdef SUPPORT_DEVICE_FILE
+#ifdef Z7_DEVICE_FILE
#include "../../C/Alloc.h"
#endif
@@ -20,6 +20,15 @@
#include "FileIO.h"
#include "FileName.h"
+#ifdef Z7_OLD_WIN_SDK
+#ifndef ERROR_INVALID_REPARSE_DATA
+#define ERROR_INVALID_REPARSE_DATA 4392L
+#endif
+#ifndef ERROR_REPARSE_TAG_INVALID
+#define ERROR_REPARSE_TAG_INVALID 4393L
+#endif
+#endif
+
#ifndef _UNICODE
extern bool g_IsNT;
#endif
@@ -72,13 +81,13 @@ static const UInt32 kReparseFlags_Alias = (1 << 29);
static const UInt32 kReparseFlags_HighLatency = (1 << 30);
static const UInt32 kReparseFlags_Microsoft = ((UInt32)1 << 31);
-#define _my_IO_REPARSE_TAG_HSM (0xC0000004L)
-#define _my_IO_REPARSE_TAG_HSM2 (0x80000006L)
-#define _my_IO_REPARSE_TAG_SIS (0x80000007L)
-#define _my_IO_REPARSE_TAG_WIM (0x80000008L)
-#define _my_IO_REPARSE_TAG_CSV (0x80000009L)
-#define _my_IO_REPARSE_TAG_DFS (0x8000000AL)
-#define _my_IO_REPARSE_TAG_DFSR (0x80000012L)
+#define Z7_WIN_IO_REPARSE_TAG_HSM (0xC0000004L)
+#define Z7_WIN_IO_REPARSE_TAG_HSM2 (0x80000006L)
+#define Z7_WIN_IO_REPARSE_TAG_SIS (0x80000007L)
+#define Z7_WIN_IO_REPARSE_TAG_WIM (0x80000008L)
+#define Z7_WIN_IO_REPARSE_TAG_CSV (0x80000009L)
+#define Z7_WIN_IO_REPARSE_TAG_DFS (0x8000000AL)
+#define Z7_WIN_IO_REPARSE_TAG_DFSR (0x80000012L)
*/
#define Get16(p) GetUi16(p)
@@ -112,7 +121,7 @@ static void WriteString(Byte *dest, const wchar_t *path)
wchar_t c = *path++;
if (c == 0)
return;
- Set16(dest, (UInt16)c);
+ Set16(dest, (UInt16)c)
dest += 2;
}
}
@@ -133,10 +142,10 @@ bool FillLinkData(CByteBuffer &dest, const wchar_t *path, bool isSymLink, bool i
return false;
dest.Alloc(8 + size);
Byte *p = dest;
- Set32(p, _my_IO_REPARSE_TAG_LX_SYMLINK);
- Set16(p + 4, (UInt16)(size));
- Set16(p + 6, 0);
- Set32(p + 8, _my_LX_SYMLINK_FLAG);
+ Set32(p, Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK)
+ Set16(p + 4, (UInt16)(size))
+ Set16(p + 6, 0)
+ Set32(p + 8, Z7_WIN_LX_SYMLINK_FLAG)
memcpy(p + 12, utf.Ptr(), utf.Len());
return true;
}
@@ -176,12 +185,12 @@ bool FillLinkData(CByteBuffer &dest, const wchar_t *path, bool isSymLink, bool i
dest.Alloc(size);
memset(dest, 0, size);
const UInt32 tag = isSymLink ?
- _my_IO_REPARSE_TAG_SYMLINK :
- _my_IO_REPARSE_TAG_MOUNT_POINT;
+ Z7_WIN_IO_REPARSE_TAG_SYMLINK :
+ Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT;
Byte *p = dest;
- Set32(p, tag);
- Set16(p + 4, (UInt16)(size - 8));
- Set16(p + 6, 0);
+ Set32(p, tag)
+ Set16(p + 4, (UInt16)(size - 8))
+ Set16(p + 6, 0)
p += 8;
unsigned subOffs = 0;
@@ -191,16 +200,16 @@ bool FillLinkData(CByteBuffer &dest, const wchar_t *path, bool isSymLink, bool i
else
printOffs = (unsigned)len1 + 2;
- Set16(p + 0, (UInt16)subOffs);
- Set16(p + 2, (UInt16)len1);
- Set16(p + 4, (UInt16)printOffs);
- Set16(p + 6, (UInt16)len2);
+ Set16(p + 0, (UInt16)subOffs)
+ Set16(p + 2, (UInt16)len1)
+ Set16(p + 4, (UInt16)printOffs)
+ Set16(p + 6, (UInt16)len2)
p += 8;
if (isSymLink)
{
- UInt32 flags = isAbs ? 0 : _my_SYMLINK_FLAG_RELATIVE;
- Set32(p, flags);
+ UInt32 flags = isAbs ? 0 : Z7_WIN_SYMLINK_FLAG_RELATIVE;
+ Set32(p, flags)
p += 4;
}
@@ -255,9 +264,9 @@ bool CReparseAttr::Parse(const Byte *p, size_t size)
HeaderError = false;
- if ( Tag != _my_IO_REPARSE_TAG_MOUNT_POINT
- && Tag != _my_IO_REPARSE_TAG_SYMLINK
- && Tag != _my_IO_REPARSE_TAG_LX_SYMLINK)
+ if ( Tag != Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT
+ && Tag != Z7_WIN_IO_REPARSE_TAG_SYMLINK
+ && Tag != Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK)
{
// for unsupported reparse points
ErrorCode = (DWORD)ERROR_REPARSE_TAG_INVALID; // ERROR_REPARSE_TAG_MISMATCH
@@ -270,12 +279,12 @@ bool CReparseAttr::Parse(const Byte *p, size_t size)
p += 8;
size -= 8;
- if (Tag == _my_IO_REPARSE_TAG_LX_SYMLINK)
+ if (Tag == Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK)
{
if (len < 4)
return false;
Flags = Get32(p); // maybe it's not Flags
- if (Flags != _my_LX_SYMLINK_FLAG)
+ if (Flags != Z7_WIN_LX_SYMLINK_FLAG)
return false;
len -= 4;
p += 4;
@@ -304,7 +313,7 @@ bool CReparseAttr::Parse(const Byte *p, size_t size)
p += 8;
Flags = 0;
- if (Tag == _my_IO_REPARSE_TAG_SYMLINK)
+ if (Tag == Z7_WIN_IO_REPARSE_TAG_SYMLINK)
{
if (len < 4)
return false;
@@ -341,8 +350,8 @@ bool CReparseShortInfo::Parse(const Byte *p, size_t size)
(type & kReparseFlags_Microsoft) == 0 ||
(type & 0xFFFF) != 3)
*/
- if (Tag != _my_IO_REPARSE_TAG_MOUNT_POINT &&
- Tag != _my_IO_REPARSE_TAG_SYMLINK)
+ if (Tag != Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT &&
+ Tag != Z7_WIN_IO_REPARSE_TAG_SYMLINK)
// return true;
return false;
@@ -365,7 +374,7 @@ bool CReparseShortInfo::Parse(const Byte *p, size_t size)
p += 8;
// UInt32 Flags = 0;
- if (Tag == _my_IO_REPARSE_TAG_SYMLINK)
+ if (Tag == Z7_WIN_IO_REPARSE_TAG_SYMLINK)
{
if (len < 4)
return false;
@@ -426,13 +435,13 @@ UString CReparseAttr::GetPath() const
return s;
}
-#ifdef SUPPORT_DEVICE_FILE
+#ifdef Z7_DEVICE_FILE
namespace NSystem
{
bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize);
}
-#endif // SUPPORT_DEVICE_FILE
+#endif // Z7_DEVICE_FILE
#if defined(_WIN32) && !defined(UNDER_CE)
diff --git a/3rdparty/lzma/CPP/Windows/FileMapping.h b/3rdparty/lzma/CPP/Windows/FileMapping.h
index f90c429f1d7..caa7ea3ed77 100644
--- a/3rdparty/lzma/CPP/Windows/FileMapping.h
+++ b/3rdparty/lzma/CPP/Windows/FileMapping.h
@@ -1,7 +1,7 @@
// Windows/FileMapping.h
-#ifndef __WINDOWS_FILEMAPPING_H
-#define __WINDOWS_FILEMAPPING_H
+#ifndef ZIP7_INC_WINDOWS_FILE_MAPPING_H
+#define ZIP7_INC_WINDOWS_FILE_MAPPING_H
#include "../Common/MyTypes.h"
@@ -34,7 +34,7 @@ public:
return res;
#else
_handle = ::OpenFileMapping(desiredAccess, FALSE, name);
- if (_handle != 0)
+ if (_handle != NULL)
return 0;
return ::GetLastError();
#endif
diff --git a/3rdparty/lzma/CPP/Windows/FileName.cpp b/3rdparty/lzma/CPP/Windows/FileName.cpp
index d61ff7e1dd6..c9c4f8b6ce9 100644
--- a/3rdparty/lzma/CPP/Windows/FileName.cpp
+++ b/3rdparty/lzma/CPP/Windows/FileName.cpp
@@ -6,9 +6,9 @@
#include <limits.h>
#include <unistd.h>
#include "../Common/StringConvert.h"
-#include "FileDir.h"
#endif
+#include "FileDir.h"
#include "FileName.h"
#ifndef _UNICODE
@@ -68,7 +68,7 @@ void NormalizeDirPathPrefix(UString &dirPath)
#ifdef _WIN32
#ifndef USE_UNICODE_FSTRING
-#ifdef WIN_LONG_PATH
+#ifdef Z7_LONG_PATH
static void NormalizeDirSeparators(UString &s)
{
const unsigned len = s.Len();
@@ -90,7 +90,7 @@ void NormalizeDirSeparators(FString &s)
#endif
-#define IS_LETTER_CHAR(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))
+#define IS_LETTER_CHAR(c) ((((unsigned)(int)(c) | 0x20) - (unsigned)'a' <= (unsigned)('z' - 'a')))
bool IsDrivePath(const wchar_t *s) throw() { return IS_LETTER_CHAR(s[0]) && s[1] == ':' && IS_SEPAR(s[2]); }
@@ -120,7 +120,7 @@ bool IsAltPathPrefix(CFSTR s) throw()
#if defined(_WIN32) && !defined(UNDER_CE)
const char * const kSuperPathPrefix = "\\\\?\\";
-#ifdef WIN_LONG_PATH
+#ifdef Z7_LONG_PATH
static const char * const kSuperUncPrefix = "\\\\?\\UNC\\";
#endif
@@ -191,7 +191,7 @@ unsigned GetNetworkServerPrefixSize(CFSTR s) throw()
if (c == '.' || c == '?')
return 0;
}
- int pos = FindSepar(s + prefixSize);
+ const int pos = FindSepar(s + prefixSize);
if (pos < 0)
return 0;
return prefixSize + (unsigned)(pos + 1);
@@ -199,11 +199,11 @@ unsigned GetNetworkServerPrefixSize(CFSTR s) throw()
bool IsNetworkShareRootPath(CFSTR s) throw()
{
- unsigned prefixSize = GetNetworkServerPrefixSize(s);
+ const unsigned prefixSize = GetNetworkServerPrefixSize(s);
if (prefixSize == 0)
return false;
s += prefixSize;
- int pos = FindSepar(s);
+ const int pos = FindSepar(s);
if (pos < 0)
return true;
return s[(unsigned)pos + 1] == 0;
@@ -217,6 +217,37 @@ bool IsSuperPath(const wchar_t *s) throw() { return IS_SUPER_PREFIX(s); }
bool IsSuperOrDevicePath(const wchar_t *s) throw() { return IS_SUPER_OR_DEVICE_PATH(s); }
// bool IsSuperUncPath(const wchar_t *s) throw() { return (IS_SUPER_PREFIX(s) && IS_UNC_WITH_SLASH(s + kSuperPathPrefixSize)); }
+bool IsAltStreamPrefixWithColon(const UString &s) throw()
+{
+ if (s.IsEmpty())
+ return false;
+ if (s.Back() != ':')
+ return false;
+ unsigned pos = 0;
+ if (IsSuperPath(s))
+ pos = kSuperPathPrefixSize;
+ if (s.Len() - pos == 2 && IsDrivePath2(s.Ptr(pos)))
+ return false;
+ return true;
+}
+
+bool If_IsSuperPath_RemoveSuperPrefix(UString &s)
+{
+ if (!IsSuperPath(s))
+ return false;
+ unsigned start = 0;
+ unsigned count = kSuperPathPrefixSize;
+ const wchar_t *s2 = s.Ptr(kSuperPathPrefixSize);
+ if (IS_UNC_WITH_SLASH(s2))
+ {
+ start = 2;
+ count = kSuperUncPathPrefixSize - 2;
+ }
+ s.Delete(start, count);
+ return true;
+}
+
+
#ifndef USE_UNICODE_FSTRING
bool IsDrivePath2(CFSTR s) throw() { return IS_LETTER_CHAR(s[0]) && s[1] == ':'; }
// bool IsDriveName2(CFSTR s) throw() { return IS_LETTER_CHAR(s[0]) && s[1] == ':' && s[2] == 0; }
@@ -288,7 +319,7 @@ static unsigned GetRootPrefixSize_Of_SimplePath(CFSTR s)
return 0;
if (s[1] == 0 || !IS_SEPAR(s[1]))
return 1;
- unsigned size = GetRootPrefixSize_Of_NetworkPath(s + 2);
+ const unsigned size = GetRootPrefixSize_Of_NetworkPath(s + 2);
return (size == 0) ? 0 : 2 + size;
}
@@ -296,11 +327,11 @@ static unsigned GetRootPrefixSize_Of_SuperPath(CFSTR s)
{
if (IS_UNC_WITH_SLASH(s + kSuperPathPrefixSize))
{
- unsigned size = GetRootPrefixSize_Of_NetworkPath(s + kSuperUncPathPrefixSize);
+ const unsigned size = GetRootPrefixSize_Of_NetworkPath(s + kSuperUncPathPrefixSize);
return (size == 0) ? 0 : kSuperUncPathPrefixSize + size;
}
// we support \\?\c:\ paths and volume GUID paths \\?\Volume{GUID}\"
- int pos = FindSepar(s + kSuperPathPrefixSize);
+ const int pos = FindSepar(s + kSuperPathPrefixSize);
if (pos < 0)
return 0;
return kSuperPathPrefixSize + pos + 1;
@@ -379,42 +410,26 @@ unsigned GetRootPrefixSize(const wchar_t *s) throw() { return IS_SEPAR(s[0]) ? 1
#ifndef UNDER_CE
-static bool GetCurDir(UString &path)
-{
- path.Empty();
- #ifdef _WIN32
+#ifdef USE_UNICODE_FSTRING
- DWORD needLength;
- #ifndef _UNICODE
- if (!g_IsNT)
- {
- TCHAR s[MAX_PATH + 2];
- s[0] = 0;
- needLength = ::GetCurrentDirectory(MAX_PATH + 1, s);
- path = fs2us(fas2fs(s));
- }
- else
- #endif
- {
- WCHAR s[MAX_PATH + 2];
- s[0] = 0;
- needLength = ::GetCurrentDirectoryW(MAX_PATH + 1, s);
- path = s;
- }
- return (needLength > 0 && needLength <= MAX_PATH);
+#define GetCurDir NDir::GetCurrentDir
- #else
+#else
+static bool GetCurDir(UString &path)
+{
+ path.Empty();
FString s;
if (!NDir::GetCurrentDir(s))
return false;
- path = GetUnicodeString(s);
+ path = fs2us(s);
return true;
-
- #endif
}
+#endif
+
+
static bool ResolveDotsFolders(UString &s)
{
#ifdef _WIN32
@@ -516,7 +531,7 @@ static bool AreThereDotsFolders(CFSTR s)
#endif
#endif // LONG_PATH_DOTS_FOLDERS_PARSING
-#ifdef WIN_LONG_PATH
+#ifdef Z7_LONG_PATH
/*
Most of Windows versions have problems, if some file or dir name
@@ -610,11 +625,11 @@ static bool GetSuperPathBase(CFSTR s, UString &res)
return true;
UString temp = fs2us(s);
- unsigned fixedSize = GetRootPrefixSize_Of_SuperPath(temp);
+ const unsigned fixedSize = GetRootPrefixSize_Of_SuperPath(temp);
if (fixedSize == 0)
return true;
- UString rem = &temp[fixedSize];
+ UString rem = temp.Ptr(fixedSize);
if (!ResolveDotsFolders(rem))
return true;
@@ -632,13 +647,13 @@ static bool GetSuperPathBase(CFSTR s, UString &res)
if (IS_SEPAR(s[1]))
{
UString temp = fs2us(s + 2);
- unsigned fixedSize = GetRootPrefixSize_Of_NetworkPath(temp);
+ const unsigned fixedSize = GetRootPrefixSize_Of_NetworkPath(temp);
// we ignore that error to allow short network paths server\share?
/*
if (fixedSize == 0)
return false;
*/
- UString rem = &temp[fixedSize];
+ UString rem = temp.Ptr(fixedSize);
if (!ResolveDotsFolders(rem))
return false;
res += kSuperUncPrefix;
@@ -783,7 +798,7 @@ bool GetSuperPath(CFSTR path, UString &superPath)
return false;
}
*/
-#endif // WIN_LONG_PATH
+#endif // Z7_LONG_PATH
bool GetFullPath(CFSTR dirPrefix, CFSTR s, FString &res)
{
@@ -801,8 +816,11 @@ bool GetFullPath(CFSTR dirPrefix, CFSTR s, FString &res)
#else
- unsigned prefixSize = GetRootPrefixSize(s);
+ const unsigned prefixSize = GetRootPrefixSize(s);
if (prefixSize != 0)
+#ifdef _WIN32
+ if (prefixSize != 1)
+#endif
{
if (!AreThereDotsFolders(s + prefixSize))
return true;
@@ -815,21 +833,9 @@ bool GetFullPath(CFSTR dirPrefix, CFSTR s, FString &res)
return true;
}
- /*
- FChar c = s[0];
- if (c == 0)
- return true;
- if (c == '.' && (s[1] == 0 || (s[1] == '.' && s[2] == 0)))
- return true;
- if (IS_SEPAR(c) && IS_SEPAR(s[1]))
- return true;
- if (IsDrivePath(s))
- return true;
- */
-
UString curDir;
- if (dirPrefix)
- curDir = fs2us(dirPrefix);
+ if (dirPrefix && prefixSize == 0)
+ curDir = fs2us(dirPrefix); // we use (dirPrefix), only if (s) path is relative
else
{
if (!GetCurDir(curDir))
@@ -837,46 +843,40 @@ bool GetFullPath(CFSTR dirPrefix, CFSTR s, FString &res)
}
NormalizeDirPathPrefix(curDir);
- unsigned fixedSize = 0;
+ unsigned fixedSize = GetRootPrefixSize(curDir);
- #ifdef _WIN32
-
- if (IsSuperPath(curDir))
+ UString temp;
+#ifdef _WIN32
+ if (prefixSize != 0)
{
- fixedSize = GetRootPrefixSize_Of_SuperPath(curDir);
+ /* (s) is absolute path, but only (prefixSize == 1) is possible here.
+ So for full resolving we need root of current folder and
+ relative part of (s). */
+ s += prefixSize;
+ // (s) is relative part now
if (fixedSize == 0)
- return false;
- }
- else
- {
- if (IsDrivePath(curDir))
- fixedSize = kDrivePrefixSize;
- else
{
- if (!IsPathSepar(curDir[0]) || !IsPathSepar(curDir[1]))
- return false;
- fixedSize = GetRootPrefixSize_Of_NetworkPath(curDir.Ptr(2));
- if (fixedSize == 0)
- return false;
- fixedSize += 2;
+ // (curDir) is not absolute.
+ // That case is unexpected, but we support it too.
+ curDir.Empty();
+ curDir.Add_PathSepar();
+ fixedSize = 1;
+ // (curDir) now is just Separ character.
+ // So final (res) path later also will have Separ prefix.
}
}
-
- #endif // _WIN32
-
- UString temp;
- if (IS_SEPAR(s[0]))
- {
- temp = fs2us(s + 1);
- }
else
+#endif // _WIN32
{
- temp += curDir.Ptr(fixedSize);
- temp += fs2us(s);
+ // (s) is relative path
+ temp = curDir.Ptr(fixedSize);
+ // (temp) is relative_part_of(curDir)
}
+ temp += fs2us(s);
if (!ResolveDotsFolders(temp))
return false;
curDir.DeleteFrom(fixedSize);
+ // (curDir) now contains only absolute prefix part
res = us2fs(curDir);
res += us2fs(temp);
@@ -885,6 +885,7 @@ bool GetFullPath(CFSTR dirPrefix, CFSTR s, FString &res)
return true;
}
+
bool GetFullPath(CFSTR path, FString &fullPath)
{
return GetFullPath(NULL, path, fullPath);
diff --git a/3rdparty/lzma/CPP/Windows/FileName.h b/3rdparty/lzma/CPP/Windows/FileName.h
index de8bd13488f..219b656b297 100644
--- a/3rdparty/lzma/CPP/Windows/FileName.h
+++ b/3rdparty/lzma/CPP/Windows/FileName.h
@@ -1,7 +1,7 @@
// Windows/FileName.h
-#ifndef __WINDOWS_FILE_NAME_H
-#define __WINDOWS_FILE_NAME_H
+#ifndef ZIP7_INC_WINDOWS_FILE_NAME_H
+#define ZIP7_INC_WINDOWS_FILE_NAME_H
#include "../Common/MyString.h"
@@ -54,6 +54,10 @@ bool IsDrivePath2(const wchar_t *s) throw(); // first 2 chars are drive chars li
bool IsSuperPath(const wchar_t *s) throw();
bool IsSuperOrDevicePath(const wchar_t *s) throw();
+bool IsAltStreamPrefixWithColon(const UString &s) throw();
+// returns true, if super prefix was removed
+bool If_IsSuperPath_RemoveSuperPrefix(UString &s);
+
#ifndef USE_UNICODE_FSTRING
bool IsDrivePath2(CFSTR s) throw(); // first 2 chars are drive chars like "a:"
// bool IsDriveName2(CFSTR s) throw(); // is drive name like "a:"
@@ -82,7 +86,7 @@ int FindAltStreamColon(CFSTR path) throw();
bool IsAbsolutePath(const wchar_t *s) throw();
unsigned GetRootPrefixSize(const wchar_t *s) throw();
-#ifdef WIN_LONG_PATH
+#ifdef Z7_LONG_PATH
const int kSuperPathType_UseOnlyMain = 0;
const int kSuperPathType_UseOnlySuper = 1;
@@ -92,16 +96,16 @@ int GetUseSuperPathType(CFSTR s) throw();
bool GetSuperPath(CFSTR path, UString &superPath, bool onlyIfNew);
bool GetSuperPaths(CFSTR s1, CFSTR s2, UString &d1, UString &d2, bool onlyIfNew);
-#define USE_MAIN_PATH (__useSuperPathType != kSuperPathType_UseOnlySuper)
-#define USE_MAIN_PATH_2 (__useSuperPathType1 != kSuperPathType_UseOnlySuper && __useSuperPathType2 != kSuperPathType_UseOnlySuper)
+#define USE_MAIN_PATH (_useSuperPathType != kSuperPathType_UseOnlySuper)
+#define USE_MAIN_PATH_2 (_useSuperPathType1 != kSuperPathType_UseOnlySuper && _useSuperPathType2 != kSuperPathType_UseOnlySuper)
-#define USE_SUPER_PATH (__useSuperPathType != kSuperPathType_UseOnlyMain)
-#define USE_SUPER_PATH_2 (__useSuperPathType1 != kSuperPathType_UseOnlyMain || __useSuperPathType2 != kSuperPathType_UseOnlyMain)
+#define USE_SUPER_PATH (_useSuperPathType != kSuperPathType_UseOnlyMain)
+#define USE_SUPER_PATH_2 (_useSuperPathType1 != kSuperPathType_UseOnlyMain || _useSuperPathType2 != kSuperPathType_UseOnlyMain)
-#define IF_USE_MAIN_PATH int __useSuperPathType = GetUseSuperPathType(path); if (USE_MAIN_PATH)
+#define IF_USE_MAIN_PATH int _useSuperPathType = GetUseSuperPathType(path); if (USE_MAIN_PATH)
#define IF_USE_MAIN_PATH_2(x1, x2) \
- int __useSuperPathType1 = GetUseSuperPathType(x1); \
- int __useSuperPathType2 = GetUseSuperPathType(x2); \
+ int _useSuperPathType1 = GetUseSuperPathType(x1); \
+ int _useSuperPathType2 = GetUseSuperPathType(x2); \
if (USE_MAIN_PATH_2)
#else
@@ -109,8 +113,18 @@ bool GetSuperPaths(CFSTR s1, CFSTR s2, UString &d1, UString &d2, bool onlyIfNew)
#define IF_USE_MAIN_PATH
#define IF_USE_MAIN_PATH_2(x1, x2)
-#endif // WIN_LONG_PATH
-
+#endif // Z7_LONG_PATH
+
+/*
+ if (dirPrefix != NULL && (path) is relative)
+ {
+ (dirPrefix) will be used
+ result (fullPath) will contain prefix part of (dirPrefix).
+ }
+ Current_Dir path can be used in 2 cases:
+ 1) if (path) is relative && dirPrefix == NULL
+ 2) for _WIN32: if (path) is absolute starting wuth "\"
+*/
bool GetFullPath(CFSTR dirPrefix, CFSTR path, FString &fullPath);
bool GetFullPath(CFSTR path, FString &fullPath);
diff --git a/3rdparty/lzma/CPP/Windows/FileSystem.cpp b/3rdparty/lzma/CPP/Windows/FileSystem.cpp
index 6259453225e..6a262d92d7f 100644
--- a/3rdparty/lzma/CPP/Windows/FileSystem.cpp
+++ b/3rdparty/lzma/CPP/Windows/FileSystem.cpp
@@ -71,14 +71,14 @@ UINT MyGetDriveType(CFSTR pathName)
}
}
-typedef BOOL (WINAPI * GetDiskFreeSpaceExA_Pointer)(
+typedef BOOL (WINAPI * Func_GetDiskFreeSpaceExA)(
LPCSTR lpDirectoryName, // directory name
PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk
PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk
);
-typedef BOOL (WINAPI * GetDiskFreeSpaceExW_Pointer)(
+typedef BOOL (WINAPI * Func_GetDiskFreeSpaceExW)(
LPCWSTR lpDirectoryName, // directory name
PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk
@@ -92,12 +92,14 @@ bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize,
#ifndef _UNICODE
if (!g_IsNT)
{
- GetDiskFreeSpaceExA_Pointer pGetDiskFreeSpaceEx = (GetDiskFreeSpaceExA_Pointer)(void *)GetProcAddress(
- GetModuleHandle(TEXT("kernel32.dll")), "GetDiskFreeSpaceExA");
- if (pGetDiskFreeSpaceEx)
+ const
+ Func_GetDiskFreeSpaceExA f = Z7_GET_PROC_ADDRESS(
+ Func_GetDiskFreeSpaceExA, GetModuleHandle(TEXT("kernel32.dll")),
+ "GetDiskFreeSpaceExA");
+ if (f)
{
ULARGE_INTEGER freeBytesToCaller2, totalSize2, freeSize2;
- sizeIsDetected = BOOLToBool(pGetDiskFreeSpaceEx(fs2fas(rootPath), &freeBytesToCaller2, &totalSize2, &freeSize2));
+ sizeIsDetected = BOOLToBool(f(fs2fas(rootPath), &freeBytesToCaller2, &totalSize2, &freeSize2));
totalSize = totalSize2.QuadPart;
freeSize = freeSize2.QuadPart;
}
@@ -107,12 +109,14 @@ bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize,
else
#endif
{
- GetDiskFreeSpaceExW_Pointer pGetDiskFreeSpaceEx = (GetDiskFreeSpaceExW_Pointer)(void *)GetProcAddress(
- GetModuleHandle(TEXT("kernel32.dll")), "GetDiskFreeSpaceExW");
- if (pGetDiskFreeSpaceEx)
+ const
+ Func_GetDiskFreeSpaceExW f = Z7_GET_PROC_ADDRESS(
+ Func_GetDiskFreeSpaceExW, GetModuleHandle(TEXT("kernel32.dll")),
+ "GetDiskFreeSpaceExW");
+ if (f)
{
ULARGE_INTEGER freeBytesToCaller2, totalSize2, freeSize2;
- sizeIsDetected = BOOLToBool(pGetDiskFreeSpaceEx(fs2us(rootPath), &freeBytesToCaller2, &totalSize2, &freeSize2));
+ sizeIsDetected = BOOLToBool(f(fs2us(rootPath), &freeBytesToCaller2, &totalSize2, &freeSize2));
totalSize = totalSize2.QuadPart;
freeSize = freeSize2.QuadPart;
}
diff --git a/3rdparty/lzma/CPP/Windows/FileSystem.h b/3rdparty/lzma/CPP/Windows/FileSystem.h
index 9b49a025a3b..9f9e399ce75 100644
--- a/3rdparty/lzma/CPP/Windows/FileSystem.h
+++ b/3rdparty/lzma/CPP/Windows/FileSystem.h
@@ -1,7 +1,7 @@
// Windows/FileSystem.h
-#ifndef __WINDOWS_FILE_SYSTEM_H
-#define __WINDOWS_FILE_SYSTEM_H
+#ifndef ZIP7_INC_WINDOWS_FILE_SYSTEM_H
+#define ZIP7_INC_WINDOWS_FILE_SYSTEM_H
#include "../Common/MyString.h"
#include "../Common/MyTypes.h"
diff --git a/3rdparty/lzma/CPP/Windows/Handle.h b/3rdparty/lzma/CPP/Windows/Handle.h
index 5878c830448..6ae09ecf53c 100644
--- a/3rdparty/lzma/CPP/Windows/Handle.h
+++ b/3rdparty/lzma/CPP/Windows/Handle.h
@@ -1,9 +1,9 @@
// Windows/Handle.h
-#ifndef __WINDOWS_HANDLE_H
-#define __WINDOWS_HANDLE_H
+#ifndef ZIP7_INC_WINDOWS_HANDLE_H
+#define ZIP7_INC_WINDOWS_HANDLE_H
-#include "../Common/MyTypes.h"
+#include "../Common/MyWindows.h"
namespace NWindows {
@@ -28,7 +28,7 @@ public:
void Attach(HANDLE handle) { _handle = handle; }
HANDLE Detach()
{
- HANDLE handle = _handle;
+ const HANDLE handle = _handle;
_handle = NULL;
return handle;
}
diff --git a/3rdparty/lzma/CPP/Windows/MemoryGlobal.h b/3rdparty/lzma/CPP/Windows/MemoryGlobal.h
index c217510e584..68525915800 100644
--- a/3rdparty/lzma/CPP/Windows/MemoryGlobal.h
+++ b/3rdparty/lzma/CPP/Windows/MemoryGlobal.h
@@ -1,7 +1,7 @@
// Windows/MemoryGlobal.h
-#ifndef __WINDOWS_MEMORY_GLOBAL_H
-#define __WINDOWS_MEMORY_GLOBAL_H
+#ifndef ZIP7_INC_WINDOWS_MEMORY_GLOBAL_H
+#define ZIP7_INC_WINDOWS_MEMORY_GLOBAL_H
#include "../Common/MyWindows.h"
@@ -12,7 +12,7 @@ class CGlobal
{
HGLOBAL _global;
public:
- CGlobal(): _global(NULL){};
+ CGlobal(): _global(NULL) {}
~CGlobal() { Free(); }
operator HGLOBAL() const { return _global; }
void Attach(HGLOBAL hGlobal)
@@ -22,7 +22,7 @@ public:
}
HGLOBAL Detach()
{
- HGLOBAL h = _global;
+ const HGLOBAL h = _global;
_global = NULL;
return h;
}
@@ -42,10 +42,10 @@ public:
CGlobalLock(HGLOBAL hGlobal): _global(hGlobal)
{
_ptr = GlobalLock(hGlobal);
- };
+ }
~CGlobalLock()
{
- if (_ptr != NULL)
+ if (_ptr)
GlobalUnlock(_global);
}
};
diff --git a/3rdparty/lzma/CPP/Windows/MemoryLock.cpp b/3rdparty/lzma/CPP/Windows/MemoryLock.cpp
index 24866b1aeb3..0bd7504f1cc 100644
--- a/3rdparty/lzma/CPP/Windows/MemoryLock.cpp
+++ b/3rdparty/lzma/CPP/Windows/MemoryLock.cpp
@@ -21,7 +21,10 @@ typedef BOOL (WINAPI * Func_LookupPrivilegeValue)(LPCTSTR lpSystemName, LPCTSTR
typedef BOOL (WINAPI * Func_AdjustTokenPrivileges)(HANDLE TokenHandle, BOOL DisableAllPrivileges,
PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength);
}
-#define GET_PROC_ADDR(fff, name) Func_ ## fff my_ ## fff = (Func_ ## fff) (void(*)()) GetProcAddress(hModule, name)
+
+#define GET_PROC_ADDR(fff, name) \
+ const Func_ ## fff my_ ## fff = Z7_GET_PROC_ADDRESS( \
+ Func_ ## fff, hModule, name);
#endif
bool EnablePrivilege(LPCTSTR privilegeName, bool enable)
@@ -30,13 +33,19 @@ bool EnablePrivilege(LPCTSTR privilegeName, bool enable)
#ifndef _UNICODE
- HMODULE hModule = ::LoadLibrary(TEXT("Advapi32.dll"));
- if (hModule == NULL)
+ const HMODULE hModule = ::LoadLibrary(TEXT("advapi32.dll"));
+ if (!hModule)
return false;
- GET_PROC_ADDR(OpenProcessToken, "OpenProcessToken");
- GET_PROC_ADDR(LookupPrivilegeValue, "LookupPrivilegeValueA");
- GET_PROC_ADDR(AdjustTokenPrivileges, "AdjustTokenPrivileges");
+ GET_PROC_ADDR(
+ OpenProcessToken,
+ "OpenProcessToken")
+ GET_PROC_ADDR(
+ LookupPrivilegeValue,
+ "LookupPrivilegeValueA")
+ GET_PROC_ADDR(
+ AdjustTokenPrivileges,
+ "AdjustTokenPrivileges")
if (my_OpenProcessToken &&
my_AdjustTokenPrivileges &&
@@ -85,10 +94,13 @@ typedef void (WINAPI * Func_RtlGetVersion) (OSVERSIONINFOEXW *);
unsigned Get_LargePages_RiskLevel()
{
OSVERSIONINFOEXW vi;
- HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll");
+ const HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll");
if (!ntdll)
return 0;
- Func_RtlGetVersion func = (Func_RtlGetVersion)(void *)GetProcAddress(ntdll, "RtlGetVersion");
+ const
+ Func_RtlGetVersion func = Z7_GET_PROC_ADDRESS(
+ Func_RtlGetVersion, ntdll,
+ "RtlGetVersion");
if (!func)
return 0;
func(&vi);
diff --git a/3rdparty/lzma/CPP/Windows/MemoryLock.h b/3rdparty/lzma/CPP/Windows/MemoryLock.h
index dcaf182e95e..2b850029f7a 100644
--- a/3rdparty/lzma/CPP/Windows/MemoryLock.h
+++ b/3rdparty/lzma/CPP/Windows/MemoryLock.h
@@ -1,7 +1,7 @@
// Windows/MemoryLock.h
-#ifndef __WINDOWS_MEMORY_LOCK_H
-#define __WINDOWS_MEMORY_LOCK_H
+#ifndef ZIP7_INC_WINDOWS_MEMORY_LOCK_H
+#define ZIP7_INC_WINDOWS_MEMORY_LOCK_H
#include "../Common/MyWindows.h"
diff --git a/3rdparty/lzma/CPP/Windows/NtCheck.h b/3rdparty/lzma/CPP/Windows/NtCheck.h
index 0af32911909..362a05ad973 100644
--- a/3rdparty/lzma/CPP/Windows/NtCheck.h
+++ b/3rdparty/lzma/CPP/Windows/NtCheck.h
@@ -1,19 +1,29 @@
// Windows/NtCheck.h
-#ifndef __WINDOWS_NT_CHECK_H
-#define __WINDOWS_NT_CHECK_H
+#ifndef ZIP7_INC_WINDOWS_NT_CHECK_H
+#define ZIP7_INC_WINDOWS_NT_CHECK_H
#ifdef _WIN32
#include "../Common/MyWindows.h"
#if !defined(_WIN64) && !defined(UNDER_CE)
+
+#if defined(_MSC_VER) && _MSC_VER >= 1900
+#pragma warning(push)
+// GetVersionExW was declared deprecated
+#pragma warning(disable : 4996)
+#endif
static inline bool IsItWindowsNT()
{
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
return (::GetVersionEx(&vi) && vi.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
+#if defined(_MSC_VER) && _MSC_VER >= 1900
+#pragma warning(pop)
+#endif
+
#endif
#ifndef _UNICODE
diff --git a/3rdparty/lzma/CPP/Windows/PropVariant.cpp b/3rdparty/lzma/CPP/Windows/PropVariant.cpp
index 2b179500479..457b1dcbbee 100644
--- a/3rdparty/lzma/CPP/Windows/PropVariant.cpp
+++ b/3rdparty/lzma/CPP/Windows/PropVariant.cpp
@@ -197,17 +197,17 @@ BSTR CPropVariant::AllocBstr(unsigned numChars)
void CPropVariant::Set_Int32(Int32 value) throw()
{
- SET_PROP_id_dest(VT_I4, lVal);
+ SET_PROP_id_dest(VT_I4, lVal)
}
void CPropVariant::Set_Int64(Int64 value) throw()
{
- SET_PROP_id_dest(VT_I8, hVal.QuadPart);
+ SET_PROP_id_dest(VT_I8, hVal.QuadPart)
}
#define SET_PROP_FUNC(type, id, dest) \
CPropVariant& CPropVariant::operator=(type value) throw() \
- { SET_PROP_id_dest(id, dest); return *this; }
+ { SET_PROP_id_dest(id, dest) return *this; }
SET_PROP_FUNC(Byte, VT_UI1, bVal)
// SET_PROP_FUNC(Int16, VT_I2, iVal)
@@ -245,7 +245,7 @@ SET_PROP_FUNC(const FILETIME &, VT_FILETIME, filetime)
we call system functions for VT_BSTR and for unknown typed
*/
-CPropVariant::~CPropVariant()
+CPropVariant::~CPropVariant() throw()
{
switch ((unsigned)vt)
{
diff --git a/3rdparty/lzma/CPP/Windows/PropVariant.h b/3rdparty/lzma/CPP/Windows/PropVariant.h
index 171402f743a..f358fdea12f 100644
--- a/3rdparty/lzma/CPP/Windows/PropVariant.h
+++ b/3rdparty/lzma/CPP/Windows/PropVariant.h
@@ -1,7 +1,7 @@
// Windows/PropVariant.h
-#ifndef __WINDOWS_PROP_VARIANT_H
-#define __WINDOWS_PROP_VARIANT_H
+#ifndef ZIP7_INC_WINDOWS_PROP_VARIANT_H
+#define ZIP7_INC_WINDOWS_PROP_VARIANT_H
#include "../Common/MyTypes.h"
#include "../Common/MyWindows.h"
@@ -64,7 +64,7 @@ public:
// wReserved2 = 0;
// wReserved3 = 0;
// uhVal.QuadPart = 0;
- bstrVal = 0;
+ bstrVal = NULL;
}
@@ -104,13 +104,13 @@ public:
const unsigned ns100 = wReserved2;
if (prec == 0
&& prec <= k_PropVar_TimePrec_1ns
- && ns100 < 100
+ && ns100 < 100
&& wReserved3 == 0)
return ns100;
return 0;
}
- ~CPropVariant();
+ ~CPropVariant() throw();
CPropVariant(const PROPVARIANT &varSrc);
CPropVariant(const CPropVariant &varSrc);
CPropVariant(BSTR bstrSrc);
diff --git a/3rdparty/lzma/CPP/Windows/PropVariantConv.cpp b/3rdparty/lzma/CPP/Windows/PropVariantConv.cpp
index 3c9bbd1702f..5fb96a7c53a 100644
--- a/3rdparty/lzma/CPP/Windows/PropVariantConv.cpp
+++ b/3rdparty/lzma/CPP/Windows/PropVariantConv.cpp
@@ -36,17 +36,17 @@ bool ConvertUtcFileTimeToString2(const FILETIME &utc, unsigned ns100, char *s, i
s[0] = (char)('0' + val / 10);
s += 4;
}
- UINT_TO_STR_2('-', st.wMonth);
- UINT_TO_STR_2('-', st.wDay);
+ UINT_TO_STR_2('-', st.wMonth)
+ UINT_TO_STR_2('-', st.wDay)
if (level > kTimestampPrintLevel_DAY)
{
- UINT_TO_STR_2(' ', st.wHour);
- UINT_TO_STR_2(':', st.wMinute);
+ UINT_TO_STR_2(' ', st.wHour)
+ UINT_TO_STR_2(':', st.wMinute)
if (level >= kTimestampPrintLevel_SEC)
{
- UINT_TO_STR_2(':', st.wSecond);
+ UINT_TO_STR_2(':', st.wSecond)
if (level > kTimestampPrintLevel_SEC)
{
diff --git a/3rdparty/lzma/CPP/Windows/PropVariantConv.h b/3rdparty/lzma/CPP/Windows/PropVariantConv.h
index 606778406f4..ec5223bd9c5 100644
--- a/3rdparty/lzma/CPP/Windows/PropVariantConv.h
+++ b/3rdparty/lzma/CPP/Windows/PropVariantConv.h
@@ -1,7 +1,7 @@
// Windows/PropVariantConv.h
-#ifndef __PROP_VARIANT_CONV_H
-#define __PROP_VARIANT_CONV_H
+#ifndef ZIP7_INC_PROP_VARIANT_CONV_H
+#define ZIP7_INC_PROP_VARIANT_CONV_H
#include "../Common/MyTypes.h"
diff --git a/3rdparty/lzma/CPP/Windows/Registry.h b/3rdparty/lzma/CPP/Windows/Registry.h
index ca79dfe3cda..0d3b4fcc3d5 100644
--- a/3rdparty/lzma/CPP/Windows/Registry.h
+++ b/3rdparty/lzma/CPP/Windows/Registry.h
@@ -1,7 +1,7 @@
// Windows/Registry.h
-#ifndef __WINDOWS_REGISTRY_H
-#define __WINDOWS_REGISTRY_H
+#ifndef ZIP7_INC_WINDOWS_REGISTRY_H
+#define ZIP7_INC_WINDOWS_REGISTRY_H
#include "../Common/MyBuffer.h"
#include "../Common/MyString.h"
diff --git a/3rdparty/lzma/CPP/Windows/ResourceString.h b/3rdparty/lzma/CPP/Windows/ResourceString.h
index f0bdabf47fe..773307b931c 100644
--- a/3rdparty/lzma/CPP/Windows/ResourceString.h
+++ b/3rdparty/lzma/CPP/Windows/ResourceString.h
@@ -1,9 +1,10 @@
// Windows/ResourceString.h
-#ifndef __WINDOWS_RESOURCE_STRING_H
-#define __WINDOWS_RESOURCE_STRING_H
+#ifndef ZIP7_INC_WINDOWS_RESOURCE_STRING_H
+#define ZIP7_INC_WINDOWS_RESOURCE_STRING_H
#include "../Common/MyString.h"
+#include "../Common/MyWindows.h"
namespace NWindows {
diff --git a/3rdparty/lzma/CPP/Windows/SecurityUtils.cpp b/3rdparty/lzma/CPP/Windows/SecurityUtils.cpp
index ede83faf565..d4282d070c2 100644
--- a/3rdparty/lzma/CPP/Windows/SecurityUtils.cpp
+++ b/3rdparty/lzma/CPP/Windows/SecurityUtils.cpp
@@ -4,9 +4,6 @@
#include "SecurityUtils.h"
-#define MY_CAST_FUNC (void(*)())
-// #define MY_CAST_FUNC
-
namespace NWindows {
namespace NSecurity {
@@ -35,7 +32,7 @@ bool MyLookupAccountSid(LPCTSTR systemName, PSID sid,
static void SetLsaString(LPWSTR src, PLSA_UNICODE_STRING dest)
{
- size_t len = (size_t)wcslen(src);
+ const size_t len = (size_t)wcslen(src);
dest->Length = (USHORT)(len * sizeof(WCHAR));
dest->MaximumLength = (USHORT)((len + 1) * sizeof(WCHAR));
dest->Buffer = src;
@@ -72,13 +69,14 @@ typedef BOOL (WINAPI * Func_LookupAccountNameW)(
static PSID GetSid(LPWSTR accountName)
{
#ifndef _UNICODE
- HMODULE hModule = GetModuleHandle(TEXT("Advapi32.dll"));
- if (hModule == NULL)
+ const HMODULE hModule = GetModuleHandle(TEXT("advapi32.dll"));
+ if (!hModule)
return NULL;
- Func_LookupAccountNameW lookupAccountNameW = (Func_LookupAccountNameW)
- MY_CAST_FUNC
- GetProcAddress(hModule, "LookupAccountNameW");
- if (lookupAccountNameW == NULL)
+ const
+ Func_LookupAccountNameW lookupAccountNameW = Z7_GET_PROC_ADDRESS(
+ Func_LookupAccountNameW, hModule,
+ "LookupAccountNameW");
+ if (!lookupAccountNameW)
return NULL;
#endif
@@ -88,21 +86,21 @@ static PSID GetSid(LPWSTR accountName)
#ifdef _UNICODE
::LookupAccountNameW
#else
- lookupAccountNameW
+ lookupAccountNameW
#endif
- (NULL, accountName, NULL, &sidLen, NULL, &domainLen, &sidNameUse))
+ (NULL, accountName, NULL, &sidLen, NULL, &domainLen, &sidNameUse))
{
if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
- PSID pSid = ::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sidLen);
+ const PSID pSid = ::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sidLen);
LPWSTR domainName = (LPWSTR)::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (domainLen + 1) * sizeof(WCHAR));
- BOOL res =
+ const BOOL res =
#ifdef _UNICODE
::LookupAccountNameW
#else
- lookupAccountNameW
+ lookupAccountNameW
#endif
- (NULL, accountName, pSid, &sidLen, domainName, &domainLen, &sidNameUse);
+ (NULL, accountName, pSid, &sidLen, domainName, &domainLen, &sidNameUse);
::HeapFree(GetProcessHeap(), 0, domainName);
if (res)
return pSid;
@@ -111,7 +109,7 @@ static PSID GetSid(LPWSTR accountName)
return NULL;
}
-#define MY__SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
+#define Z7_WIN_SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
bool AddLockMemoryPrivilege()
{
@@ -131,13 +129,13 @@ bool AddLockMemoryPrivilege()
!= 0)
return false;
LSA_UNICODE_STRING userRights;
- wchar_t s[128] = MY__SE_LOCK_MEMORY_NAME;
+ wchar_t s[128] = Z7_WIN_SE_LOCK_MEMORY_NAME;
SetLsaString(s, &userRights);
WCHAR userName[256 + 2];
DWORD size = 256;
if (!GetUserNameW(userName, &size))
return false;
- PSID psid = GetSid(userName);
+ const PSID psid = GetSid(userName);
if (psid == NULL)
return false;
bool res = false;
@@ -176,7 +174,7 @@ bool AddLockMemoryPrivilege()
res = true;
}
*/
- NTSTATUS status = policy.AddAccountRights(psid, &userRights);
+ const NTSTATUS status = policy.AddAccountRights(psid, &userRights);
if (status == 0)
res = true;
// ULONG res = LsaNtStatusToWinError(status);
diff --git a/3rdparty/lzma/CPP/Windows/SecurityUtils.h b/3rdparty/lzma/CPP/Windows/SecurityUtils.h
index c0d7b127a0f..4ef3939f8e4 100644
--- a/3rdparty/lzma/CPP/Windows/SecurityUtils.h
+++ b/3rdparty/lzma/CPP/Windows/SecurityUtils.h
@@ -1,7 +1,7 @@
// Windows/SecurityUtils.h
-#ifndef __WINDOWS_SECURITY_UTILS_H
-#define __WINDOWS_SECURITY_UTILS_H
+#ifndef ZIP7_INC_WINDOWS_SECURITY_UTILS_H
+#define ZIP7_INC_WINDOWS_SECURITY_UTILS_H
#include <NTSecAPI.h>
@@ -20,7 +20,7 @@ typedef NTSTATUS (NTAPI *Func_LsaAddAccountRights)(LSA_HANDLE PolicyHandle,
#define POLICY_FUNC_CALL(fff, str) \
if (hModule == NULL) return MY_STATUS_NOT_IMPLEMENTED; \
- Func_ ## fff v = (Func_ ## fff) (void(*)()) GetProcAddress(hModule, str); \
+ const Func_ ## fff v = Z7_GET_PROC_ADDRESS(Func_ ## fff, hModule, str); \
if (!v) return MY_STATUS_NOT_IMPLEMENTED; \
const NTSTATUS res = v
@@ -39,7 +39,7 @@ class CAccessToken
{
HANDLE _handle;
public:
- CAccessToken(): _handle(NULL) {};
+ CAccessToken(): _handle(NULL) {}
~CAccessToken() { Close(); }
bool Close()
{
@@ -93,9 +93,9 @@ public:
CPolicy(): _handle(NULL)
{
#ifndef _UNICODE
- hModule = GetModuleHandle(TEXT("Advapi32.dll"));
+ hModule = GetModuleHandle(TEXT("advapi32.dll"));
#endif
- };
+ }
~CPolicy() { Close(); }
NTSTATUS Open(PLSA_UNICODE_STRING systemName, PLSA_OBJECT_ATTRIBUTES objectAttributes,
diff --git a/3rdparty/lzma/CPP/Windows/Shell.cpp b/3rdparty/lzma/CPP/Windows/Shell.cpp
index 071833cfa8e..b2a3489870d 100644
--- a/3rdparty/lzma/CPP/Windows/Shell.cpp
+++ b/3rdparty/lzma/CPP/Windows/Shell.cpp
@@ -2,23 +2,50 @@
#include "StdAfx.h"
-/*
-#include <stdio.h>
-#include <string.h>
-*/
-
#include "../Common/MyCom.h"
-#ifndef _UNICODE
#include "../Common/StringConvert.h"
-#endif
#include "COM.h"
+#include "FileName.h"
+#include "MemoryGlobal.h"
#include "Shell.h"
#ifndef _UNICODE
extern bool g_IsNT;
#endif
+// MSVC6 and old SDK don't support this function:
+// #define LWSTDAPI EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE
+// LWSTDAPI StrRetToStrW(STRRET *pstr, LPCITEMIDLIST pidl, LPWSTR *ppsz);
+
+// #define SHOW_DEBUG_SHELL
+
+#ifdef SHOW_DEBUG_SHELL
+
+#include "../Common/IntToString.h"
+
+static void Print_Number(UInt32 number, const char *s)
+{
+ AString s2;
+ s2.Add_UInt32(number);
+ s2.Add_Space();
+ s2 += s;
+ OutputDebugStringA(s2);
+}
+
+#define ODS(sz) { OutputDebugStringA(sz); }
+#define ODS_U(s) { OutputDebugStringW(s); }
+#define ODS_(op) { op; }
+
+#else
+
+#define ODS(sz)
+#define ODS_U(s)
+#define ODS_(op)
+
+#endif
+
+
namespace NWindows {
namespace NShell {
@@ -28,12 +55,24 @@ namespace NShell {
void CItemIDList::Free()
{
- if (m_Object == NULL)
+ if (!m_Object)
return;
+ /* DOCs:
+ SHGetMalloc was introduced in Windows 95 and Microsoft Windows NT 4.0,
+ but as of Windows 2000 it is no longer necessary.
+ In its place, programs can call the equivalent (and easier to use) CoTaskMemAlloc and CoTaskMemFree.
+ Description from oldnewthings:
+ shell functions could work without COM (if OLE32.DLL is not loaded),
+ but now if OLE32.DLL is loaded, then shell functions and com functions do same things.
+ 22.02: so we use OLE32.DLL function to free memory:
+ */
+ /*
CMyComPtr<IMalloc> shellMalloc;
if (::SHGetMalloc(&shellMalloc) != NOERROR)
throw 41099;
shellMalloc->Free(m_Object);
+ */
+ CoTaskMemFree(m_Object);
m_Object = NULL;
}
@@ -70,9 +109,354 @@ CItemIDList& CItemIDList::operator=(const CItemIDList &object)
}
*/
+
+static HRESULT ReadUnicodeStrings(const wchar_t *p, size_t size, UStringVector &names)
+{
+ names.Clear();
+ const wchar_t *lim = p + size;
+ UString s;
+ /*
+ if (size == 0 || p[size - 1] != 0)
+ return E_INVALIDARG;
+ if (size == 1)
+ return S_OK;
+ if (p[size - 2] != 0)
+ return E_INVALIDARG;
+ */
+ for (;;)
+ {
+ const wchar_t *start = p;
+ for (;;)
+ {
+ if (p == lim) return E_INVALIDARG; // S_FALSE
+ if (*p++ == 0)
+ break;
+ }
+ const size_t num = (size_t)(p - start);
+ if (num == 1)
+ {
+ if (p != lim) return E_INVALIDARG; // S_FALSE
+ return S_OK;
+ }
+ s.SetFrom(start, (unsigned)(num - 1));
+ ODS_U(s)
+ names.Add(s);
+ // names.ReserveOnePosition();
+ // names.AddInReserved_Ptr_of_new(new UString((unsigned)num - 1, start));
+ }
+}
+
+
+static HRESULT ReadAnsiStrings(const char *p, size_t size, UStringVector &names)
+{
+ names.Clear();
+ AString name;
+ for (; size != 0; size--)
+ {
+ const char c = *p++;
+ if (c == 0)
+ {
+ if (name.IsEmpty())
+ return S_OK;
+ names.Add(GetUnicodeString(name));
+ name.Empty();
+ }
+ else
+ name += c;
+ }
+ return E_INVALIDARG;
+}
+
+
+#define INIT_FORMATETC_HGLOBAL(type) { (type), NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }
+
+static HRESULT DataObject_GetData_HGLOBAL(IDataObject *dataObject, CLIPFORMAT cf, NCOM::CStgMedium &medium)
+{
+ FORMATETC etc = INIT_FORMATETC_HGLOBAL(cf);
+ RINOK(dataObject->GetData(&etc, &medium))
+ if (medium.tymed != TYMED_HGLOBAL)
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+static HRESULT DataObject_GetData_HDROP_Names(IDataObject *dataObject, UStringVector &names)
+{
+ names.Clear();
+ NCOM::CStgMedium medium;
+
+ /* Win10 : if (dataObject) is from IContextMenu::Initialize() and
+ if (len_of_path >= MAX_PATH (260) for some file in data object)
+ {
+ GetData() returns HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
+ "The data area passed to a system call is too small",
+ Is there a way to fix this code for long paths?
+ } */
+
+ RINOK(DataObject_GetData_HGLOBAL(dataObject, CF_HDROP, medium))
+ const size_t blockSize = GlobalSize(medium.hGlobal);
+ if (blockSize < sizeof(DROPFILES))
+ return E_INVALIDARG;
+ NMemory::CGlobalLock dropLock(medium.hGlobal);
+ const DROPFILES *dropFiles = (const DROPFILES *)dropLock.GetPointer();
+ if (!dropFiles)
+ return E_INVALIDARG;
+ if (blockSize < dropFiles->pFiles
+ || dropFiles->pFiles < sizeof(DROPFILES)
+ // || dropFiles->pFiles != sizeof(DROPFILES)
+ )
+ return E_INVALIDARG;
+ const size_t size = blockSize - dropFiles->pFiles;
+ const void *namesData = (const Byte *)(const void *)dropFiles + dropFiles->pFiles;
+ HRESULT hres;
+ if (dropFiles->fWide)
+ {
+ if (size % sizeof(wchar_t) != 0)
+ return E_INVALIDARG;
+ hres = ReadUnicodeStrings((const wchar_t *)namesData, size / sizeof(wchar_t), names);
+ }
+ else
+ hres = ReadAnsiStrings((const char *)namesData, size, names);
+
+ ODS_(Print_Number(names.Size(), "DataObject_GetData_HDROP_Names"))
+ return hres;
+}
+
+
+
+// CF_IDLIST:
+#define MYWIN_CFSTR_SHELLIDLIST TEXT("Shell IDList Array")
+
+typedef struct
+{
+ UINT cidl;
+ UINT aoffset[1];
+} MYWIN_CIDA;
+/*
+ cidl : number of PIDLs that are being transferred, not including the parent folder.
+ aoffset : An array of offsets, relative to the beginning of this structure.
+ aoffset[0] - fully qualified PIDL of a parent folder.
+ If this PIDL is empty, the parent folder is the desktop.
+ aoffset[1] ... aoffset[cidl] : offset to one of the PIDLs to be transferred.
+ All of these PIDLs are relative to the PIDL of the parent folder.
+*/
+
+static HRESULT DataObject_GetData_IDLIST(IDataObject *dataObject, UStringVector &names)
+{
+ names.Clear();
+ NCOM::CStgMedium medium;
+ RINOK(DataObject_GetData_HGLOBAL(dataObject, (CLIPFORMAT)
+ RegisterClipboardFormat(MYWIN_CFSTR_SHELLIDLIST), medium))
+ const size_t blockSize = GlobalSize(medium.hGlobal);
+ if (blockSize < sizeof(MYWIN_CIDA) || blockSize >= (UInt32)((UInt32)0 - 1))
+ return E_INVALIDARG;
+ NMemory::CGlobalLock dropLock(medium.hGlobal);
+ const MYWIN_CIDA *cida = (const MYWIN_CIDA *)dropLock.GetPointer();
+ if (!cida)
+ return E_INVALIDARG;
+ if (cida->cidl == 0)
+ {
+ // is it posssible to have no selected items?
+ // it's unexpected case.
+ return E_INVALIDARG;
+ }
+ if (cida->cidl >= (blockSize - (UInt32)sizeof(MYWIN_CIDA)) / sizeof(UINT))
+ return E_INVALIDARG;
+ const UInt32 start = cida->cidl * (UInt32)sizeof(UINT) + (UInt32)sizeof(MYWIN_CIDA);
+
+ STRRET strret;
+ CMyComPtr<IShellFolder> parentFolder;
+ {
+ const UINT offset = cida->aoffset[0];
+ if (offset < start || offset >= blockSize
+ // || offset != start
+ )
+ return E_INVALIDARG;
+
+ CMyComPtr<IShellFolder> desktopFolder;
+ RINOK(::SHGetDesktopFolder(&desktopFolder))
+ if (!desktopFolder)
+ return E_FAIL;
+
+ LPCITEMIDLIST const lpcItem = (LPCITEMIDLIST)(const void *)((const Byte *)cida + offset);
+
+ #ifdef SHOW_DEBUG_SHELL
+ {
+ const HRESULT res = desktopFolder->GetDisplayNameOf(
+ lpcItem, SHGDN_FORPARSING, &strret);
+ if (res == S_OK && strret.uType == STRRET_WSTR)
+ {
+ ODS_U(strret.pOleStr)
+ /* if lpcItem is empty, the path will be
+ "C:\Users\user_name\Desktop"
+ if lpcItem is "My Computer" folder, the path will be
+ "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" */
+ CoTaskMemFree(strret.pOleStr);
+ }
+ }
+ #endif
+
+ RINOK(desktopFolder->BindToObject(lpcItem,
+ NULL, IID_IShellFolder, (void **)&parentFolder))
+ if (!parentFolder)
+ return E_FAIL;
+ }
+
+ names.ClearAndReserve(cida->cidl);
+ UString path;
+
+ // for (int y = 0; y < 1; y++) // for debug
+ for (unsigned i = 1; i <= cida->cidl; i++)
+ {
+ const UINT offset = cida->aoffset[i];
+ if (offset < start || offset >= blockSize)
+ return E_INVALIDARG;
+ const void *p = (const Byte *)(const void *)cida + offset;
+ /* ITEMIDLIST of file can contain more than one SHITEMID item.
+ In win10 only SHGDN_FORPARSING returns path that contains
+ all path parts related to parts of ITEMIDLIST.
+ So we can use only SHGDN_FORPARSING here.
+ Don't use (SHGDN_INFOLDER)
+ Don't use (SHGDN_INFOLDER | SHGDN_FORPARSING)
+ */
+ RINOK(parentFolder->GetDisplayNameOf((LPCITEMIDLIST)p, SHGDN_FORPARSING, &strret))
+
+ /*
+ // MSVC6 and old SDK do not support StrRetToStrW().
+ LPWSTR lpstr;
+ RINOK (StrRetToStrW(&strret, NULL, &lpstr))
+ ODS_U(lpstr)
+ path = lpstr;
+ CoTaskMemFree(lpstr);
+ */
+ if (strret.uType != STRRET_WSTR)
+ return E_INVALIDARG;
+ ODS_U(strret.pOleStr)
+ path = strret.pOleStr;
+ // the path could have super path prefix "\\\\?\\"
+ // we can remove super path prefix here, if we don't need that prefix
+ #ifdef Z7_LONG_PATH
+ // we remove super prefix, if we can work without that prefix
+ NFile::NName::If_IsSuperPath_RemoveSuperPrefix(path);
+ #endif
+ names.AddInReserved(path);
+ CoTaskMemFree(strret.pOleStr);
+ }
+
+ ODS_(Print_Number(cida->cidl, "CFSTR_SHELLIDLIST END"))
+ return S_OK;
+}
+
+
+HRESULT DataObject_GetData_HDROP_or_IDLIST_Names(IDataObject *dataObject, UStringVector &paths)
+{
+ ODS("-- DataObject_GetData_HDROP_or_IDLIST_Names START")
+ HRESULT hres = NShell::DataObject_GetData_HDROP_Names(dataObject, paths);
+ // if (hres == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER))
+ if (hres != S_OK)
+ {
+ ODS("-- DataObject_GetData_IDLIST START")
+ // for (int y = 0; y < 10000; y++) // for debug
+ hres = NShell::DataObject_GetData_IDLIST(dataObject, paths);
+ }
+ ODS("-- DataObject_GetData_HDROP_or_IDLIST_Names END")
+ return hres;
+}
+
+
+
+// #if (NTDDI_VERSION >= NTDDI_VISTA)
+typedef struct
+{
+ UINT cItems; // number of items in rgdwFileAttributes array
+ DWORD dwSumFileAttributes; // all of the attributes ORed together
+ DWORD dwProductFileAttributes; // all of the attributes ANDed together
+ DWORD rgdwFileAttributes[1]; // array
+} MYWIN_FILE_ATTRIBUTES_ARRAY;
+
+#define MYWIN_CFSTR_FILE_ATTRIBUTES_ARRAY TEXT("File Attributes Array")
+
+HRESULT DataObject_GetData_FILE_ATTRS(IDataObject *dataObject, CFileAttribs &attribs)
+{
+ attribs.Clear();
+ NCOM::CStgMedium medium;
+ RINOK(DataObject_GetData_HGLOBAL(dataObject, (CLIPFORMAT)
+ RegisterClipboardFormat(MYWIN_CFSTR_FILE_ATTRIBUTES_ARRAY), medium))
+ const size_t blockSize = GlobalSize(medium.hGlobal);
+ if (blockSize < sizeof(MYWIN_FILE_ATTRIBUTES_ARRAY))
+ return E_INVALIDARG;
+ NMemory::CGlobalLock dropLock(medium.hGlobal);
+ const MYWIN_FILE_ATTRIBUTES_ARRAY *faa = (const MYWIN_FILE_ATTRIBUTES_ARRAY *)dropLock.GetPointer();
+ if (!faa)
+ return E_INVALIDARG;
+ const unsigned numFiles = faa->cItems;
+ if (numFiles == 0)
+ {
+ // is it posssible to have empty array here?
+ return E_INVALIDARG;
+ }
+ if ((blockSize - (sizeof(MYWIN_FILE_ATTRIBUTES_ARRAY) - sizeof(DWORD)))
+ / sizeof(DWORD) != numFiles)
+ return E_INVALIDARG;
+ // attribs.Sum = faa->dwSumFileAttributes;
+ // attribs.Product = faa->dwProductFileAttributes;
+ // attribs.Vals.SetFromArray(faa->rgdwFileAttributes, numFiles);
+ // attribs.IsDirVector.ClearAndSetSize(numFiles);
+
+ if ((faa->dwSumFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
+ {
+ /* in win10: if selected items are volumes (c:\, d:\ ..) in My Compter,
+ all items have FILE_ATTRIBUTE_DIRECTORY attribute
+ ntfs volume also have FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM
+ udf volume: FILE_ATTRIBUTE_READONLY
+ dvd-rom device: (-1) : all bits are set
+ */
+ const DWORD *attr = faa->rgdwFileAttributes;
+ // DWORD product = (UInt32)0 - 1, sum = 0;
+ for (unsigned i = 0; i < numFiles; i++)
+ {
+ if (attr[i] & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ // attribs.ThereAreDirs = true;
+ attribs.FirstDirIndex = (int)i;
+ break;
+ }
+ // attribs.IsDirVector[i] = (attr[i] & FILE_ATTRIBUTE_DIRECTORY) != 0;
+ // product &= v;
+ // sum |= v;
+ }
+ // ODS_(Print_Number(product, "Product calc FILE_ATTRIBUTES_ARRAY ==== DataObject_GetData_HDROP_Names"))
+ // ODS_(Print_Number(sum, "Sum calc FILE_ATTRIBUTES_ARRAY ==== DataObject_GetData_HDROP_Names"))
+ }
+ // ODS_(Print_Number(attribs.Product, "Product FILE_ATTRIBUTES_ARRAY ==== DataObject_GetData_HDROP_Names"))
+ // ODS_(Print_Number(attribs.Sum, "Sum FILE_ATTRIBUTES_ARRAY ==== DataObject_GetData_HDROP_Names"))
+ ODS_(Print_Number(numFiles, "FILE_ATTRIBUTES_ARRAY ==== DataObject_GetData_HDROP_Names"))
+ return S_OK;
+}
+
+
/////////////////////////////
// CDrop
+/*
+ win10:
+ DragQueryFile() implementation code is not effective because
+ there is no pointer inside DROP internal file list, so
+ DragQueryFile(fileIndex) runs all names in range [0, fileIndex].
+ DragQueryFile(,, buf, bufSize)
+ if (buf == NULL) by spec
+ {
+ returns value is the required size
+ in characters, of the buffer, not including the terminating null character
+ tests show that if (bufSize == 0), then it also returns required size.
+ }
+ if (bufSize != NULL)
+ {
+ returns: the count of the characters copied, not including null character.
+ win10: null character is also copied at position buf[ret_count];
+ }
+*/
+
+/*
void CDrop::Attach(HDROP object)
{
Free();
@@ -92,56 +476,133 @@ UINT CDrop::QueryCountOfFiles()
return QueryFile(0xFFFFFFFF, (LPTSTR)NULL, 0);
}
-UString CDrop::QueryFileName(UINT fileIndex)
+void CDrop::QueryFileName(UINT fileIndex, UString &fileName)
{
- UString fileName;
#ifndef _UNICODE
if (!g_IsNT)
{
AString fileNameA;
- UINT bufferSize = QueryFile(fileIndex, (LPTSTR)NULL, 0);
- const unsigned len = bufferSize + 2;
- QueryFile(fileIndex, fileNameA.GetBuf(len), bufferSize + 1);
+ const UINT len = QueryFile(fileIndex, (LPTSTR)NULL, 0);
+ const UINT numCopied = QueryFile(fileIndex, fileNameA.GetBuf(len + 2), len + 2);
fileNameA.ReleaseBuf_CalcLen(len);
+ if (numCopied != len)
+ throw 20221223;
fileName = GetUnicodeString(fileNameA);
}
else
#endif
{
- UINT bufferSize = QueryFile(fileIndex, (LPWSTR)NULL, 0);
- const unsigned len = bufferSize + 2;
- QueryFile(fileIndex, fileName.GetBuf(len), bufferSize + 1);
+ // kReserve must be >= 3 for additional buffer size
+ // safety and for optimal performance
+ const unsigned kReserve = 3;
+ {
+ unsigned len = 0;
+ wchar_t *buf = fileName.GetBuf_GetMaxAvail(len);
+ if (len >= kReserve)
+ {
+ const UINT numCopied = QueryFile(fileIndex, buf, len);
+ if (numCopied < len - 1)
+ {
+ // (numCopied < len - 1) case means that it have copied full string.
+ fileName.ReleaseBuf_CalcLen(numCopied);
+ return;
+ }
+ }
+ }
+ const UINT len = QueryFile(fileIndex, (LPWSTR)NULL, 0);
+ const UINT numCopied = QueryFile(fileIndex,
+ fileName.GetBuf(len + kReserve), len + kReserve);
fileName.ReleaseBuf_CalcLen(len);
+ if (numCopied != len)
+ throw 20221223;
}
- return fileName;
}
+
void CDrop::QueryFileNames(UStringVector &fileNames)
{
UINT numFiles = QueryCountOfFiles();
- /*
- char s[100];
- sprintf(s, "QueryFileNames: %d files", numFiles);
- OutputDebugStringA(s);
- */
+
+ Print_Number(numFiles, "\n====== CDrop::QueryFileNames START ===== \n");
+
fileNames.ClearAndReserve(numFiles);
+ UString s;
for (UINT i = 0; i < numFiles; i++)
{
- const UString s2 = QueryFileName(i);
- if (!s2.IsEmpty())
- fileNames.AddInReserved(s2);
- /*
- OutputDebugStringW(L"file ---");
- OutputDebugStringW(s2);
- */
+ QueryFileName(i, s);
+ if (!s.IsEmpty())
+ fileNames.AddInReserved(s);
}
+ Print_Number(numFiles, "\n====== CDrop::QueryFileNames END ===== \n");
+}
+*/
+
+
+// #if (NTDDI_VERSION >= NTDDI_VISTA)
+// SHGetPathFromIDListEx returns a win32 file system path for the item in the name space.
+typedef int Z7_WIN_GPFIDL_FLAGS;
+
+extern "C" {
+typedef BOOL (WINAPI * Func_SHGetPathFromIDListW)(LPCITEMIDLIST pidl, LPWSTR pszPath);
+typedef BOOL (WINAPI * Func_SHGetPathFromIDListEx)(LPCITEMIDLIST pidl, PWSTR pszPath, DWORD cchPath, Z7_WIN_GPFIDL_FLAGS uOpts);
}
+#ifndef _UNICODE
-bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path)
+bool GetPathFromIDList(LPCITEMIDLIST itemIDList, AString &path)
+{
+ path.Empty();
+ const unsigned len = MAX_PATH + 16;
+ const bool result = BOOLToBool(::SHGetPathFromIDList(itemIDList, path.GetBuf(len)));
+ path.ReleaseBuf_CalcLen(len);
+ return result;
+}
+
+#endif
+
+bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path)
{
- const unsigned len = MAX_PATH * 2;
+ path.Empty();
+ unsigned len = MAX_PATH + 16;
+
+#ifdef _UNICODE
bool result = BOOLToBool(::SHGetPathFromIDList(itemIDList, path.GetBuf(len)));
+#else
+ const
+ Func_SHGetPathFromIDListW
+ shGetPathFromIDListW = Z7_GET_PROC_ADDRESS(
+ Func_SHGetPathFromIDListW, ::GetModuleHandleW(L"shell32.dll"),
+ "SHGetPathFromIDListW");
+ if (!shGetPathFromIDListW)
+ return false;
+ bool result = BOOLToBool(shGetPathFromIDListW(itemIDList, path.GetBuf(len)));
+#endif
+
+ if (!result)
+ {
+ ODS("==== GetPathFromIDList() SHGetPathFromIDList() returned false")
+ /* for long path we need SHGetPathFromIDListEx().
+ win10: SHGetPathFromIDListEx() for long path returns path with
+ with super path prefix "\\\\?\\". */
+ const
+ Func_SHGetPathFromIDListEx
+ func_SHGetPathFromIDListEx = Z7_GET_PROC_ADDRESS(
+ Func_SHGetPathFromIDListEx, ::GetModuleHandleW(L"shell32.dll"),
+ "SHGetPathFromIDListEx");
+ if (func_SHGetPathFromIDListEx)
+ {
+ ODS("==== GetPathFromIDList() (SHGetPathFromIDListEx)")
+ do
+ {
+ len *= 4;
+ result = BOOLToBool(func_SHGetPathFromIDListEx(itemIDList, path.GetBuf(len), len, 0));
+ if (result)
+ break;
+ }
+ while (len <= (1 << 16));
+ }
+ }
+
path.ReleaseBuf_CalcLen(len);
return result;
}
@@ -180,11 +641,16 @@ bool BrowseForFolder(HWND /* owner */, LPCTSTR /* title */,
#else
+/* win10: SHBrowseForFolder() doesn't support long paths,
+ even if long path suppport is enabled in registry and in manifest.
+ and SHBrowseForFolder() doesn't support super path prefix "\\\\?\\". */
+
bool BrowseForFolder(LPBROWSEINFO browseInfo, CSysString &resultPath)
{
+ resultPath.Empty();
NWindows::NCOM::CComInitializer comInitializer;
LPITEMIDLIST itemIDList = ::SHBrowseForFolder(browseInfo);
- if (itemIDList == NULL)
+ if (!itemIDList)
return false;
CItemIDList itemIDListHolder;
itemIDListHolder.Attach(itemIDList);
@@ -240,11 +706,18 @@ static bool BrowseForFolder(HWND owner, LPCTSTR title, UINT ulFlags,
browseInfo.lpszTitle = title;
// #endif
browseInfo.ulFlags = ulFlags;
- browseInfo.lpfn = (initialFolder != NULL) ? BrowseCallbackProc : NULL;
+ browseInfo.lpfn = initialFolder ? BrowseCallbackProc : NULL;
browseInfo.lParam = (LPARAM)initialFolder;
return BrowseForFolder(&browseInfo, resultPath);
}
+#ifdef Z7_OLD_WIN_SDK
+// ShlObj.h:
+#ifndef BIF_NEWDIALOGSTYLE
+#define BIF_NEWDIALOGSTYLE 0x0040
+#endif
+#endif
+
bool BrowseForFolder(HWND owner, LPCTSTR title,
LPCTSTR initialFolder, CSysString &resultPath)
{
@@ -259,38 +732,21 @@ bool BrowseForFolder(HWND owner, LPCTSTR title,
#ifndef _UNICODE
extern "C" {
-typedef BOOL (WINAPI * Func_SHGetPathFromIDListW)(LPCITEMIDLIST pidl, LPWSTR pszPath);
typedef LPITEMIDLIST (WINAPI * Func_SHBrowseForFolderW)(LPBROWSEINFOW lpbi);
}
-#define MY_CAST_FUNC (void(*)())
-// #define MY_CAST_FUNC
-
-bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path)
-{
- path.Empty();
- Func_SHGetPathFromIDListW shGetPathFromIDListW = (Func_SHGetPathFromIDListW)
- MY_CAST_FUNC
- ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHGetPathFromIDListW");
- if (!shGetPathFromIDListW)
- return false;
- const unsigned len = MAX_PATH * 2;
- bool result = BOOLToBool(shGetPathFromIDListW(itemIDList, path.GetBuf(len)));
- path.ReleaseBuf_CalcLen(len);
- return result;
-}
-
-
static bool BrowseForFolder(LPBROWSEINFOW browseInfo, UString &resultPath)
{
NWindows::NCOM::CComInitializer comInitializer;
- Func_SHBrowseForFolderW shBrowseForFolderW = (Func_SHBrowseForFolderW)
- MY_CAST_FUNC
- ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHBrowseForFolderW");
- if (!shBrowseForFolderW)
+ const
+ Func_SHBrowseForFolderW
+ f_SHBrowseForFolderW = Z7_GET_PROC_ADDRESS(
+ Func_SHBrowseForFolderW, ::GetModuleHandleW(L"shell32.dll"),
+ "SHBrowseForFolderW");
+ if (!f_SHBrowseForFolderW)
return false;
- LPITEMIDLIST itemIDList = shBrowseForFolderW(browseInfo);
- if (itemIDList == NULL)
+ LPITEMIDLIST itemIDList = f_SHBrowseForFolderW(browseInfo);
+ if (!itemIDList)
return false;
CItemIDList itemIDListHolder;
itemIDListHolder.Attach(itemIDList);
@@ -336,7 +792,7 @@ static bool BrowseForFolder(HWND owner, LPCWSTR title, UINT ulFlags,
browseInfo.pszDisplayName = displayName.GetBuf(MAX_PATH);
browseInfo.lpszTitle = title;
browseInfo.ulFlags = ulFlags;
- browseInfo.lpfn = (initialFolder != NULL) ? BrowseCallbackProc2 : NULL;
+ browseInfo.lpfn = initialFolder ? BrowseCallbackProc2 : NULL;
browseInfo.lParam = (LPARAM)initialFolder;
return BrowseForFolder(&browseInfo, resultPath);
}
diff --git a/3rdparty/lzma/CPP/Windows/Shell.h b/3rdparty/lzma/CPP/Windows/Shell.h
index de91d3f1142..b4cdb3048e1 100644
--- a/3rdparty/lzma/CPP/Windows/Shell.h
+++ b/3rdparty/lzma/CPP/Windows/Shell.h
@@ -1,17 +1,22 @@
// Windows/Shell.h
-#ifndef __WINDOWS_SHELL_H
-#define __WINDOWS_SHELL_H
+#ifndef ZIP7_WINDOWS_SHELL_H
+#define ZIP7_WINDOWS_SHELL_H
+#include "../Common/Common.h"
#include "../Common/MyWindows.h"
+#if defined(__MINGW32__) || defined(__MINGW64__)
+#include <shlobj.h>
+#else
#include <ShlObj.h>
+#endif
#include "../Common/MyString.h"
#include "Defs.h"
-namespace NWindows{
-namespace NShell{
+namespace NWindows {
+namespace NShell {
/////////////////////////
// CItemIDList
@@ -20,6 +25,7 @@ namespace NShell{
class CItemIDList
{
LPITEMIDLIST m_Object;
+ Z7_CLASS_NO_COPY(CItemIDList)
public:
CItemIDList(): m_Object(NULL) {}
// CItemIDList(LPCITEMIDLIST itemIDList);
@@ -49,6 +55,7 @@ public:
/////////////////////////////
// CDrop
+/*
class CDrop
{
HDROP m_Object;
@@ -63,22 +70,51 @@ public:
operator HDROP() { return m_Object;}
bool QueryPoint(LPPOINT point)
{ return BOOLToBool(::DragQueryPoint(m_Object, point)); }
- void Finish() { ::DragFinish(m_Object); }
- UINT QueryFile(UINT fileIndex, LPTSTR fileName, UINT fileNameSize)
- { return ::DragQueryFile(m_Object, fileIndex, fileName, fileNameSize); }
+ void Finish()
+ {
+ ::DragFinish(m_Object);
+ }
+ UINT QueryFile(UINT fileIndex, LPTSTR fileName, UINT bufSize)
+ { return ::DragQueryFile(m_Object, fileIndex, fileName, bufSize); }
#ifndef _UNICODE
- UINT QueryFile(UINT fileIndex, LPWSTR fileName, UINT fileNameSize)
- { return ::DragQueryFileW(m_Object, fileIndex, fileName, fileNameSize); }
+ UINT QueryFile(UINT fileIndex, LPWSTR fileName, UINT bufSize)
+ { return ::DragQueryFileW(m_Object, fileIndex, fileName, bufSize); }
#endif
UINT QueryCountOfFiles();
- UString QueryFileName(UINT fileIndex);
+ void QueryFileName(UINT fileIndex, UString &fileName);
void QueryFileNames(UStringVector &fileNames);
};
-
+*/
#endif
-/////////////////////////////
-// Functions
+struct CFileAttribs
+{
+ int FirstDirIndex;
+ // DWORD Sum;
+ // DWORD Product;
+ // CRecordVector<DWORD> Vals;
+ // CRecordVector<bool> IsDirVector;
+
+ CFileAttribs()
+ {
+ Clear();
+ }
+
+ void Clear()
+ {
+ FirstDirIndex = -1;
+ // Sum = 0;
+ // Product = 0;
+ // IsDirVector.Clear();
+ }
+};
+
+
+/* read pathnames from HDROP or SHELLIDLIST.
+ The parser can return E_INVALIDARG, if there is some unexpected data in dataObject */
+HRESULT DataObject_GetData_HDROP_or_IDLIST_Names(IDataObject *dataObject, UStringVector &names);
+
+HRESULT DataObject_GetData_FILE_ATTRS(IDataObject *dataObject, CFileAttribs &attribs);
bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path);
bool BrowseForFolder(LPBROWSEINFO lpbi, CSysString &resultPath);
diff --git a/3rdparty/lzma/CPP/Windows/StdAfx.h b/3rdparty/lzma/CPP/Windows/StdAfx.h
index 1766dfa860a..bd5084fdbfe 100644
--- a/3rdparty/lzma/CPP/Windows/StdAfx.h
+++ b/3rdparty/lzma/CPP/Windows/StdAfx.h
@@ -1,7 +1,11 @@
// StdAfx.h
-#ifndef __STDAFX_H
-#define __STDAFX_H
+#ifndef ZIP7_INC_STDAFX_H
+#define ZIP7_INC_STDAFX_H
+
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+#pragma warning(disable : 4464) // relative include path contains '..'
+#endif
#include "../Common/Common.h"
diff --git a/3rdparty/lzma/CPP/Windows/Synchronization.cpp b/3rdparty/lzma/CPP/Windows/Synchronization.cpp
index fbf919dcbda..d5542af4864 100644
--- a/3rdparty/lzma/CPP/Windows/Synchronization.cpp
+++ b/3rdparty/lzma/CPP/Windows/Synchronization.cpp
@@ -19,6 +19,30 @@ namespace NSynchronization {
DWORD WaitForMultipleObjects(DWORD count, const HANDLE *handles, BOOL wait_all, DWORD timeout);
*/
+/* clang: we need to place some virtual functions in cpp file to rid off the warning:
+ 'CBaseHandle_WFMO' has no out-of-line virtual method definitions;
+ its vtable will be emitted in every translation unit */
+CBaseHandle_WFMO::~CBaseHandle_WFMO()
+{
+}
+
+bool CBaseEvent_WFMO::IsSignaledAndUpdate()
+{
+ if (this->_state == false)
+ return false;
+ if (this->_manual_reset == false)
+ this->_state = false;
+ return true;
+}
+
+bool CSemaphore_WFMO::IsSignaledAndUpdate()
+{
+ if (this->_count == 0)
+ return false;
+ this->_count--;
+ return true;
+}
+
DWORD WINAPI WaitForMultiObj_Any_Infinite(DWORD count, const CHandle_WFMO *handles)
{
if (count < 1)
diff --git a/3rdparty/lzma/CPP/Windows/Synchronization.h b/3rdparty/lzma/CPP/Windows/Synchronization.h
index 7d2e8d2aef2..afd03d2cb06 100644
--- a/3rdparty/lzma/CPP/Windows/Synchronization.h
+++ b/3rdparty/lzma/CPP/Windows/Synchronization.h
@@ -1,7 +1,7 @@
// Windows/Synchronization.h
-#ifndef __WINDOWS_SYNCHRONIZATION_H
-#define __WINDOWS_SYNCHRONIZATION_H
+#ifndef ZIP7_INC_WINDOWS_SYNCHRONIZATION_H
+#define ZIP7_INC_WINDOWS_SYNCHRONIZATION_H
#include "../../C/Threads.h"
@@ -32,14 +32,14 @@ public:
WRes Create(bool manualReset, bool initiallyOwn, LPCTSTR name = NULL, LPSECURITY_ATTRIBUTES sa = NULL)
{
_object = ::CreateEvent(sa, BoolToBOOL(manualReset), BoolToBOOL(initiallyOwn), name);
- if (name == NULL && _object != 0)
+ if (name == NULL && _object != NULL)
return 0;
return ::GetLastError();
}
WRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name)
{
_object = ::OpenEvent(desiredAccess, BoolToBOOL(inheritHandle), name);
- if (_object != 0)
+ if (_object != NULL)
return 0;
return ::GetLastError();
}
@@ -227,8 +227,8 @@ public:
}
WRes Create()
{
- RINOK(::pthread_mutex_init(&_mutex, 0));
- WRes ret = ::pthread_cond_init(&_cond, 0);
+ RINOK(::pthread_mutex_init(&_mutex, NULL))
+ const WRes ret = ::pthread_cond_init(&_cond, NULL);
_isValid = 1;
return ret;
}
@@ -246,8 +246,8 @@ public:
}
WRes LeaveAndSignal()
{
- WRes res1 = ::pthread_cond_broadcast(&_cond);
- WRes res2 = ::pthread_mutex_unlock(&_mutex);
+ const WRes res1 = ::pthread_cond_broadcast(&_cond);
+ const WRes res2 = ::pthread_mutex_unlock(&_mutex);
return (res2 ? res2 : res1);
}
};
@@ -268,6 +268,7 @@ struct CBaseHandle_WFMO MY_UNCOPYABLE
CSynchro *_sync;
CBaseHandle_WFMO(): _sync(NULL) {}
+ virtual ~CBaseHandle_WFMO();
operator CHandle_WFMO() { return this; }
virtual bool IsSignaledAndUpdate() = 0;
@@ -283,7 +284,7 @@ public:
// bool IsCreated() { return (this->_sync != NULL); }
// CBaseEvent_WFMO() { ; }
- ~CBaseEvent_WFMO() { Close(); }
+ // ~CBaseEvent_WFMO() Z7_override { Close(); }
WRes Close() { this->_sync = NULL; return 0; }
@@ -299,37 +300,30 @@ public:
WRes Set()
{
- RINOK(this->_sync->Enter());
+ RINOK(this->_sync->Enter())
this->_state = true;
return this->_sync->LeaveAndSignal();
}
WRes Reset()
{
- RINOK(this->_sync->Enter());
+ RINOK(this->_sync->Enter())
this->_state = false;
return this->_sync->Leave();
}
- virtual bool IsSignaledAndUpdate()
- {
- if (this->_state == false)
- return false;
- if (this->_manual_reset == false)
- this->_state = false;
- return true;
- }
+ virtual bool IsSignaledAndUpdate() Z7_override;
};
-class CManualResetEvent_WFMO: public CBaseEvent_WFMO
+class CManualResetEvent_WFMO Z7_final: public CBaseEvent_WFMO
{
public:
WRes Create(CSynchro *sync, bool initiallyOwn = false) { return CBaseEvent_WFMO::Create(sync, true, initiallyOwn); }
};
-class CAutoResetEvent_WFMO: public CBaseEvent_WFMO
+class CAutoResetEvent_WFMO Z7_final: public CBaseEvent_WFMO
{
public:
WRes Create(CSynchro *sync) { return CBaseEvent_WFMO::Create(sync, false, false); }
@@ -340,7 +334,7 @@ public:
};
-class CSemaphore_WFMO : public CBaseHandle_WFMO
+class CSemaphore_WFMO Z7_final: public CBaseHandle_WFMO
{
UInt32 _count;
UInt32 _maxCount;
@@ -365,11 +359,11 @@ public:
if (releaseCount < 1)
return EINVAL;
- RINOK(this->_sync->Enter());
+ RINOK(this->_sync->Enter())
UInt32 newCount = this->_count + releaseCount;
if (newCount > this->_maxCount)
{
- RINOK(this->_sync->Leave());
+ RINOK(this->_sync->Leave())
return ERROR_TOO_MANY_POSTS; // EINVAL
}
this->_count = newCount;
@@ -377,13 +371,7 @@ public:
return this->_sync->LeaveAndSignal();
}
- virtual bool IsSignaledAndUpdate()
- {
- if (this->_count == 0)
- return false;
- this->_count--;
- return true;
- }
+ virtual bool IsSignaledAndUpdate() Z7_override;
};
#endif // _WIN32
diff --git a/3rdparty/lzma/CPP/Windows/System.cpp b/3rdparty/lzma/CPP/Windows/System.cpp
index 3a14b77ddd2..dbe287a0c45 100644
--- a/3rdparty/lzma/CPP/Windows/System.cpp
+++ b/3rdparty/lzma/CPP/Windows/System.cpp
@@ -4,6 +4,7 @@
#ifndef _WIN32
#include <unistd.h>
+#include <limits.h>
#ifdef __APPLE__
#include <sys/sysctl.h>
#else
@@ -74,7 +75,7 @@ BOOL CProcessAffinity::Get()
return TRUE;
*/
- #ifdef _7ZIP_AFFINITY_SUPPORTED
+ #ifdef Z7_AFFINITY_SUPPORTED
// numSysThreads = sysconf(_SC_NPROCESSORS_ONLN); // The number of processors currently online
if (sched_getaffinity(0, sizeof(cpu_set), &cpu_set) != 0)
@@ -93,7 +94,7 @@ BOOL CProcessAffinity::Get()
UInt32 GetNumberOfProcessors()
{
- #ifndef _7ZIP_ST
+ #ifndef Z7_ST
long n = sysconf(_SC_NPROCESSORS_CONF); // The number of processors configured
if (n < 1)
n = 1;
@@ -110,7 +111,8 @@ UInt32 GetNumberOfProcessors()
#ifndef UNDER_CE
-#if !defined(_WIN64) && defined(__GNUC__)
+#if !defined(_WIN64) && \
+ (defined(__MINGW32_VERSION) || defined(Z7_OLD_WIN_SDK))
typedef struct _MY_MEMORYSTATUSEX {
DWORD dwLength;
@@ -131,7 +133,7 @@ typedef struct _MY_MEMORYSTATUSEX {
#endif
-typedef BOOL (WINAPI *GlobalMemoryStatusExP)(MY_LPMEMORYSTATUSEX lpBuffer);
+typedef BOOL (WINAPI *Func_GlobalMemoryStatusEx)(MY_LPMEMORYSTATUSEX lpBuffer);
#endif // !UNDER_CE
@@ -155,9 +157,11 @@ bool GetRamSize(UInt64 &size)
#else
#ifndef UNDER_CE
- GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
- (void *)::GetProcAddress(::GetModuleHandleA("kernel32.dll"), "GlobalMemoryStatusEx");
- if (globalMemoryStatusEx && globalMemoryStatusEx(&stat))
+ const
+ Func_GlobalMemoryStatusEx fn = Z7_GET_PROC_ADDRESS(
+ Func_GlobalMemoryStatusEx, ::GetModuleHandleA("kernel32.dll"),
+ "GlobalMemoryStatusEx");
+ if (fn && fn(&stat))
{
size = MyMin(stat.ullTotalVirtual, stat.ullTotalPhys);
return true;
@@ -231,4 +235,44 @@ bool GetRamSize(UInt64 &size)
#endif
+
+unsigned long Get_File_OPEN_MAX()
+{
+ #ifdef _WIN32
+ return (1 << 24) - (1 << 16); // ~16M handles
+ #else
+ // some linux versions have default open file limit for user process of 1024 files.
+ long n = sysconf(_SC_OPEN_MAX);
+ // n = -1; // for debug
+ // n = 9; // for debug
+ if (n < 1)
+ {
+ // n = OPEN_MAX; // ???
+ // n = FOPEN_MAX; // = 16 : <stdio.h>
+ #ifdef _POSIX_OPEN_MAX
+ n = _POSIX_OPEN_MAX; // = 20 : <limits.h>
+ #else
+ n = 30; // our limit
+ #endif
+ }
+ return (unsigned long)n;
+ #endif
+}
+
+unsigned Get_File_OPEN_MAX_Reduced_for_3_tasks()
+{
+ unsigned long numFiles_OPEN_MAX = NSystem::Get_File_OPEN_MAX();
+ const unsigned delta = 10; // the reserve for another internal needs of process
+ if (numFiles_OPEN_MAX > delta)
+ numFiles_OPEN_MAX -= delta;
+ else
+ numFiles_OPEN_MAX = 1;
+ numFiles_OPEN_MAX /= 3; // we suppose that we have up to 3 tasks in total for multiple file processing
+ numFiles_OPEN_MAX = MyMax(numFiles_OPEN_MAX, (unsigned long)3);
+ unsigned n = (UInt32)(UInt32)-1;
+ if (n > numFiles_OPEN_MAX)
+ n = (unsigned)numFiles_OPEN_MAX;
+ return n;
+}
+
}}
diff --git a/3rdparty/lzma/CPP/Windows/System.h b/3rdparty/lzma/CPP/Windows/System.h
index 23cb0dabcb0..06500074c7a 100644
--- a/3rdparty/lzma/CPP/Windows/System.h
+++ b/3rdparty/lzma/CPP/Windows/System.h
@@ -1,7 +1,7 @@
// Windows/System.h
-#ifndef __WINDOWS_SYSTEM_H
-#define __WINDOWS_SYSTEM_H
+#ifndef ZIP7_INC_WINDOWS_SYSTEM_H
+#define ZIP7_INC_WINDOWS_SYSTEM_H
#ifndef _WIN32
// #include <sched.h>
@@ -9,11 +9,11 @@
#endif
#include "../Common/MyTypes.h"
+#include "../Common/MyWindows.h"
namespace NWindows {
namespace NSystem {
-
#ifdef _WIN32
UInt32 CountAffinity(DWORD_PTR mask);
@@ -64,7 +64,7 @@ struct CProcessAffinity
UInt32 GetNumSystemThreads() const { return (UInt32)numSysThreads; }
BOOL Get();
- #ifdef _7ZIP_AFFINITY_SUPPORTED
+ #ifdef Z7_AFFINITY_SUPPORTED
CCpuSet cpu_set;
@@ -86,7 +86,7 @@ struct CProcessAffinity
return sched_setaffinity(0, sizeof(cpu_set), &cpu_set) == 0;
}
- #else
+ #else // Z7_AFFINITY_SUPPORTED
void InitST()
{
@@ -114,16 +114,19 @@ struct CProcessAffinity
return FALSE;
}
- #endif
+ #endif // Z7_AFFINITY_SUPPORTED
};
-#endif
+#endif // _WIN32
UInt32 GetNumberOfProcessors();
bool GetRamSize(UInt64 &size); // returns false, if unknown ram size
+unsigned long Get_File_OPEN_MAX();
+unsigned Get_File_OPEN_MAX_Reduced_for_3_tasks();
+
}}
#endif
diff --git a/3rdparty/lzma/CPP/Windows/SystemInfo.cpp b/3rdparty/lzma/CPP/Windows/SystemInfo.cpp
index d882a8ee404..6bafc8046b3 100644
--- a/3rdparty/lzma/CPP/Windows/SystemInfo.cpp
+++ b/3rdparty/lzma/CPP/Windows/SystemInfo.cpp
@@ -102,38 +102,44 @@ static void PrintHex(AString &s, UInt64 v)
#ifdef MY_CPU_X86_OR_AMD64
+Z7_NO_INLINE
static void PrintCpuChars(AString &s, UInt32 v)
{
- for (int j = 0; j < 4; j++)
+ for (unsigned j = 0; j < 4; j++)
{
Byte b = (Byte)(v & 0xFF);
v >>= 8;
if (b == 0)
break;
- s += (char)b;
+ if (b >= 0x20 && b <= 0x7f)
+ s += (char)b;
+ else
+ {
+ s += '[';
+ char temp[16];
+ ConvertUInt32ToHex(b, temp);
+ s += temp;
+ s += ']';
+ }
}
}
-static void x86cpuid_to_String(const Cx86cpuid &c, AString &s, AString &ver)
+static void x86cpuid_to_String(AString &s)
{
s.Empty();
- UInt32 maxFunc2 = 0;
- UInt32 t[3];
+ UInt32 a[4];
+ // cpuid was called already. So we don't check for cpuid availability here
+ z7_x86_cpuid(a, 0x80000000);
- MyCPUID(0x80000000, &maxFunc2, &t[0], &t[1], &t[2]);
-
- bool fullNameIsAvail = (maxFunc2 >= 0x80000004);
-
- if (fullNameIsAvail)
+ if (a[0] >= 0x80000004) // if (maxFunc2 >= hi+4) the full name is available
{
for (unsigned i = 0; i < 3; i++)
{
- UInt32 d[4] = { 0 };
- MyCPUID(0x80000002 + i, &d[0], &d[1], &d[2], &d[3]);
+ z7_x86_cpuid(a, 0x80000002 + i);
for (unsigned j = 0; j < 4; j++)
- PrintCpuChars(s, d[j]);
+ PrintCpuChars(s, a[j]);
}
}
@@ -141,16 +147,14 @@ static void x86cpuid_to_String(const Cx86cpuid &c, AString &s, AString &ver)
if (s.IsEmpty())
{
- for (int i = 0; i < 3; i++)
- PrintCpuChars(s, c.vendor[i]);
+ z7_x86_cpuid(a, 0);
+ for (unsigned i = 1; i < 4; i++)
+ {
+ const unsigned j = (i ^ (i >> 1));
+ PrintCpuChars(s, a[j]);
+ }
s.Trim();
}
-
- {
- char temp[32];
- ConvertUInt32ToHex(c.ver, temp);
- ver += temp;
- }
}
/*
@@ -184,7 +188,7 @@ static void x86cpuid_all_to_String(AString &s)
{
char temp[32];
ConvertUInt32ToHex8Digits(d[i], temp);
- s += " ";
+ s.Add_Space();
s += temp;
}
}
@@ -215,12 +219,12 @@ static const char * const k_PROCESSOR_ARCHITECTURE[] =
, "ARM32_ON_WIN64"
};
-#define MY__PROCESSOR_ARCHITECTURE_INTEL 0
-#define MY__PROCESSOR_ARCHITECTURE_AMD64 9
+#define Z7_WIN_PROCESSOR_ARCHITECTURE_INTEL 0
+#define Z7_WIN_PROCESSOR_ARCHITECTURE_AMD64 9
-#define MY__PROCESSOR_INTEL_PENTIUM 586
-#define MY__PROCESSOR_AMD_X8664 8664
+#define Z7_WIN_PROCESSOR_INTEL_PENTIUM 586
+#define Z7_WIN_PROCESSOR_AMD_X8664 8664
/*
static const CUInt32PCharPair k_PROCESSOR[] =
@@ -303,19 +307,20 @@ static const char * const k_PF[] =
#endif
-#ifdef _WIN32
-
-static void PrintPage(AString &s, UInt32 v)
+static void PrintPage(AString &s, UInt64 v)
{
- if ((v & 0x3FF) == 0)
+ const char *t = "B";
+ if ((v & 0x3ff) == 0)
{
- s.Add_UInt32(v >> 10);
- s += "K";
+ v >>= 10;
+ t = "KB";
}
- else
- s.Add_UInt32(v >> 10);
+ s.Add_UInt64(v);
+ s += t;
}
+#ifdef _WIN32
+
static AString TypeToString2(const char * const table[], unsigned num, UInt32 value)
{
char sz[16];
@@ -330,7 +335,7 @@ static AString TypeToString2(const char * const table[], unsigned num, UInt32 va
return (AString)p;
}
-// #if defined(_7ZIP_LARGE_PAGES) || defined(_WIN32)
+// #if defined(Z7_LARGE_PAGES) || defined(_WIN32)
// #ifdef _WIN32
void PrintSize_KMGT_Or_Hex(AString &s, UInt64 v)
{
@@ -342,32 +347,32 @@ void PrintSize_KMGT_Or_Hex(AString &s, UInt64 v)
}}}}
else
{
+ // s += "0x";
PrintHex(s, v);
return;
}
- char temp[32];
- ConvertUInt64ToString(v, temp);
- s += temp;
+ s.Add_UInt64(v);
if (c)
s += c;
+ s += 'B';
}
// #endif
// #endif
static void SysInfo_To_String(AString &s, const SYSTEM_INFO &si)
{
- s += TypeToString2(k_PROCESSOR_ARCHITECTURE, ARRAY_SIZE(k_PROCESSOR_ARCHITECTURE), si.wProcessorArchitecture);
+ s += TypeToString2(k_PROCESSOR_ARCHITECTURE, Z7_ARRAY_SIZE(k_PROCESSOR_ARCHITECTURE), si.wProcessorArchitecture);
- if (!( (si.wProcessorArchitecture == MY__PROCESSOR_ARCHITECTURE_INTEL && si.dwProcessorType == MY__PROCESSOR_INTEL_PENTIUM)
- || (si.wProcessorArchitecture == MY__PROCESSOR_ARCHITECTURE_AMD64 && si.dwProcessorType == MY__PROCESSOR_AMD_X8664)))
+ if (!( (si.wProcessorArchitecture == Z7_WIN_PROCESSOR_ARCHITECTURE_INTEL && si.dwProcessorType == Z7_WIN_PROCESSOR_INTEL_PENTIUM)
+ || (si.wProcessorArchitecture == Z7_WIN_PROCESSOR_ARCHITECTURE_AMD64 && si.dwProcessorType == Z7_WIN_PROCESSOR_AMD_X8664)))
{
- s += " ";
- // s += TypePairToString(k_PROCESSOR, ARRAY_SIZE(k_PROCESSOR), si.dwProcessorType);
+ s.Add_Space();
+ // s += TypePairToString(k_PROCESSOR, Z7_ARRAY_SIZE(k_PROCESSOR), si.dwProcessorType);
s.Add_UInt32(si.dwProcessorType);
}
- s += " ";
+ s.Add_Space();
PrintHex(s, si.wProcessorLevel);
- s += ".";
+ s.Add_Dot();
PrintHex(s, si.wProcessorRevision);
if ((UInt64)si.dwActiveProcessorMask + 1 != ((UInt64)1 << si.dwNumberOfProcessors))
if ((UInt64)si.dwActiveProcessorMask + 1 != 0 || si.dwNumberOfProcessors != sizeof(UInt64) * 8)
@@ -387,9 +392,9 @@ static void SysInfo_To_String(AString &s, const SYSTEM_INFO &si)
s += " gran:";
PrintPage(s, si.dwAllocationGranularity);
}
- s += " ";
+ s.Add_Space();
- DWORD_PTR minAdd = (DWORD_PTR)si.lpMinimumApplicationAddress;
+ const DWORD_PTR minAdd = (DWORD_PTR)si.lpMinimumApplicationAddress;
UInt64 maxSize = (UInt64)(DWORD_PTR)si.lpMaximumApplicationAddress + 1;
const UInt32 kReserveSize = ((UInt32)1 << 16);
if (minAdd != kReserveSize)
@@ -419,7 +424,7 @@ static void Add_sysctlbyname_to_String(const char *name, AString &s)
{
size_t bufSize = 256;
char buf[256];
- if (My_sysctlbyname_Get(name, &buf, &bufSize) == 0)
+ if (z7_sysctlbyname_Get(name, &buf, &bufSize) == 0)
s += buf;
}
#endif
@@ -440,12 +445,14 @@ void GetSysInfo(AString &s1, AString &s2)
}
#if !defined(_WIN64) && !defined(UNDER_CE)
- Func_GetNativeSystemInfo fn_GetNativeSystemInfo = (Func_GetNativeSystemInfo)(void *)GetProcAddress(
- GetModuleHandleA("kernel32.dll"), "GetNativeSystemInfo");
- if (fn_GetNativeSystemInfo)
+ const
+ Func_GetNativeSystemInfo fn = Z7_GET_PROC_ADDRESS(
+ Func_GetNativeSystemInfo, GetModuleHandleA("kernel32.dll"),
+ "GetNativeSystemInfo");
+ if (fn)
{
SYSTEM_INFO si2;
- fn_GetNativeSystemInfo(&si2);
+ fn(&si2);
// if (memcmp(&si, &si2, sizeof(si)) != 0)
{
// s += " - ";
@@ -500,18 +507,20 @@ void CCpuName::Fill()
#ifdef MY_CPU_X86_OR_AMD64
{
- Cx86cpuid cpuid;
- if (x86cpuid_CheckAndRead(&cpuid))
- {
- x86cpuid_to_String(cpuid, s, Revision);
- }
+ #if !defined(MY_CPU_AMD64)
+ if (!z7_x86_cpuid_GetMaxFunc())
+ s += "x86";
else
- {
- #ifdef MY_CPU_AMD64
- s += "x64";
- #else
- s += "x86";
#endif
+ {
+ x86cpuid_to_String(s);
+ {
+ UInt32 a[4];
+ z7_x86_cpuid(a, 1);
+ char temp[16];
+ ConvertUInt32ToHex(a[0], temp);
+ Revision += temp;
+ }
}
}
#elif defined(__APPLE__)
@@ -534,12 +543,12 @@ void CCpuName::Fill()
{
AString s2;
UInt32 v = 0;
- if (My_sysctlbyname_Get_UInt32("machdep.cpu.core_count", &v) == 0)
+ if (z7_sysctlbyname_Get_UInt32("machdep.cpu.core_count", &v) == 0)
{
s2.Add_UInt32(v);
s2 += 'C';
}
- if (My_sysctlbyname_Get_UInt32("machdep.cpu.thread_count", &v) == 0)
+ if (z7_sysctlbyname_Get_UInt32("machdep.cpu.thread_count", &v) == 0)
{
s2.Add_UInt32(v);
s2 += 'T';
@@ -561,7 +570,7 @@ void CCpuName::Fill()
LONG res[2];
CByteBuffer bufs[2];
{
- for (int i = 0; i < 2; i++)
+ for (unsigned i = 0; i < 2; i++)
{
UInt32 size = 0;
res[i] = key.QueryValue(i == 0 ?
@@ -574,7 +583,7 @@ void CCpuName::Fill()
}
if (res[0] == ERROR_SUCCESS || res[1] == ERROR_SUCCESS)
{
- for (int i = 0; i < 2; i++)
+ for (unsigned i = 0; i < 2; i++)
{
if (i == 1)
Microcode += "->";
@@ -598,7 +607,7 @@ void CCpuName::Fill()
#endif
- #ifdef _7ZIP_LARGE_PAGES
+ #ifdef Z7_LARGE_PAGES
Add_LargePages_String(LargePages);
#endif
}
@@ -608,7 +617,7 @@ void AddCpuFeatures(AString &s)
{
#ifdef _WIN32
// const unsigned kNumFeatures_Extra = 32; // we check also for unknown features
- // const unsigned kNumFeatures = ARRAY_SIZE(k_PF) + kNumFeatures_Extra;
+ // const unsigned kNumFeatures = Z7_ARRAY_SIZE(k_PF) + kNumFeatures_Extra;
const unsigned kNumFeatures = 64;
UInt64 flags = 0;
for (unsigned i = 0; i < kNumFeatures; i++)
@@ -617,7 +626,7 @@ void AddCpuFeatures(AString &s)
{
flags += (UInt64)1 << i;
// s.Add_Space_if_NotEmpty();
- // s += TypeToString2(k_PF, ARRAY_SIZE(k_PF), i);
+ // s += TypeToString2(k_PF, Z7_ARRAY_SIZE(k_PF), i);
}
}
s.Add_OptSpaced("f:");
@@ -626,11 +635,10 @@ void AddCpuFeatures(AString &s)
#elif defined(__APPLE__)
{
UInt32 v = 0;
- if (My_sysctlbyname_Get_UInt32("hw.pagesize", &v) == 0)
+ if (z7_sysctlbyname_Get_UInt32("hw.pagesize", &v) == 0)
{
- s += "PageSize:";
- s.Add_UInt32(v >> 10);
- s += "KB";
+ s.Add_OptSpaced("PageSize:");
+ PrintPage(s, v);
}
}
@@ -639,10 +647,8 @@ void AddCpuFeatures(AString &s)
const long v = sysconf(_SC_PAGESIZE);
if (v != -1)
{
- s.Add_Space_if_NotEmpty();
- s += "PageSize:";
- s.Add_UInt32((UInt32)(v >> 10));
- s += "KB";
+ s.Add_OptSpaced("PageSize:");
+ PrintPage(s, (unsigned long)v);
}
#if !defined(_AIX)
@@ -659,11 +665,11 @@ void AddCpuFeatures(AString &s)
const int pos = s2.Find('[');
if (pos >= 0)
{
- const int pos2 = s2.Find(']', pos + 1);
+ const int pos2 = s2.Find(']', (unsigned)pos + 1);
if (pos2 >= 0)
{
- s2.DeleteFrom(pos2);
- s2.DeleteFrontal(pos + 1);
+ s2.DeleteFrom((unsigned)pos2);
+ s2.DeleteFrontal((unsigned)pos + 1);
}
}
s += s2;
@@ -722,10 +728,13 @@ EXTERN_C_END
static BOOL My_RtlGetVersion(OSVERSIONINFOEXW *vi)
{
- HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll");
+ const HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll");
if (!ntdll)
return FALSE;
- Func_RtlGetVersion func = (Func_RtlGetVersion)(void *)GetProcAddress(ntdll, "RtlGetVersion");
+ const
+ Func_RtlGetVersion func = Z7_GET_PROC_ADDRESS(
+ Func_RtlGetVersion, ntdll,
+ "RtlGetVersion");
if (!func)
return FALSE;
func(vi);
@@ -752,18 +761,18 @@ void GetOsInfoText(AString &sRes)
s += "Windows";
if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT)
s.Add_UInt32(vi.dwPlatformId);
- s += " "; s.Add_UInt32(vi.dwMajorVersion);
- s += "."; s.Add_UInt32(vi.dwMinorVersion);
- s += " "; s.Add_UInt32(vi.dwBuildNumber);
+ s.Add_Space(); s.Add_UInt32(vi.dwMajorVersion);
+ s.Add_Dot(); s.Add_UInt32(vi.dwMinorVersion);
+ s.Add_Space(); s.Add_UInt32(vi.dwBuildNumber);
if (vi.wServicePackMajor != 0 || vi.wServicePackMinor != 0)
{
s += " SP:"; s.Add_UInt32(vi.wServicePackMajor);
- s += "."; s.Add_UInt32(vi.wServicePackMinor);
+ s.Add_Dot(); s.Add_UInt32(vi.wServicePackMinor);
}
// s += " Suite:"; PrintHex(s, vi.wSuiteMask);
// s += " Type:"; s.Add_UInt32(vi.wProductType);
- // s += " "; s += GetOemString(vi.szCSDVersion);
+ // s.Add_Space(); s += GetOemString(vi.szCSDVersion);
}
/*
{
@@ -793,6 +802,17 @@ void GetOsInfoText(AString &sRes)
#endif // _WIN32
sRes += s;
+ #ifdef MY_CPU_X86_OR_AMD64
+ {
+ AString s2;
+ GetVirtCpuid(s2);
+ if (!s2.IsEmpty())
+ {
+ sRes += " : ";
+ sRes += s2;
+ }
+ }
+ #endif
}
@@ -875,6 +895,61 @@ void GetCpuName_MultiLine(AString &s)
}
}
+
+#ifdef MY_CPU_X86_OR_AMD64
+
+void GetVirtCpuid(AString &s)
+{
+ const UInt32 kHv = 0x40000000;
+
+ Z7_IF_X86_CPUID_SUPPORTED
+ {
+ UInt32 a[4];
+ z7_x86_cpuid(a, kHv);
+
+ if (a[0] < kHv || a[0] >= kHv + (1 << 16))
+ return;
+ {
+ {
+ for (unsigned j = 1; j < 4; j++)
+ PrintCpuChars(s, a[j]);
+ }
+ }
+ if (a[0] >= kHv + 1)
+ {
+ UInt32 d[4];
+ z7_x86_cpuid(d, kHv + 1);
+ s += " : ";
+ PrintCpuChars(s, d[0]);
+ if (a[0] >= kHv + 2)
+ {
+ z7_x86_cpuid(d, kHv + 2);
+ s += " : ";
+ s.Add_UInt32(d[1] >> 16);
+ s.Add_Dot(); s.Add_UInt32(d[1] & 0xffff);
+ s.Add_Dot(); s.Add_UInt32(d[0]);
+ s.Add_Dot(); s.Add_UInt32(d[2]);
+ s.Add_Dot(); s.Add_UInt32(d[3] >> 24);
+ s.Add_Dot(); s.Add_UInt32(d[3] & 0xffffff);
+ }
+ /*
+ if (a[0] >= kHv + 5)
+ {
+ z7_x86_cpuid(d, kHv + 5);
+ s += " : ";
+ s.Add_UInt32(d[0]);
+ s += "p";
+ s.Add_UInt32(d[1]);
+ s += "t";
+ }
+ */
+ }
+ }
+}
+
+#endif
+
+
void GetCompiler(AString &s)
{
#ifdef __VERSION__
@@ -884,28 +959,28 @@ void GetCompiler(AString &s)
#ifdef __GNUC__
s += " GCC ";
s.Add_UInt32(__GNUC__);
- s += '.';
+ s.Add_Dot();
s.Add_UInt32(__GNUC_MINOR__);
- s += '.';
+ s.Add_Dot();
s.Add_UInt32(__GNUC_PATCHLEVEL__);
#endif
#ifdef __clang__
s += " CLANG ";
s.Add_UInt32(__clang_major__);
- s += '.';
+ s.Add_Dot();
s.Add_UInt32(__clang_minor__);
#endif
#ifdef __xlC__
s += " XLC ";
s.Add_UInt32(__xlC__ >> 8);
- s += '.';
+ s.Add_Dot();
s.Add_UInt32(__xlC__ & 0xFF);
#ifdef __xlC_ver__
- s += '.';
+ s.Add_Dot();
s.Add_UInt32(__xlC_ver__ >> 8);
- s += '.';
+ s.Add_Dot();
s.Add_UInt32(__xlC_ver__ & 0xFF);
#endif
#endif
@@ -914,4 +989,34 @@ void GetCompiler(AString &s)
s += " MSC ";
s.Add_UInt32(_MSC_VER);
#endif
+
+ #if defined(__AVX2__)
+ #define MY_CPU_COMPILE_ISA "AVX2"
+ #elif defined(__AVX__)
+ #define MY_CPU_COMPILE_ISA "AVX"
+ #elif defined(__SSE2__)
+ #define MY_CPU_COMPILE_ISA "SSE2"
+ #elif defined(_M_IX86_FP) && (_M_IX86_FP >= 2)
+ #define MY_CPU_COMPILE_ISA "SSE2"
+ #elif defined(__SSE__)
+ #define MY_CPU_COMPILE_ISA "SSE"
+ #elif defined(_M_IX86_FP) && (_M_IX86_FP >= 1)
+ #define MY_CPU_COMPILE_ISA "SSE"
+ #elif defined(__i686__)
+ #define MY_CPU_COMPILE_ISA "i686"
+ #elif defined(__i586__)
+ #define MY_CPU_COMPILE_ISA "i586"
+ #elif defined(__i486__)
+ #define MY_CPU_COMPILE_ISA "i486"
+ #elif defined(__i386__)
+ #define MY_CPU_COMPILE_ISA "i386"
+ #elif defined(_M_IX86_FP)
+ #define MY_CPU_COMPILE_ISA "IA32"
+ #endif
+
+
+ #ifdef MY_CPU_COMPILE_ISA
+ s += ':';
+ s.Add_OptSpaced(MY_CPU_COMPILE_ISA);
+ #endif
}
diff --git a/3rdparty/lzma/CPP/Windows/SystemInfo.h b/3rdparty/lzma/CPP/Windows/SystemInfo.h
index e941d0aa418..c2e2e3b19fa 100644
--- a/3rdparty/lzma/CPP/Windows/SystemInfo.h
+++ b/3rdparty/lzma/CPP/Windows/SystemInfo.h
@@ -1,7 +1,7 @@
// Windows/SystemInfo.h
-#ifndef __WINDOWS_SYSTEM_INFO_H
-#define __WINDOWS_SYSTEM_INFO_H
+#ifndef ZIP7_INC_WINDOWS_SYSTEM_INFO_H
+#define ZIP7_INC_WINDOWS_SYSTEM_INFO_H
#include "../Common/MyString.h"
@@ -14,5 +14,6 @@ void PrintSize_KMGT_Or_Hex(AString &s, UInt64 v);
void Add_LargePages_String(AString &s);
void GetCompiler(AString &s);
+void GetVirtCpuid(AString &s);
#endif
diff --git a/3rdparty/lzma/CPP/Windows/Thread.h b/3rdparty/lzma/CPP/Windows/Thread.h
index 5fca173f00d..d72f64c47ab 100644
--- a/3rdparty/lzma/CPP/Windows/Thread.h
+++ b/3rdparty/lzma/CPP/Windows/Thread.h
@@ -1,7 +1,7 @@
// Windows/Thread.h
-#ifndef __WINDOWS_THREAD_H
-#define __WINDOWS_THREAD_H
+#ifndef ZIP7_INC_WINDOWS_THREAD_H
+#define ZIP7_INC_WINDOWS_THREAD_H
#include "../../C/Threads.h"
@@ -13,7 +13,7 @@ class CThread MY_UNCOPYABLE
{
::CThread thread;
public:
- CThread() { Thread_Construct(&thread); }
+ CThread() { Thread_CONSTRUCT(&thread) }
~CThread() { Close(); }
bool IsCreated() { return Thread_WasCreated(&thread) != 0; }
WRes Close() { return Thread_Close(&thread); }
diff --git a/3rdparty/lzma/CPP/Windows/TimeUtils.cpp b/3rdparty/lzma/CPP/Windows/TimeUtils.cpp
index 77d2c510293..e80ae13dcac 100644
--- a/3rdparty/lzma/CPP/Windows/TimeUtils.cpp
+++ b/3rdparty/lzma/CPP/Windows/TimeUtils.cpp
@@ -258,7 +258,7 @@ void GetCurUtc_FiTime(CFiTime &ft) throw()
FiTime_Clear(ft);
struct timeval now;
- if (gettimeofday(&now, 0 ) == 0)
+ if (gettimeofday(&now, NULL) == 0)
{
ft.tv_sec = now.tv_sec;
ft.tv_nsec = now.tv_usec * 1000;
@@ -272,7 +272,7 @@ void GetCurUtcFileTime(FILETIME &ft) throw()
{
UInt64 v = 0;
struct timeval now;
- if (gettimeofday(&now, 0 ) == 0)
+ if (gettimeofday(&now, NULL) == 0)
{
v = ((UInt64)now.tv_sec + kUnixTimeOffset) *
kNumTimeQuantumsInSecond + (UInt64)now.tv_usec * 10;
diff --git a/3rdparty/lzma/CPP/Windows/TimeUtils.h b/3rdparty/lzma/CPP/Windows/TimeUtils.h
index 60ee739f221..4a9d0f2fade 100644
--- a/3rdparty/lzma/CPP/Windows/TimeUtils.h
+++ b/3rdparty/lzma/CPP/Windows/TimeUtils.h
@@ -1,7 +1,7 @@
// Windows/TimeUtils.h
-#ifndef __WINDOWS_TIME_UTILS_H
-#define __WINDOWS_TIME_UTILS_H
+#ifndef ZIP7_INC_WINDOWS_TIME_UTILS_H
+#define ZIP7_INC_WINDOWS_TIME_UTILS_H
#include "../Common/MyTypes.h"
#include "../Common/MyWindows.h"
diff --git a/3rdparty/lzma/CPP/Windows/Window.cpp b/3rdparty/lzma/CPP/Windows/Window.cpp
index 32af4aabcfa..102c503a567 100644
--- a/3rdparty/lzma/CPP/Windows/Window.cpp
+++ b/3rdparty/lzma/CPP/Windows/Window.cpp
@@ -111,7 +111,7 @@ bool MySetWindowText(HWND wnd, LPCWSTR s)
}
#endif
-bool CWindow::GetText(CSysString &s)
+bool CWindow::GetText(CSysString &s) const
{
s.Empty();
unsigned len = (unsigned)GetTextLength();
@@ -119,7 +119,7 @@ bool CWindow::GetText(CSysString &s)
return (::GetLastError() == ERROR_SUCCESS);
TCHAR *p = s.GetBuf(len);
{
- unsigned len2 = (unsigned)GetText(p, (int)(len + 1));
+ const unsigned len2 = (unsigned)GetText(p, (int)(len + 1));
if (len > len2)
len = len2;
}
@@ -130,7 +130,7 @@ bool CWindow::GetText(CSysString &s)
}
#ifndef _UNICODE
-bool CWindow::GetText(UString &s)
+bool CWindow::GetText(UString &s) const
{
if (g_IsNT)
{
@@ -140,7 +140,7 @@ bool CWindow::GetText(UString &s)
return (::GetLastError() == ERROR_SUCCESS);
wchar_t *p = s.GetBuf(len);
{
- unsigned len2 = (unsigned)GetWindowTextW(_window, p, (int)(len + 1));
+ const unsigned len2 = (unsigned)GetWindowTextW(_window, p, (int)(len + 1));
if (len > len2)
len = len2;
}
@@ -150,7 +150,7 @@ bool CWindow::GetText(UString &s)
return true;
}
CSysString sysString;
- bool result = GetText(sysString);
+ const bool result = GetText(sysString);
MultiByteToUnicodeString2(s, sysString);
return result;
}
diff --git a/3rdparty/lzma/CPP/Windows/Window.h b/3rdparty/lzma/CPP/Windows/Window.h
index 83726c7ad7d..a99143bd131 100644
--- a/3rdparty/lzma/CPP/Windows/Window.h
+++ b/3rdparty/lzma/CPP/Windows/Window.h
@@ -1,7 +1,7 @@
// Windows/Window.h
-#ifndef __WINDOWS_WINDOW_H
-#define __WINDOWS_WINDOW_H
+#ifndef ZIP7_INC_WINDOWS_WINDOW_H
+#define ZIP7_INC_WINDOWS_WINDOW_H
#include "../Common/MyWindows.h"
#include "../Common/MyString.h"
@@ -9,23 +9,100 @@
#include "Defs.h"
#ifndef UNDER_CE
+#ifdef WM_CHANGEUISTATE
+#define Z7_WIN_WM_CHANGEUISTATE WM_CHANGEUISTATE
+#define Z7_WIN_WM_UPDATEUISTATE WM_UPDATEUISTATE
+#define Z7_WIN_WM_QUERYUISTATE WM_QUERYUISTATE
+#else
+// these are defined for (_WIN32_WINNT >= 0x0500):
+#define Z7_WIN_WM_CHANGEUISTATE 0x0127
+#define Z7_WIN_WM_UPDATEUISTATE 0x0128
+#define Z7_WIN_WM_QUERYUISTATE 0x0129
+#endif
+
+#ifdef UIS_SET
-#define MY__WM_CHANGEUISTATE 0x0127
-#define MY__WM_UPDATEUISTATE 0x0128
-#define MY__WM_QUERYUISTATE 0x0129
+#define Z7_WIN_UIS_SET UIS_SET
+#define Z7_WIN_UIS_CLEAR UIS_CLEAR
+#define Z7_WIN_UIS_INITIALIZE UIS_INITIALIZE
+#define Z7_WIN_UISF_HIDEFOCUS UISF_HIDEFOCUS
+#define Z7_WIN_UISF_HIDEACCEL UISF_HIDEACCEL
+
+#else
+// these are defined for (_WIN32_WINNT >= 0x0500):
// LOWORD(wParam) values in WM_*UISTATE
-#define MY__UIS_SET 1
-#define MY__UIS_CLEAR 2
-#define MY__UIS_INITIALIZE 3
+#define Z7_WIN_UIS_SET 1
+#define Z7_WIN_UIS_CLEAR 2
+#define Z7_WIN_UIS_INITIALIZE 3
// HIWORD(wParam) values in WM_*UISTATE
-#define MY__UISF_HIDEFOCUS 0x1
-#define MY__UISF_HIDEACCEL 0x2
-#define MY__UISF_ACTIVE 0x4
+#define Z7_WIN_UISF_HIDEFOCUS 0x1
+#define Z7_WIN_UISF_HIDEACCEL 0x2
+// defined for for (_WIN32_WINNT >= 0x0501):
+// #define Z7_WIN_UISF_ACTIVE 0x4
#endif
+#endif // UNDER_CE
+
+
+#ifdef Z7_OLD_WIN_SDK
+
+// #define VK_OEM_1 0xBA // ';:' for US
+#define VK_OEM_PLUS 0xBB // '+' any country
+// #define VK_OEM_COMMA 0xBC // ',' any country
+#define VK_OEM_MINUS 0xBD // '-' any country
+// #define VK_OEM_PERIOD 0xBE // '.' any country
+// #define VK_OEM_2 0xBF // '/?' for US
+// #define VK_OEM_3 0xC0 // '`~' for US
+
+// #ifndef GWLP_USERDATA
+#define GWLP_WNDPROC (-4)
+#define GWLP_USERDATA (-21)
+// #endif
+#define DWLP_MSGRESULT 0
+// #define DWLP_DLGPROC DWLP_MSGRESULT + sizeof(LRESULT)
+// #define DWLP_USER DWLP_DLGPROC + sizeof(DLGPROC)
+
+#define BTNS_BUTTON TBSTYLE_BUTTON // 0x0000
+
+/*
+vc6 defines INT_PTR via long:
+ typedef long INT_PTR, *PINT_PTR;
+ typedef unsigned long UINT_PTR, *PUINT_PTR;
+but newer sdk (sdk2003+) defines INT_PTR via int:
+ typedef _W64 int INT_PTR, *PINT_PTR;
+ typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
+*/
+
+#define IS_INTRESOURCE(_r) (((ULONG_PTR)(_r) >> 16) == 0)
+
+#define GetWindowLongPtrA GetWindowLongA
+#define GetWindowLongPtrW GetWindowLongW
+#ifdef UNICODE
+#define GetWindowLongPtr GetWindowLongPtrW
+#else
+#define GetWindowLongPtr GetWindowLongPtrA
+#endif // !UNICODE
+
+#define SetWindowLongPtrA SetWindowLongA
+#define SetWindowLongPtrW SetWindowLongW
+#ifdef UNICODE
+#define SetWindowLongPtr SetWindowLongPtrW
+#else
+#define SetWindowLongPtr SetWindowLongPtrA
+#endif // !UNICODE
+
+#define ListView_SetCheckState(hwndLV, i, fCheck) \
+ ListView_SetItemState(hwndLV, i, INDEXTOSTATEIMAGEMASK((fCheck)?2:1), LVIS_STATEIMAGEMASK)
+
+#endif // Z7_OLD_WIN_SDK
+
+inline bool LRESULTToBool(LRESULT v) { return (v != FALSE); }
+
+#define MY_int_TO_WPARAM(i) ((WPARAM)(INT_PTR)(i))
+
namespace NWindows {
inline ATOM MyRegisterClass(CONST WNDCLASS *wndClass)
@@ -52,12 +129,13 @@ bool MySetWindowText(HWND wnd, LPCWSTR s);
class CWindow
{
+ Z7_CLASS_NO_COPY(CWindow)
private:
- // bool ModifyStyleBase(int styleOffset, DWORD remove, DWORD add, UINT flags);
+ // bool ModifyStyleBase(int styleOffset, DWORD remove, DWORD add, UINT flags);
protected:
HWND _window;
public:
- CWindow(HWND newWindow = NULL): _window(newWindow){};
+ CWindow(HWND newWindow = NULL): _window(newWindow) {}
CWindow& operator=(HWND newWindow)
{
_window = newWindow;
@@ -174,6 +252,7 @@ public:
void SetRedraw(bool redraw = true) { SendMsg(WM_SETREDRAW, (WPARAM)BoolToBOOL(redraw), 0); }
LONG_PTR SetStyle(LONG_PTR style) { return SetLongPtr(GWL_STYLE, style); }
+ // LONG_PTR SetStyle(DWORD style) { return SetLongPtr(GWL_STYLE, (LONG_PTR)style); }
LONG_PTR GetStyle() const { return GetLongPtr(GWL_STYLE); }
// bool MyIsMaximized() const { return ((GetStyle() & WS_MAXIMIZE) != 0); }
@@ -246,19 +325,19 @@ public:
{ return GetWindowTextLength(_window); }
int GetText(LPTSTR string, int maxCount) const
{ return GetWindowText(_window, string, maxCount); }
- bool GetText(CSysString &s);
+ bool GetText(CSysString &s) const;
#ifndef _UNICODE
/*
UINT GetText(LPWSTR string, int maxCount) const
{ return GetWindowTextW(_window, string, maxCount); }
*/
- bool GetText(UString &s);
+ bool GetText(UString &s) const;
#endif
bool Enable(bool enable)
{ return BOOLToBool(::EnableWindow(_window, BoolToBOOL(enable))); }
- bool IsEnabled()
+ bool IsEnabled() const
{ return BOOLToBool(::IsWindowEnabled(_window)); }
#ifndef UNDER_CE
@@ -266,7 +345,7 @@ public:
{ return ::GetSystemMenu(_window, BoolToBOOL(revert)); }
#endif
- UINT_PTR SetTimer(UINT_PTR idEvent, UINT elapse, TIMERPROC timerFunc = 0)
+ UINT_PTR SetTimer(UINT_PTR idEvent, UINT elapse, TIMERPROC timerFunc = NULL)
{ return ::SetTimer(_window, idEvent, elapse, timerFunc); }
bool KillTimer(UINT_PTR idEvent)
{return BOOLToBool(::KillTimer(_window, idEvent)); }