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() {