mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Allow for better contextual file reference handling
This commit is contained in:
parent
277f7f8c04
commit
f454e6d905
1 changed files with 19 additions and 0 deletions
|
@ -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<ContextualFileReference> parseIfInDataDirectory(String s) {
|
||||
var cf = of(s);
|
||||
if (cf.serialize().contains("<DATA>")) {
|
||||
return Optional.of(cf);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<String> resolveIfInDataDirectory(ShellControl shellControl, String s) {
|
||||
if (s.contains("<DATA>")) {
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue