diff options
author | André Klitzing <aklitzing@gmail.com> | 2017-07-08 16:42:02 (GMT) |
---|---|---|
committer | André Klitzing <aklitzing@gmail.com> | 2017-07-14 06:57:17 (GMT) |
commit | c4647d84321f4a7b52301237394087065f5df33c (patch) | |
tree | 7fb689a0052667a611020e9d9169afa2160b1ba5 /Source/cmSystemTools.cxx | |
parent | 501a4feea8d0d007ce292defec1c97d6eb702409 (diff) | |
download | CMake-c4647d84321f4a7b52301237394087065f5df33c.zip CMake-c4647d84321f4a7b52301237394087065f5df33c.tar.gz CMake-c4647d84321f4a7b52301237394087065f5df33c.tar.bz2 |
Change ComputeFileMD5 to ComputeFileHash
* Use a parameter to select hash algorithm
* Return a std::string as result or an empty
string if it fails
* Avoids unnecessary copy of hash value
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index f7192e0..9f214c3 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -934,19 +934,17 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) #endif } -bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out) +std::string cmSystemTools::ComputeFileHash(const std::string& source, + cmCryptoHash::Algo algo) { #if defined(CMAKE_BUILD_WITH_CMAKE) - cmCryptoHash md5(cmCryptoHash::AlgoMD5); - std::string const str = md5.HashFile(source); - strncpy(md5out, str.c_str(), 32); - return !str.empty(); + cmCryptoHash hash(algo); + return hash.HashFile(source); #else (void)source; - (void)md5out; - cmSystemTools::Message("md5sum not supported in bootstrapping mode", + cmSystemTools::Message("hashsum not supported in bootstrapping mode", "Error"); - return false; + return std::string(); #endif } |