summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-09-30 14:11:37 +0300
committerTimo Teräs <timo.teras@iki.fi>2020-10-09 16:09:19 +0300
commitefe0c4afecb9fd3da2ab4849d2b8edd5bea14d08 (patch)
treeb04a9d2533148a1fcb4a28560ffd76c4bbc5e5ad /src/io.c
parent81782bfc150225df75b11efa4fa0ade428ae3676 (diff)
downloadapk-tools-efe0c4afecb9fd3da2ab4849d2b8edd5bea14d08.tar.gz
apk-tools-efe0c4afecb9fd3da2ab4849d2b8edd5bea14d08.tar.bz2
apk-tools-efe0c4afecb9fd3da2ab4849d2b8edd5bea14d08.tar.xz
apk-tools-efe0c4afecb9fd3da2ab4849d2b8edd5bea14d08.zip
adb: introduce apk-tools database format, and few applets
This is a flat buffers inspired format that allows fast mmaped access to the data with low overhead, signature support and relatively good forward support.
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/io.c b/src/io.c
index 9643218..db640da 100644
--- a/src/io.c
+++ b/src/io.c
@@ -827,7 +827,7 @@ struct apk_istream *apk_istream_from_file_gz(int atfd, const char *file)
struct apk_fd_ostream {
struct apk_ostream os;
- int fd, rc;
+ int fd;
const char *file, *tmpfile;
int atfd;
@@ -860,7 +860,7 @@ static ssize_t fdo_flush(struct apk_fd_ostream *fos)
return 0;
if ((r = safe_write(fos->fd, fos->buffer, fos->bytes)) != fos->bytes) {
- fos->rc = r < 0 ? r : -EIO;
+ apk_ostream_cancel(&fos->os, r < 0 ? r : -EIO);
return r;
}
@@ -879,8 +879,7 @@ static ssize_t fdo_write(struct apk_ostream *os, const void *ptr, size_t size)
return r;
if (size >= sizeof(fos->buffer) / 2) {
r = safe_write(fos->fd, ptr, size);
- if (r != size)
- fos->rc = r < 0 ? r : -EIO;
+ if (r != size) apk_ostream_cancel(&fos->os, r < 0 ? r : -EIO);
return r;
}
}
@@ -897,7 +896,7 @@ static int fdo_close(struct apk_ostream *os)
int rc;
fdo_flush(fos);
- rc = fos->rc;
+ rc = fos->os.rc;
if (fos->fd > STDERR_FILENO &&
close(fos->fd) < 0)