diff options
author | Nikias Bassen | 2019-09-26 04:36:39 +0200 |
---|---|---|
committer | Nikias Bassen | 2019-09-26 04:36:39 +0200 |
commit | a18ad835cb84268fa07118cf6abed01d1e93856a (patch) | |
tree | 92e9a9e40a9e7cbb29971087ad89d2735a92fafc /src/ipsw.c | |
parent | 5c4680dcdcb751ab3d8185f2cf7dc5900037574d (diff) | |
download | idevicerestore-a18ad835cb84268fa07118cf6abed01d1e93856a.tar.gz idevicerestore-a18ad835cb84268fa07118cf6abed01d1e93856a.tar.bz2 |
Make sure CTRL+C is working at specific stages of the process
Diffstat (limited to 'src/ipsw.c')
-rw-r--r-- | src/ipsw.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -48,6 +48,8 @@ typedef struct { char *path; } ipsw_archive; +static int cancel_flag = 0; + ipsw_archive* ipsw_open(const char* ipsw); void ipsw_close(ipsw_archive* archive); @@ -155,6 +157,8 @@ int ipsw_extract_to_file_with_progress(const char* ipsw, const char* infile, con return -1; } + cancel_flag = 0; + if (archive->zip) { int zindex = zip_name_locate(archive->zip, infile, 0); if (zindex < 0) { @@ -192,6 +196,9 @@ int ipsw_extract_to_file_with_progress(const char* ipsw, const char* infile, con int count, size = BUFSIZE; double progress; for(i = zstat.size; i > 0; i -= count) { + if (cancel_flag) { + break; + } if (i < BUFSIZE) size = i; count = zip_fread(zfile, buffer, size); @@ -260,6 +267,9 @@ int ipsw_extract_to_file_with_progress(const char* ipsw, const char* infile, con uint64_t bytes = 0; double progress; while (!feof(fi)) { + if (cancel_flag) { + break; + } ssize_t r = fread(buffer, 1, BUFSIZE, fi); if (r < 0) { error("ERROR: fread failed: %s\n", strerror(errno)); @@ -287,6 +297,9 @@ int ipsw_extract_to_file_with_progress(const char* ipsw, const char* infile, con free(filepath); } ipsw_close(archive); + if (cancel_flag) { + ret = -2; + } return ret; } @@ -789,3 +802,8 @@ int ipsw_download_latest_fw(plist_t version_data, const char* product, const cha return res; } + +void ipsw_cancel(void) +{ + cancel_flag++; +} |