From 48b5562e8dced09e9810ca78cb8288450f5036f4 Mon Sep 17 00:00:00 2001 From: dborth Date: Sun, 25 Jan 2009 07:10:16 +0000 Subject: [PATCH] add unzip progress for auto-update --- source/ngc/menudraw.h | 1 + source/ngc/networkop.cpp | 2 +- source/unzip/{miniunz.c => miniunz.cpp} | 52 ++++++++++++++++++++++++- source/unzip/miniunz.h | 8 ---- 4 files changed, 52 insertions(+), 11 deletions(-) rename source/unzip/{miniunz.c => miniunz.cpp} (82%) diff --git a/source/ngc/menudraw.h b/source/ngc/menudraw.h index 13968ae..473c0b2 100644 --- a/source/ngc/menudraw.h +++ b/source/ngc/menudraw.h @@ -17,6 +17,7 @@ #ifndef _NGCMENUDRAW_ #define _NGCMENUDRAW_ +#include #include "filesel.h" #define PAGESIZE 13 // max item listing on a screen diff --git a/source/ngc/networkop.cpp b/source/ngc/networkop.cpp index e65370b..59d7d96 100644 --- a/source/ngc/networkop.cpp +++ b/source/ngc/networkop.cpp @@ -140,7 +140,7 @@ bool DownloadUpdate() retval = http_request(updateURL, hfile, NULL, (1024*1024*5)); fclose (hfile); } - ShowAction("Installing..."); + bool unzipResult = unzipArchive(updateFile, (char *)"sd:/"); remove(updateFile); // delete update file diff --git a/source/unzip/miniunz.c b/source/unzip/miniunz.cpp similarity index 82% rename from source/unzip/miniunz.c rename to source/unzip/miniunz.cpp index 5fe3819..45e967c 100644 --- a/source/unzip/miniunz.c +++ b/source/unzip/miniunz.cpp @@ -12,15 +12,20 @@ #include #include #include -# include -# include +#include +#include #include "unzip.h" +#include "menudraw.h" #define CASESENSITIVITY (0) #define WRITEBUFFERSIZE (1024*256) #define MAXFILENAME (256) +// used to display unzip progress +static uLong total_size; +static uLong total_unzipped; + static int mymkdir(const char* dirname) { int ret=0; @@ -204,6 +209,9 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat err=UNZ_ERRNO; break; } + total_unzipped += size_buf; + // show progress + ShowProgress("Unzipping...", total_unzipped, total_size); } while (err>0); if (fout) @@ -227,6 +235,42 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat return err; } +static uLong zipSize(unzFile uf) +{ + uLong i; + unz_global_info gi; + int err; + + uLong total = 0; + + unz_file_info file_info; + char filename_inzip[256]; + + err = unzGetGlobalInfo (uf,&gi); + + for (i=0;i