mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
More shell fixes
This commit is contained in:
parent
e9340c40a8
commit
88ca584410
5 changed files with 18 additions and 7 deletions
|
@ -20,6 +20,8 @@ public interface ProcessControl extends Closeable, AutoCloseable {
|
|||
|
||||
void writeLine(String line) throws IOException;
|
||||
|
||||
void write(byte[] b) throws IOException;
|
||||
|
||||
@Override
|
||||
void close() throws IOException;
|
||||
void kill() throws Exception;
|
||||
|
|
|
@ -53,8 +53,6 @@ public interface ShellProcessControl extends ProcessControl {
|
|||
|
||||
ShellProcessControl elevation(SecretValue value);
|
||||
|
||||
ShellProcessControl startTimeout(Integer timeout);
|
||||
|
||||
SecretValue getElevationPassword();
|
||||
|
||||
default ShellProcessControl subShell(@NonNull ShellType type) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public interface ShellType {
|
|||
|
||||
List<String> createMkdirsCommand(String dirs);
|
||||
|
||||
List<String> createFileReadCommand(String file);
|
||||
String createFileReadCommand(String file);
|
||||
|
||||
String createFileWriteCommand(String file);
|
||||
|
||||
|
|
|
@ -11,19 +11,22 @@ public interface MachineStore extends FileSystemStore, ShellStore {
|
|||
|
||||
@Override
|
||||
public default InputStream openInput(String file) throws Exception {
|
||||
return create().command(proc -> proc.getShellType().flatten(proc.getShellType().createFileReadCommand(proc.getOsType().normalizeFileName(file))))
|
||||
return create().command(proc -> proc.getShellType()
|
||||
.createFileReadCommand(proc.getOsType().normalizeFileName(file)))
|
||||
.startExternalStdout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public default OutputStream openOutput(String file) throws Exception {
|
||||
return create().command(proc -> proc.getShellType().createFileWriteCommand(proc.getOsType().normalizeFileName(file)))
|
||||
return create().command(proc -> proc.getShellType()
|
||||
.createFileWriteCommand(proc.getOsType().normalizeFileName(file)))
|
||||
.startExternalStdin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public default boolean exists(String file) throws Exception {
|
||||
try (var pc = create().command(proc -> proc.getShellType().createFileExistsCommand(proc.getOsType().normalizeFileName(file)))
|
||||
try (var pc = create().command(proc -> proc.getShellType()
|
||||
.createFileExistsCommand(proc.getOsType().normalizeFileName(file)))
|
||||
.start()) {
|
||||
return pc.discardAndCheckExit();
|
||||
}
|
||||
|
@ -31,7 +34,9 @@ public interface MachineStore extends FileSystemStore, ShellStore {
|
|||
|
||||
@Override
|
||||
public default boolean mkdirs(String file) throws Exception {
|
||||
try (var pc = create().command(proc -> proc.getShellType().flatten(proc.getShellType().createMkdirsCommand(proc.getOsType().normalizeFileName(file))))
|
||||
try (var pc = create().command(proc -> proc.getShellType()
|
||||
.flatten(proc.getShellType()
|
||||
.createMkdirsCommand(proc.getOsType().normalizeFileName(file))))
|
||||
.start()) {
|
||||
return pc.discardAndCheckExit();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.xpipe.core.util;
|
||||
|
||||
import io.xpipe.core.impl.FileNames;
|
||||
import io.xpipe.core.process.OsType;
|
||||
import io.xpipe.core.process.ShellProcessControl;
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
|
||||
|
@ -22,6 +23,11 @@ public class XPipeTempDirectory {
|
|||
throw new IOException("Unable to access or create temporary directory " + dir);
|
||||
}
|
||||
|
||||
if (proc.getOsType().equals(OsType.LINUX)) {
|
||||
proc.executeSimpleCommand("(chmod -f 777 \"" + dir + "\" || true)");
|
||||
|
||||
}
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue