Skip to content

Commit 56b147c

Browse files
committed
comment
1 parent 1995093 commit 56b147c

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/CheckedFile.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@
3232

3333
#if defined( _WIN32 )
3434
#if defined( _MSC_VER )
35-
#include <codecvt>
35+
#include <codecvt> // codecvt_utf8_utf16 is deprecated in C++17, removed in C++226
3636
#include <io.h>
37-
#include <stringapiset.h>
38-
#define NOMINMAX
37+
#define NOMINMAX // prevents <windows.h> to #define min and max. Sigh ...
38+
// clang-format off: <windows.h> MUST be included before <stringapiset.h>
3939
#include <windows.h>
40+
#include <stringapiset.h> // Use WIN32 API to replace codecvt_utf8_utf16
41+
// clang-format on
4042
#elif defined( __GNUC__ )
4143
#ifndef _LARGEFILE64_SOURCE
4244
#define _LARGEFILE64_SOURCE
@@ -247,10 +249,11 @@ int CheckedFile::open64( const ustring &fileName, int flags, int mode )
247249
widePath.resize( sizeUtf16 + 1 );
248250
sizeUtf16 =
249251
::MultiByteToWideChar( CP_UTF8, 0, fileName.c_str(), -1, &widePath[0], sizeUtf16 );
250-
if ( sizeUtf16 <= 0 )
251-
{
252-
widePath.resize( 0 );
253-
}
252+
}
253+
if ( sizeUtf16 <= 0 )
254+
{
255+
throw E57_EXCEPTION2( ErrorOpenFailed,
256+
"Error in converting file name to UTF16. " + " 'fileName=" + fileName );
254257
}
255258
#else
256259
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;

0 commit comments

Comments
 (0)