summaryrefslogtreecommitdiff
path: root/src/net/download.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-26 21:48:31 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-26 21:48:31 +0200
commit96150f1aeacf55d311c41ffe12d9e754b1cda001 (patch)
tree94252db740b9c2b6ad8122523baa732c0b913fbc /src/net/download.cpp
parent4c04665b29cd7304717cefe49d70d881d8b38ca3 (diff)
downloadplus-96150f1aeacf55d311c41ffe12d9e754b1cda001.tar.gz
plus-96150f1aeacf55d311c41ffe12d9e754b1cda001.tar.bz2
plus-96150f1aeacf55d311c41ffe12d9e754b1cda001.tar.xz
plus-96150f1aeacf55d311c41ffe12d9e754b1cda001.zip
Add ability to redownload update files if file checksum incorrect.
Diffstat (limited to 'src/net/download.cpp')
-rw-r--r--src/net/download.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 95dfcd298..40d7c872a 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -37,25 +37,6 @@
const char *DOWNLOAD_ERROR_MESSAGE_THREAD
= "Could not create download thread!";
-/**
- * Calculates the Alder-32 checksum for the given file.
- */
-static unsigned long fadler32(FILE *file)
-{
- // Obtain file size
- fseek(file, 0, SEEK_END);
- long fileSize = ftell(file);
- rewind(file);
-
- // Calculate Adler-32 checksum
- char *buffer = static_cast<char*>(malloc(fileSize));
- const size_t read = fread(buffer, 1, fileSize, file);
- unsigned long adler = adler32(0L, Z_NULL, 0);
- adler = adler32(static_cast<uInt>(adler), (Bytef*)buffer, read);
- free(buffer);
-
- return adler;
-}
enum
{
@@ -97,6 +78,26 @@ Download::~Download()
free(mError);
}
+/**
+ * Calculates the Alder-32 checksum for the given file.
+ */
+unsigned long Download::fadler32(FILE *file)
+{
+ // Obtain file size
+ fseek(file, 0, SEEK_END);
+ long fileSize = ftell(file);
+ rewind(file);
+
+ // Calculate Adler-32 checksum
+ char *buffer = static_cast<char*>(malloc(fileSize));
+ const size_t read = fread(buffer, 1, fileSize, file);
+ unsigned long adler = adler32(0L, Z_NULL, 0);
+ adler = adler32(static_cast<uInt>(adler), (Bytef*)buffer, read);
+ free(buffer);
+
+ return adler;
+}
+
void Download::addHeader(const std::string &header)
{
mHeaders = curl_slist_append(mHeaders, header.c_str());