aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze_util_posix.cc
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2016-11-10 13:31:27 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-11-10 16:17:29 +0000
commit9c95196bf21e42bf46df9436a84d263c26e972d2 (patch)
tree5960e30273a63b95c5f16ca458d9b3511f3d7092 /src/main/cpp/blaze_util_posix.cc
parentbff767a0e24be19c6535214abb69f3d5d1d24210 (diff)
Bazel client: wrap some POSIX functions
This change: - starts using blaze_util::CanAccess and blaze_util::PathExists instead of access(2) - implements and starts using blaze_util::GetCwd instead of getcwd(2) - implements and starts using blaze_util::ChangeDirectory instead of chdir(2) - adds tests for the new wrapper methods -- MOS_MIGRATED_REVID=138750297
Diffstat (limited to 'src/main/cpp/blaze_util_posix.cc')
-rw-r--r--src/main/cpp/blaze_util_posix.cc13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc
index 7b4718ad90..e67876144a 100644
--- a/src/main/cpp/blaze_util_posix.cc
+++ b/src/main/cpp/blaze_util_posix.cc
@@ -14,7 +14,7 @@
#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
+#include <limits.h> // PATH_MAX
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
@@ -26,6 +26,7 @@
#include "src/main/cpp/util/errors.h"
#include "src/main/cpp/util/exit_code.h"
#include "src/main/cpp/util/file.h"
+#include "src/main/cpp/util/file_platform.h"
namespace blaze {
@@ -43,13 +44,9 @@ void ExecuteProgram(const string &exe, const vector<string> &args_vector) {
dbg.append(" ");
}
- char cwd[PATH_MAX] = {};
- if (getcwd(cwd, sizeof(cwd)) == NULL) {
- pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, "getcwd() failed");
- }
-
- fprintf(stderr, "Invoking binary %s in %s:\n %s\n", exe.c_str(), cwd,
- dbg.c_str());
+ string cwd = blaze_util::GetCwd();
+ fprintf(stderr, "Invoking binary %s in %s:\n %s\n", exe.c_str(),
+ cwd.c_str(), dbg.c_str());
}
// Copy to a char* array for execv: