mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge pull request #3595 from RaiKoHoff/Dev_RC
Fix INVALID_HANDLE_VALUE in case of Win32 (32-bit) build (SimpleIni.h)
This commit is contained in:
commit
e852dc7050
@ -214,6 +214,11 @@
|
||||
# pragma warning (disable: 4127 4503 4702 4786)
|
||||
#endif
|
||||
|
||||
// workaround for invalid (false positive) assertion SI_ASSERT(hFile != INVALID_HANDLE_VALUE)
|
||||
#ifndef _WIN64
|
||||
# undef INVALID_HANDLE_VALUE
|
||||
# define INVALID_HANDLE_VALUE ((HANDLE)INTPTR_MAX)
|
||||
#endif
|
||||
|
||||
// Defines the conversion classes for different libraries. Before including
|
||||
// SimpleIni.h, set the converter that you wish you use by defining one of the
|
||||
@ -306,6 +311,10 @@ enum class SI_Error : int {
|
||||
# define SI_WCHAR_T UChar
|
||||
#endif
|
||||
|
||||
#ifndef IS_VALID_HANDLE
|
||||
#define IS_VALID_HANDLE(HNDL) ((HNDL) && ((HNDL) != INVALID_HANDLE_VALUE))
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// MAIN TEMPLATE CLASS
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -1435,22 +1444,22 @@ CSimpleIniTempl<SI_CHAR, SI_STRLESS, SI_CONVERTER>::LoadFile(
|
||||
)
|
||||
{
|
||||
if (a_pwszFile && a_pwszFile[0])
|
||||
{
|
||||
HANDLE hFile = CreateFile(a_pwszFile,
|
||||
GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
{
|
||||
HANDLE hFile = CreateFile(a_pwszFile,
|
||||
GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
SI_ASSERT(hFile != INVALID_HANDLE_VALUE);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
return SI_Error::SI_FILE;
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
return SI_Error::SI_FILE;
|
||||
}
|
||||
|
||||
SI_Error rc = LoadFile(hFile);
|
||||
|
||||
CloseHandle(hFile);
|
||||
return rc;
|
||||
}
|
||||
|
||||
SI_Error rc = LoadFile(hFile);
|
||||
|
||||
CloseHandle(hFile);
|
||||
return rc;
|
||||
}
|
||||
return SI_Error::SI_FILE;
|
||||
}
|
||||
|
||||
@ -2641,22 +2650,22 @@ CSimpleIniTempl<SI_CHAR, SI_STRLESS, SI_CONVERTER>::SaveFile(
|
||||
) const
|
||||
{
|
||||
if (a_pwszFile && a_pwszFile[0])
|
||||
{
|
||||
HANDLE hFile = CreateFile(a_pwszFile,
|
||||
GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
{
|
||||
HANDLE hFile = CreateFile(a_pwszFile,
|
||||
GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
SI_ASSERT(hFile != INVALID_HANDLE_VALUE);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
return SI_Error::SI_FILE;
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
return SI_Error::SI_FILE;
|
||||
}
|
||||
|
||||
SI_Error rc = SaveFile(hFile, a_bAddSignature);
|
||||
|
||||
CloseHandle(hFile);
|
||||
return rc;
|
||||
}
|
||||
|
||||
SI_Error rc = SaveFile(hFile, a_bAddSignature);
|
||||
|
||||
CloseHandle(hFile);
|
||||
return rc;
|
||||
}
|
||||
return SI_Error::SI_FILE;
|
||||
}
|
||||
|
||||
|
||||
@ -214,6 +214,11 @@
|
||||
# pragma warning (disable: 4127 4503 4702 4786)
|
||||
#endif
|
||||
|
||||
// workaround for invalid (false positive) assertion SI_ASSERT(hFile != INVALID_HANDLE_VALUE)
|
||||
#ifndef _WIN64
|
||||
# undef INVALID_HANDLE_VALUE
|
||||
# define INVALID_HANDLE_VALUE ((HANDLE)INTPTR_MAX)
|
||||
#endif
|
||||
|
||||
// Defines the conversion classes for different libraries. Before including
|
||||
// SimpleIni.h, set the converter that you wish you use by defining one of the
|
||||
@ -300,14 +305,14 @@ enum class SI_Error : int {
|
||||
#if defined(_WIN32)
|
||||
# define SI_HAS_WIDE_FILE
|
||||
# define SI_USE_LOCKING_WIDE_FILE
|
||||
# define SI_WCHAR_T wchar_t
|
||||
# define SI_WCHAR_T wchar_t
|
||||
#elif defined(SI_CONVERT_ICU)
|
||||
# define SI_HAS_WIDE_FILE
|
||||
# define SI_WCHAR_T UChar
|
||||
#endif
|
||||
|
||||
#ifndef IS_VALID_HANDLE
|
||||
#define IS_VALID_HANDLE(HNDL) (((HNDL) && ((HNDL) != INVALID_HANDLE_VALUE)) ? true : false)
|
||||
#define IS_VALID_HANDLE(HNDL) ((HNDL) && ((HNDL) != INVALID_HANDLE_VALUE))
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user