From f114ba9900215fe1a9863962d53134db4746b96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Sat, 29 Aug 2009 19:06:19 +0000 Subject: [PATCH] Fix removing leading double slashes in filenames which are used for network resources on Windows (closes #2844085). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4139 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 3 +++ src/utils.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9e65df117..9b3bd1ee7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ * src/build.c, src/filetypes.c: Fix compiler warnings. + * src/utils.c: + Fix removing leading double slashes in filenames which are used for + network resources on Windows (closes #2844085). 2009-08-27 Nick Treleaven diff --git a/src/utils.c b/src/utils.c index f5ed542af..40aef2b78 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1719,13 +1719,20 @@ void utils_tidy_path(gchar *filename) const gchar *c, *needle; gchar *tmp; gssize pos; + gboolean preserve_double_backslash = FALSE; g_return_if_fail(g_path_is_absolute(filename)); + if (str->len >= 2 && strncmp(str->str, "\\\\", 2) == 0) + preserve_double_backslash = TRUE; + /* replace "/./" and "//" */ utils_string_replace_all(str, G_DIR_SEPARATOR_S "." G_DIR_SEPARATOR_S, G_DIR_SEPARATOR_S); utils_string_replace_all(str, G_DIR_SEPARATOR_S G_DIR_SEPARATOR_S, G_DIR_SEPARATOR_S); + if (preserve_double_backslash) + g_string_prepend(str, "\\"); + /* replace "/.." */ needle = G_DIR_SEPARATOR_S ".."; while (1)