summaryrefslogtreecommitdiff
path: root/Source/cmOutputConverter.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2016-10-04 22:56:30 +0200
committerStephen Kelly <steveire@gmail.com>2016-10-06 20:02:06 +0200
commitc3264f48c2960325b9141d3ec58c6b49afe120c9 (patch)
treed5c7cca2ea2d5c6e40c029eaf70723b846ef7941 /Source/cmOutputConverter.cxx
parent52168f3210ca07a8d80991958d588789c2693d63 (diff)
downloadcmake-c3264f48c2960325b9141d3ec58c6b49afe120c9.tar.gz
Convert: Extract method to determine if paths are in directory
The conditional early return can be moved to clients, which would have many benefits, notably making cmOutputConverter independent of directory-specific state.
Diffstat (limited to 'Source/cmOutputConverter.cxx')
-rw-r--r--Source/cmOutputConverter.cxx18
1 files changed, 13 insertions, 5 deletions
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index 5d31f02fdc..dfc1610b0c 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -76,13 +76,14 @@ static bool cmOutputConverterNotAbove(const char* a, const char* b)
cmSystemTools::IsSubDirectory(a, b));
}
-std::string cmOutputConverter::ConvertToRelativePath(
- std::string const& local_path, std::string const& remote_path) const
+bool cmOutputConverter::ContainedInDirectory(std::string const& local_path,
+ std::string const& remote_path,
+ cmState::Directory directory)
{
const std::string relativePathTopBinary =
- this->StateSnapshot.GetDirectory().GetRelativePathTopBinary();
+ directory.GetRelativePathTopBinary();
const std::string relativePathTopSource =
- this->StateSnapshot.GetDirectory().GetRelativePathTopSource();
+ directory.GetRelativePathTopSource();
const bool bothInBinary =
cmOutputConverterNotAbove(local_path.c_str(),
@@ -96,7 +97,14 @@ std::string cmOutputConverter::ConvertToRelativePath(
cmOutputConverterNotAbove(remote_path.c_str(),
relativePathTopSource.c_str());
- if (!(bothInSource || bothInBinary)) {
+ return bothInSource || bothInBinary;
+}
+
+std::string cmOutputConverter::ConvertToRelativePath(
+ std::string const& local_path, std::string const& remote_path) const
+{
+ if (!ContainedInDirectory(local_path, remote_path,
+ this->StateSnapshot.GetDirectory())) {
return remote_path;
}