From e4bba930c65158ffedb8b389138be16cddf4c489 Mon Sep 17 00:00:00 2001
From: Chuck Atkins <chuck.atkins@kitware.com>
Date: Mon, 2 Jun 2014 11:49:39 -0400
Subject: [PATCH] Directory: Make sure the /* suffix uses correct slashes

When applying the /* wildcard suffix to a directory, make sure the
direction of the slash getting appended is consistent with the other
slashes in the path, i.e. /foo/bar and /foo/bar/ become /foo/bar/* and
similarly \foo\bar and \foo\bar\ become \foo\bar\*.

Change-Id: I44fcf7e97be65923a37aaed615ba5f4012756893
---
 Directory.cxx | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/Directory.cxx b/Directory.cxx
index d54e607..b305fd7 100644
--- a/Directory.cxx
+++ b/Directory.cxx
@@ -113,15 +113,24 @@ bool Directory::Load(const char* name)
 #endif
   char* buf;
   size_t n = strlen(name);
-  if ( name[n - 1] == '/' )
+  if ( name[n - 1] == '/' || name[n - 1] == '\\' )
     {
     buf = new char[n + 1 + 1];
     sprintf(buf, "%s*", name);
     }
   else
     {
+    // Make sure the slashes in the wildcard suffix are consistent with the
+    // rest of the path
     buf = new char[n + 2 + 1];
-    sprintf(buf, "%s/*", name);
+    if ( strchr(name, '\\') )
+      {
+      sprintf(buf, "%s\\*", name);
+      }
+    else
+      {
+      sprintf(buf, "%s/*", name);
+      }
     }
   struct _wfinddata_t data;      // data of current file
 
-- 
GitLab