Separate shell init commands not into lines anymore

This should improve any script requirement issues.
This commit is contained in:
crschnick 2023-04-07 17:18:01 +00:00
parent ffe2326e7f
commit ff27f54535
4 changed files with 16 additions and 18 deletions

View file

@ -279,7 +279,7 @@ final class OpenFileSystemModel {
if (store.getValue() instanceof ShellStore s) {
var connection = ((ConnectionFileSystem) fileSystem).getShellControl();
var command = s.create()
.initWith(List.of(connection.getShellDialect().getCdCommand(directory)))
.initWith(connection.getShellDialect().getCdCommand(directory))
.prepareTerminalOpen();
TerminalHelper.open(directory, command);
}

View file

@ -67,6 +67,8 @@ public interface ShellControl extends ProcessControl {
ShellControl elevationPassword(SecretValue value);
ShellControl initWith(String cmds);
ShellControl initWith(List<String> cmds);
ShellControl startTimeout(int ms);

View file

@ -35,7 +35,7 @@ public class XPipeSession {
return;
}
var sessionFile = XPipeTempDirectory.getLocal().resolve("xpipe_session");
var sessionFile = Path.of(System.getProperty("java.io.tmpdir")).resolve("xpipe_session");
var isNewSystemSession = !Files.exists(sessionFile);
var systemSessionId = isNewSystemSession
? UUID.randomUUID()

View file

@ -5,36 +5,32 @@ import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellControl;
import java.io.IOException;
import java.nio.file.Path;
public class XPipeTempDirectory {
public static Path getLocal() {
if (OsType.getLocal().equals(OsType.WINDOWS)) {
return Path.of(System.getenv("TEMP")).resolve("xpipe");
} else if (OsType.getLocal().equals(OsType.LINUX)) {
return Path.of("/tmp/xpipe");
} else {
return Path.of(System.getenv("TMPDIR"), "xpipe");
}
public static String getSystemTempDirectory(ShellControl proc) throws Exception {
return proc.getOsType().getTempDirectory(proc);
}
public static String get(ShellControl proc) throws Exception {
public static String getSubDirectory(ShellControl proc) throws Exception {
var base = proc.getOsType().getTempDirectory(proc);
var dir = FileNames.join(base, "xpipe");
proc.executeSimpleCommand(proc.getShellDialect().getMkdirsCommand(dir),
"Unable to access or create temporary directory " + dir);
if (!proc.getShellDialect().createFileExistsCommand(proc, dir).executeAndCheck()) {
proc.executeSimpleCommand(
proc.getShellDialect().getMkdirsCommand(dir),
"Unable to access or create temporary directory " + dir);
if (proc.getOsType().equals(OsType.LINUX) || proc.getOsType().equals(OsType.MACOS)) {
proc.executeSimpleCommand("chmod -f 777 \"" + dir + "\"");
if (proc.getOsType().equals(OsType.LINUX) || proc.getOsType().equals(OsType.MACOS)) {
proc.executeSimpleCommand("chmod -f 777 \"" + dir + "\"");
}
}
return dir;
}
public static void clear(ShellControl proc) throws Exception {
var dir = get(proc);
public static void clearSubDirectory(ShellControl proc) throws Exception {
var dir = getSubDirectory(proc);
if (!proc.executeBooleanSimpleCommand(proc.getShellDialect().getFileDeleteCommand(dir))) {
throw new IOException("Unable to delete temporary directory " + dir);
}