More support for symlinks

This commit is contained in:
crschnick
2023-06-18 17:49:28 +00:00
parent f8b2afe44c
commit 7605a4331a
20 changed files with 357 additions and 193 deletions
@@ -31,7 +31,9 @@ public interface ShellDialect {
CommandControl directoryExists(ShellControl shellControl, String directory);
CommandControl normalizeDirectory(ShellControl shellControl, String directory);
CommandControl evaluateExpression(ShellControl shellControl, String s);
CommandControl resolveDirectory(ShellControl shellControl, String directory);
String fileArgument(String s);
@@ -2,8 +2,11 @@ package io.xpipe.core.store;
import io.xpipe.core.impl.FileNames;
import io.xpipe.core.process.ShellControl;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.Setter;
import lombok.Value;
import lombok.experimental.NonFinal;
import java.io.Closeable;
import java.io.InputStream;
@@ -17,11 +20,14 @@ import java.util.stream.Stream;
public interface FileSystem extends Closeable, AutoCloseable {
@Value
@NonFinal
class FileEntry {
@NonNull
FileSystem fileSystem;
@NonNull
@NonFinal
@Setter
String path;
Instant date;
@@ -52,11 +58,34 @@ public interface FileSystem extends Closeable, AutoCloseable {
this.size = size;
}
public FileEntry resolved() {
return this;
}
public static FileEntry ofDirectory(FileSystem fileSystem, String path) {
return new FileEntry(fileSystem, path, Instant.now(), true, false, 0, null, FileKind.DIRECTORY);
}
}
@Value
@EqualsAndHashCode(callSuper = true)
class LinkFileEntry extends FileEntry {
@NonNull
FileEntry target;
public LinkFileEntry(
@NonNull FileSystem fileSystem, @NonNull String path, Instant date, boolean hidden, Boolean executable, long size, String mode, @NonNull FileEntry target
) {
super(fileSystem, path, date, hidden, executable, size, mode, FileKind.LINK);
this.target = target;
}
public FileEntry resolved() {
return target;
}
}
FileSystemStore getStore();
Optional<ShellControl> getShell();