From 9c95196bf21e42bf46df9436a84d263c26e972d2 Mon Sep 17 00:00:00 2001 From: Laszlo Csomor Date: Thu, 10 Nov 2016 13:31:27 +0000 Subject: 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 --- src/main/cpp/blaze_util_posix.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/main/cpp/blaze_util_posix.cc') 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 #include -#include +#include // PATH_MAX #include #include #include @@ -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 &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: -- cgit v1.2.3