
31 Oct
2007
31 Oct
'07
1:59 p.m.
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