From 1634f0cf5ec3a1a538c760d08b417ddb0d7a0a94 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sun, 25 Jun 2017 16:46:59 -0700 Subject: [PATCH] Use CompareStringOrdinal in DoFileSearch instead of _wcsicmp --- Source/Core/Common/FileSearch.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Core/Common/FileSearch.cpp b/Source/Core/Common/FileSearch.cpp index 53eca6fcca..3f810132f5 100644 --- a/Source/Core/Common/FileSearch.cpp +++ b/Source/Core/Common/FileSearch.cpp @@ -9,6 +9,7 @@ #include "Common/FileSearch.h" #ifdef _MSC_VER +#include #include namespace fs = std::experimental::filesystem; #define HAS_STD_FILESYSTEM @@ -85,9 +86,10 @@ std::vector DoFileSearch(const std::vector& directorie return std::any_of(native_exts.cbegin(), native_exts.cend(), [&native_path](const auto& ext) { // TODO provide cross-platform compat for the comparison function, once more platforms // support std::filesystem - return native_path.length() >= ext.native().length() && - _wcsicmp(&native_path.c_str()[native_path.length() - ext.native().length()], - ext.c_str()) == 0; + int compare_len = static_cast(ext.native().length()); + return native_path.length() >= compare_len && + CompareStringOrdinal(&native_path.c_str()[native_path.length() - compare_len], + compare_len, ext.c_str(), compare_len, TRUE) == CSTR_EQUAL; }); }; @@ -102,12 +104,12 @@ std::vector DoFileSearch(const std::vector& directorie if (recursive) { // TODO use fs::directory_options::follow_directory_symlink ? - for (auto& entry : fs::recursive_directory_iterator(fs::path(directory.c_str()))) + for (auto& entry : fs::recursive_directory_iterator(fs::path(directory))) add_filtered(entry); } else { - for (auto& entry : fs::directory_iterator(fs::path(directory.c_str()))) + for (auto& entry : fs::directory_iterator(fs::path(directory))) add_filtered(entry); } }