From fb23318d5a04056109c242248870ab15cec1c584 Mon Sep 17 00:00:00 2001 From: Erik Fleischer Date: Sun, 5 Jul 2015 19:23:11 +0200 Subject: [PATCH] Fix --repair on 32 bit platforms for files > 2 GB. --- src/downloader.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/downloader.cpp b/src/downloader.cpp index fa06f34..d0da2da 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -1225,6 +1225,7 @@ CURLcode Downloader::downloadFile(const std::string& url, const std::string& fil { bResume = true; fseek(outfile, 0, SEEK_END); + // use ftello to support large files on 32 bit platforms offset = ftello(outfile); curl_easy_setopt(curlhandle, CURLOPT_RESUME_FROM_LARGE, offset); this->resume_position = offset; @@ -1366,10 +1367,10 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, { int res = 0; FILE *outfile; - uintmax_t offset=0, from_offset, to_offset, filesize; + off_t offset=0, from_offset, to_offset, filesize; std::string filehash; int chunks; - std::vector chunk_from, chunk_to; + std::vector chunk_from, chunk_to; std::vector chunk_hash; bool bParsingFailed = false; @@ -1475,7 +1476,8 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, if ((outfile = fopen(filepath.c_str(), "r+"))!=NULL ) { fseek(outfile, 0, SEEK_END); - offset = ftell(outfile); + // use ftello to support large files on 32 bit platforms + offset = ftello(outfile); } else { @@ -1503,7 +1505,8 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, } return res; } - + + // check if file sizes match if (offset != filesize) { std::cout << "Filesizes don't match" << std::endl @@ -1561,13 +1564,14 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, int iChunksRepaired = 0; for (int i=0; i