mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-01 00:15:14 +01:00
add unzip progress for auto-update
This commit is contained in:
parent
3f55b4fbc7
commit
7eea07a60c
@ -20,6 +20,7 @@
|
|||||||
#ifndef _NGCMENUDRAW_
|
#ifndef _NGCMENUDRAW_
|
||||||
#define _NGCMENUDRAW_
|
#define _NGCMENUDRAW_
|
||||||
|
|
||||||
|
#include <gccore.h>
|
||||||
#include "filesel.h"
|
#include "filesel.h"
|
||||||
|
|
||||||
#define PAGESIZE 17 // max item listing on a screen
|
#define PAGESIZE 17 // max item listing on a screen
|
||||||
|
@ -126,7 +126,7 @@ bool DownloadUpdate()
|
|||||||
retval = http_request(updateURL, hfile, NULL, (1024*1024*5));
|
retval = http_request(updateURL, hfile, NULL, (1024*1024*5));
|
||||||
fclose (hfile);
|
fclose (hfile);
|
||||||
}
|
}
|
||||||
ShowAction("Installing...");
|
|
||||||
bool unzipResult = unzipArchive(updateFile, (char *)"sd:/");
|
bool unzipResult = unzipArchive(updateFile, (char *)"sd:/");
|
||||||
remove(updateFile); // delete update file
|
remove(updateFile); // delete update file
|
||||||
|
|
||||||
|
@ -12,15 +12,20 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
# include <unistd.h>
|
#include <unistd.h>
|
||||||
# include <utime.h>
|
#include <utime.h>
|
||||||
|
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
|
#include "menudraw.h"
|
||||||
|
|
||||||
#define CASESENSITIVITY (0)
|
#define CASESENSITIVITY (0)
|
||||||
#define WRITEBUFFERSIZE (1024*256)
|
#define WRITEBUFFERSIZE (1024*256)
|
||||||
#define MAXFILENAME (256)
|
#define MAXFILENAME (256)
|
||||||
|
|
||||||
|
// used to display unzip progress
|
||||||
|
static uLong total_size;
|
||||||
|
static uLong total_unzipped;
|
||||||
|
|
||||||
static int mymkdir(const char* dirname)
|
static int mymkdir(const char* dirname)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
@ -204,6 +209,9 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
|
|||||||
err=UNZ_ERRNO;
|
err=UNZ_ERRNO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
total_unzipped += size_buf;
|
||||||
|
// show progress
|
||||||
|
ShowProgress("Unzipping...", total_unzipped, total_size);
|
||||||
}
|
}
|
||||||
while (err>0);
|
while (err>0);
|
||||||
if (fout)
|
if (fout)
|
||||||
@ -227,6 +235,42 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
|
|||||||
return err;
|
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<gi.number_entry;i++)
|
||||||
|
{
|
||||||
|
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
||||||
|
|
||||||
|
if (err!=UNZ_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
total += file_info.uncompressed_size;
|
||||||
|
|
||||||
|
if ((i+1)<gi.number_entry)
|
||||||
|
{
|
||||||
|
err = unzGoToNextFile(uf);
|
||||||
|
if (err!=UNZ_OK)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = unzGoToFirstFile(uf);
|
||||||
|
if (err!=UNZ_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password)
|
int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password)
|
||||||
{
|
{
|
||||||
@ -234,6 +278,10 @@ int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const c
|
|||||||
unz_global_info gi;
|
unz_global_info gi;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
total_size = zipSize(uf);
|
||||||
|
total_unzipped = 0;
|
||||||
|
ShowProgress("Unzipping...", total_unzipped, total_size);
|
||||||
|
|
||||||
err = unzGetGlobalInfo (uf,&gi);
|
err = unzGetGlobalInfo (uf,&gi);
|
||||||
//if (err!=UNZ_OK)
|
//if (err!=UNZ_OK)
|
||||||
// printf("error %d with zipfile in unzGetGlobalInfo \n",err);
|
// printf("error %d with zipfile in unzGetGlobalInfo \n",err);
|
@ -2,16 +2,8 @@
|
|||||||
#ifndef _miniunz_H
|
#ifndef _miniunz_H
|
||||||
#define _miniunz_H
|
#define _miniunz_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password);
|
int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password);
|
||||||
int extractZipOnefile(unzFile uf,const char* filename,int opt_extract_without_path,int opt_overwrite,const char* password);
|
int extractZipOnefile(unzFile uf,const char* filename,int opt_extract_without_path,int opt_overwrite,const char* password);
|
||||||
int makedir(char *newdir);
|
int makedir(char *newdir);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user