From dfbe078ed0d714983ef0463d68a44b90d609a4f6 Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 17 Sep 2026 14:41:53 +0000 Subject: [PATCH] Rebase upstream --- app/src/main/java/io/xpipe/app/util/FilePath.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/util/FilePath.java b/app/src/main/java/io/xpipe/app/util/FilePath.java index 7b2865f1d..6a39b7a1b 100644 --- a/app/src/main/java/io/xpipe/app/util/FilePath.java +++ b/app/src/main/java/io/xpipe/app/util/FilePath.java @@ -224,14 +224,24 @@ public final class FilePath { } var joined = String.join("/", split()); - var prefix = value.startsWith("/") ? "/" : ""; + var prefix = hasWindowsUncPrefix() ? "//" : value.startsWith("/") ? "/" : ""; var suffix = value.endsWith("/") || value.endsWith("\\") ? "/" : ""; return FilePath.of(prefix + joined + suffix); } public FilePath toWindows() { + var prefix = hasWindowsUncPrefix() ? "\\\\" : ""; var suffix = value.endsWith("/") || value.endsWith("\\") ? "\\" : ""; - return FilePath.of(String.join("\\", split()) + suffix); + return FilePath.of(prefix + String.join("\\", split()) + suffix); + } + + /** + * Returns whether this file path has a Universal Naming Convention (UNC) prefix. + * + * @return true if the file path has a UNC prefix, false otherwise + */ + private boolean hasWindowsUncPrefix() { + return value.startsWith("\\\\") && !split().isEmpty(); } public boolean isRoot() {