From 7e8f707846343f32a242999c3e9f9a2481ad55fc Mon Sep 17 00:00:00 2001 From: Erik Fleischer Date: Sun, 5 Jul 2015 15:50:16 +0200 Subject: [PATCH] Fixed segmentation fault on startup on 32 bit platforms. Fixed downloading files > 2GB on 32 bit systems. --- include/downloader.h | 8 ++++---- src/downloader.cpp | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/downloader.h b/include/downloader.h index e4287fc..f305645 100644 --- a/include/downloader.h +++ b/include/downloader.h @@ -99,9 +99,9 @@ class Downloader void saveSerials(const std::string& serials, const std::string& filepath); static int progressCallback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); - static uintmax_t writeMemoryCallback(char *ptr, uintmax_t size, uintmax_t nmemb, void *userp); - static uintmax_t writeData(void *ptr, uintmax_t size, uintmax_t nmemb, FILE *stream); - static uintmax_t readData(void *ptr, uintmax_t size, uintmax_t nmemb, FILE *stream); + static size_t writeMemoryCallback(char *ptr, size_t size, size_t nmemb, void *userp); + static size_t writeData(void *ptr, size_t size, size_t nmemb, FILE *stream); + static size_t readData(void *ptr, size_t size, size_t nmemb, FILE *stream); API *gogAPI; @@ -109,7 +109,7 @@ class Downloader std::vector games; std::string coverXML; - uintmax_t resume_position; + off_t resume_position; int retries; std::ofstream report_ofs; }; diff --git a/src/downloader.cpp b/src/downloader.cpp index 329d97f..fa06f34 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -1158,7 +1158,7 @@ CURLcode Downloader::downloadFile(const std::string& url, const std::string& fil CURLcode res = CURLE_RECV_ERROR; // assume network error bool bResume = false; FILE *outfile; - uintmax_t offset=0; + off_t offset=0; // Get directory from filepath boost::filesystem::path pathname = filepath; @@ -1225,7 +1225,7 @@ CURLcode Downloader::downloadFile(const std::string& url, const std::string& fil { bResume = true; fseek(outfile, 0, SEEK_END); - offset = ftell(outfile); + offset = ftello(outfile); curl_easy_setopt(curlhandle, CURLOPT_RESUME_FROM_LARGE, offset); this->resume_position = offset; } @@ -1870,19 +1870,19 @@ int Downloader::progressCallback(void *clientp, double dltotal, double dlnow, do return 0; } -uintmax_t Downloader::writeMemoryCallback(char *ptr, uintmax_t size, uintmax_t nmemb, void *userp) { +size_t Downloader::writeMemoryCallback(char *ptr, size_t size, size_t nmemb, void *userp) { std::ostringstream *stream = (std::ostringstream*)userp; - uintmax_t count = size * nmemb; + size_t count = size * nmemb; stream->write(ptr, count); return count; } -uintmax_t Downloader::writeData(void *ptr, uintmax_t size, uintmax_t nmemb, FILE *stream) +size_t Downloader::writeData(void *ptr, size_t size, size_t nmemb, FILE *stream) { return fwrite(ptr, size, nmemb, stream); } -uintmax_t Downloader::readData(void *ptr, uintmax_t size, uintmax_t nmemb, FILE *stream) +size_t Downloader::readData(void *ptr, size_t size, size_t nmemb, FILE *stream) { return fread(ptr, size, nmemb, stream); }