mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-23 09:46:36 +00:00
Renames
This commit is contained in:
@@ -36,7 +36,7 @@ public class LocalStore extends JacksonizedValue implements ShellStore {
|
||||
|
||||
@Override
|
||||
public FileSystem createFileSystem() {
|
||||
return new ConnectionFileSystem(ShellStore.createLocal().create(), LocalStore.this) {
|
||||
return new ConnectionFileSystem(ShellStore.createLocal().control(), LocalStore.this) {
|
||||
|
||||
@Override
|
||||
public FileSystemStore getStore() {
|
||||
@@ -128,7 +128,7 @@ public class LocalStore extends JacksonizedValue implements ShellStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShellControl createControl() {
|
||||
public ShellControl createBasicControl() {
|
||||
return ProcessControlProvider.createLocal(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public interface OsType {
|
||||
|
||||
@Override
|
||||
public String getHomeDirectory(ShellControl pc) throws Exception {
|
||||
return pc.executeStringSimpleCommand(
|
||||
return pc.executeSimpleStringCommand(
|
||||
pc.getShellDialect().getPrintEnvironmentVariableCommand("USERPROFILE"));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public interface OsType {
|
||||
|
||||
@Override
|
||||
public String getTempDirectory(ShellControl pc) throws Exception {
|
||||
return pc.executeStringSimpleCommand(pc.getShellDialect().getPrintEnvironmentVariableCommand("TEMP"));
|
||||
return pc.executeSimpleStringCommand(pc.getShellDialect().getPrintEnvironmentVariableCommand("TEMP"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,13 +62,13 @@ public interface OsType {
|
||||
@Override
|
||||
public String determineOperatingSystemName(ShellControl pc) throws Exception {
|
||||
try {
|
||||
return pc.executeStringSimpleCommand("wmic os get Caption")
|
||||
return pc.executeSimpleStringCommand("wmic os get Caption")
|
||||
.lines()
|
||||
.skip(1)
|
||||
.collect(Collectors.joining())
|
||||
.trim()
|
||||
+ " "
|
||||
+ pc.executeStringSimpleCommand("wmic os get Version")
|
||||
+ pc.executeSimpleStringCommand("wmic os get Version")
|
||||
.lines()
|
||||
.skip(1)
|
||||
.collect(Collectors.joining())
|
||||
@@ -84,7 +84,7 @@ public interface OsType {
|
||||
|
||||
@Override
|
||||
public String getHomeDirectory(ShellControl pc) throws Exception {
|
||||
return pc.executeStringSimpleCommand(pc.getShellDialect().getPrintEnvironmentVariableCommand("HOME"));
|
||||
return pc.executeSimpleStringCommand(pc.getShellDialect().getPrintEnvironmentVariableCommand("HOME"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,12 +142,12 @@ public interface OsType {
|
||||
|
||||
@Override
|
||||
public String getHomeDirectory(ShellControl pc) throws Exception {
|
||||
return pc.executeStringSimpleCommand(pc.getShellDialect().getPrintEnvironmentVariableCommand("HOME"));
|
||||
return pc.executeSimpleStringCommand(pc.getShellDialect().getPrintEnvironmentVariableCommand("HOME"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTempDirectory(ShellControl pc) throws Exception {
|
||||
var found = pc.executeStringSimpleCommand(pc.getShellDialect().getPrintVariableCommand("TMPDIR"));
|
||||
var found = pc.executeSimpleStringCommand(pc.getShellDialect().getPrintVariableCommand("TMPDIR"));
|
||||
|
||||
// This variable is not defined for root users, so manually fix it. Why? ...
|
||||
if (found.isBlank()) {
|
||||
@@ -174,7 +174,7 @@ public interface OsType {
|
||||
@Override
|
||||
public String determineOperatingSystemName(ShellControl pc) throws Exception {
|
||||
var properties = getProperties(pc);
|
||||
var name = pc.executeStringSimpleCommand(
|
||||
var name = pc.executeSimpleStringCommand(
|
||||
"awk '/SOFTWARE LICENSE AGREEMENT FOR macOS/' '/System/Library/CoreServices/Setup "
|
||||
+ "Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf' | "
|
||||
+ "awk -F 'macOS ' '{print $NF}' | awk '{print substr($0, 0, length($0)-1)}'");
|
||||
|
||||
@@ -29,13 +29,13 @@ public interface ShellControl extends ProcessControl {
|
||||
|
||||
public void checkRunning() throws Exception;
|
||||
|
||||
default String executeStringSimpleCommand(String command) throws Exception {
|
||||
default String executeSimpleStringCommand(String command) throws Exception {
|
||||
try (CommandControl c = command(command).start()) {
|
||||
return c.readOrThrow();
|
||||
}
|
||||
}
|
||||
|
||||
default boolean executeBooleanSimpleCommand(String command) throws Exception {
|
||||
default boolean executeSimpleBooleanCommand(String command) throws Exception {
|
||||
try (CommandControl c = command(command).start()) {
|
||||
return c.discardAndCheckExit();
|
||||
}
|
||||
@@ -55,9 +55,9 @@ public interface ShellControl extends ProcessControl {
|
||||
}
|
||||
}
|
||||
|
||||
default String executeStringSimpleCommand(ShellDialect type, String command) throws Exception {
|
||||
default String executeSimpleStringCommand(ShellDialect type, String command) throws Exception {
|
||||
try (var sub = subShell(type).start()) {
|
||||
return sub.executeStringSimpleCommand(command);
|
||||
return sub.executeSimpleStringCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import io.xpipe.core.process.ShellControl;
|
||||
public interface DelegateShellStore extends ShellStore {
|
||||
|
||||
@Override
|
||||
default ShellControl createControl() {
|
||||
return getDelegateHost().create();
|
||||
default ShellControl createBasicControl() {
|
||||
return getDelegateHost().control();
|
||||
}
|
||||
|
||||
ShellStore getDelegateHost();
|
||||
|
||||
@@ -19,16 +19,16 @@ public interface ShellStore extends DataStore, StatefulDataStore, LaunchableStor
|
||||
|
||||
@Override
|
||||
default FileSystem createFileSystem() {
|
||||
return new ConnectionFileSystem(create(), this);
|
||||
return new ConnectionFileSystem(control(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
default String prepareLaunchCommand() throws Exception {
|
||||
return create().prepareTerminalOpen();
|
||||
return control().prepareTerminalOpen();
|
||||
}
|
||||
|
||||
default ShellControl create() {
|
||||
var pc = createControl();
|
||||
default ShellControl control() {
|
||||
var pc = createBasicControl();
|
||||
pc.onInit(processControl -> {
|
||||
setState("type", processControl.getShellDialect());
|
||||
setState("os", processControl.getOsType());
|
||||
@@ -49,21 +49,21 @@ public interface ShellStore extends DataStore, StatefulDataStore, LaunchableStor
|
||||
return getState("charset", Charset.class, null);
|
||||
}
|
||||
|
||||
ShellControl createControl();
|
||||
ShellControl createBasicControl();
|
||||
|
||||
public default ShellDialect determineType() throws Exception {
|
||||
try (var pc = create().start()) {
|
||||
try (var pc = control().start()) {
|
||||
return pc.getShellDialect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default void validate() throws Exception {
|
||||
try (ShellControl pc = create().start()) {}
|
||||
try (ShellControl pc = control().start()) {}
|
||||
}
|
||||
|
||||
public default String queryMachineName() throws Exception {
|
||||
try (var pc = create().start()) {
|
||||
try (var pc = control().start()) {
|
||||
var operatingSystem = pc.getOsType();
|
||||
return operatingSystem.determineOperatingSystemName(pc);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class XPipeInstallation {
|
||||
|
||||
public static String getDataBasePath(ShellControl p) throws Exception {
|
||||
if (p.getOsType().equals(OsType.WINDOWS)) {
|
||||
var base = p.executeStringSimpleCommand(p.getShellDialect().getPrintVariableCommand("userprofile"));
|
||||
var base = p.executeSimpleStringCommand(p.getShellDialect().getPrintVariableCommand("userprofile"));
|
||||
return FileNames.join(base, ".xpipe");
|
||||
} else {
|
||||
return FileNames.join("~", ".xpipe");
|
||||
@@ -222,7 +222,7 @@ public class XPipeInstallation {
|
||||
public static String getDefaultInstallationBasePath(ShellControl p, boolean acceptPortable)
|
||||
throws Exception {
|
||||
if (acceptPortable) {
|
||||
var customHome = p.executeStringSimpleCommand(p.getShellDialect().getPrintVariableCommand("XPIPE_HOME"));
|
||||
var customHome = p.executeSimpleStringCommand(p.getShellDialect().getPrintVariableCommand("XPIPE_HOME"));
|
||||
if (!customHome.isEmpty()) {
|
||||
return customHome;
|
||||
}
|
||||
@@ -230,7 +230,7 @@ public class XPipeInstallation {
|
||||
|
||||
String path = null;
|
||||
if (p.getOsType().equals(OsType.WINDOWS)) {
|
||||
var base = p.executeStringSimpleCommand(p.getShellDialect().getPrintVariableCommand("LOCALAPPDATA"));
|
||||
var base = p.executeSimpleStringCommand(p.getShellDialect().getPrintVariableCommand("LOCALAPPDATA"));
|
||||
path = FileNames.join(base, "X-Pipe");
|
||||
} else if (p.getOsType().equals(OsType.LINUX)) {
|
||||
path = "/opt/xpipe";
|
||||
|
||||
@@ -22,7 +22,7 @@ public class XPipeTempDirectory {
|
||||
"Unable to access or create temporary directory " + dir);
|
||||
|
||||
if (proc.getOsType().equals(OsType.LINUX) || proc.getOsType().equals(OsType.MACOS)) {
|
||||
proc.executeBooleanSimpleCommand("chmod 777 \"" + dir + "\"");
|
||||
proc.executeSimpleBooleanCommand("chmod 777 \"" + dir + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class XPipeTempDirectory {
|
||||
|
||||
public static void clearSubDirectory(ShellControl proc) throws Exception {
|
||||
var dir = getSubDirectory(proc);
|
||||
if (!proc.executeBooleanSimpleCommand(proc.getShellDialect().getFileDeleteCommand(dir))) {
|
||||
if (!proc.executeSimpleBooleanCommand(proc.getShellDialect().getFileDeleteCommand(dir))) {
|
||||
throw new IOException("Unable to delete temporary directory " + dir);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user