1 //===- SystemUtils.h - Utilities to do low-level system stuff --*- C++ -*--===//
3 // This file contains functions used to do a variety of low-level, often
4 // system-specific, tasks.
6 //===----------------------------------------------------------------------===//
13 /// isExecutableFile - This function returns true if the filename specified
14 /// exists and is executable.
16 bool isExecutableFile(const std::string &ExeFileName);
18 // FindExecutable - Find a named executable, giving the argv[0] of bugpoint.
19 // This assumes the executable is in the same directory as bugpoint itself.
20 // If the executable cannot be found, return an empty string.
22 std::string FindExecutable(const std::string &ExeName,
23 const std::string &BugPointPath);
25 /// removeFile - Delete the specified file
27 void removeFile(const std::string &Filename);
29 /// getUniqueFilename - Return a filename with the specified prefix. If the
30 /// file does not exist yet, return it, otherwise add a suffix to make it
33 std::string getUniqueFilename(const std::string &FilenameBase);
35 /// RunProgramWithTimeout - This function executes the specified program, with
36 /// the specified null-terminated argument array, with the stdin/out/err fd's
37 /// redirected, with a timeout specified on the commandline. This terminates
38 /// the calling program if there is an error executing the specified program.
39 /// It returns the return value of the program, or -1 if a timeout is detected.
41 int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args,
42 const std::string &StdInFile = "",
43 const std::string &StdOutFile = "",
44 const std::string &StdErrFile = "");