mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Added a CommandLauncher.getCommandLine()
This commit is contained in:
parent
16f0fdb92f
commit
a1d50b221a
1 changed files with 27 additions and 10 deletions
|
@ -72,6 +72,15 @@ public class CommandLauncher {
|
|||
return EnvironmentReader.getEnvVars();
|
||||
}
|
||||
|
||||
/**
|
||||
* return the constructed Command line.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getCommandLine() {
|
||||
return getCommandLine(getCommandArgs());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a command array that will be passed to the process
|
||||
*/
|
||||
|
@ -103,7 +112,7 @@ public class CommandLauncher {
|
|||
*/
|
||||
public int waitAndRead(OutputStream out, OutputStream err) {
|
||||
if (fShowCommand) {
|
||||
printCommandLine(fCommandArgs, out);
|
||||
printCommandLine(out);
|
||||
}
|
||||
|
||||
if (fProcess == null) {
|
||||
|
@ -123,7 +132,7 @@ public class CommandLauncher {
|
|||
*/
|
||||
public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) {
|
||||
if (fShowCommand) {
|
||||
printCommandLine(fCommandArgs, output);
|
||||
printCommandLine(output);
|
||||
}
|
||||
|
||||
if (fProcess == null) {
|
||||
|
@ -207,20 +216,28 @@ public class CommandLauncher {
|
|||
return state;
|
||||
}
|
||||
|
||||
protected void printCommandLine(String[] commandArgs, OutputStream os) {
|
||||
protected void printCommandLine(OutputStream os) {
|
||||
if (os != null) {
|
||||
StringBuffer buf= new StringBuffer();
|
||||
for (int i= 0; i < commandArgs.length; i++) {
|
||||
buf.append(commandArgs[i]);
|
||||
buf.append(' ');
|
||||
}
|
||||
buf.append(lineSeparator);
|
||||
String cmd = getCommandLine(getCommandArgs());
|
||||
try {
|
||||
os.write(buf.toString().getBytes());
|
||||
os.write(cmd.getBytes());
|
||||
os.flush();
|
||||
} catch (IOException e) {
|
||||
// ignore;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getCommandLine(String[] commandArgs) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
if (fCommandArgs != null) {
|
||||
for (int i= 0; i < commandArgs.length; i++) {
|
||||
buf.append(commandArgs[i]);
|
||||
buf.append(' ');
|
||||
}
|
||||
buf.append(lineSeparator);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue