From 20a4e5acd78dcb5f681ab5320adb0289cebfc277 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 14 May 2023 13:13:38 +0200 Subject: libio: Add a function to open an istream_t from a directory iterator For the native versions, this is currently dummied out, always returning an error number. The idea is to laster wrap the libtar interface around a directory iterator, here we need that method to support the existing use case in tar2sqfs. Signed-off-by: David Oberhollenzer --- include/io/dir_iterator.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/io/dir_iterator.h') diff --git a/include/io/dir_iterator.h b/include/io/dir_iterator.h index 60c3796..b7212b3 100644 --- a/include/io/dir_iterator.h +++ b/include/io/dir_iterator.h @@ -8,6 +8,7 @@ #define IO_DIR_ITERATOR_H #include "sqfs/predef.h" +#include "io/istream.h" /** * @struct dir_entry_t @@ -136,6 +137,19 @@ typedef struct dir_iterator_t { * @param it A pointer to the iterator itself. */ void (*ignore_subdir)(struct dir_iterator_t *it); + + /** + * @brief If the last entry was a regular file, open it. + * + * If next() returned a file, this can be used to create an istream + * to read from it. + * + * @param it A pointer to the iterator itself. + * @param out Returns a pointer to a @ref istream_t on success. + * + * @return Zero on success, negative @ref SQFS_ERROR value on failure. + */ + int (*open_file_ro)(struct dir_iterator_t *it, istream_t **out); } dir_iterator_t; enum { -- cgit v1.2.3