]>
git.saurik.com Git - apt.git/blob - apt-pkg/contrib/hashsum.cc
1 // Cryptographic API Base
5 #include "hashsum_template.h"
7 // Summation::AddFD - Add content of file into the checksum /*{{{*/
8 // ---------------------------------------------------------------------
10 bool SummationImplementation::AddFD(int const Fd
, unsigned long long Size
) {
11 unsigned char Buf
[64 * 64];
13 int ToEOF
= (Size
== 0);
14 while (Size
!= 0 || ToEOF
)
16 unsigned long long n
= sizeof(Buf
);
17 if (!ToEOF
) n
= std::min(Size
, n
);
18 Res
= read(Fd
, Buf
, n
);
19 if (Res
< 0 || (!ToEOF
&& Res
!= (ssize_t
) n
)) // error, or short read
21 if (ToEOF
&& Res
== 0) // EOF