aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-07-18 21:54:50 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-08-10 09:28:27 +0200
commit5a3b741b92b793be7221a481efca316aec208ebe (patch)
tree81eaa29e7f4510f4419a3dc2f0b29120aa5114ab /include
parent9d431639effb4e33169110031a689fd1e9d435cf (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 'include')
-rw-r--r--include/common.h4
-rw-r--r--include/sqfs/data_reader.h21
2 files changed, 21 insertions, 4 deletions
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