33 #include "XrdVersion.hh"
35 #include <sys/types.h>
62 for( it = pCalculators.begin(); it != pCalculators.end(); ++it )
74 CalcMap::iterator it = pCalculators.find( algName );
75 if( it == pCalculators.end() )
77 char *errBuff =
new char[1024];
80 XrdCksCalc *c = pLoader->
Load( algName.c_str(),
"", errBuff, 1024 );
84 algName.c_str(), errBuff );
91 pCalculators[algName] = c;
94 return it->second->
New();;
101 const std::string &algName,
102 const std::string &filePath )
116 std::unique_ptr<XrdCksCalc> calcPtr( calc );
124 int fd =
open( filePath.c_str(), O_RDONLY );
135 const uint32_t buffSize = 2*1024*1024;
136 char *buffer =
new char[buffSize];
137 int64_t bytesRead = 0;
139 while( (bytesRead =
read( fd, buffer, buffSize )) )
141 if( bytesRead == -1 )
149 calc->
Update( buffer, bytesRead );
154 result.
Set( (
void*)calc->
Final(), size );
int open(const char *path, int oflag,...)
ssize_t read(int fildes, void *buf, size_t nbyte)
const char * XrdSysE2T(int errcode)
virtual void Update(const char *Buff, int BLen)=0
virtual const char * Type(int &csSize)=0
virtual XrdCksCalc * New()=0
int Set(const char *csName)
XrdCksCalc * Load(const char *csName, const char *csParms=0, char *eBuff=0, int eBlen=0, bool orig=false)
XrdCksCalc * GetCalculator(const std::string &algName)
virtual ~CheckSumManager()
CheckSumManager()
Constructor.
bool Calculate(XrdCksData &result, const std::string &algName, const std::string &filePath)
Calculate a checksum of for a given file.
static Log * GetLog()
Get default log.
void Error(uint64_t topic, const char *format,...)
Report an error.
void Dump(uint64_t topic, const char *format,...)
Print a dump message.
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
const uint64_t UtilityMsg