diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2016-09-01 11:17:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-09-02 13:19:00 (GMT) |
commit | 228f4e9b336757ddbf3085637e47962692278c45 (patch) | |
tree | bc754d220623c37167f948f96c405f3e098f91ec /Source/cmFilePathUuid.cxx | |
parent | b481ddb3df21e02e16038854ec7d256601717018 (diff) | |
download | CMake-228f4e9b336757ddbf3085637e47962692278c45.zip CMake-228f4e9b336757ddbf3085637e47962692278c45.tar.gz CMake-228f4e9b336757ddbf3085637e47962692278c45.tar.bz2 |
cmFilePathUuid: Use Base32 string instead of Base64 string
This produces files that will not collide on a case-insensitive
filesystem. It also avoids the need for special character
substitutions.
Diffstat (limited to 'Source/cmFilePathUuid.cxx')
-rw-r--r-- | Source/cmFilePathUuid.cxx | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/Source/cmFilePathUuid.cxx b/Source/cmFilePathUuid.cxx index 2839b63..f99646c 100644 --- a/Source/cmFilePathUuid.cxx +++ b/Source/cmFilePathUuid.cxx @@ -12,10 +12,10 @@ #include "cmFilePathUuid.h" +#include "cmBase32.h" #include "cmCryptoHash.h" #include "cmMakefile.h" #include "cmSystemTools.h" -#include "cmsys/Base64.h" cmFilePathUuid::cmFilePathUuid(cmMakefile* makefile) { @@ -111,22 +111,16 @@ std::string cmFilePathUuid::GetChecksumString( const std::string& sourceFilename, const std::string& sourceRelPath, const std::string& sourceRelSeed) { - std::string checksumBase64; + std::string checksumBase32; { // Calculate the file ( seed + relative path + name ) checksum std::vector<unsigned char> hashBytes = cmCryptoHash::New("SHA256")->ByteHashString( (sourceRelSeed + sourceRelPath + sourceFilename).c_str()); - // Convert hash bytes to Base64 text string - std::vector<unsigned char> base64Bytes(hashBytes.size() * 2, 0); - cmsysBase64_Encode(&hashBytes[0], hashBytes.size(), &base64Bytes[0], 0); - checksumBase64 = reinterpret_cast<const char*>(&base64Bytes[0]); + + checksumBase32 = + cmBase32Encoder().encodeString(&hashBytes[0], hashBytes.size(), false); } - // Base64 allows '/', '+' and '=' characters which are problematic - // when used in file names. Replace them with safer alternatives. - std::replace(checksumBase64.begin(), checksumBase64.end(), '/', '-'); - std::replace(checksumBase64.begin(), checksumBase64.end(), '+', '_'); - std::replace(checksumBase64.begin(), checksumBase64.end(), '=', '_'); - return checksumBase64; + return checksumBase32; } |