diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-02-07 20:06:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-08 18:05:32 (GMT) |
commit | 77f60392d93f41a8828d3db1d7b76d45f1535d07 (patch) | |
tree | f9269d9beaa720270a4d2eed879d79b9d22aef54 | |
parent | 473ca1ac4a5df336ff09ee2c666e437eabf43bc9 (diff) | |
download | CMake-77f60392d93f41a8828d3db1d7b76d45f1535d07.zip CMake-77f60392d93f41a8828d3db1d7b76d45f1535d07.tar.gz CMake-77f60392d93f41a8828d3db1d7b76d45f1535d07.tar.bz2 |
stringapi: Accept strings when MD5 hashing data
-rw-r--r-- | Source/cmCryptoHash.cxx | 10 | ||||
-rw-r--r-- | Source/cmCryptoHash.h | 4 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 4 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 4 |
4 files changed, 11 insertions, 11 deletions
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 7f4b10f..0d3c6bb 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -35,18 +35,18 @@ cmsys::auto_ptr<cmCryptoHash> cmCryptoHash::New(const char* algo) } //---------------------------------------------------------------------------- -std::string cmCryptoHash::HashString(const char* input) +std::string cmCryptoHash::HashString(const std::string& input) { this->Initialize(); - this->Append(reinterpret_cast<unsigned char const*>(input), - static_cast<int>(strlen(input))); + this->Append(reinterpret_cast<unsigned char const*>(&input[0]), + static_cast<int>(input.size())); return this->Finalize(); } //---------------------------------------------------------------------------- -std::string cmCryptoHash::HashFile(const char* file) +std::string cmCryptoHash::HashFile(const std::string& file) { - cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(file.c_str(), std::ios::in | cmsys_ios_binary); if(!fin) { return ""; diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 1bea9ab..88cd240 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -21,8 +21,8 @@ class cmCryptoHash public: virtual ~cmCryptoHash() {} static cmsys::auto_ptr<cmCryptoHash> New(const char* algo); - std::string HashString(const char* input); - std::string HashFile(const char* file); + std::string HashString(const std::string& input); + std::string HashFile(const std::string& file); protected: virtual void Initialize()=0; virtual void Append(unsigned char const*, int)=0; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7cc63bb..18eb62e 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -944,7 +944,7 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) #endif } -bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) +bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out) { #if defined(CMAKE_BUILD_WITH_CMAKE) cmCryptoHashMD5 md5; @@ -959,7 +959,7 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) #endif } -std::string cmSystemTools::ComputeStringMD5(const char* input) +std::string cmSystemTools::ComputeStringMD5(const std::string& input) { #if defined(CMAKE_BUILD_WITH_CMAKE) cmCryptoHashMD5 md5; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 4a5d298..da37ceb 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -185,10 +185,10 @@ public: static bool RenameFile(const char* oldname, const char* newname); ///! Compute the md5sum of a file - static bool ComputeFileMD5(const char* source, char* md5out); + static bool ComputeFileMD5(const std::string& source, char* md5out); /** Compute the md5sum of a string. */ - static std::string ComputeStringMD5(const char* input); + static std::string ComputeStringMD5(const std::string& input); /** * Run a single executable command |