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