summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2016-06-26 18:09:26 +0200
committerGravatar Nikias Bassen2016-06-26 18:09:26 +0200
commitdd20797c1c75b13affdd2df955c897c06755edf0 (patch)
treeccc6aee6f145b09ab0cc1cd2a9cb9e263524aca2
parente4cd7225dc002cbdba664a892ae7e5f4427e6a72 (diff)
downloadidevicerestore-dd20797c1c75b13affdd2df955c897c06755edf0.tar.gz
idevicerestore-dd20797c1c75b13affdd2df955c897c06755edf0.tar.bz2
ipsw: Add ipsw_extract_to_file_with_progress() and remove progress bar from ipsw_extract_to_file()
-rw-r--r--src/idevicerestore.c2
-rw-r--r--src/ipsw.c14
-rw-r--r--src/ipsw.h1
3 files changed, 13 insertions, 4 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 5263c76..43904e5 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -728,7 +728,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
// Extract filesystem from IPSW
info("Extracting filesystem from IPSW\n");
- if (ipsw_extract_to_file(client->ipsw, fsname, filesystem) < 0) {
+ if (ipsw_extract_to_file_with_progress(client->ipsw, fsname, filesystem, 1) < 0) {
error("ERROR: Unable to extract filesystem from IPSW\n");
if (client->tss)
plist_free(client->tss);
diff --git a/src/ipsw.c b/src/ipsw.c
index 061d00d..a0ed824 100644
--- a/src/ipsw.c
+++ b/src/ipsw.c
@@ -86,7 +86,8 @@ int ipsw_get_file_size(const char* ipsw, const char* infile, off_t* size) {
return 0;
}
-int ipsw_extract_to_file(const char* ipsw, const char* infile, const char* outfile) {
+int ipsw_extract_to_file_with_progress(const char* ipsw, const char* infile, const char* outfile, int print_progress)
+{
int ret = 0;
ipsw_archive* archive = ipsw_open(ipsw);
if (archive == NULL || archive->zip == NULL) {
@@ -145,8 +146,10 @@ int ipsw_extract_to_file(const char* ipsw, const char* infile, const char* outfi
}
bytes += size;
- progress = ((double)bytes / (double)zstat.size) * 100.0;
- print_progress_bar(progress);
+ if (print_progress) {
+ progress = ((double)bytes / (double)zstat.size) * 100.0;
+ print_progress_bar(progress);
+ }
}
fclose(fd);
@@ -156,6 +159,11 @@ int ipsw_extract_to_file(const char* ipsw, const char* infile, const char* outfi
return ret;
}
+int ipsw_extract_to_file(const char* ipsw, const char* infile, const char* outfile)
+{
+ return ipsw_extract_to_file_with_progress(ipsw, infile, outfile, 0);
+}
+
int ipsw_file_exists(const char* ipsw, const char* infile)
{
ipsw_archive* archive = ipsw_open(ipsw);
diff --git a/src/ipsw.h b/src/ipsw.h
index d197aee..c4a1a4e 100644
--- a/src/ipsw.h
+++ b/src/ipsw.h
@@ -41,6 +41,7 @@ typedef struct {
int ipsw_get_file_size(const char* ipsw, const char* infile, off_t* size);
int ipsw_extract_to_file(const char* ipsw, const char* infile, const char* outfile);
+int ipsw_extract_to_file_with_progress(const char* ipsw, const char* infile, const char* outfile, int print_progress);
int ipsw_extract_to_memory(const char* ipsw, const char* infile, unsigned char** pbuffer, unsigned int* psize);
int ipsw_extract_build_manifest(const char* ipsw, plist_t* buildmanifest, int *tss_enabled);
int ipsw_extract_restore_plist(const char* ipsw, plist_t* restore_plist);