summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-07-17 19:05:35 +0200
committerGravatar Nikias Bassen2012-07-17 19:05:35 +0200
commite292d68b72ad4999e463e94ac8b9ea0d46b5d040 (patch)
tree460545c371cde34a7d1d56f25dc5ab2e11ba2f7a
parent67bb07bb55577970761b51effa9e17b05b86a2a2 (diff)
downloadidevicerestore-e292d68b72ad4999e463e94ac8b9ea0d46b5d040.tar.gz
idevicerestore-e292d68b72ad4999e463e94ac8b9ea0d46b5d040.tar.bz2
main: use extracted filesystem if present
-rw-r--r--src/idevicerestore.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index edf88f8..f1454fc 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -1260,6 +1260,30 @@ int ipsw_extract_filesystem(const char* ipsw, plist_t build_identity, char** fil
return -1;
}
+ // check if we already have an extracted filesystem
+ // for /path/X.ipsw we check /path/X/[filename].dmg
+ char tmpf[1024];
+ strcpy(tmpf, ipsw);
+ char* p = strrchr((const char*)tmpf, '.');
+ if (p) {
+ *p = '\0';
+ }
+ strcat(tmpf, "/");
+ strcat(tmpf, filename);
+
+ struct stat st;
+ memset(&st, '\0', sizeof(struct stat));
+ if (stat(tmpf, &st) == 0) {
+ off_t fssize = 0;
+ ipsw_get_file_size(ipsw, filename, &fssize);
+ if ((fssize > 0) && (st.st_size == fssize)) {
+ info("Using cached filesystem from '%s'\n", tmpf);
+ *filesystem = strdup(tmpf);
+ free(filename);
+ return 0;
+ }
+ }
+
char* outfile = tempnam(NULL, "ipsw_");
if (!outfile) {
error("WARNING: Could not get temporary filename!\n");