aboutsummaryrefslogtreecommitdiffstats
path: root/src/package.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-11-28 16:28:54 +0200
committerTimo Teras <timo.teras@iki.fi>2008-11-28 16:28:54 +0200
commitdc2ffc30e812fc52ad2bf4c11f36a69940f8d1ea (patch)
tree4fc16f961139f7e4b06c33ffdcc7dd7ce81a9567 /src/package.c
parent4bafa681feb2b902553e26fd88df0f06b0c0778a (diff)
downloadaports-dc2ffc30e812fc52ad2bf4c11f36a69940f8d1ea.tar.bz2
aports-dc2ffc30e812fc52ad2bf4c11f36a69940f8d1ea.tar.xz
io: apk_ostream stuff
Diffstat (limited to 'src/package.c')
-rw-r--r--src/package.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/package.c b/src/package.c
index d4195969c4..8a87b14397 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);