summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-07-16 14:54:32 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-07-16 14:54:32 (GMT)
commit5bb94ce16635954f460edcacd5422bc8d53fb8c1 (patch)
tree2632f80554b159a3cd195d4afdc2be1bdc856c17 /Source/cmake.cxx
parent56838c115ed813711f3e5cbd5bef4646677e5467 (diff)
downloadCMake-5bb94ce16635954f460edcacd5422bc8d53fb8c1.zip
CMake-5bb94ce16635954f460edcacd5422bc8d53fb8c1.tar.gz
CMake-5bb94ce16635954f460edcacd5422bc8d53fb8c1.tar.bz2
ENH: apply patch from Mathieu, add argument -E md5sum to compute md5sums of
files, compatible to md5sum output Alex
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index c928603..3518067 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -865,6 +865,7 @@ void CMakeCommandUsage(const char* program)
" line\n"
<< " environment - display the current enviroment\n"
<< " make_directory dir - create a directory\n"
+ << " md5sum file1 [...] - compute md5sum of files\n"
<< " remove_directory dir - remove a directory and its contents\n"
<< " remove file1 file2 ... - remove the file(s)\n"
<< " tar [cxt][vfz] file.tar file/dir1 file/dir2 ... - create a tar.\n"
@@ -1056,6 +1057,31 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
return 0;
}
+ // Command to calculate the md5sum of a file
+ else if (args[1] == "md5sum" && args.size() >= 3)
+ {
+ char md5out[32];
+ for (std::string::size_type cc = 2; cc < args.size(); cc ++)
+ {
+ const char *filename = args[cc].c_str();
+ // Cannot compute md5sum of a directory
+ if(cmSystemTools::FileIsDirectory(filename))
+ {
+ std::cerr << "Error: " << filename << " is a directory" << std::endl;
+ }
+ else if(!cmSystemTools::ComputeFileMD5(filename, md5out))
+ {
+ // To mimic md5sum behavior in a shell:
+ std::cerr << filename << ": No such file or directory" << std::endl;
+ }
+ else
+ {
+ std::cout << std::string(md5out,32) << " " << filename << std::endl;
+ }
+ }
+ return 1;
+ }
+
// Command to change directory and run a program.
else if (args[1] == "chdir" && args.size() >= 4)
{