From 13e0f88d4aba326da9217c225d6ab5e642eb611d Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 21 Jun 2011 21:23:33 -0400 Subject: archive: refactor list of archive formats Most of the tar and zip code was nicely split out into two abstracted files which knew only about their specific formats. The entry point to this code was a single "write archive" function. However, as these basic formats grow more complex (e.g., by handling multiple file extensions and format names), a static list of the entry point functions won't be enough. Instead, let's provide a way for the tar and zip code to tell the main archive code what they support by registering archiver names and functions. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- archive-zip.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'archive-zip.c') diff --git a/archive-zip.c b/archive-zip.c index cf285044e3..a776d8359c 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -261,7 +261,7 @@ static void dos_time(time_t *time, int *dos_date, int *dos_time) *dos_time = t->tm_sec / 2 + t->tm_min * 32 + t->tm_hour * 2048; } -int write_zip_archive(struct archiver_args *args) +static int write_zip_archive(struct archiver_args *args) { int err; @@ -278,3 +278,14 @@ int write_zip_archive(struct archiver_args *args) return err; } + +static struct archiver zip_archiver = { + "zip", + write_zip_archive, + ARCHIVER_WANT_COMPRESSION_LEVELS +}; + +void init_zip_archiver(void) +{ + register_archiver(&zip_archiver); +} -- cgit v1.2.1