archive.h 1.4 KB

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