From 77db89961b46f5d9989c0093fcaf7ad99df8fa3c Mon Sep 17 00:00:00 2001
From: Sergey Lyubka <valenok@gmail.com>
Date: Mon, 3 Mar 2014 01:00:38 +0000
Subject: [PATCH] mg_stat() fix for paths like X:\

---
 mongoose.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mongoose.c b/mongoose.c
index a5a16885a..9d15bef79 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -1277,10 +1277,9 @@ static void to_wchar(const char *path, wchar_t *wbuf, size_t wbuf_len) {
   strncpy(buf, path, sizeof(buf));
   buf[sizeof(buf) - 1] = '\0';
 
-  // Trim trailing slashes
+  // Trim trailing slashes. Leave backslash for paths like X:\
   p = buf + strlen(buf) - 1;
-  while (p > buf && p[0] == '\\' || p[0] == '/') *p-- = '\0';
-  //change_slashes_to_backslashes(buf);
+  while (p > buf && p[-1] != ':' && (p[0] == '\\' || p[0] == '/')) *p-- = '\0';
 
   // Convert to Unicode and back. If doubly-converted string does not
   // match the original, something is fishy, reject.
-- 
GitLab