diff options
author | Nikias Bassen | 2012-07-17 19:00:33 +0200 |
---|---|---|
committer | Nikias Bassen | 2012-07-17 19:00:33 +0200 |
commit | 67bb07bb55577970761b51effa9e17b05b86a2a2 (patch) | |
tree | d8d298d1830ad438db4f81d8c22114616d63d88c | |
parent | b32de647e7942147a64b55df1b4e9fc331119ef4 (diff) | |
download | idevicerestore-67bb07bb55577970761b51effa9e17b05b86a2a2.tar.gz idevicerestore-67bb07bb55577970761b51effa9e17b05b86a2a2.tar.bz2 |
ipsw: add function ipsw_get_file_size() to get uncompressed file size
-rw-r--r-- | src/ipsw.c | 26 | ||||
-rw-r--r-- | src/ipsw.h | 2 |
2 files changed, 28 insertions, 0 deletions
@@ -56,6 +56,32 @@ ipsw_archive* ipsw_open(const char* ipsw) { return archive; } +int ipsw_get_file_size(const char* ipsw, const char* infile, off_t* size) { + ipsw_archive* archive = ipsw_open(ipsw); + if (archive == NULL || archive->zip == NULL) { + error("ERROR: Invalid archive\n"); + return -1; + } + + int zindex = zip_name_locate(archive->zip, infile, 0); + if (zindex < 0) { + error("ERROR: zip_name_locate: %s\n", infile); + return -1; + } + + struct zip_stat zstat; + zip_stat_init(&zstat); + if (zip_stat_index(archive->zip, zindex, 0, &zstat) != 0) { + error("ERROR: zip_stat_index: %s\n", infile); + return -1; + } + + *size = zstat.size; + + ipsw_close(archive); + return 0; +} + int ipsw_extract_to_file(const char* ipsw, const char* infile, const char* outfile) { ipsw_archive* archive = ipsw_open(ipsw); if (archive == NULL || archive->zip == NULL) { @@ -37,6 +37,8 @@ typedef struct { unsigned char* data; } ipsw_file; +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_memory(const char* ipsw, const char* infile, char** pbuffer, uint32_t* 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); |