Add more terminals plus various small improvements [stage]

This commit is contained in:
crschnick
2023-06-19 16:05:26 +00:00
parent 4689bcc2aa
commit 1aa50d50ca
16 changed files with 245 additions and 23 deletions
@@ -17,6 +17,26 @@ public class CommandBuilder {
private final boolean noQuoting;
private final StringBuilder builder = new StringBuilder();
public CommandBuilder add(String... s) {
for (String s1 : s) {
add(s1);
}
return this;
}
public CommandBuilder addQuoted(String s) {
if (!builder.isEmpty()) {
builder.append(' ');
}
if (noQuoting) {
throw new IllegalArgumentException("No quoting rule conflicts with spaces an argument");
}
builder.append("\"").append(s).append("\"");
return this;
}
public CommandBuilder add(String s) {
if (!builder.isEmpty()) {
builder.append(' ');
@@ -147,6 +147,8 @@ public interface ShellDialect {
CommandControl createFileExistsCommand(ShellControl sc, String file);
CommandControl symbolicLink(ShellControl sc, String linkFile, String targetFile);
String getFileTouchCommand(String file);
String getWhichCommand(String executable);
@@ -134,7 +134,14 @@ public class ConnectionFileSystem implements FileSystem {
public void touch(String file) throws Exception {
try (var pc = shellControl
.command(proc -> proc.getShellDialect().getFileTouchCommand(file))
.complex()
.start()) {
pc.discardOrThrow();
}
}
@Override
public void symbolicLink(String linkFile, String targetFile) throws Exception {
try (var pc = shellControl.getShellDialect().symbolicLink(shellControl,linkFile, targetFile)
.start()) {
pc.discardOrThrow();
}
@@ -108,6 +108,8 @@ public interface FileSystem extends Closeable, AutoCloseable {
void touch(String file) throws Exception;
void symbolicLink(String linkFile, String targetFile) throws Exception;
boolean directoryExists(String file) throws Exception;
void directoryAccessible(String file) throws Exception;