| Chris Lattner | 555eaf5 | 2003-09-30 18:37:50 +0000 | [diff] [blame] | 1 | //===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===// | 
| Chris Lattner | de4aa4c | 2002-12-23 23:50:16 +0000 | [diff] [blame] | 2 | // | 
|  | 3 | // This file contains functions used to do a variety of low-level, often | 
|  | 4 | // system-specific, tasks. | 
|  | 5 | // | 
|  | 6 | //===----------------------------------------------------------------------===// | 
|  | 7 |  | 
|  | 8 | #ifndef SYSTEMUTILS_H | 
|  | 9 | #define SYSTEMUTILS_H | 
|  | 10 |  | 
|  | 11 | #include <string> | 
|  | 12 |  | 
|  | 13 | /// isExecutableFile - This function returns true if the filename specified | 
|  | 14 | /// exists and is executable. | 
|  | 15 | /// | 
|  | 16 | bool isExecutableFile(const std::string &ExeFileName); | 
|  | 17 |  | 
| Misha Brukman | b02e413 | 2003-08-07 21:33:33 +0000 | [diff] [blame] | 18 | /// FindExecutable - Find a named executable, giving the argv[0] of program | 
|  | 19 | /// being executed. This allows us to find another LLVM tool if it is built into | 
|  | 20 | /// the same directory, but that directory is neither the current directory, nor | 
|  | 21 | /// in the PATH.  If the executable cannot be found, return an empty string. | 
|  | 22 | /// | 
| Chris Lattner | de4aa4c | 2002-12-23 23:50:16 +0000 | [diff] [blame] | 23 | std::string FindExecutable(const std::string &ExeName, | 
| Misha Brukman | 3c1d88a | 2003-09-29 22:37:57 +0000 | [diff] [blame] | 24 | const std::string &ProgramPath); | 
| Chris Lattner | de4aa4c | 2002-12-23 23:50:16 +0000 | [diff] [blame] | 25 |  | 
| Chris Lattner | de4aa4c | 2002-12-23 23:50:16 +0000 | [diff] [blame] | 26 | /// RunProgramWithTimeout - This function executes the specified program, with | 
|  | 27 | /// the specified null-terminated argument array, with the stdin/out/err fd's | 
|  | 28 | /// redirected, with a timeout specified on the commandline.  This terminates | 
|  | 29 | /// the calling program if there is an error executing the specified program. | 
|  | 30 | /// It returns the return value of the program, or -1 if a timeout is detected. | 
|  | 31 | /// | 
|  | 32 | int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args, | 
| Misha Brukman | 3c1d88a | 2003-09-29 22:37:57 +0000 | [diff] [blame] | 33 | const std::string &StdInFile = "", | 
|  | 34 | const std::string &StdOutFile = "", | 
|  | 35 | const std::string &StdErrFile = ""); | 
| Chris Lattner | de4aa4c | 2002-12-23 23:50:16 +0000 | [diff] [blame] | 36 |  | 
| Misha Brukman | 3c1d88a | 2003-09-29 22:37:57 +0000 | [diff] [blame] | 37 | /// ExecWait - Execute a program with the given arguments and environment and | 
|  | 38 | /// wait for it to terminate. | 
| John Criswell | f13ec35 | 2003-09-17 15:14:25 +0000 | [diff] [blame] | 39 | /// | 
| John Criswell | 74c8947 | 2003-09-17 19:02:49 +0000 | [diff] [blame] | 40 | int ExecWait (const char * const argv[], const char * const envp[]); | 
| Chris Lattner | de4aa4c | 2002-12-23 23:50:16 +0000 | [diff] [blame] | 41 | #endif |