diff options
author | ccalvarin <ccalvarin@google.com> | 2018-06-07 11:05:54 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-07 11:07:04 -0700 |
commit | 755278df00f65818dc092fe4f8a31bdec1aaaab5 (patch) | |
tree | 0517b2df05754f953f157a1043188929a76c8be6 /src/main/cpp/util/path_posix.cc | |
parent | a1c9f8d33457cd1f3b01299863bcab2667c13a52 (diff) |
blaze_util::ConvertPath should not make paths absolute.
It does not claim to, and this was already true for posix platforms. Windows platforms, however, always made the path absolute, which was a hard-to-diagnose difference between the two.
Similarly, MakeAbsolute was relying on this to be correct for windows, so this change splits the implementation and keeps the behavior consistent. While we're here, also remove the empty-string behavior from MakeAbsolute, and instead make it clear at all sites that this behavior is present and affects accepted flag syntax. We may want to remove this later.
RELNOTES: None.
PiperOrigin-RevId: 199663395
Diffstat (limited to 'src/main/cpp/util/path_posix.cc')
-rw-r--r-- | src/main/cpp/util/path_posix.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/cpp/util/path_posix.cc b/src/main/cpp/util/path_posix.cc index bbeffca30c..267dc22931 100644 --- a/src/main/cpp/util/path_posix.cc +++ b/src/main/cpp/util/path_posix.cc @@ -20,7 +20,9 @@ #include <unistd.h> // access, open, close, fsync #include "src/main/cpp/util/errors.h" #include "src/main/cpp/util/exit_code.h" +#include "src/main/cpp/util/file_platform.h" #include "src/main/cpp/util/logging.h" +#include "src/main/cpp/util/path.h" namespace blaze_util { @@ -57,4 +59,11 @@ bool IsAbsolute(const std::string &path) { return !path.empty() && path[0] == '/'; } +std::string MakeAbsolute(const std::string &path) { + if (blaze_util::IsAbsolute(path) || path.empty()) { + return path; + } + + return JoinPath(blaze_util::GetCwd(), path); +} } // namespace blaze_util |