diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2016-12-19 15:46:47 +0000 |
---|---|---|
committer | Klaus Aehlig <aehlig@google.com> | 2016-12-19 16:16:14 +0000 |
commit | 760f7866032df14327aed591c39308104f0e4722 (patch) | |
tree | bd0911465f5512b6148092624537d95ed6fa08ce /src/main/cpp/util/file_platform.h | |
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/util/file_platform.h')
-rw-r--r-- | src/main/cpp/util/file_platform.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/cpp/util/file_platform.h b/src/main/cpp/util/file_platform.h index 78322dfeb8..e6df884ea0 100644 --- a/src/main/cpp/util/file_platform.h +++ b/src/main/cpp/util/file_platform.h @@ -69,6 +69,12 @@ bool CanAccess(const std::string& path, bool read, bool write, bool exec); // Returns true if `path` refers to a directory or a symlink/junction to one. bool IsDirectory(const std::string& path); +// Returns true if `path` is the root directory or a Windows drive root. +bool IsRootDirectory(const std::string &path); + +// Returns true if `path` is absolute. +bool IsAbsolute(const std::string &path); + // Calls fsync() on the file (or directory) specified in 'file_path'. // pdie() if syncing fails. void SyncFile(const std::string& path); |