diff options
author | Nikias Bassen | 2021-11-19 10:01:49 +0100 |
---|---|---|
committer | Nikias Bassen | 2021-11-19 10:01:49 +0100 |
commit | edda59e031862e189532c516fa7d40345b89f4f6 (patch) | |
tree | 083a56e2415d88711dbdd4a4f9b7f2ecae63f693 /src/ipsw.c | |
parent | 7fdd29bb8c779a66d2ea74694a08c48b81c076ec (diff) | |
download | idevicerestore-edda59e031862e189532c516fa7d40345b89f4f6.tar.gz idevicerestore-edda59e031862e189532c516fa7d40345b89f4f6.tar.bz2 |
Fix compilation on Windows
Diffstat (limited to 'src/ipsw.c')
-rw-r--r-- | src/ipsw.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -630,8 +630,12 @@ int ipsw_extract_to_memory(const char* ipsw, const char* infile, unsigned char** } else { char *filepath = build_path(archive->path, infile); struct stat fst; +#ifdef WIN32 + if (stat(filepath, &fst) != 0) { +#else if (lstat(filepath, &fst) != 0) { - error("ERROR: %s: fstat failed for %s: %s\n", __func__, filepath, strerror(errno)); +#endif + error("ERROR: %s: stat failed for %s: %s\n", __func__, filepath, strerror(errno)); free(filepath); ipsw_close(archive); return -1; @@ -645,8 +649,9 @@ int ipsw_extract_to_memory(const char* ipsw, const char* infile, unsigned char** return -1; } +#ifndef WIN32 if (S_ISLNK(fst.st_mode)) { - if (readlink(filepath, buffer, size) < 0) { + if (readlink(filepath, (char*)buffer, size) < 0) { error("ERROR: %s: readlink failed for %s: %s\n", __func__, filepath, strerror(errno)); free(filepath); free(buffer); @@ -654,6 +659,7 @@ int ipsw_extract_to_memory(const char* ipsw, const char* infile, unsigned char** return -1; } } else { +#endif FILE *f = fopen(filepath, "rb"); if (!f) { error("ERROR: %s: fopen failed for %s: %s\n", __func__, filepath, strerror(errno)); @@ -671,7 +677,9 @@ int ipsw_extract_to_memory(const char* ipsw, const char* infile, unsigned char** return -1; } fclose(f); +#ifndef WIN32 } +#endif buffer[size] = '\0'; free(filepath); @@ -756,9 +764,13 @@ static int ipsw_list_contents_recurse(ipsw_archive *archive, const char *path, i subpath = strdup(dir->d_name); struct stat st; +#ifdef WIN32 + ret = stat(fpath, &st); +#else ret = lstat(fpath, &st); +#endif if (ret != 0) { - error("ERROR: failed to stat %s\n", fpath); + error("ERROR: %s: stat failed for %s: %s\n", __func__, fpath, strerror(errno)); free(fpath); free(subpath); break; |