LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

llvm::sys::Program Class Reference

An abstraction for finding and executing programs. More...

#include <Program.h>

List of all members.

Static Public Member Functions

Methods
static Path FindProgramByName (const std::string &name)
 Construct a Program by finding it by name.
static int ExecuteAndWait (const Path &path, const std::vector< std::string > &args)
 Executes the program with the given set of arguments.


Detailed Description

An abstraction for finding and executing programs.

This class provides an abstraction for programs that are executable by the operating system. It provides a platform generic way to find executable programs from the path and to execute them. The sys::Path class is used to locate the Program.

Since:
1.4

Definition at line 29 of file Program.h.


Member Function Documentation

int llvm::Program::ExecuteAndWait const Path path,
const std::vector< std::string > &  args
[static]
 

Executes the program with the given set of arguments.

This function executes the program using the arguments provided and waits for the program to exit. This function will block the current program until the invoked program exits. The invoked program will inherit the stdin, stdout, and stderr file descriptors, the environment and other configuration settings of the inoking program. If Path::executable() does not return true when this function is called then a std::string is thrown. Path::executable() returns true.

Parameters:
path A sys::Path object providing the path of the program to be executed. It is presumed this is the result of the FindProgramByName method.
args A vector of strings that are passed to the program. The first element should *not* be the name of the program.
Returns:
an integer result code indicating the status of the program.
Exceptions:
std::string on a variety of error conditions or if the invoked program aborted abnormally.
See also:
FindProgrambyName

Definition at line 81 of file Unix/Program.cpp.

References llvm::sys::Path::c_str(), environ, llvm::sys::Path::executable(), llvm::sys::Path::get(), llvm::sys::Path::getLast(), index, and ThrowErrno().

Path llvm::Program::FindProgramByName const std::string &  name  )  [static]
 

Construct a Program by finding it by name.

This static constructor (factory) will attempt to locate a program in the operating system's file system using some pre-determined set of locations to search (e.g. the PATH on Unix).

Returns:
A Path object initialized to the path of the program or a Path object that is empty (invalid) if the program could not be found.
Exceptions:
nothing 

Definition at line 34 of file Unix/Program.cpp.

References llvm::sys::Path::appendFile(), llvm::sys::Path::executable(), llvm::sys::Path::setDirectory(), and llvm::sys::Path::setFile().


The documentation for this class was generated from the following files: