1#ifndef ARCHIVE_H
2#define ARCHIVE_H
3
4#include "cache.h"
5#include "pathspec.h"
6
7struct repository;
8
9struct archiver_args {
10 struct repository *repo;
11 const char *base;
12 size_t baselen;
13 struct tree *tree;
14 const unsigned char *commit_sha1;
15 const struct commit *commit;
16 timestamp_t time;
17 struct pathspec pathspec;
18 unsigned int verbose : 1;
19 unsigned int worktree_attributes : 1;
20 unsigned int convert : 1;
21 int compression_level;
22};
23
24/* main api */
25
26extern int write_archive(int argc, const char **argv, const char *prefix,
27 struct repository *repo,
28 const char *name_hint, int remote);
29
30const char *archive_format_from_filename(const char *filename);
31
32/* archive backend stuff */
33
34#define ARCHIVER_WANT_COMPRESSION_LEVELS 1
35#define ARCHIVER_REMOTE 2
36struct archiver {
37 const char *name;
38 int (*write_archive)(const struct archiver *, struct archiver_args *);
39 unsigned flags;
40 void *data;
41};
42extern void register_archiver(struct archiver *);
43
44extern void init_tar_archiver(void);
45extern void init_zip_archiver(void);
46
47typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,
48 const struct object_id *oid,
49 const char *path, size_t pathlen,
50 unsigned int mode);
51
52extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
53extern void *object_file_to_archive(const struct archiver_args *args,
54 const char *path, const struct object_id *oid,
55 unsigned int mode, enum object_type *type,
56 unsigned long *sizep);
57
58#endif /* ARCHIVE_H */