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 8e1e3219e..3e8e75c68 100644 --- a/app/src/main/java/io/xpipe/app/storage/ContextualFileReference.java +++ b/app/src/main/java/io/xpipe/app/storage/ContextualFileReference.java @@ -9,6 +9,7 @@ import lombok.NonNull; import java.nio.file.InvalidPathException; import java.nio.file.Path; +import java.util.Optional; import java.util.regex.Matcher; @AllArgsConstructor(access = AccessLevel.PRIVATE) @@ -36,6 +37,24 @@ public class ContextualFileReference { } } + public static Optional parseIfInDataDirectory(String s) { + var cf = of(s); + if (cf.serialize().contains("")) { + return Optional.of(cf); + } else { + return Optional.empty(); + } + } + + public static Optional resolveIfInDataDirectory(ShellControl shellControl, String s) { + if (s.contains("")) { + var cf = of(s); + return Optional.of(cf.toFilePath(shellControl)); + } else { + return Optional.empty(); + } + } + public static ContextualFileReference of(String s) { if (s == null) { return null;