|
| 1 | +/* |
| 2 | + * Copyright (C) the libgit2 contributors. All rights reserved. |
| 3 | + * |
| 4 | + * This file is part of libgit2, distributed under the GNU GPL v2 with |
| 5 | + * a Linking Exception. For full terms see the included COPYING file. |
| 6 | + */ |
| 7 | +#ifndef INCLUDE_sys_git_midx_h__ |
| 8 | +#define INCLUDE_sys_git_midx_h__ |
| 9 | + |
| 10 | +#include "git2/common.h" |
| 11 | +#include "git2/types.h" |
| 12 | + |
| 13 | +/** |
| 14 | + * @file git2/midx.h |
| 15 | + * @brief Git multi-pack-index routines |
| 16 | + * @defgroup git_midx Git multi-pack-index routines |
| 17 | + * @ingroup Git |
| 18 | + * @{ |
| 19 | + */ |
| 20 | +GIT_BEGIN_DECL |
| 21 | + |
| 22 | +/** |
| 23 | + * Create a new writer for `multi-pack-index` files. |
| 24 | + * |
| 25 | + * @param out location to store the writer pointer. |
| 26 | + * @param pack_dir the directory where the `.pack` and `.idx` files are. The |
| 27 | + * `multi-pack-index` file will be written in this directory, too. |
| 28 | + * @return 0 or an error code |
| 29 | + */ |
| 30 | +GIT_EXTERN(int) git_midx_writer_new( |
| 31 | + git_midx_writer **out, |
| 32 | + const char *pack_dir); |
| 33 | + |
| 34 | +/** |
| 35 | + * Free the multi-pack-index writer and its resources. |
| 36 | + * |
| 37 | + * @param w the writer to free. If NULL no action is taken. |
| 38 | + */ |
| 39 | +GIT_EXTERN(void) git_midx_writer_free(git_midx_writer *w); |
| 40 | + |
| 41 | +/** |
| 42 | + * Add an `.idx` file to the writer. |
| 43 | + * |
| 44 | + * @param w the writer |
| 45 | + * @param idx_path the path of an `.idx` file. |
| 46 | + * @return 0 or an error code |
| 47 | + */ |
| 48 | +GIT_EXTERN(int) git_midx_writer_add( |
| 49 | + git_midx_writer *w, |
| 50 | + const char *idx_path); |
| 51 | + |
| 52 | +/** |
| 53 | + * Write a `multi-pack-index` file to a file. |
| 54 | + * |
| 55 | + * @param w the writer |
| 56 | + * @return 0 or an error code |
| 57 | + */ |
| 58 | +GIT_EXTERN(int) git_midx_writer_commit( |
| 59 | + git_midx_writer *w); |
| 60 | + |
| 61 | +/** |
| 62 | + * Dump the contents of the `multi-pack-index` to an in-memory buffer. |
| 63 | + * |
| 64 | + * @param midx Buffer where to store the contents of the `multi-pack-index`. |
| 65 | + * @param w the writer |
| 66 | + * @return 0 or an error code |
| 67 | + */ |
| 68 | +GIT_EXTERN(int) git_midx_writer_dump( |
| 69 | + git_buf *midx, |
| 70 | + git_midx_writer *w); |
| 71 | + |
| 72 | +/** @} */ |
| 73 | +GIT_END_DECL |
| 74 | +#endif |
0 commit comments