aboutsummaryrefslogtreecommitdiff
path: root/bin/sqfsdiff/extract.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-04 19:26:31 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-16 09:34:35 +0200
commit0a0cbefc6ebb6174aad3e6f0b8a6dea87aed49da (patch)
tree7b1a69382f7480e442620b6176c1673abcf81b3c /bin/sqfsdiff/extract.c
parent4b994ac359757098ebc09263fff9e2290a58de71 (diff)
Remodel file extraction tools to use libfstream
This commit rewrites the libtar write paths to use libfstream insead of a FILE pointer. Also, the libcommon file extraction function is remodeled to use libfstream. In accordance, rdsquashfs, sqfs2tar and sqfsdiff have some minor adjustments made to work with the ported libtar and libcommon. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/sqfsdiff/extract.c')
-rw-r--r--bin/sqfsdiff/extract.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/bin/sqfsdiff/extract.c b/bin/sqfsdiff/extract.c
index 979572a..0c68918 100644
--- a/bin/sqfsdiff/extract.c
+++ b/bin/sqfsdiff/extract.c
@@ -10,7 +10,7 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode,
const char *prefix, const char *path, size_t block_size)
{
char *ptr, *temp;
- FILE *fp;
+ ostream_t *fp;
temp = alloca(strlen(prefix) + strlen(path) + 2);
sprintf(temp, "%s/%s", prefix, path);
@@ -21,19 +21,20 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode,
return -1;
*ptr = '/';
- fp = fopen(temp, "wb");
+ fp = ostream_open_file(temp, OSTREAM_OPEN_OVERWRITE |
+ OSTREAM_OPEN_SPARSE);
if (fp == NULL) {
perror(temp);
return -1;
}
- if (sqfs_data_reader_dump(path, data, inode, fp, block_size, true)) {
- fclose(fp);
+ if (sqfs_data_reader_dump(path, data, inode, fp, block_size)) {
+ sqfs_destroy(fp);
return -1;
}
- fflush(fp);
- fclose(fp);
+ ostream_flush(fp);
+ sqfs_destroy(fp);
return 0;
}