Skip to content

Commit 5cf3686

Browse files
committed
comment
1 parent 90595a6 commit 5cf3686

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/CheckedFile.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ CheckedFile::CheckedFile( const char *input, uint64_t size, ReadChecksumPolicy p
238238
int CheckedFile::open64( const ustring &fileName, int flags, int mode )
239239
{
240240
#if defined( _MSC_VER )
241-
// Ref: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/sopen-s-wsopen-s
242241

243242
// Handle UTF-8 file names - Windows requires conversion to UTF-16
244243
#if ( ( defined( _MSVC_LANG ) && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L )
244+
// Ref: https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar
245245
std::wstring widePath;
246246
int sizeUtf16 = ::MultiByteToWideChar( CP_UTF8, 0, fileName.c_str(), -1, NULL, 0 );
247247
if ( sizeUtf16 > 0 )
@@ -256,10 +256,12 @@ int CheckedFile::open64( const ustring &fileName, int flags, int mode )
256256
"Error in converting file name to UTF16. fileName=" + fileName );
257257
}
258258
#else
259+
// Until C++17
259260
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
260261
std::wstring widePath = converter.from_bytes( fileName );
261262
#endif
262263

264+
// Ref: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/sopen-s-wsopen-s
263265
int handle;
264266
errno_t err = _wsopen_s( &handle, widePath.c_str(), flags, _SH_DENYNO, mode );
265267
if ( err != 0 )

0 commit comments

Comments
 (0)