From b0976d55b727f2dba8e59ea12e049e6064eecde5 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 17 Feb 2023 16:00:34 +0100 Subject: [PATCH] chore(developer): Not ready yet: changes in CheckFilenameConsistency to use on non-windows --- .../src/kmcmplib/src/CheckFilenameConsistency.cpp | 2 +- developer/src/kmcmplib/src/UnreachableRules.cpp | 10 +++++++++- developer/src/kmcmplib/src/kmx_u16.cpp | 9 --------- developer/src/kmcmplib/src/kmx_u16.h | 2 -- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/developer/src/kmcmplib/src/CheckFilenameConsistency.cpp b/developer/src/kmcmplib/src/CheckFilenameConsistency.cpp index 46a142b458..17fc263f75 100644 --- a/developer/src/kmcmplib/src/CheckFilenameConsistency.cpp +++ b/developer/src/kmcmplib/src/CheckFilenameConsistency.cpp @@ -87,7 +87,7 @@ KMX_DWORD CheckFilenameConsistency(KMX_WCHAR const * Filename, bool ReportMissin std::wstring wstr = convert_pchar16T_To_pwcharT(Name); const KMX_WCHART* wchptr = wstr.c_str(); - nfile = _wfsopen(wchptr, L"rb", _SH_DENYWR); + nfile = _wfsopen(wchptr, L"rb", _SH_DENYNO); _wfinddata_t fi; n = _wfindfirst(wchptr, &fi); _findclose(n); diff --git a/developer/src/kmcmplib/src/UnreachableRules.cpp b/developer/src/kmcmplib/src/UnreachableRules.cpp index b40c954d54..d652f884cc 100644 --- a/developer/src/kmcmplib/src/UnreachableRules.cpp +++ b/developer/src/kmcmplib/src/UnreachableRules.cpp @@ -15,11 +15,19 @@ namespace kmcmp { + WCHAR conv_KMX_WCHAR__TO__WCHAR(KMX_WCHAR in) { + // char16_t -> std::u16string -> std::string -> std::wstring -> wchar_t + std::u16string u16str(&in); + std::string stri = string_from_u16string(u16str); + std::wstring wstr = wstring_from_string(stri); + return *wstr.c_str(); + } + std::wstring MakeHashKeyFromFileKey16(PFILE_KEY kp) { std::wstringstream Key_16; std::wstring Context_ws = u16fmt((const PKMX_WCHAR) kp->dpContext); - Key_16 << convert_KMX_WCHAR__TO__WCHAR(kp->Key) << "," << (DWORD) kp->ShiftFlags << ","; + Key_16 << conv_KMX_WCHAR__TO__WCHAR(kp->Key) << "," << (DWORD) kp->ShiftFlags << ","; if ((KMX_WCHART*) Context_ws.c_str()) Key_16 << (KMX_WCHART*) Context_ws.c_str(); return Key_16.str(); diff --git a/developer/src/kmcmplib/src/kmx_u16.cpp b/developer/src/kmcmplib/src/kmx_u16.cpp index 9b1bb90a1e..b68b66eca7 100644 --- a/developer/src/kmcmplib/src/kmx_u16.cpp +++ b/developer/src/kmcmplib/src/kmx_u16.cpp @@ -73,15 +73,6 @@ std::wstring convert_pchar16T_To_pwcharT(KMX_WCHAR Name[_MAX_PATH]){ return wstr; } - -KMX_WCHART convert_KMX_WCHAR__TO__WCHAR(KMX_WCHAR in) { - // char16_t -> std::u16string -> std::string -> std::wstring -> wchar_t - std::u16string u16str(&in); - std::string stri = string_from_u16string(u16str); - std::wstring wstr = wstring_from_string(stri); - return *wstr.c_str(); -} - long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) { auto s = string_from_u16string(str); diff --git a/developer/src/kmcmplib/src/kmx_u16.h b/developer/src/kmcmplib/src/kmx_u16.h index 56ddb340dd..edb182735e 100644 --- a/developer/src/kmcmplib/src/kmx_u16.h +++ b/developer/src/kmcmplib/src/kmx_u16.h @@ -6,7 +6,6 @@ #include #include #include -#include std::string string_from_wstring(std::wstring const str); std::wstring wstring_from_string(std::string const str); @@ -17,7 +16,6 @@ std::wstring u16fmt(const KMX_WCHAR * str); void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...) ; std::wstring convert_pchar16T_To_pwcharT(KMX_WCHAR Name[_MAX_PATH]); -KMX_WCHART convert_KMX_WCHAR__TO__WCHAR(KMX_WCHAR in) ; size_t u16len(const KMX_WCHAR *p); int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q);