mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
40e7629194
commit
13e0f88d4a
17
archive.h
17
archive.h
@@ -14,16 +14,19 @@ struct archiver_args {
|
||||
int compression_level;
|
||||
};
|
||||
|
||||
typedef int (*write_archive_fn_t)(struct archiver_args *);
|
||||
#define ARCHIVER_WANT_COMPRESSION_LEVELS 1
|
||||
struct archiver {
|
||||
const char *name;
|
||||
int (*write_archive)(struct archiver_args *);
|
||||
unsigned flags;
|
||||
};
|
||||
extern void register_archiver(struct archiver *);
|
||||
|
||||
extern void init_tar_archiver(void);
|
||||
extern void init_zip_archiver(void);
|
||||
|
||||
typedef int (*write_archive_entry_fn_t)(struct archiver_args *args, const unsigned char *sha1, const char *path, size_t pathlen, unsigned int mode, void *buffer, unsigned long size);
|
||||
|
||||
/*
|
||||
* Archive-format specific backends.
|
||||
*/
|
||||
extern int write_tar_archive(struct archiver_args *);
|
||||
extern int write_zip_archive(struct archiver_args *);
|
||||
|
||||
extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
|
||||
extern int write_archive(int argc, const char **argv, const char *prefix, int setup_prefix);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user