From 569a1aeda4a38f9874fefc3f918bc994f74ffa52 Mon Sep 17 00:00:00 2001
From: Todd Martin <nztoddler@yahoo.com>
Date: Mon, 14 Oct 2019 14:54:51 +1300
Subject: [PATCH] Encoding: Add ToWindowsExtendedPath support for wide string

---
 Encoding.hxx.in |  2 ++
 EncodingCXX.cxx | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Encoding.hxx.in b/Encoding.hxx.in
index b0675211..75a2d4d0 100644
--- a/Encoding.hxx.in
+++ b/Encoding.hxx.in
@@ -68,6 +68,8 @@ public:
    * absolute paths with Windows-style backslashes.
    **/
   static std::wstring ToWindowsExtendedPath(std::string const&);
+  static std::wstring ToWindowsExtendedPath(const char* source);
+  static std::wstring ToWindowsExtendedPath(std::wstring const& wsource);
 #  endif
 
 #endif // @KWSYS_NAMESPACE@_STL_HAS_WSTRING
diff --git a/EncodingCXX.cxx b/EncodingCXX.cxx
index 4593c925..5cad934e 100644
--- a/EncodingCXX.cxx
+++ b/EncodingCXX.cxx
@@ -221,8 +221,18 @@ std::string Encoding::ToNarrow(const wchar_t* wcstr)
 // Convert local paths to UNC style paths
 std::wstring Encoding::ToWindowsExtendedPath(std::string const& source)
 {
-  std::wstring wsource = Encoding::ToWide(source);
+  return ToWindowsExtendedPath(ToWide(source));
+}
 
+// Convert local paths to UNC style paths
+std::wstring Encoding::ToWindowsExtendedPath(const char* source)
+{
+  return ToWindowsExtendedPath(ToWide(source));
+}
+
+// Convert local paths to UNC style paths
+std::wstring Encoding::ToWindowsExtendedPath(std::wstring const& wsource)
+{
   // Resolve any relative paths
   DWORD wfull_len;
 
@@ -269,7 +279,7 @@ std::wstring Encoding::ToWindowsExtendedPath(std::string const& source)
 
   // If this case has been reached, then the path is invalid.  Leave it
   // unchanged
-  return Encoding::ToWide(source);
+  return wsource;
 }
 #  endif
 
-- 
GitLab