diff options
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r-- | Source/cmcmd.cxx | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index d5b0861..70ebd83 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -3,6 +3,7 @@ #include "cmcmd.h" #include "cmAlgorithms.h" +#include "cmCryptoHash.h" #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -641,7 +642,6 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Command to calculate the md5sum of a file if (args[1] == "md5sum" && args.size() >= 3) { - char md5out[32]; int retval = 0; for (std::string::size_type cc = 2; cc < args.size(); cc++) { const char* filename = args[cc].c_str(); @@ -649,13 +649,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if (cmSystemTools::FileIsDirectory(filename)) { std::cerr << "Error: " << filename << " is a directory" << std::endl; retval++; - } else if (!cmSystemTools::ComputeFileMD5(filename, md5out)) { - // To mimic md5sum behavior in a shell: - std::cerr << filename << ": No such file or directory" << std::endl; - retval++; } else { - std::cout << std::string(md5out, 32) << " " << filename - << std::endl; + std::string value = + cmSystemTools::ComputeFileHash(filename, cmCryptoHash::AlgoMD5); + if (value.empty()) { + // To mimic "md5sum" behavior in a shell: + std::cerr << filename << ": No such file or directory" + << std::endl; + retval++; + } else { + std::cout << value << " " << filename << std::endl; + } } } return retval; |