1
0
Fork 0
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:
Alain Magloire 2003-12-19 17:14:41 +00:00
parent 16f0fdb92f
commit a1d50b221a

View file

@ -72,6 +72,15 @@ public class CommandLauncher {
return EnvironmentReader.getEnvVars(); 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 * 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) { public int waitAndRead(OutputStream out, OutputStream err) {
if (fShowCommand) { if (fShowCommand) {
printCommandLine(fCommandArgs, out); printCommandLine(out);
} }
if (fProcess == null) { if (fProcess == null) {
@ -123,7 +132,7 @@ public class CommandLauncher {
*/ */
public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) { public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) {
if (fShowCommand) { if (fShowCommand) {
printCommandLine(fCommandArgs, output); printCommandLine(output);
} }
if (fProcess == null) { if (fProcess == null) {
@ -207,20 +216,28 @@ public class CommandLauncher {
return state; return state;
} }
protected void printCommandLine(String[] commandArgs, OutputStream os) { protected void printCommandLine(OutputStream os) {
if (os != null) { if (os != null) {
StringBuffer buf= new StringBuffer(); String cmd = getCommandLine(getCommandArgs());
for (int i= 0; i < commandArgs.length; i++) {
buf.append(commandArgs[i]);
buf.append(' ');
}
buf.append(lineSeparator);
try { try {
os.write(buf.toString().getBytes()); os.write(cmd.getBytes());
os.flush(); os.flush();
} catch (IOException e) { } catch (IOException e) {
// ignore; // 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();
}
} }