com.partnersoft.os
Class OsCommand

java.lang.Object
  extended by com.partnersoft.os.OsCommand

public class OsCommand
extends java.lang.Object

An operating-system specific, native command builder and manager.

OsCommand takes care of the various issues involved in starting native processes. Naive use of Runtime.exec() can cause lots of problems - incorrect starting directory, spaces in filenames, etc.

It serves as an object-oriented builder and runner, with the actual work being passed to com.partnersoft.system.RuntimeLib methods for execution.

Copyright 2008 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Constructor Summary
OsCommand()
           
OsCommand(VfsFile file, java.lang.String... arguments)
           
 
Method Summary
 void addArgument(java.lang.String argument)
           
 void addArguments(java.lang.String... arguments)
           
 void execAndHalt()
          Executes the command and halts the current Java system.
 int execAndWait()
          Executes the command, waits for it to finish, and returns the exit value.
 void execNoWait()
          Executes the command and returns immediately, without waiting for it to finish.
 java.lang.String getCommand()
          Gets the name or path of the command.
 VfsDirectory getDirectory()
           
 java.util.List<java.lang.String> listArguments()
           
 void setCommand(java.lang.String command)
          Sets the name or path of the command as a string.
 void setCommandAsFile(VfsFile file)
           
 void setDirectory(VfsDirectory directory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OsCommand

public OsCommand()

OsCommand

public OsCommand(VfsFile file,
                 java.lang.String... arguments)
          throws java.io.IOException
Throws:
java.io.IOException
Method Detail

setCommandAsFile

public void setCommandAsFile(VfsFile file)
                      throws java.io.IOException
Throws:
java.io.IOException

addArgument

public void addArgument(java.lang.String argument)

addArguments

public void addArguments(java.lang.String... arguments)

execAndWait

public int execAndWait()
                throws java.io.IOException
Executes the command, waits for it to finish, and returns the exit value.

Throws:
java.io.IOException

execNoWait

public void execNoWait()
                throws java.io.IOException
Executes the command and returns immediately, without waiting for it to finish.

Throws:
java.io.IOException

execAndHalt

public void execAndHalt()
                 throws java.io.IOException
Executes the command and halts the current Java system.

Throws:
java.io.IOException

setCommand

public void setCommand(java.lang.String command)
Sets the name or path of the command as a string.


getCommand

public java.lang.String getCommand()
Gets the name or path of the command.


listArguments

public java.util.List<java.lang.String> listArguments()

getDirectory

public VfsDirectory getDirectory()

setDirectory

public void setDirectory(VfsDirectory directory)