This commit is contained in:
Christopher Schnick
2022-06-20 01:35:51 +02:00
parent b80b8121f6
commit af17d731ab
29 changed files with 60 additions and 308 deletions
@@ -27,6 +27,11 @@ public class FileStore implements StreamDataStore, FilenameStore {
this.file = file;
}
@Override
public boolean canOpen() {
return machine.exists(file);
}
@Override
public String toDisplay() {
return file + "@" + machine.toDisplay();
@@ -109,7 +109,7 @@ public class InputStreamDataStore implements StreamDataStore {
}
@Override
public boolean exists() {
public boolean canOpen() {
return true;
}
}
@@ -10,6 +10,11 @@ import java.nio.file.Path;
@JsonTypeName("local")
public class LocalMachineStore implements MachineStore {
@Override
public boolean exists(String file) {
return Files.exists(Path.of(file));
}
@Override
public String toDisplay() {
return "local";
@@ -13,4 +13,5 @@ public interface MachineStore extends DataStore {
OutputStream openOutput(String file) throws Exception;
public boolean exists(String file);
}
@@ -22,7 +22,7 @@ public class OutputStreamStore implements StreamDataStore {
}
@Override
public boolean exists() {
public boolean canOpen() {
return true;
}
}
@@ -87,7 +87,7 @@ public class StdinDataStore implements StreamDataStore {
}
@Override
public boolean exists() {
public boolean canOpen() {
return false;
}
}
@@ -40,7 +40,7 @@ public class StdoutDataStore implements StreamDataStore {
}
@Override
public boolean exists() {
public boolean canOpen() {
return false;
}
}
@@ -23,12 +23,8 @@ public interface StreamDataStore extends DataStore {
throw new UnsupportedOperationException("Can't open store output");
}
default OutputStream openAppendingOutput() throws Exception {
throw new UnsupportedOperationException("Can't open store output");
}
default boolean exists() {
return false;
default boolean canOpen() {
return true;
}
default boolean persistent() {
@@ -16,7 +16,7 @@ public class URLDataStore implements StreamDataStore {
}
@Override
public boolean exists() {
public boolean canOpen() {
return true;
}
}