|
Boost : |
From: Chris Fairles (chris.fairles_at_[hidden])
Date: 2007-10-31 09:59:37
To calculate md5's of large files, I added a ctor to message_digest:
template <typename charT, class traits>
explicit message_digest(const std::basic_ios<charT, traits> & s)
{
std::basic_streambuf<charT, traits> * sb = s.rdbuf();
std::streamsize sz = 0;
charT buf[block_size];
while( (sz = sb->sgetn(buf, block_size)) != 0 ) {
input(buf, sz);
}
}
Its just as easy to do this outside the message_digest class using
input(void*,size_t) but it seems that calculating md5 checksums for
large files might be common enough to warrant it.
This may not be the best impl. I use basic_ios because its the first
class in the ios_base hierarchy that provides rdbuf().
Thoughts?
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk