archive.h 1.35 KB
Newer Older
Franck Bui-Huu's avatar
Franck Bui-Huu committed
1 2 3
#ifndef ARCHIVE_H
#define ARCHIVE_H

4 5
#include "pathspec.h"

Franck Bui-Huu's avatar
Franck Bui-Huu committed
6 7
struct archiver_args {
	const char *base;
8
	size_t baselen;
Franck Bui-Huu's avatar
Franck Bui-Huu committed
9 10
	struct tree *tree;
	const unsigned char *commit_sha1;
11
	const struct commit *commit;
Franck Bui-Huu's avatar
Franck Bui-Huu committed
12
	time_t time;
13
	struct pathspec pathspec;
14
	unsigned int verbose : 1;
15
	unsigned int worktree_attributes : 1;
16
	unsigned int convert : 1;
17
	int compression_level;
Franck Bui-Huu's avatar
Franck Bui-Huu committed
18 19
};

20
#define ARCHIVER_WANT_COMPRESSION_LEVELS 1
21
#define ARCHIVER_REMOTE 2
22 23
struct archiver {
	const char *name;
24
	int (*write_archive)(const struct archiver *, struct archiver_args *);
25
	unsigned flags;
26
	void *data;
27 28
};
extern void register_archiver(struct archiver *);
Franck Bui-Huu's avatar
Franck Bui-Huu committed
29

30 31
extern void init_tar_archiver(void);
extern void init_zip_archiver(void);
32

33 34 35 36
typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,
					const unsigned char *sha1,
					const char *path, size_t pathlen,
					unsigned int mode);
Franck Bui-Huu's avatar
Franck Bui-Huu committed
37

38
extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
39
extern int write_archive(int argc, const char **argv, const char *prefix, int setup_prefix, const char *name_hint, int remote);
40 41

const char *archive_format_from_filename(const char *filename);
42 43 44 45
extern void *sha1_file_to_archive(const struct archiver_args *args,
				  const char *path, const unsigned char *sha1,
				  unsigned int mode, enum object_type *type,
				  unsigned long *sizep);
46

Franck Bui-Huu's avatar
Franck Bui-Huu committed
47
#endif	/* ARCHIVE_H */