From 674a8b5f3310c405b56bbe3a019e27f8f5eb2774 Mon Sep 17 00:00:00 2001 From: Timo Strunk Date: Tue, 9 Sep 2014 16:00:38 +0200 Subject: [PATCH] Added zipfile support to all compressed file factories - i.e. file_list, path_is_compressed and read_compressed_file --- file_path.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/file_path.c b/file_path.c index 17f4740ad9..d1629fa455 100644 --- a/file_path.c +++ b/file_path.c @@ -63,6 +63,9 @@ #ifdef HAVE_7ZIP #include "decompress/7zip_support.h" #endif +#ifdef HAVE_ZLIB +#include "decompress/zip_support.h" +#endif /* Dump to file. */ bool write_file(const char *path, const void *data, size_t size) @@ -81,8 +84,18 @@ bool write_file(const char *path, const void *data, size_t size) #ifdef HAVE_COMPRESSION long read_compressed_file(const char * archive_path, const char *relative_path, void **buf) { + const char* file_ext = path_get_extension(archive_path); #ifdef HAVE_7ZIP - return read_7zip_file(archive_path,relative_path,buf); + if (strcmp(file_ext,"7z") == 0) + { + return read_7zip_file(archive_path,relative_path,buf); + } +#endif +#ifdef HAVE_ZLIB + if (strcmp(file_ext,"zip") == 0) + { + return read_zip_file(archive_path,relative_path,buf); + } #endif return -1; } @@ -387,6 +400,12 @@ struct string_list *compressed_file_list_new(const char *path, return compressed_7zip_file_list_new(path,ext); } #endif +#ifdef HAVE_ZLIB + if (strcmp(file_ext,"zip") == 0) + { + return compressed_zip_file_list_new(path,ext); + } +#endif #endif return NULL; @@ -613,6 +632,12 @@ bool path_is_compressed_file(const char* path) return true; } #endif +#ifdef HAVE_ZLIB + if (strcmp(file_ext,"zip") == 0) + { + return true; + } +#endif #endif return false;