diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-08-14 13:48:31 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-08-14 13:48:31 +0000 |
| commit | 2f14fec78dfc96b88a905621d35f1d726df0791d (patch) | |
| tree | 8eb4dc9cf94f021ccbdf77dca88924c2c9bf4cea /src/AbstractDiskWriter.cc | |
| parent | 43dae4fd916bb35bf7fd8554fc86ce34c3e7a31b (diff) | |
| parent | 7ca1b43eddd1aba1c71a38dfb46b5ac5685b43d0 (diff) | |
Tagging 0.7.0 release of aria2release-0.7.0
Diffstat (limited to 'src/AbstractDiskWriter.cc')
| -rw-r--r-- | src/AbstractDiskWriter.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index 7f6f85c8..ff56fa57 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -30,17 +30,21 @@ #include <errno.h> #include <fcntl.h> -AbstractDiskWriter::AbstractDiskWriter():fd(0) { +AbstractDiskWriter::AbstractDiskWriter(): + fd(0) +#ifdef ENABLE_MESSAGE_DIGEST + ,ctx(DIGEST_ALGO_SHA1) +#endif // ENABLE_MESSAGE_DIGEST +{ #ifdef ENABLE_MESSAGE_DIGEST - ctx.setAlgo(MessageDigestContext::ALGO_SHA1); - digestInit(ctx); + ctx.digestInit(); #endif // ENABLE_MESSAGE_DIGEST } AbstractDiskWriter::~AbstractDiskWriter() { closeFile(); #ifdef ENABLE_MESSAGE_DIGEST - digestFree(ctx); + ctx.digestFree(); #endif // ENABLE_MESSAGE_DIGEST } @@ -100,7 +104,7 @@ int AbstractDiskWriter::readDataInternal(char* data, int len) { string AbstractDiskWriter::sha1Sum(long long int offset, long long int length) { #ifdef ENABLE_MESSAGE_DIGEST - digestReset(ctx); + ctx.digestReset(); try { int BUFSIZE = 16*1024; char buf[BUFSIZE]; @@ -108,7 +112,7 @@ string AbstractDiskWriter::sha1Sum(long long int offset, long long int length) { if(BUFSIZE != readData(buf, BUFSIZE, offset)) { throw string("error"); } - digestUpdate(ctx, buf, BUFSIZE); + ctx.digestUpdate(buf, BUFSIZE); offset += BUFSIZE; } int r = length%BUFSIZE; @@ -116,10 +120,10 @@ string AbstractDiskWriter::sha1Sum(long long int offset, long long int length) { if(r != readData(buf, r, offset)) { throw string("error"); } - digestUpdate(ctx, buf, r); + ctx.digestUpdate(buf, r); } unsigned char hashValue[20]; - digestFinal(ctx, hashValue); + ctx.digestFinal(hashValue); return Util::toHex(hashValue, 20); } catch(string ex) { throw new DlAbortEx(EX_FILE_SHA1SUM, filename.c_str(), strerror(errno)); |
