summaryrefslogtreecommitdiffhomepage
path: root/test/util/fs_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/util/fs_util.cc')
-rw-r--r--test/util/fs_util.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/test/util/fs_util.cc b/test/util/fs_util.cc
index e7e8be1d8..6bd424417 100644
--- a/test/util/fs_util.cc
+++ b/test/util/fs_util.cc
@@ -550,25 +550,35 @@ std::pair<absl::string_view, absl::string_view> SplitPath(
std::string::size_type pos = path.find_last_of('/');
// Handle the case with no '/' in 'path'.
- if (pos == absl::string_view::npos)
+ if (pos == absl::string_view::npos) {
return std::make_pair(path.substr(0, 0), path);
+ }
// Handle the case with a single leading '/' in 'path'.
- if (pos == 0)
+ if (pos == 0) {
return std::make_pair(path.substr(0, 1), absl::ClippedSubstr(path, 1));
+ }
return std::make_pair(path.substr(0, pos),
absl::ClippedSubstr(path, pos + 1));
}
std::string JoinPath(absl::string_view path1, absl::string_view path2) {
- if (path1.empty()) return std::string(path2);
- if (path2.empty()) return std::string(path1);
+ if (path1.empty()) {
+ return std::string(path2);
+ }
+ if (path2.empty()) {
+ return std::string(path1);
+ }
+
if (path1.back() == '/') {
- if (path2.front() == '/')
+ if (path2.front() == '/') {
return absl::StrCat(path1, absl::ClippedSubstr(path2, 1));
+ }
} else {
- if (path2.front() != '/') return absl::StrCat(path1, "/", path2);
+ if (path2.front() != '/') {
+ return absl::StrCat(path1, "/", path2);
+ }
}
return absl::StrCat(path1, path2);
}