|
@@ -13,10 +13,10 @@ cmFilePathChecksum::cmFilePathChecksum()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-cmFilePathChecksum::cmFilePathChecksum(const std::string& currentSrcDir,
|
|
|
- const std::string& currentBinDir,
|
|
|
- const std::string& projectSrcDir,
|
|
|
- const std::string& projectBinDir)
|
|
|
+cmFilePathChecksum::cmFilePathChecksum(std::string const& currentSrcDir,
|
|
|
+ std::string const& currentBinDir,
|
|
|
+ std::string const& projectSrcDir,
|
|
|
+ std::string const& projectBinDir)
|
|
|
{
|
|
|
setupParentDirs(currentSrcDir, currentBinDir, projectSrcDir, projectBinDir);
|
|
|
}
|
|
@@ -29,36 +29,35 @@ cmFilePathChecksum::cmFilePathChecksum(cmMakefile* makefile)
|
|
|
makefile->GetHomeOutputDirectory());
|
|
|
}
|
|
|
|
|
|
-void cmFilePathChecksum::setupParentDirs(const std::string& currentSrcDir,
|
|
|
- const std::string& currentBinDir,
|
|
|
- const std::string& projectSrcDir,
|
|
|
- const std::string& projectBinDir)
|
|
|
+void cmFilePathChecksum::setupParentDirs(std::string const& currentSrcDir,
|
|
|
+ std::string const& currentBinDir,
|
|
|
+ std::string const& projectSrcDir,
|
|
|
+ std::string const& projectBinDir)
|
|
|
{
|
|
|
- parentDirs[0].first = cmsys::SystemTools::GetRealPath(currentSrcDir);
|
|
|
- parentDirs[1].first = cmsys::SystemTools::GetRealPath(currentBinDir);
|
|
|
- parentDirs[2].first = cmsys::SystemTools::GetRealPath(projectSrcDir);
|
|
|
- parentDirs[3].first = cmsys::SystemTools::GetRealPath(projectBinDir);
|
|
|
+ this->parentDirs[0].first = cmsys::SystemTools::GetRealPath(currentSrcDir);
|
|
|
+ this->parentDirs[1].first = cmsys::SystemTools::GetRealPath(currentBinDir);
|
|
|
+ this->parentDirs[2].first = cmsys::SystemTools::GetRealPath(projectSrcDir);
|
|
|
+ this->parentDirs[3].first = cmsys::SystemTools::GetRealPath(projectBinDir);
|
|
|
|
|
|
- parentDirs[0].second = "CurrentSource";
|
|
|
- parentDirs[1].second = "CurrentBinary";
|
|
|
- parentDirs[2].second = "ProjectSource";
|
|
|
- parentDirs[3].second = "ProjectBinary";
|
|
|
+ this->parentDirs[0].second = "CurrentSource";
|
|
|
+ this->parentDirs[1].second = "CurrentBinary";
|
|
|
+ this->parentDirs[2].second = "ProjectSource";
|
|
|
+ this->parentDirs[3].second = "ProjectBinary";
|
|
|
}
|
|
|
|
|
|
-std::string cmFilePathChecksum::get(const std::string& filePath) const
|
|
|
+std::string cmFilePathChecksum::get(std::string const& filePath) const
|
|
|
{
|
|
|
std::string relPath;
|
|
|
std::string relSeed;
|
|
|
{
|
|
|
- const std::string fileReal = cmsys::SystemTools::GetRealPath(filePath);
|
|
|
+ std::string const fileReal = cmsys::SystemTools::GetRealPath(filePath);
|
|
|
std::string parentDir;
|
|
|
// Find closest project parent directory
|
|
|
- for (size_t ii = 0; ii != numParentDirs; ++ii) {
|
|
|
- const std::string& pDir = parentDirs[ii].first;
|
|
|
- if (!pDir.empty() &&
|
|
|
- cmsys::SystemTools::IsSubDirectory(fileReal, pDir)) {
|
|
|
- relSeed = parentDirs[ii].second;
|
|
|
- parentDir = pDir;
|
|
|
+ for (auto const& pDir : this->parentDirs) {
|
|
|
+ if (!pDir.first.empty() &&
|
|
|
+ cmsys::SystemTools::IsSubDirectory(fileReal, pDir.first)) {
|
|
|
+ parentDir = pDir.first;
|
|
|
+ relSeed = pDir.second;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -77,11 +76,11 @@ std::string cmFilePathChecksum::get(const std::string& filePath) const
|
|
|
cmCryptoHash(cmCryptoHash::AlgoSHA256).ByteHashString(relSeed + relPath);
|
|
|
|
|
|
// Convert binary checksum to string
|
|
|
- return cmBase32Encoder().encodeString(&hashBytes[0], hashBytes.size(),
|
|
|
+ return cmBase32Encoder().encodeString(&hashBytes.front(), hashBytes.size(),
|
|
|
false);
|
|
|
}
|
|
|
|
|
|
-std::string cmFilePathChecksum::getPart(const std::string& filePath,
|
|
|
+std::string cmFilePathChecksum::getPart(std::string const& filePath,
|
|
|
size_t length) const
|
|
|
{
|
|
|
return get(filePath).substr(0, length);
|