Renamed MultiPlatformBinaryManager to OSALBinaryManager
This commit is contained in:
parent
16959f49e8
commit
6217c838a7
3 changed files with 32 additions and 7 deletions
|
|
@ -73,13 +73,17 @@ public class MultiCommandExecutor implements AutoCloseable{
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Unable to initiate shell",e);
|
throw new RuntimeException("Unable to initiate shell", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public void exec(String cmd) throws IOException {
|
* Method will execute a given command. Note that any previous output of a command will be flushed.
|
||||||
while (readLine() != null); // read the output from previous exec
|
*
|
||||||
|
* @param cmd Is a String containing the command to execute.
|
||||||
|
*/
|
||||||
|
public synchronized void exec(String cmd) throws IOException {
|
||||||
|
clear();
|
||||||
eol = false;
|
eol = false;
|
||||||
|
|
||||||
stdin.write(cmd);
|
stdin.write(cmd);
|
||||||
|
|
@ -94,6 +98,19 @@ public class MultiCommandExecutor implements AutoCloseable{
|
||||||
stdin.flush();
|
stdin.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a String containing all content until the end of the command execution.
|
||||||
|
*/
|
||||||
|
public String readAll() throws IOException {
|
||||||
|
StringBuffer buff = new StringBuffer();
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while ((line= readLine()) != null) {
|
||||||
|
buff.append(line).append('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
return buff.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return one line from command execution, or null if the command has finished running
|
* @return one line from command execution, or null if the command has finished running
|
||||||
|
|
@ -101,19 +118,27 @@ public class MultiCommandExecutor implements AutoCloseable{
|
||||||
public String readLine() throws IOException {
|
public String readLine() throws IOException {
|
||||||
if (eol)
|
if (eol)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
String line = stdout.readLine();
|
String line = stdout.readLine();
|
||||||
if (line != null && line.startsWith(delimiter)) {
|
if (line != null && line.startsWith(delimiter)) {
|
||||||
eol = true;
|
eol = true;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will clear any existing command output from buffer.
|
||||||
|
*/
|
||||||
|
public void clear() throws IOException {
|
||||||
|
while (readLine() != null); // read the output from previous exec
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
try {
|
try {
|
||||||
// finally close the shell by execution exit command
|
// close the shell by execution exit command
|
||||||
stdin.write("exit");
|
stdin.write("exit");
|
||||||
stdin.newLine();
|
stdin.newLine();
|
||||||
stdin.flush();
|
stdin.flush();
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import java.io.File;
|
||||||
/**
|
/**
|
||||||
* This is a dummy implementation for unknown platforms
|
* This is a dummy implementation for unknown platforms
|
||||||
*/
|
*/
|
||||||
public class OsalDummyImpl extends OSAbstractionLayer {
|
public class OSALDummyImpl extends OSAbstractionLayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OSType getOSType() {
|
public OSType getOSType() {
|
||||||
|
|
@ -55,7 +55,7 @@ public abstract class OSAbstractionLayer {
|
||||||
if (os.contains("Linux")) return new OsalLinuxImpl();
|
if (os.contains("Linux")) return new OsalLinuxImpl();
|
||||||
else if (os.contains("Windows")) return new OsalWindowsImpl();
|
else if (os.contains("Windows")) return new OsalWindowsImpl();
|
||||||
else if (os.contains("Mac")) return new OsalMacOSImpl();
|
else if (os.contains("Mac")) return new OsalMacOSImpl();
|
||||||
else return new OsalDummyImpl();
|
else return new OSALDummyImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue