diff options
author | 2016-12-19 15:46:47 +0000 | |
---|---|---|
committer | 2016-12-19 16:16:14 +0000 | |
commit | 760f7866032df14327aed591c39308104f0e4722 (patch) | |
tree | bd0911465f5512b6148092624537d95ed6fa08ce /src/main/cpp/blaze_util_posix.cc | |
parent | 5402993a5e9065984a42eca2132ec56ca3aa456f (diff) |
Bazel client: generalize path handling
Use/implement utility methods to join paths, check
if they are the root directory or are absolute,
etc. Doing so (instead of say checking if a path
starts with "/") allows for correct behavior on
Windows.
See https://github.com/bazelbuild/bazel/issues/2107
--
PiperOrigin-RevId: 142446027
MOS_MIGRATED_REVID=142446027
Diffstat (limited to 'src/main/cpp/blaze_util_posix.cc')
-rw-r--r-- | src/main/cpp/blaze_util_posix.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc index a90c602639..9be1c4e7ce 100644 --- a/src/main/cpp/blaze_util_posix.cc +++ b/src/main/cpp/blaze_util_posix.cc @@ -125,6 +125,14 @@ string GetProcessIdAsString() { return ToString(getpid()); } +string FindSystemWideBlazerc() { + string path = "/etc/bazel.bazelrc"; + if (blaze_util::CanAccess(path, true, false, false)) { + return path; + } + return ""; +} + void ExecuteProgram(const string &exe, const vector<string> &args_vector) { if (VerboseLogging()) { string dbg; @@ -323,7 +331,7 @@ string GetHashedBaseDir(const string& root, const string& hashable) { blaze_util::Md5Digest digest; digest.Update(hashable.data(), hashable.size()); digest.Finish(buf); - return root + "/" + digest.String(); + return blaze_util::JoinPath(root, digest.String()); } void CreateSecureOutputRoot(const string& path) { @@ -424,7 +432,7 @@ void SigPrintf(const char *format, ...) { uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block, BlazeLock* blaze_lock) { - string lockfile = output_base + "/lock"; + string lockfile = blaze_util::JoinPath(output_base, "lock"); int lockfd = open(lockfile.c_str(), O_CREAT|O_RDWR, 0644); if (lockfd < 0) { |