Mantid
Loading...
Searching...
No Matches
Functions
Mantid::Kernel::ChecksumHelper Namespace Reference

ChecksumHelper : A selection of helper methods for calculating checksums. More...

Functions

MANTID_KERNEL_DLL std::string gitSha1FromFile (const std::string &filepath)
 create a git checksum from a file (these match the git hash-object command) More...
 
MANTID_KERNEL_DLL std::string loadFile (const std::string &filepath, const bool unixEOL=false)
 Load contents of file into a string. More...
 
MANTID_KERNEL_DLL std::string md5FromString (const std::string &input)
 create a md5 checksum from a string More...
 
MANTID_KERNEL_DLL std::string sha1FromFile (const std::string &filepath, const bool unixEOL)
 create a SHA-1 checksum from a file More...
 
MANTID_KERNEL_DLL std::string sha1FromString (const std::string &input)
 create a SHA-1 checksum from a string More...
 

Detailed Description

ChecksumHelper : A selection of helper methods for calculating checksums.

Function Documentation

◆ gitSha1FromFile()

std::string Mantid::Kernel::ChecksumHelper::gitSha1FromFile ( const std::string &  filepath)

create a git checksum from a file (these match the git hash-object command)

Creates a git checksum from a file (these match the git hash-object command).

This works by reading in the file, converting all line endings into linux style endings, then the following is prepended to the file contents "blob <content_length>\0", the result is then ran through a SHA-1 checksum.

Parameters
filepathThe path to the file
Returns
a checksum string

Definition at line 94 of file ChecksumHelper.cpp.

References loadFile().

Referenced by Mantid::DataHandling::DownloadInstrument::getFileShas().

◆ loadFile()

std::string Mantid::Kernel::ChecksumHelper::loadFile ( const std::string &  filepath,
const bool  unixEOL = false 
)

Load contents of file into a string.

The line endings are preserved

Parameters
filepathFull path to the file to be opened
unixEOLIf true convert all lineendings to Unix-style

Definition at line 109 of file ChecksumHelper.cpp.

Referenced by Mantid::Geometry::IDFObject::getMangledName(), gitSha1FromFile(), and sha1FromFile().

◆ md5FromString()

std::string Mantid::Kernel::ChecksumHelper::md5FromString ( const std::string &  input)

create a md5 checksum from a string

Creates a md5 checksum from a string.

Parameters
inputThe string to checksum
Returns
a checksum string

Definition at line 65 of file ChecksumHelper.cpp.

Referenced by Mantid::Kernel::ErrorReporter::generateErrorMessage(), and Mantid::Kernel::UsageServiceImpl::generateStartupMessage().

◆ sha1FromFile()

std::string Mantid::Kernel::ChecksumHelper::sha1FromFile ( const std::string &  filepath,
const bool  unixEOL = false 
)

create a SHA-1 checksum from a file

Creates a SHA-1 checksum from a file.

Parameters
filepathThe path to the file
unixEOLIf true convert all lineendings to Unix-style
Returns
a checksum string

Definition at line 78 of file ChecksumHelper.cpp.

References loadFile().

◆ sha1FromString()

std::string Mantid::Kernel::ChecksumHelper::sha1FromString ( const std::string &  input)

create a SHA-1 checksum from a string

Creates a SHA-1 checksum from a string.

Parameters
inputThe string to checksum
Returns
a checksum string

Definition at line 71 of file ChecksumHelper.cpp.

Referenced by Mantid::Geometry::InstrumentDefinitionParser::getMangledName(), and Mantid::Geometry::IDFObject::getMangledName().