mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-29 03:45:43 +00:00
Rebase upstream
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user