diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-13 20:06:28 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-13 20:06:28 +0000 |
commit | 6828fe475a2aaa538e368b977d438be1cbedc4d7 (patch) | |
tree | 52b3e44436596d536b53279b4a7331a0a1d99920 /llvm/lib/Support/Program.cpp | |
parent | ec9dc01b3324195e76f0ccdc1b0268fafc7f63e4 (diff) | |
download | bcm5719-llvm-6828fe475a2aaa538e368b977d438be1cbedc4d7.tar.gz bcm5719-llvm-6828fe475a2aaa538e368b977d438be1cbedc4d7.zip |
Add a version of sys::ExecuteAndWait that takes StringRefs.
llvm-svn: 183934
Diffstat (limited to 'llvm/lib/Support/Program.cpp')
-rw-r--r-- | llvm/lib/Support/Program.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Support/Program.cpp b/llvm/lib/Support/Program.cpp index b1a9b98755c..165972610d8 100644 --- a/llvm/lib/Support/Program.cpp +++ b/llvm/lib/Support/Program.cpp @@ -29,6 +29,29 @@ static bool Execute(void **Data, const Path &path, const char **args, static int Wait(void *&Data, const Path &path, unsigned secondsToWait, std::string *ErrMsg); +int sys::ExecuteAndWait(StringRef path, const char **args, const char **env, + const StringRef **redirects, unsigned secondsToWait, + unsigned memoryLimit, std::string *ErrMsg, + bool *ExecutionFailed) { + Path P(path); + if (!redirects) + return ExecuteAndWait(P, args, env, 0, secondsToWait, memoryLimit, ErrMsg, + ExecutionFailed); + Path IO[3]; + const Path *IOP[3]; + for (int I = 0; I < 3; ++I) { + if (redirects[I]) { + IO[I] = *redirects[I]; + IOP[I] = &IO[I]; + } else { + IOP[I] = 0; + } + } + + return ExecuteAndWait(P, args, env, IOP, secondsToWait, memoryLimit, ErrMsg, + ExecutionFailed); +} + int sys::ExecuteAndWait(const Path &path, const char **args, const char **envp, const Path **redirects, unsigned secondsToWait, unsigned memoryLimit, std::string *ErrMsg, |