#include <MediaBlockList.h>
Public Member Functions | |
MediaBlockList (off_t filesize=off_t(-1)) | |
bool | haveBlocks () const |
do we have a blocklist describing the file? set to true when addBlock() is called | |
size_t | addBlock (off_t off, size_t size) |
add a block with offset off and size size to the block list. | |
MediaBlock | getBlock (size_t blkno) const |
return the offset/size of a block with number blkno | |
size_t | numBlocks () const |
return the number of blocks in the blocklist | |
void | setFilesize (off_t newfilesize=off_t(-1)) |
set / return the size of the whole file | |
off_t | getFilesize () const |
bool | haveFilesize () const |
void | setFileChecksum (std::string ctype, int cl, unsigned char *c) |
set / verify the checksum over the whole file | |
bool | createFileDigest (Digest &digest) const |
bool | verifyFileDigest (Digest &digest) const |
bool | haveFileChecksum () const |
void | setChecksum (size_t blkno, std::string cstype, int csl, unsigned char *cs, size_t cspad=0) |
set / verify the (strong) checksum over a single block | |
bool | checkChecksum (size_t blkno, const unsigned char *buf, size_t bufl) const |
bool | createDigest (Digest &digest) const |
bool | verifyDigest (size_t blkno, Digest &digest) const |
bool | haveChecksum (size_t blkno) const |
void | setRsum (size_t blkno, int rsl, unsigned int rs, size_t rspad=0) |
set / verify the (weak) rolling checksum over a single block | |
bool | checkRsum (size_t blkno, const unsigned char *buf, size_t bufl) const |
unsigned int | updateRsum (unsigned int rs, const char *bytes, size_t len) const |
bool | verifyRsum (size_t blkno, unsigned int rs) const |
bool | haveRsum (size_t blkno) const |
void | reuseBlocks (FILE *wfp, std::string filename) |
scan a file for blocks from our blocklist. | |
std::string | asString () const |
return block list as string | |
Private Member Functions | |
void | writeBlock (size_t blkno, FILE *fp, const unsigned char *buf, size_t bufl, size_t start, std::vector< bool > &found) const |
bool | checkChecksumRotated (size_t blkno, const unsigned char *buf, size_t bufl, size_t start) const |
Private Attributes | |
off_t | filesize |
std::string | fsumtype |
std::vector< unsigned char > | fsum |
bool | haveblocks |
std::vector< MediaBlock > | blocks |
std::string | chksumtype |
int | chksumlen |
size_t | chksumpad |
std::vector< unsigned char > | chksums |
std::string | rsumtype |
int | rsumlen |
size_t | rsumpad |
std::vector< unsigned int > | rsums |
Definition at line 35 of file MediaBlockList.h.
zypp::media::MediaBlockList::MediaBlockList | ( | off_t | filesize = off_t(-1) |
) |
Definition at line 33 of file MediaBlockList.cc.
References chksumlen, chksumpad, filesize, haveblocks, rsumlen, and rsumpad.
bool zypp::media::MediaBlockList::haveBlocks | ( | ) | const [inline] |
do we have a blocklist describing the file? set to true when addBlock() is called
Definition at line 43 of file MediaBlockList.h.
References haveblocks.
Referenced by zypp::media::MediaMultiCurl::multifetch().
size_t zypp::media::MediaBlockList::addBlock | ( | off_t | off, | |
size_t | size | |||
) |
add a block with offset off and size size to the block list.
Note that blocks must be ordered and must not overlap. returns the block number.
Definition at line 44 of file MediaBlockList.cc.
References blocks, and haveblocks.
Referenced by zypp::media::MetaLinkParser::getBlockList().
MediaBlock zypp::media::MediaBlockList::getBlock | ( | size_t | blkno | ) | const [inline] |
return the offset/size of a block with number blkno
Definition at line 56 of file MediaBlockList.h.
References blocks.
Referenced by zypp::media::multifetchrequest::multifetchrequest(), and zypp::media::multifetchworker::nextjob().
size_t zypp::media::MediaBlockList::numBlocks | ( | ) | const [inline] |
return the number of blocks in the blocklist
Definition at line 62 of file MediaBlockList.h.
References blocks.
Referenced by zypp::media::MediaMultiCurl::multifetch(), zypp::media::multifetchrequest::multifetchrequest(), and zypp::media::multifetchworker::nextjob().
void zypp::media::MediaBlockList::setFilesize | ( | off_t | newfilesize = off_t(-1) |
) | [inline] |
set / return the size of the whole file
Definition at line 69 of file MediaBlockList.h.
References filesize.
off_t zypp::media::MediaBlockList::getFilesize | ( | ) | const [inline] |
Definition at line 72 of file MediaBlockList.h.
References filesize.
Referenced by zypp::media::MediaMultiCurl::multifetch().
bool zypp::media::MediaBlockList::haveFilesize | ( | ) | const [inline] |
Definition at line 75 of file MediaBlockList.h.
References filesize.
Referenced by zypp::media::MediaMultiCurl::multifetch().
void zypp::media::MediaBlockList::setFileChecksum | ( | std::string | ctype, | |
int | cl, | |||
unsigned char * | c | |||
) |
set / verify the checksum over the whole file
Definition at line 52 of file MediaBlockList.cc.
References fsum, and fsumtype.
Referenced by zypp::media::MetaLinkParser::getBlockList().
bool zypp::media::MediaBlockList::createFileDigest | ( | Digest & | digest | ) | const |
Definition at line 62 of file MediaBlockList.cc.
References zypp::Digest::create(), and fsumtype.
Referenced by zypp::media::MediaMultiCurl::checkFileDigest().
bool zypp::media::MediaBlockList::verifyFileDigest | ( | Digest & | digest | ) | const |
Definition at line 68 of file MediaBlockList.cc.
References zypp::Digest::digestVector(), fsum, and haveFileChecksum().
Referenced by zypp::media::MediaMultiCurl::checkFileDigest().
bool zypp::media::MediaBlockList::haveFileChecksum | ( | ) | const [inline] |
Definition at line 85 of file MediaBlockList.h.
References fsum, and fsumtype.
Referenced by zypp::media::MediaMultiCurl::checkFileDigest(), and verifyFileDigest().
void zypp::media::MediaBlockList::setChecksum | ( | size_t | blkno, | |
std::string | cstype, | |||
int | csl, | |||
unsigned char * | cs, | |||
size_t | cspad = 0 | |||
) |
set / verify the (strong) checksum over a single block
Definition at line 79 of file MediaBlockList.cc.
References chksumlen, chksumpad, chksums, and chksumtype.
Referenced by zypp::media::MetaLinkParser::getBlockList().
bool zypp::media::MediaBlockList::checkChecksum | ( | size_t | blkno, | |
const unsigned char * | buf, | |||
size_t | bufl | |||
) | const |
Definition at line 197 of file MediaBlockList.cc.
References blocks, createDigest(), zypp::Digest::update(), and verifyDigest().
bool zypp::media::MediaBlockList::createDigest | ( | Digest & | digest | ) | const |
Definition at line 115 of file MediaBlockList.cc.
References chksumtype, and zypp::Digest::create().
Referenced by checkChecksum(), checkChecksumRotated(), zypp::media::multifetchworker::recheckChecksum(), and zypp::media::multifetchworker::run().
bool zypp::media::MediaBlockList::verifyDigest | ( | size_t | blkno, | |
Digest & | digest | |||
) | const |
Definition at line 121 of file MediaBlockList.cc.
References blocks, chksumlen, chksumpad, chksums, zypp::Digest::digestVector(), haveChecksum(), and zypp::Digest::update().
Referenced by zypp::media::multifetchworker::checkChecksum(), checkChecksum(), checkChecksumRotated(), and zypp::media::multifetchworker::recheckChecksum().
bool zypp::media::MediaBlockList::haveChecksum | ( | size_t | blkno | ) | const [inline] |
Definition at line 96 of file MediaBlockList.h.
References chksumlen, and chksums.
Referenced by zypp::media::MediaMultiCurl::doGetFileCopy(), zypp::media::multifetchworker::multifetchworker(), zypp::media::multifetchworker::nextjob(), and verifyDigest().
void zypp::media::MediaBlockList::setRsum | ( | size_t | blkno, | |
int | rsl, | |||
unsigned int | rs, | |||
size_t | rspad = 0 | |||
) |
set / verify the (weak) rolling checksum over a single block
Definition at line 98 of file MediaBlockList.cc.
References rsumlen, rsumpad, and rsums.
Referenced by zypp::media::MetaLinkParser::getBlockList().
bool zypp::media::MediaBlockList::checkRsum | ( | size_t | blkno, | |
const unsigned char * | buf, | |||
size_t | bufl | |||
) | const |
Definition at line 188 of file MediaBlockList.cc.
References blocks, updateRsum(), and verifyRsum().
unsigned int zypp::media::MediaBlockList::updateRsum | ( | unsigned int | rs, | |
const char * | bytes, | |||
size_t | len | |||
) | const |
bool zypp::media::MediaBlockList::verifyRsum | ( | size_t | blkno, | |
unsigned int | rs | |||
) | const |
Definition at line 158 of file MediaBlockList.cc.
References blocks, haveRsum(), rsumlen, rsumpad, and rsums.
Referenced by checkRsum().
bool zypp::media::MediaBlockList::haveRsum | ( | size_t | blkno | ) | const [inline] |
Definition at line 107 of file MediaBlockList.h.
References rsumlen, and rsums.
Referenced by verifyRsum().
void zypp::media::MediaBlockList::reuseBlocks | ( | FILE * | wfp, | |
std::string | filename | |||
) |
scan a file for blocks from our blocklist.
if we find a suitable block, it is removed from the list
Referenced by zypp::media::MediaMultiCurl::doGetFileCopy().
std::string zypp::media::MediaBlockList::asString | ( | ) | const |
return block list as string
Definition at line 489 of file MediaBlockList.cc.
References blocks, chksumlen, chksumpad, chksums, chksumtype, filesize, zypp::str::form(), haveblocks, rsumlen, rsumpad, and rsums.
Referenced by zypp::media::operator<<().
void zypp::media::MediaBlockList::writeBlock | ( | size_t | blkno, | |
FILE * | fp, | |||
const unsigned char * | buf, | |||
size_t | bufl, | |||
size_t | start, | |||
std::vector< bool > & | found | |||
) | const [private] |
bool zypp::media::MediaBlockList::checkChecksumRotated | ( | size_t | blkno, | |
const unsigned char * | buf, | |||
size_t | bufl, | |||
size_t | start | |||
) | const [private] |
Definition at line 210 of file MediaBlockList.cc.
References blocks, createDigest(), zypp::Digest::update(), and verifyDigest().
off_t zypp::media::MediaBlockList::filesize [private] |
Definition at line 126 of file MediaBlockList.h.
Referenced by asString(), getFilesize(), haveFilesize(), MediaBlockList(), and setFilesize().
std::string zypp::media::MediaBlockList::fsumtype [private] |
Definition at line 127 of file MediaBlockList.h.
Referenced by createFileDigest(), haveFileChecksum(), and setFileChecksum().
std::vector<unsigned char> zypp::media::MediaBlockList::fsum [private] |
Definition at line 128 of file MediaBlockList.h.
Referenced by haveFileChecksum(), setFileChecksum(), and verifyFileDigest().
bool zypp::media::MediaBlockList::haveblocks [private] |
Definition at line 130 of file MediaBlockList.h.
Referenced by addBlock(), asString(), haveBlocks(), and MediaBlockList().
std::vector<MediaBlock> zypp::media::MediaBlockList::blocks [private] |
Definition at line 131 of file MediaBlockList.h.
Referenced by addBlock(), asString(), checkChecksum(), checkChecksumRotated(), checkRsum(), getBlock(), numBlocks(), verifyDigest(), and verifyRsum().
std::string zypp::media::MediaBlockList::chksumtype [private] |
Definition at line 133 of file MediaBlockList.h.
Referenced by asString(), createDigest(), and setChecksum().
int zypp::media::MediaBlockList::chksumlen [private] |
Definition at line 134 of file MediaBlockList.h.
Referenced by asString(), haveChecksum(), MediaBlockList(), setChecksum(), and verifyDigest().
size_t zypp::media::MediaBlockList::chksumpad [private] |
Definition at line 135 of file MediaBlockList.h.
Referenced by asString(), MediaBlockList(), setChecksum(), and verifyDigest().
std::vector<unsigned char> zypp::media::MediaBlockList::chksums [private] |
Definition at line 136 of file MediaBlockList.h.
Referenced by asString(), haveChecksum(), setChecksum(), and verifyDigest().
std::string zypp::media::MediaBlockList::rsumtype [private] |
Definition at line 138 of file MediaBlockList.h.
int zypp::media::MediaBlockList::rsumlen [private] |
Definition at line 139 of file MediaBlockList.h.
Referenced by asString(), haveRsum(), MediaBlockList(), setRsum(), and verifyRsum().
size_t zypp::media::MediaBlockList::rsumpad [private] |
Definition at line 140 of file MediaBlockList.h.
Referenced by asString(), MediaBlockList(), setRsum(), and verifyRsum().
std::vector<unsigned int> zypp::media::MediaBlockList::rsums [private] |
Definition at line 141 of file MediaBlockList.h.
Referenced by asString(), haveRsum(), setRsum(), and verifyRsum().