|
@@ -3,6 +3,7 @@
|
|
#include "cmcmd.h"
|
|
#include "cmcmd.h"
|
|
|
|
|
|
#include "cmAlgorithms.h"
|
|
#include "cmAlgorithms.h"
|
|
|
|
+#include "cmCryptoHash.h"
|
|
#include "cmGlobalGenerator.h"
|
|
#include "cmGlobalGenerator.h"
|
|
#include "cmLocalGenerator.h"
|
|
#include "cmLocalGenerator.h"
|
|
#include "cmMakefile.h"
|
|
#include "cmMakefile.h"
|
|
@@ -641,7 +642,6 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|
|
|
|
|
// Command to calculate the md5sum of a file
|
|
// Command to calculate the md5sum of a file
|
|
if (args[1] == "md5sum" && args.size() >= 3) {
|
|
if (args[1] == "md5sum" && args.size() >= 3) {
|
|
- char md5out[32];
|
|
|
|
int retval = 0;
|
|
int retval = 0;
|
|
for (std::string::size_type cc = 2; cc < args.size(); cc++) {
|
|
for (std::string::size_type cc = 2; cc < args.size(); cc++) {
|
|
const char* filename = args[cc].c_str();
|
|
const char* filename = args[cc].c_str();
|
|
@@ -649,13 +649,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|
if (cmSystemTools::FileIsDirectory(filename)) {
|
|
if (cmSystemTools::FileIsDirectory(filename)) {
|
|
std::cerr << "Error: " << filename << " is a directory" << std::endl;
|
|
std::cerr << "Error: " << filename << " is a directory" << std::endl;
|
|
retval++;
|
|
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 {
|
|
} 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;
|
|
return retval;
|