diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-07-18 21:54:50 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-08-10 09:28:27 +0200 |
commit | 5a3b741b92b793be7221a481efca316aec208ebe (patch) | |
tree | 81eaa29e7f4510f4419a3dc2f0b29120aa5114ab /bin/sqfsdiff | |
parent | 9d431639effb4e33169110031a689fd1e9d435cf (diff) |
Add a data reader based sqfs_istream_t implementation
To the sqfs_data_reader_t is added, an sqfs_istream_t implementation
that internally reads through the data reader. The uses of the
data_reader_dump function are removed and the function is subsequently
removed from libcommon.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/sqfsdiff')
-rw-r--r-- | bin/sqfsdiff/src/extract.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/bin/sqfsdiff/src/extract.c b/bin/sqfsdiff/src/extract.c index cbc4381..df74f0f 100644 --- a/bin/sqfsdiff/src/extract.c +++ b/bin/sqfsdiff/src/extract.c @@ -11,6 +11,7 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, { char *ptr, *temp; sqfs_ostream_t *fp; + sqfs_istream_t *in; int ret; temp = alloca(strlen(prefix) + strlen(path) + 2); @@ -28,12 +29,23 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, return -1; } - if (sqfs_data_reader_dump(path, data, inode, fp, block_size)) { + ret = sqfs_data_reader_create_stream(data, inode, path, &in); + if (ret) { sqfs_drop(fp); return -1; } - ret = fp->flush(fp); + do { + ret = sqfs_istream_splice(in, fp, block_size); + if (ret < 0) + sqfs_perror(path, "splicing data", ret); + } while (ret > 0); + + sqfs_drop(in); + + if (ret == 0) + ret = fp->flush(fp); + if (ret) { sqfs_perror(fp->get_filename(fp), NULL, ret); sqfs_drop(fp); |