From 0669c9bfac7aead01f1400444e691d542f7645c2 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 1 Jun 2008 21:47:31 -0500 Subject: Use correct C type for file sizes We have been using unsigned long as a file size type for a while, which works but isn't quite correct and could easily break. Worse was probably our use of int in the download callback functions, which could be restrictive for packages > 2GB in size. Switch all file size variables to use off_t, which is the preferred type for file sizes. Note that at least on Linux, all applications compiled against libalpm must now be sure to use large file support, where _FILE_OFFSET_BITS is defined to be 64 or there will be some weird issues that crop up. Signed-off-by: Dan McGee --- lib/libalpm/dload.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/libalpm/dload.c') diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 44acec70..b5f0b876 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -112,7 +112,7 @@ static int download_internal(const char *url, const char *localpath, struct url_stat ust; struct stat st; int chk_resume = 0; - int dl_thisfile = 0; + size_t dl_thisfile = 0; char *tempfile, *destfile, *filename; int ret = 0; struct url *fileurl = url_for_string(url); @@ -200,7 +200,7 @@ static int download_internal(const char *url, const char *localpath, handle->dlcb(filename, 0, ust.size); } - int nread = 0; + size_t nread = 0; char buffer[PM_DLBUF_LEN]; while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) { if(ferror(dlf)) { @@ -211,7 +211,7 @@ static int download_internal(const char *url, const char *localpath, goto cleanup; } - int nwritten = 0; + size_t nwritten = 0; while(nwritten < nread) { nwritten += fwrite(buffer, 1, (nread - nwritten), localf); if(ferror(localf)) { -- cgit v1.2.3-54-g00ecf