From e54a6566cc898424b62232038d4ea17b018a4f35 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 5 Mar 2025 19:42:35 +0000 Subject: [PATCH] Fixes --- .../browser/file/BrowserFileSystemHelper.java | 2 +- .../file/BrowserFileSystemTabModel.java | 2 +- .../file/BrowserFileTransferOperation.java | 4 +- .../browser/file/BrowserLocalFileSystem.java | 2 +- .../ContextualFileReferenceChoiceComp.java | 6 +- .../io/xpipe/app/core/AppOpenArguments.java | 2 +- .../xpipe/app/ext/ConnectionFileSystem.java | 2 +- .../io/xpipe/app/icon/SystemIconSource.java | 2 +- .../app/storage/ContextualFileReference.java | 12 ++-- .../terminal/TerminalLaunchConfiguration.java | 2 +- .../io/xpipe/app/util/CommandSupport.java | 2 +- .../io/xpipe/app/util/DesktopShortcuts.java | 6 +- .../java/io/xpipe/app/util/FileReference.java | 2 +- .../java/io/xpipe/app/util/ScriptHelper.java | 2 +- .../java/io/xpipe/core/process/OsType.java | 14 ++--- .../java/io/xpipe/core/process/ShellView.java | 2 +- .../java/io/xpipe/core/store/FileEntry.java | 2 +- .../java/io/xpipe/core/store/FilePath.java | 60 +++++++++++-------- .../io/xpipe/core/util/CoreJacksonModule.java | 2 +- .../ext/base/action/SampleStoreAction.java | 2 +- .../xpipe/ext/base/browser/NewItemAction.java | 2 +- .../browser/compress/BaseCompressAction.java | 2 +- .../browser/compress/BaseUntarAction.java | 2 +- .../browser/compress/BaseUnzipUnixAction.java | 2 +- .../compress/BaseUnzipWindowsAction.java | 2 +- .../identity/SshIdentityStateManager.java | 4 +- .../io/xpipe/ext/base/script/ScriptStore.java | 4 +- .../IncusContainerEditRunConfigAction.java | 2 +- .../lxd/LxdContainerEditRunConfigAction.java | 2 +- 29 files changed, 82 insertions(+), 70 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemHelper.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemHelper.java index 83719ba0b..663ef7bbe 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemHelper.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemHelper.java @@ -79,7 +79,7 @@ public class BrowserFileSystemHelper { return path; } - var resolved = new FilePath(shell.get() + var resolved = FilePath.of(shell.get() .getShellDialect() .resolveDirectory(shell.get(), path.toString()) .readStdoutOrThrow()); diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabModel.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabModel.java index 1028fd1a3..a3dea907d 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabModel.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabModel.java @@ -335,7 +335,7 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab> var syncedTarget = handler.addDataFile( source, target, sync.getPerUser().test(source)); Platform.runLater(() -> { - filePath.setValue(new FilePath(syncedTarget)); + filePath.setValue(FilePath.of(syncedTarget)); }); } } catch (Exception e) { @@ -155,7 +155,7 @@ public class ContextualFileReferenceChoiceComp extends Comp> prop.set(s != null ? s.toString() : null); })); prop.addListener((observable, oldValue, newValue) -> { - filePath.setValue(newValue != null ? new FilePath(newValue) : null); + filePath.setValue(newValue != null ? FilePath.of(newValue) : null); }); var combo = new ComboTextFieldComp(prop, items, param -> { return new ListCell<>() { @@ -187,7 +187,7 @@ public class ContextualFileReferenceChoiceComp extends Comp> prop.set(s != null ? s.toString() : null); })); prop.addListener((observable, oldValue, newValue) -> { - filePath.setValue(newValue != null ? new FilePath(newValue) : null); + filePath.setValue(newValue != null ? FilePath.of(newValue) : null); }); var fileNameComp = new TextFieldComp(prop) .apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS)) diff --git a/app/src/main/java/io/xpipe/app/core/AppOpenArguments.java b/app/src/main/java/io/xpipe/app/core/AppOpenArguments.java index 58f913608..0fbbca907 100644 --- a/app/src/main/java/io/xpipe/app/core/AppOpenArguments.java +++ b/app/src/main/java/io/xpipe/app/core/AppOpenArguments.java @@ -134,7 +134,7 @@ public class AppOpenArguments { var dir = Files.isDirectory(file) ? file : file.getParent(); AppLayoutModel.get().selectBrowser(); BrowserFullSessionModel.DEFAULT.openFileSystemAsync( - DataStorage.get().local().ref(), model -> new FilePath(dir.toString()), null); + DataStorage.get().local().ref(), model -> FilePath.of(dir.toString()), null); } } } diff --git a/app/src/main/java/io/xpipe/app/ext/ConnectionFileSystem.java b/app/src/main/java/io/xpipe/app/ext/ConnectionFileSystem.java index 8effcaa87..c2e133dd8 100644 --- a/app/src/main/java/io/xpipe/app/ext/ConnectionFileSystem.java +++ b/app/src/main/java/io/xpipe/app/ext/ConnectionFileSystem.java @@ -173,7 +173,7 @@ public class ConnectionFileSystem implements FileSystem { @Override public List listRoots() throws Exception { - return shellControl.getShellDialect().listRoots(shellControl).map(s -> new FilePath(s)).toList(); + return shellControl.getShellDialect().listRoots(shellControl).map(s -> FilePath.of(s)).toList(); } @Override diff --git a/app/src/main/java/io/xpipe/app/icon/SystemIconSource.java b/app/src/main/java/io/xpipe/app/icon/SystemIconSource.java index 6f10005aa..b675b8a84 100644 --- a/app/src/main/java/io/xpipe/app/icon/SystemIconSource.java +++ b/app/src/main/java/io/xpipe/app/icon/SystemIconSource.java @@ -101,7 +101,7 @@ public interface SystemIconSource { .execute(); } else { sc.command(CommandBuilder.of().add("git", "pull")) - .withWorkingDirectory(new FilePath(dir)) + .withWorkingDirectory(FilePath.of(dir)) .execute(); } } diff --git a/app/src/main/java/io/xpipe/app/storage/ContextualFileReference.java b/app/src/main/java/io/xpipe/app/storage/ContextualFileReference.java index b69cc9c46..c056b94eb 100644 --- a/app/src/main/java/io/xpipe/app/storage/ContextualFileReference.java +++ b/app/src/main/java/io/xpipe/app/storage/ContextualFileReference.java @@ -26,10 +26,10 @@ public class ContextualFileReference { private static FilePath getDataDir() { if (DataStorage.get() == null) { - return lastDataDir != null ? lastDataDir : new FilePath(AppPrefs.DEFAULT_STORAGE_DIR.resolve("data")).toUnix(); + return lastDataDir != null ? lastDataDir : FilePath.of(AppPrefs.DEFAULT_STORAGE_DIR.resolve("data")).toUnix(); } - return lastDataDir = new FilePath(DataStorage.get().getDataDir()).toUnix(); + return lastDataDir = FilePath.of(DataStorage.get().getDataDir()).toUnix(); } public static Optional resolveIfInDataDirectory(ShellControl shellControl, String s) { @@ -47,7 +47,7 @@ public class ContextualFileReference { } var ns = p.normalize().toUnix(); - var home = new FilePath(System.getProperty("user.home")).normalize().toUnix(); + var home = FilePath.of(System.getProperty("user.home")).normalize().toUnix(); String replaced; var withHomeResolved = ns.toString().replace("~", home.toString()); @@ -61,11 +61,11 @@ public class ContextualFileReference { } public static ContextualFileReference of(String s) { - return of(s != null ? new FilePath(s) : null); + return of(s != null ? FilePath.of(s) : null); } public FilePath toAbsoluteFilePath(ShellControl sc) { - return new FilePath(path.replaceAll("/", Matcher.quoteReplacement(sc != null ? sc.getOsType().getFileSystemSeparator() : "/"))); + return FilePath.of(path.replaceAll("/", Matcher.quoteReplacement(sc != null ? sc.getOsType().getFileSystemSeparator() : "/"))); } public boolean isInDataDirectory() { @@ -74,7 +74,7 @@ public class ContextualFileReference { public String serialize() { var start = getDataDir(); - var normalizedPath = new FilePath(path).normalize().toUnix(); + var normalizedPath = FilePath.of(path).normalize().toUnix(); if (normalizedPath.startsWith(start) && !normalizedPath.equals(start)) { return "" + "/" + start.relativize(normalizedPath); } diff --git a/app/src/main/java/io/xpipe/app/terminal/TerminalLaunchConfiguration.java b/app/src/main/java/io/xpipe/app/terminal/TerminalLaunchConfiguration.java index fcf3dca87..3e4d57e14 100644 --- a/app/src/main/java/io/xpipe/app/terminal/TerminalLaunchConfiguration.java +++ b/app/src/main/java/io/xpipe/app/terminal/TerminalLaunchConfiguration.java @@ -63,7 +63,7 @@ public class TerminalLaunchConfiguration { var logDir = AppProperties.get().getDataDir().resolve("sessions"); Files.createDirectories(logDir); - var logFile = logDir.resolve(new FilePath(DataStorage.get().getStoreEntryDisplayName(entry) + " (" + var logFile = logDir.resolve(FilePath.of(DataStorage.get().getStoreEntryDisplayName(entry) + " (" + DATE_FORMATTER.format(Instant.now()) + ").log") .fileSystemCompatible(OsType.getLocal()) .toString() diff --git a/app/src/main/java/io/xpipe/app/util/CommandSupport.java b/app/src/main/java/io/xpipe/app/util/CommandSupport.java index 9ee8ea64e..a510b174f 100644 --- a/app/src/main/java/io/xpipe/app/util/CommandSupport.java +++ b/app/src/main/java/io/xpipe/app/util/CommandSupport.java @@ -15,7 +15,7 @@ public class CommandSupport { var out = processControl .command(processControl.getShellDialect().getWhichCommand(name)) .readStdoutIfPossible(); - return out.flatMap(s -> s.lines().findFirst()).map(String::trim).map(FilePath::new); + return out.flatMap(s -> s.lines().findFirst()).map(String::trim).map(FilePath::of); } public static boolean isInPath(ShellControl processControl, String executable) throws Exception { diff --git a/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java b/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java index 34cc32a07..14accccfa 100644 --- a/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java +++ b/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java @@ -66,13 +66,13 @@ public class DesktopShortcuts { pc.executeSimpleCommand(pc.getShellDialect().getMkdirsCommand(base + "/Contents/Resources")); var macExec = base + "/Contents/MacOS/" + name; - pc.view().writeScriptFile(new FilePath(macExec), content); + pc.view().writeScriptFile(FilePath.of(macExec), content); pc.executeSimpleCommand("chmod ugo+x \"" + macExec + "\""); - pc.view().writeTextFile(new FilePath(base + "/Contents/PkgInfo"), "APPL????"); + pc.view().writeTextFile(FilePath.of(base + "/Contents/PkgInfo"), "APPL????"); pc.view() .writeTextFile( - new FilePath(base + "/Contents/Info.plist"), + FilePath.of(base + "/Contents/Info.plist"), """ diff --git a/app/src/main/java/io/xpipe/app/util/FileReference.java b/app/src/main/java/io/xpipe/app/util/FileReference.java index 4825a37c7..9fdf85b66 100644 --- a/app/src/main/java/io/xpipe/app/util/FileReference.java +++ b/app/src/main/java/io/xpipe/app/util/FileReference.java @@ -29,7 +29,7 @@ public class FileReference { } public static FileReference local(Path p) { - return new FileReference(DataStorage.get().local().ref(), new FilePath(p.toString())); + return new FileReference(DataStorage.get().local().ref(), FilePath.of(p.toString())); } public static FileReference local(FilePath p) { diff --git a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java index dfce39729..b7c1e07a3 100644 --- a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java +++ b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java @@ -73,7 +73,7 @@ public class ScriptHelper { content += nl + t.getPassthroughExitCommand(); } - return createExecScript(t, processControl, new FilePath(t.initFileName(processControl)), content); + return createExecScript(t, processControl, FilePath.of(t.initFileName(processControl)), content); } @SneakyThrows diff --git a/core/src/main/java/io/xpipe/core/process/OsType.java b/core/src/main/java/io/xpipe/core/process/OsType.java index 4894a0d4c..4663d814c 100644 --- a/core/src/main/java/io/xpipe/core/process/OsType.java +++ b/core/src/main/java/io/xpipe/core/process/OsType.java @@ -102,9 +102,9 @@ public interface OsType { home, home.join("Downloads"), home.join("Documents"), - new FilePath("/etc"), + FilePath.of("/etc"), pc.getSystemTemporaryDirectory(), - new FilePath("/var"))); + FilePath.of("/var"))); var parentHome = home.getParent(); if (parentHome != null && !parentHome.toString().equals("/")) { list.add(3, parentHome); @@ -176,11 +176,11 @@ public interface OsType { home.join("Downloads"), home.join("Documents"), home.join("Desktop"), - new FilePath("/Applications"), - new FilePath("/Library"), - new FilePath("/System"), - new FilePath("/etc"), - new FilePath("/tmp") + FilePath.of("/Applications"), + FilePath.of("/Library"), + FilePath.of("/System"), + FilePath.of("/etc"), + FilePath.of("/tmp") ); return list; } diff --git a/core/src/main/java/io/xpipe/core/process/ShellView.java b/core/src/main/java/io/xpipe/core/process/ShellView.java index e75176e6a..62734b33d 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellView.java +++ b/core/src/main/java/io/xpipe/core/process/ShellView.java @@ -36,7 +36,7 @@ public class ShellView { } public FilePath userHome() throws Exception { - return new FilePath(shellControl.getOsType().getUserHomeDirectory(shellControl)); + return FilePath.of(shellControl.getOsType().getUserHomeDirectory(shellControl)); } public boolean fileExists(FilePath path) throws Exception { diff --git a/core/src/main/java/io/xpipe/core/store/FileEntry.java b/core/src/main/java/io/xpipe/core/store/FileEntry.java index 883ceeaa4..247ee06fb 100644 --- a/core/src/main/java/io/xpipe/core/store/FileEntry.java +++ b/core/src/main/java/io/xpipe/core/store/FileEntry.java @@ -33,7 +33,7 @@ public class FileEntry { @NonNull FileKind kind) { this.fileSystem = fileSystem; this.kind = kind; - this.path = kind == FileKind.DIRECTORY ? new FilePath(path.toDirectory().toString()) : path; + this.path = kind == FileKind.DIRECTORY ? FilePath.of(path.toDirectory().toString()) : path; this.date = date; this.info = info; this.size = size; diff --git a/core/src/main/java/io/xpipe/core/store/FilePath.java b/core/src/main/java/io/xpipe/core/store/FilePath.java index cc2a9ba02..a2680c097 100644 --- a/core/src/main/java/io/xpipe/core/store/FilePath.java +++ b/core/src/main/java/io/xpipe/core/store/FilePath.java @@ -22,10 +22,20 @@ public final class FilePath { return s.startsWith("/"); } + public static FilePath of(String path) { + return path != null ? new FilePath(path) : null; + } + + public static FilePath of(Path path) { + return path != null ? new FilePath(path.toString()) : null; + } + @NonNull private final String value; - public FilePath(@NonNull String value) { + private FilePath normalized; + + private FilePath(@NonNull String value) { this.value = value; if (value.isBlank()) { throw new IllegalArgumentException(); @@ -35,10 +45,6 @@ public final class FilePath { } } - public FilePath(@NonNull Path value) { - this.value = value.toString(); - } - public FilePath fileSystemCompatible(OsType osType) { var split = split(); var needsReplacement = split.stream().anyMatch(s -> !s.equals(osType.makeFileSystemCompatible(s))); @@ -49,19 +55,19 @@ public final class FilePath { var p = Pattern.compile("[^/\\\\]+"); var m = p.matcher(value); var replaced = m.replaceAll(matchResult -> osType.makeFileSystemCompatible(matchResult.group())); - return new FilePath(replaced); + return FilePath.of(replaced); } public FilePath getRoot() { if (value.startsWith("/")) { - return new FilePath("/"); + return FilePath.of("/"); } else if (value.length() >= 2 && value.charAt(1) == ':') { // Without the trailing slash, many programs struggle with this - return new FilePath(value.substring(0, 2) + "\\"); + return FilePath.of(value.substring(0, 2) + "\\"); } else if (value.startsWith("\\\\")) { var split = split(); if (split.size() > 0) { - return new FilePath("\\\\" + split.getFirst()); + return FilePath.of("\\\\" + split.getFirst()); } } @@ -78,25 +84,25 @@ public final class FilePath { public FilePath toDirectory() { if (value.endsWith("/") || value.endsWith("\\")) { - return new FilePath(value); + return FilePath.of(value); } if (value.contains("\\")) { - return new FilePath(value + "\\"); + return FilePath.of(value + "\\"); } - return new FilePath(value + "/"); + return FilePath.of(value + "/"); } public FilePath removeTrailingSlash() { if (value.equals("/")) { - return new FilePath(value); + return FilePath.of(value); } if (value.endsWith("/") || value.endsWith("\\")) { - return new FilePath(value.substring(0, value.length() - 1)); + return FilePath.of(value.substring(0, value.length() - 1)); } - return new FilePath(value); + return FilePath.of(value); } public String getFileName() { @@ -147,7 +153,7 @@ public final class FilePath { public FilePath join(String... parts) { var joined = String.join("/", parts); - return new FilePath(value + "/" + joined).normalize(); + return FilePath.of(value + "/" + joined).normalize(); } public boolean isAbsolute() { @@ -168,14 +174,14 @@ public final class FilePath { } if (split().size() == 1) { - return value.startsWith("/") && !value.equals("/") ? new FilePath("/") : null; + return value.startsWith("/") && !value.equals("/") ? FilePath.of("/") : null; } - return new FilePath(value.substring(0, value.length() - getFileName().length() - 1)); + return FilePath.of(value.substring(0, value.length() - getFileName().length() - 1)); } public boolean startsWith(String start) { - return startsWith(new FilePath(start)); + return startsWith(FilePath.of(start)); } public boolean startsWith(FilePath start) { @@ -183,18 +189,24 @@ public final class FilePath { } public FilePath relativize(FilePath base) { - return new FilePath(normalize() + return FilePath.of(normalize() .toString() .substring(base.normalize().toDirectory().toString().length())); } public FilePath normalize() { + if (normalized != null) { + return normalized; + } + var backslash = value.contains("\\"); - return backslash ? toWindows() : toUnix(); + var r = backslash ? toWindows() : toUnix(); + normalized = r; + return r; } public FilePath resolveTildeHome(String dir) { - return value.startsWith("~") ? new FilePath(value.replace("~", dir)) : this; + return value.startsWith("~") ? FilePath.of(value.replace("~", dir)) : this; } private List split() { @@ -206,12 +218,12 @@ public final class FilePath { var joined = String.join("/", split()); var prefix = value.startsWith("/") ? "/" : ""; var suffix = value.endsWith("/") || value.endsWith("\\") ? "/" : ""; - return new FilePath(prefix + joined + suffix); + return FilePath.of(prefix + joined + suffix); } public FilePath toWindows() { var suffix = value.endsWith("/") || value.endsWith("\\") ? "\\" : ""; - return new FilePath(String.join("\\", split()) + suffix); + return FilePath.of(String.join("\\", split()) + suffix); } public Path asLocalPath() { diff --git a/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java b/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java index 31d401089..db509852f 100644 --- a/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java +++ b/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java @@ -123,7 +123,7 @@ public class CoreJacksonModule extends SimpleModule { @Override public FilePath deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - return new FilePath(p.getValueAsString()); + return FilePath.of(p.getValueAsString()); } } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/action/SampleStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/action/SampleStoreAction.java index ef7f70408..547e10655 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/action/SampleStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/action/SampleStoreAction.java @@ -112,7 +112,7 @@ public class SampleStoreAction implements ActionProvider { // You can also set a custom working directory. try (CommandControl cc = sc.command("kill ") .elevated(ElevationFunction.elevated("kill")) - .withWorkingDirectory(new FilePath("/")) + .withWorkingDirectory(FilePath.of("/")) .start()) { // Discard any output but throw an exception with the stderr contents if the exit code is not 0 cc.discardOrThrow(); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/NewItemAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/NewItemAction.java index 03fdfc7e4..ba478cf77 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/NewItemAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/NewItemAction.java @@ -120,7 +120,7 @@ public class NewItemAction implements BrowserAction, BrowserBranchAction { .buildComp() .prefWidth(350)); modal.withDefaultButtons(() -> { - model.createLinkAsync(linkName.getValue(), new FilePath(target.getValue())); + model.createLinkAsync(linkName.getValue(), FilePath.of(target.getValue())); }); modal.show(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseCompressAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseCompressAction.java index 5dc2a795c..bc9881f11 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseCompressAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseCompressAction.java @@ -48,7 +48,7 @@ public abstract class BaseCompressAction implements BrowserAction, BrowserBranch var pf = sc.command(sc.getShellDialect().getPrintEnvironmentVariableCommand("ProgramFiles")) .readStdoutOrThrow(); - var loc = new FilePath(pf).join("7-Zip", "7z.exe").toWindows(); + var loc = FilePath.of(pf).join("7-Zip", "7z.exe").toWindows(); if (model.getFileSystem().fileExists(loc)) { model.getCache().getMultiPurposeCache().put("7zExecutable", loc); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUntarAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUntarAction.java index 6e9cbc329..d0a46ced7 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUntarAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUntarAction.java @@ -74,7 +74,7 @@ public class BaseUntarAction implements BrowserApplicationPathAction, BrowserLea } private FilePath getTarget(FilePath name) { - return new FilePath(name.toString().replaceAll("\\.tar$", "").replaceAll("\\.tar.gz$", "").replaceAll("\\.tgz$", "")); + return FilePath.of(name.toString().replaceAll("\\.tar$", "").replaceAll("\\.tar.gz$", "").replaceAll("\\.tgz$", "")); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUnzipUnixAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUnzipUnixAction.java index f98653017..5a06fd9a4 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUnzipUnixAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUnzipUnixAction.java @@ -62,7 +62,7 @@ public abstract class BaseUnzipUnixAction extends ExecuteApplicationAction { } private FilePath getTarget(FilePath name) { - return new FilePath(name.toString().replaceAll("\\.zip$", "")); + return FilePath.of(name.toString().replaceAll("\\.zip$", "")); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUnzipWindowsAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUnzipWindowsAction.java index 2b974e0d1..32a0459f3 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUnzipWindowsAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/compress/BaseUnzipWindowsAction.java @@ -75,7 +75,7 @@ public abstract class BaseUnzipWindowsAction implements BrowserLeafAction { } private FilePath getTarget(FilePath name) { - return new FilePath(name.toString().replaceAll("\\.zip$", "")); + return FilePath.of(name.toString().replaceAll("\\.zip$", "")); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStateManager.java b/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStateManager.java index 540e74512..37d89a08e 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStateManager.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStateManager.java @@ -114,7 +114,7 @@ public class SshIdentityStateManager { if (sc.getOsType() == OsType.WINDOWS) { if (!content.contains("enable-win32-openssh-support")) { content += "\nenable-win32-openssh-support\n"; - sc.view().writeTextFile(new FilePath(confFile), content); + sc.view().writeTextFile(FilePath.of(confFile), content); // reloadagent does not work correctly, so kill it handleWindowsGpgAgentStop(sc); } @@ -122,7 +122,7 @@ public class SshIdentityStateManager { } else { if (!content.contains("enable-ssh-support")) { content += "\nenable-ssh-support\n"; - sc.view().writeTextFile(new FilePath(confFile), content); + sc.view().writeTextFile(FilePath.of(confFile), content); sc.executeSimpleCommand(CommandBuilder.of().add("gpg-connect-agent", "reloadagent", "/bye")); } else { sc.executeSimpleCommand(CommandBuilder.of().add("gpg-connect-agent", "/bye")); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStore.java b/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStore.java index 0b41fc12e..6542f8742 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStore.java @@ -142,10 +142,10 @@ public abstract class ScriptStore implements DataStore, StatefulDataStore file.getParent(), null, true); var found = model.findFile(file.toString()); diff --git a/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerEditRunConfigAction.java b/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerEditRunConfigAction.java index 6adcccb14..56b5afecf 100644 --- a/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerEditRunConfigAction.java +++ b/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerEditRunConfigAction.java @@ -57,7 +57,7 @@ public class LxdContainerEditRunConfigAction implements ActionProvider { var d = (LxdContainerStore) store.getStore(); var elevatedRef = ProcessControlProvider.get() .elevated(d.getCmd().getStore().getHost().get().ref()); - var file = new FilePath("/run/lxd/" + d.getContainerName() + "/lxc.conf"); + var file = FilePath.of("/run/lxd/" + d.getContainerName() + "/lxc.conf"); var model = BrowserFullSessionModel.DEFAULT.openFileSystemSync( elevatedRef, m -> file.getParent(), null, true); var found = model.findFile(file.toString());