commit - c6e8a8268ec4f4240d51dcfd54d05c5370060747
commit + 509c99732c4da3e3b74c17d09aba5a38b701716f
blob - 39aa4333097646e6b90b09899df9869839a65c43
blob + 8ba2e5dff14da3efda11c6efbcaa5ba9f743c2b3
--- lib/got_lib_pack.h
+++ lib/got_lib_pack.h
const struct got_error *got_packidx_open(struct got_packidx **,
int, const char *, int);
const struct got_error *got_packidx_close(struct got_packidx *);
+const struct got_error *got_packidx_get_packfile_path(char **, struct got_packidx *);
int got_packidx_get_object_idx(struct got_packidx *, struct got_object_id *);
const struct got_error *got_packidx_match_id_str_prefix(
struct got_object_id_queue *, struct got_packidx *, const char *);
blob - 6941187fce5faf795c7ca119dabfdb71231aff1b
blob + 45d8d172d3e1fc86252195cf8d104b348ef56f44
--- lib/object.c
+++ lib/object.c
}
static const struct got_error *
-get_packfile_path(char **path_packfile, struct got_packidx *packidx)
-{
- size_t size;
-
- /* Packfile path contains ".pack" instead of ".idx", so add one byte. */
- size = strlen(packidx->path_packidx) + 2;
- if (size < GOT_PACKFILE_NAMELEN + 1)
- return got_error_path(packidx->path_packidx, GOT_ERR_BAD_PATH);
-
- *path_packfile = malloc(size);
- if (*path_packfile == NULL)
- return got_error_from_errno("malloc");
-
- /* Copy up to and excluding ".idx". */
- if (strlcpy(*path_packfile, packidx->path_packidx,
- size - strlen(GOT_PACKIDX_SUFFIX) - 1) >= size)
- return got_error(GOT_ERR_NO_SPACE);
-
- if (strlcat(*path_packfile, GOT_PACKFILE_SUFFIX, size) >= size)
- return got_error(GOT_ERR_NO_SPACE);
-
- return NULL;
-}
-
-static const struct got_error *
request_packed_object(struct got_object **obj, struct got_pack *pack, int idx,
struct got_object_id *id)
{
if (err)
return err;
- err = get_packfile_path(&path_packfile, packidx);
+ err = got_packidx_get_packfile_path(&path_packfile, packidx);
if (err)
return err;
if (err == NULL) {
struct got_pack *pack = NULL;
- err = get_packfile_path(&path_packfile, packidx);
+ err = got_packidx_get_packfile_path(&path_packfile, packidx);
if (err)
goto done;
if (err == NULL) {
struct got_pack *pack = NULL;
- err = get_packfile_path(&path_packfile, packidx);
+ err = got_packidx_get_packfile_path(&path_packfile, packidx);
if (err)
return err;
if (err == NULL) {
struct got_pack *pack = NULL;
- err = get_packfile_path(&path_packfile, packidx);
+ err = got_packidx_get_packfile_path(&path_packfile, packidx);
if (err)
return err;
if (err == NULL) {
struct got_pack *pack = NULL;
- err = get_packfile_path(&path_packfile, packidx);
+ err = got_packidx_get_packfile_path(&path_packfile, packidx);
if (err)
goto done;
if (err == NULL) {
struct got_pack *pack = NULL;
- err = get_packfile_path(&path_packfile, packidx);
+ err = got_packidx_get_packfile_path(&path_packfile, packidx);
if (err)
return err;
return NULL;
}
- err = get_packfile_path(&path_packfile, packidx);
+ err = got_packidx_get_packfile_path(&path_packfile, packidx);
if (err)
return err;
blob - ee37e1005b535f08ac796a6547d42f3394b34916
blob + 137217342b5f0eb662a63182136a6750ffa7e2af
--- lib/pack.c
+++ lib/pack.c
return err;
}
+
+const struct got_error *
+got_packidx_get_packfile_path(char **path_packfile, struct got_packidx *packidx)
+{
+ size_t size;
+
+ /* Packfile path contains ".pack" instead of ".idx", so add one byte. */
+ size = strlen(packidx->path_packidx) + 2;
+ if (size < GOT_PACKFILE_NAMELEN + 1)
+ return got_error_path(packidx->path_packidx, GOT_ERR_BAD_PATH);
+ *path_packfile = malloc(size);
+ if (*path_packfile == NULL)
+ return got_error_from_errno("malloc");
+
+ /* Copy up to and excluding ".idx". */
+ if (strlcpy(*path_packfile, packidx->path_packidx,
+ size - strlen(GOT_PACKIDX_SUFFIX) - 1) >= size)
+ return got_error(GOT_ERR_NO_SPACE);
+
+ if (strlcat(*path_packfile, GOT_PACKFILE_SUFFIX, size) >= size)
+ return got_error(GOT_ERR_NO_SPACE);
+
+ return NULL;
+}
+
static off_t
get_object_offset(struct got_packidx *packidx, int idx)
{