From dc2ffc30e812fc52ad2bf4c11f36a69940f8d1ea Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Fri, 28 Nov 2008 16:28:54 +0200 Subject: io: apk_ostream stuff --- src/package.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'src/package.c') diff --git a/src/package.c b/src/package.c index d419596..8a87b14 100644 --- a/src/package.c +++ b/src/package.c @@ -331,35 +331,23 @@ struct apk_package *apk_pkg_read(struct apk_database *db, const char *file) { struct read_info_ctx ctx; struct apk_bstream *bs; - struct stat st; - int fd; ctx.pkg = apk_pkg_new(); if (ctx.pkg == NULL) return NULL; - fd = open(file, O_RDONLY); - if (fd < 0) + bs = apk_bstream_from_file(file); + if (bs == NULL) goto err; - fstat(fd, &st); - fcntl(fd, F_SETFD, FD_CLOEXEC); - - bs = apk_bstream_from_fd(fd); - if (bs == NULL) { - close(fd); - goto err; - } - ctx.db = db; - ctx.pkg->size = st.st_size; ctx.has_install = 0; if (apk_parse_tar_gz(bs, read_info_entry, &ctx) < 0) { apk_error("File %s is not an APK archive", file); - bs->close(bs, NULL); + bs->close(bs, NULL, NULL); goto err; } - bs->close(bs, ctx.pkg->csum); + bs->close(bs, ctx.pkg->csum, &ctx.pkg->size); if (ctx.pkg->name == NULL) { apk_error("File %s is corrupted", file); -- cgit v1.2.3-60-g2f50