cmCryptoHash: prefer to cmSystemTools::ComputeFileHash

This commit is contained in:
Ben Boeckel
2023-08-07 21:18:10 -04:00
parent 4d5198a986
commit 0abde043d2
3 changed files with 9 additions and 11 deletions
+2 -2
View File
@@ -290,8 +290,8 @@ std::string DebGenerator::generateMD5File() const
continue; continue;
} }
std::string output = cmCryptoHash hasher(cmCryptoHash::AlgoMD5);
cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5); std::string output = hasher.HashFile(file);
if (output.empty()) { if (output.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem computing the md5 of " << file << std::endl); "Problem computing the md5 of " << file << std::endl);
+4 -4
View File
@@ -285,8 +285,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
if (cmIsOn(this->GetOption("InternalTest"))) { if (cmIsOn(this->GetOption("InternalTest"))) {
upload_as += "ffffffffffffffffffffffffffffffff"; upload_as += "ffffffffffffffffffffffffffffffff";
} else { } else {
upload_as += cmCryptoHash hasher(cmCryptoHash::AlgoMD5);
cmSystemTools::ComputeFileHash(local_file, cmCryptoHash::AlgoMD5); upload_as += hasher.HashFile(local_file);
} }
if (!cmSystemTools::FileExists(local_file)) { if (!cmSystemTools::FileExists(local_file)) {
@@ -549,8 +549,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
} }
} }
std::string md5sum = cmCryptoHash hasher(cmCryptoHash::AlgoMD5);
cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5); std::string md5sum = hasher.HashFile(file);
// 1. request the buildid and check to see if the file // 1. request the buildid and check to see if the file
// has already been uploaded // has already been uploaded
// TODO I added support for subproject. You would need to add // TODO I added support for subproject. You would need to add
+3 -5
View File
@@ -13,6 +13,7 @@
#include "cmCommandLineArgument.h" #include "cmCommandLineArgument.h"
#include "cmConsoleBuf.h" #include "cmConsoleBuf.h"
#include "cmCryptoHash.h"
#include "cmDuration.h" #include "cmDuration.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmList.h" #include "cmList.h"
@@ -1692,11 +1693,8 @@ int cmcmd::HashSumFile(std::vector<std::string> const& args,
std::cerr << "Error: " << filename << " is a directory" << std::endl; std::cerr << "Error: " << filename << " is a directory" << std::endl;
retval++; retval++;
} else { } else {
std::string value cmCryptoHash hasher(algo);
#ifndef CMAKE_BOOTSTRAP std::string value = hasher.HashFile(filename);
= cmSystemTools::ComputeFileHash(filename, algo)
#endif
;
if (value.empty()) { if (value.empty()) {
// To mimic "md5sum/shasum" behavior in a shell: // To mimic "md5sum/shasum" behavior in a shell:
std::cerr << filename << ": No such file or directory" << std::endl; std::cerr << filename << ": No such file or directory" << std::endl;