mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-11 12:00:59 +00:00
Add more terminals plus various small improvements [stage]
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user