summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gzip.c18
-rw-r--r--src/gzip.h3
-rw-r--r--src/opk/write.c1
3 files changed, 19 insertions, 3 deletions
diff --git a/src/gzip.c b/src/gzip.c
index ef4d4aa..0b5d7cf 100644
--- a/src/gzip.c
+++ b/src/gzip.c
@@ -229,6 +229,21 @@ opkg_opk_gzip_written(struct opkg_opk_gzip *gzip)
}
int
+opkg_opk_gzip_finish_write(struct opkg_opk_gzip *gzip)
+{
+ /* Sanity check */
+ if (gzip->dir != _OPKG_OPK_GZIP_DIR_WRITE) {
+ return OPKG_OPK_ERROR;
+ }
+
+ if (gzip->written > 0 && _opkg_opk_gzip_write(gzip, NULL, 0, 1) !=
+ OPKG_OPK_END) {
+ return OPKG_OPK_ERROR;
+ }
+ return OPKG_OPK_OK;
+}
+
+int
opkg_opk_gzip_free(struct opkg_opk_gzip *gzip)
{
int ret;
@@ -239,9 +254,6 @@ opkg_opk_gzip_free(struct opkg_opk_gzip *gzip)
ret = OPKG_OPK_ERROR;
}
} else {
- if (_opkg_opk_gzip_write(gzip, NULL, 0, 1) != OPKG_OPK_END) {
- ret = OPKG_OPK_ERROR;
- }
if (deflateEnd(&gzip->stream) != Z_OK) {
ret = OPKG_OPK_ERROR;
}
diff --git a/src/gzip.h b/src/gzip.h
index 6eddd6a..7283e3f 100644
--- a/src/gzip.h
+++ b/src/gzip.h
@@ -68,6 +68,9 @@ opkg_opk_gzip_write(struct opkg_opk_gzip *gzip, void *record, size_t size);
size_t
opkg_opk_gzip_written(struct opkg_opk_gzip *gzip);
+int
+opkg_opk_gzip_finish_write(struct opkg_opk_gzip *gzip);
+
/*
* Frees a decompression structure.
* Parameters:
diff --git a/src/opk/write.c b/src/opk/write.c
index a00cf77..9c710f6 100644
--- a/src/opk/write.c
+++ b/src/opk/write.c
@@ -125,6 +125,7 @@ opkg_opk_opk_write(struct opkg_opk_opk *opk, const char *file_name)
out3:
opkg_opk_ustar_free(opk->outer_ustar);
out2:
+ opkg_opk_gzip_finish_write(opk->outer_gzip);
opkg_opk_gzip_free(opk->outer_gzip);
out1:
fclose(opk->file);