From 5a3b741b92b793be7221a481efca316aec208ebe Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 18 Jul 2023 21:54:50 +0200 Subject: 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 --- include/common.h | 4 ---- include/sqfs/data_reader.h | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/common.h b/include/common.h index 8e24d03..707d46b 100644 --- a/include/common.h +++ b/include/common.h @@ -33,10 +33,6 @@ typedef struct sqfs_hard_link_t { char *target; } sqfs_hard_link_t; -int sqfs_data_reader_dump(const char *name, sqfs_data_reader_t *data, - const sqfs_inode_generic_t *inode, - sqfs_ostream_t *fp, size_t block_size); - int write_data_from_file(const char *filename, sqfs_block_processor_t *data, sqfs_inode_generic_t **inode, sqfs_file_t *file, int flags); diff --git a/include/sqfs/data_reader.h b/include/sqfs/data_reader.h index 29077b7..dabf5c8 100644 --- a/include/sqfs/data_reader.h +++ b/include/sqfs/data_reader.h @@ -145,6 +145,27 @@ SQFS_API sqfs_s32 sqfs_data_reader_read(sqfs_data_reader_t *data, sqfs_u64 offset, void *buffer, sqfs_u32 size); +/** + * @brief Create an @ref sqfs_istream_t implementation for a squashfs file + * + * @memberof sqfs_data_reader_t + * + * This function creates a simple file stream implementation that internally + * reads data from a file in a SquashFS image. The reader is grabbed, the inode + * and filename are copied internally and not needed after creation. + * + * @param data A pointer to a data reader object. + * @param inode A pointer to the inode describing the file. + * @param filename A file name that the stream should return when asked. + * @param out Returns a pointer to a stream on success, NULL on failure. + * + * @return Zero on success, a negative @ref SQFS_ERROR value on failure. + */ +SQFS_API int sqfs_data_reader_create_stream(sqfs_data_reader_t *data, + const sqfs_inode_generic_t *inode, + const char *filename, + sqfs_istream_t **out); + #ifdef __cplusplus } #endif -- cgit v1.2.3