length is bigger than current file size */
#if HAVE_TRUNCATE
inline int compat_truncate(const char* path, uint64 length) {
- return truncate(path, length);
+ return truncate64(path, length);
}
#else
int compat_truncate(const char* path, uint64 length);
// First couple of k: Calculate RsyncSum rs and MD5Sum md
if (checkChecksum && rsyncLen > 0) {
while (*img && f && !f.eof() && toWrite > 0) {
- size_t n = (toWrite < readAmount ? toWrite : readAmount);
+ size_t n = (size_t)(toWrite < readAmount ? toWrite : readAmount);
readBytes(f, buf, n);
n = f.gcount();
writeBytes(*img, buf, n);
}
// Rest of file: Only calculate MD5Sum md
while (*img && f && !f.eof() && toWrite > 0) {
- size_t n = (toWrite < readAmount ? toWrite : readAmount);
+ size_t n = (size_t)(toWrite < readAmount ? toWrite : readAmount);
readBytes(f, buf, n);
n = f.gcount();
writeBytes(*img, buf, n);
// Even if there was an error - always try to write right amount
memClear(buf, readAmount);
while (*img && toWrite > 0) {
- size_t n = (toWrite < readAmount ? toWrite : readAmount);
+ size_t n = (size_t)(toWrite < readAmount ? toWrite : readAmount);
writeBytes(*img, buf, n);
reportBytesWritten(n, off, nextReport, totalBytes, reporter);
toWrite -= n;
// First couple of k: Calculate RsyncSum rs and SHA256Sum md
if (checkChecksum && rsyncLen > 0) {
while (*img && f && !f.eof() && toWrite > 0) {
- size_t n = (toWrite < readAmount ? toWrite : readAmount);
+ size_t n = (size_t)(toWrite < readAmount ? toWrite : readAmount);
readBytes(f, buf, n);
n = f.gcount();
writeBytes(*img, buf, n);
}
// Rest of file: Only calculate SHA256Sum md
while (*img && f && !f.eof() && toWrite > 0) {
- size_t n = (toWrite < readAmount ? toWrite : readAmount);
+ size_t n = (size_t)(toWrite < readAmount ? toWrite : readAmount);
readBytes(f, buf, n);
n = f.gcount();
writeBytes(*img, buf, n);
// Even if there was an error - always try to write right amount
memClear(buf, readAmount);
while (*img && toWrite > 0) {
- size_t n = (toWrite < readAmount ? toWrite : readAmount);
+ size_t n = (size_t)(toWrite < readAmount ? toWrite : readAmount);
writeBytes(*img, buf, n);
reportBytesWritten(n, off, nextReport, totalBytes, reporter);
toWrite -= n;
return 3;
}
data->read(buf, (unsigned int)(toWrite < readAmount ? toWrite : readAmount));
- size_t n = data->gcount();
+ size_t n = (size_t)data->gcount();
writeBytes(*img, buf, n);
reportBytesWritten(n, off, nextReport, totalBytes, reporter);
toWrite -= n;
// Write right amount of zeroes
memClear(buf, readAmount);
while (*img && toWrite > 0) {
- size_t n = (toWrite < readAmount ? toWrite : readAmount);
+ size_t n = (size_t)(toWrite < readAmount ? toWrite : readAmount);
writeBytes(*img, buf, n);
reportBytesWritten(n, off, nextReport, totalBytes, reporter);
toWrite -= n;
/* Copy data from file to image, taking care not to
write beyond toWrite. */
int status = fileToImageMD5(img, *mfile, *self, checkChecksum,
- blockLength, reporter, buf, readAmount, off,
+ (size_t)blockLength, reporter, buf, readAmount, off,
nextReport, totalBytes);
toCopy.pop();
if (result < status) result = status;
// Write right amount of zeroes
memClear(buf, readAmount);
while (*img && toWrite > 0) {
- size_t n = (toWrite < readAmount ? toWrite : readAmount);
+ size_t n = (size_t)(toWrite < readAmount ? toWrite : readAmount);
writeBytes(*img, buf, n);
reportBytesWritten(n, off, nextReport, totalBytes, reporter);
toWrite -= n;
/* Copy data from file to image, taking care not to
write beyond toWrite. */
int status = fileToImageSHA256(img, *mfile, *self, checkChecksum,
- blockLength, reporter, buf, readAmount, off,
+ (size_t)blockLength, reporter, buf, readAmount, off,
nextReport, totalBytes);
toCopy.pop();
if (result < status) result = status;
break;
}
int status = fileToImageMD5(img, *mfile, *matchMD5, checkChecksum,
- blockLength, reporter, buf, readAmount, bytesWritten,
+ (size_t)blockLength, reporter, buf, readAmount, bytesWritten,
nextReport, totalBytes);
toCopy.pop();
if (result < status)
break;
}
int status = fileToImageSHA256(img, *mfile, *matchSHA256, checkChecksum,
- blockLength, reporter, buf, readAmount, bytesWritten,
+ (size_t)blockLength, reporter, buf, readAmount, bytesWritten,
nextReport, totalBytes);
toCopy.pop();
if (result < status)
/* Rolling rsum matched - schedule an MD5Sum/SHA256Sum match. NB: In
extreme cases, nextEvent may be equal to off */
x->setStartOffset(off - blockLen);
- size_t eventLen = (file->size() < csumBlockLength ?
+ size_t eventLen = (size_t)(file->size() < csumBlockLength ?
file->size() : csumBlockLength);
x->setNextEvent(matches, x->startOffset() + eventLen);
debug(" %1: Head of %2 match at offset %3, my next event %4",
while (inputFile->good() && count > 0) {
// read data
readBytes(*inputFile, tmpBuf.get(),
- (readAmount < count ? readAmount : count));
+ (size_t)(readAmount < count ? readAmount : count));
size_t n = inputFile->gcount();
zip->write(tmpBuf.get(), (unsigned int)n); // will catch Zerror "upstream"
Paranoid(n <= count);
unmatchedStart = min(off - stillBuffered, x->startOffset());
debugRangeInfo(oldestMatch->startOffset(), unmatchedStart,
"UNMATCHED, re-reading partial match from", oldestMatch);
- size_t toReread = unmatchedStart - oldestMatch->startOffset();
+ size_t toReread = (size_t)(unmatchedStart - oldestMatch->startOffset());
desc.unmatchedData(toReread);
if (rereadUnmatched(oldestMatch->file(), toReread))
return FAILURE;
if (unmatchedStart < x->startOffset()) {
debugRangeInfo(unmatchedStart, x->startOffset(),
"UNMATCHED, buffer flush before match");
- size_t toWrite = x->startOffset() - unmatchedStart;
+ size_t toWrite = (size_t)(x->startOffset() - unmatchedStart);
Paranoid(off - unmatchedStart <= bufferLength);
- size_t writeStart = modSub(data, off - unmatchedStart, bufferLength);
+ size_t writeStart = modSub(data, (size_t)(off - unmatchedStart), bufferLength);
writeBuf(buf, writeStart, modAdd(writeStart, toWrite, bufferLength),
bufferLength, zip);
desc.unmatchedData(toWrite);
unmatchedStart = off - bufferLength;
debugRangeInfo(y->startOffset(), unmatchedStart,
"UNMATCHED at end, re-reading partial match from", y);
- size_t toReread = unmatchedStart - y->startOffset();
+ size_t toReread = (size_t)(unmatchedStart - y->startOffset());
desc.unmatchedData(toReread);
if (rereadUnmatched(y->file(), toReread))
return FAILURE;
// Write out data that is still buffered
if (unmatchedStart < off) {
debugRangeInfo(unmatchedStart, off, "UNMATCHED at end");
- size_t toWrite = off - unmatchedStart;
+ size_t toWrite = (size_t)(off - unmatchedStart);
Assert(toWrite <= bufferLength);
size_t writeStart = modSub(data, toWrite, bufferLength);
writeBuf(buf, writeStart, data, bufferLength, zip);
nextAlignedOff += blockLength;
Assert(nextAlignedOff > off);
- unsigned long len = nextAlignedOff - off;
- if (len > nextEvent - off) len = nextEvent - off;
+ size_t len = (size_t)(nextAlignedOff - off);
+ if (len > nextEvent - off) len = (size_t)(nextEvent - off);
// Advance rsum by len bytes in one go
# if DEBUG
RsyncSum64 rsum2 = *rsum; size_t rsumBack2 = *rsumBack;
matches->lowestStartOffset()->startOffset());
}
if (unmatchedStart < newUnmatchedStart) {
- size_t toWrite = newUnmatchedStart - unmatchedStart;
+ size_t toWrite = (size_t)(newUnmatchedStart - unmatchedStart);
Paranoid(off - unmatchedStart <= bufferLength);
//debug("off=%1 unmatchedStart=%2 buflen=%3",
// off, unmatchedStart, bufferLength);
- size_t writeStart = modSub(data, off - unmatchedStart,
+ size_t writeStart = modSub(data, (size_t)(off - unmatchedStart),
bufferLength);
debugRangeInfo(unmatchedStart, unmatchedStart + toWrite,
"UNMATCHED");
write the i*ChunkLength bytes directly to templ. */
while (!matches->empty() && matches->nextEvent() == off) {
size_t stillBuffered = bufferLength - n;
- if (stillBuffered > off) stillBuffered = off;
+ if (stillBuffered > off) stillBuffered = (size_t)off;
if (checkChecksumMatch(buf, bufferLength, data, csumBlockLength,
nextEvent, stillBuffered, desc))
return FAILURE; // no recovery possible, exit immediately
Assert(c->csumBlockLength != 0);
const size_t thisBlockLength = c->blockLength;
- MD5sums.resize((size() + c->csumBlockLength - 1) / c->csumBlockLength);
- SHA256sums.resize((size() + c->csumBlockLength - 1) / c->csumBlockLength);
+ MD5sums.resize((size_t)(size() + c->csumBlockLength - 1) / c->csumBlockLength);
+ SHA256sums.resize((size_t)(size() + c->csumBlockLength - 1) / c->csumBlockLength);
//____________________
# if HAVE_LIBDB
//______________________________________________________________________
const MD5Sum* FilePart::getMD5SumRead(JigdoCache* c) {
- if (!getChecksumsRead(c, (fileSize + c->csumBlockLength - 1) / c->csumBlockLength - 1))
+ if (!getChecksumsRead(c, (size_t)((fileSize + c->csumBlockLength - 1) / c->csumBlockLength - 1)))
return 0;
Paranoid(mdValid());
return &md5Sum;
//______________________________________________________________________
const SHA256Sum* FilePart::getSHA256SumRead(JigdoCache* c) {
- if (!getChecksumsRead(c, (fileSize + c->csumBlockLength - 1) / c->csumBlockLength - 1))
+ if (!getChecksumsRead(c, (size_t)(fileSize + c->csumBlockLength - 1) / c->csumBlockLength - 1))
return 0;
Paranoid(mdValid());
return &sha256Sum;
byte* buf = &buffer[0];
// Read from stream and update *this
while (s && !s.eof() && toRead > 0) {
- size_t n = (toRead < bufSize ? toRead : bufSize);
+ size_t n = (size_t)(toRead < bufSize ? toRead : bufSize);
readBytes(s, buf, n);
n = s.gcount();
update(buf, n);
byte* buf = &buffer[0];
// Read from stream and update *this
while (s && !s.eof() && toRead > 0) {
- size_t n = (toRead < bufSize ? toRead : bufSize);
+ size_t n = (size_t)(toRead < bufSize ? toRead : bufSize);
readBytes(s, buf, n);
n = s.gcount();
update(buf, n);
//____________________
// Read data from file into buffer?
- unsigned long toRead = (dataLen < bufSize ? dataLen : bufSize);
+ unsigned long toRead = (unsigned long)(dataLen < bufSize ? dataLen : bufSize);
byte* b = &buf[0];
z->setNextIn(b);
z->setAvailIn((unsigned int)toRead);