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

View File

@ -290,8 +290,8 @@ std::string DebGenerator::generateMD5File() const
continue;
}
std::string output =
cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5);
cmCryptoHash hasher(cmCryptoHash::AlgoMD5);
std::string output = hasher.HashFile(file);
if (output.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem computing the md5 of " << file << std::endl);

View File

@ -285,8 +285,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
if (cmIsOn(this->GetOption("InternalTest"))) {
upload_as += "ffffffffffffffffffffffffffffffff";
} else {
upload_as +=
cmSystemTools::ComputeFileHash(local_file, cmCryptoHash::AlgoMD5);
cmCryptoHash hasher(cmCryptoHash::AlgoMD5);
upload_as += hasher.HashFile(local_file);
}
if (!cmSystemTools::FileExists(local_file)) {
@ -549,8 +549,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
}
}
std::string md5sum =
cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5);
cmCryptoHash hasher(cmCryptoHash::AlgoMD5);
std::string md5sum = hasher.HashFile(file);
// 1. request the buildid and check to see if the file
// has already been uploaded
// TODO I added support for subproject. You would need to add

View File

@ -13,6 +13,7 @@
#include "cmCommandLineArgument.h"
#include "cmConsoleBuf.h"
#include "cmCryptoHash.h"
#include "cmDuration.h"
#include "cmGlobalGenerator.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;
retval++;
} else {
std::string value
#ifndef CMAKE_BOOTSTRAP
= cmSystemTools::ComputeFileHash(filename, algo)
#endif
;
cmCryptoHash hasher(algo);
std::string value = hasher.HashFile(filename);
if (value.empty()) {
// To mimic "md5sum/shasum" behavior in a shell:
std::cerr << filename << ": No such file or directory" << std::endl;