This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit d3b78367c482764155a847d014f8760afbd9421d Author: cblamauer <52042437+cblama...@users.noreply.github.com> AuthorDate: Thu Jun 20 17:13:19 2019 +0200 CAMEL-13667 Windows network UNC paths not treated correctly (File2/tempPrefix) --- .../src/main/java/org/apache/camel/util/FileUtil.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java index 852e540..1bb3015 100644 --- a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java +++ b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java @@ -292,7 +292,14 @@ public final class FileUtil { boolean endsWithSlash = path.endsWith("/") || path.endsWith("\\"); // preserve starting slash if given in input path - boolean startsWithSlash = path.startsWith("/") || path.startsWith("\\"); + int cntSlashsAtStart = 0; + if (path.startsWith("/") || path.startsWith("\\")) { + cntSlashsAtStart++; + // for Windows, preserve up to 2 starting slashes, which is necessary for UNC paths. + if (isWindows() && path.length() > 1 && (path.charAt(1) == '/' || path.charAt(1) == '\\')) { + cntSlashsAtStart++; + } + } Deque<String> stack = new ArrayDeque<>(); @@ -313,7 +320,7 @@ public final class FileUtil { // build path based on stack StringBuilder sb = new StringBuilder(); - if (startsWithSlash) { + for (int i = 0; i < cntSlashsAtStart; i++) { sb.append(separator); }