From c898376158f590103a53201a3c4a31fd83c8afcf Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 2 Dec 2019 10:58:59 +0000 Subject: [PATCH] Check for UNC paths when normalising separators in File::parseAbsolutePath() --- modules/juce_core/files/juce_File.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/juce_core/files/juce_File.cpp b/modules/juce_core/files/juce_File.cpp index 51dd5bb484..7041ecd886 100644 --- a/modules/juce_core/files/juce_File.cpp +++ b/modules/juce_core/files/juce_File.cpp @@ -111,10 +111,17 @@ static String normaliseSeparators (const String& path) String separator (File::getSeparatorString()); String doubleSeparator (separator + separator); + auto uncPath = normalisedPath.startsWith (doubleSeparator) + && ! normalisedPath.fromFirstOccurrenceOf (doubleSeparator, false, false).startsWith (separator); + + if (uncPath) + normalisedPath = normalisedPath.fromFirstOccurrenceOf (doubleSeparator, false, false); + while (normalisedPath.contains (doubleSeparator)) normalisedPath = normalisedPath.replace (doubleSeparator, separator); - return normalisedPath; + return uncPath ? doubleSeparator + normalisedPath + : normalisedPath; } bool File::isRoot() const