diff options
Diffstat (limited to 'libsparse/include/sparse')
-rw-r--r-- | libsparse/include/sparse/sparse.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libsparse/include/sparse/sparse.h b/libsparse/include/sparse/sparse.h index 3d5fb0c53..586578633 100644 --- a/libsparse/include/sparse/sparse.h +++ b/libsparse/include/sparse/sparse.h @@ -210,6 +210,37 @@ int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, int (*write)(void *priv, const void *data, size_t len), void *priv); /** + * sparse_file_callback_typed - call a callback for blocks based on type + * + * @s - sparse file cookie + * @sparse - write in the Android sparse file format + * @data_write - function to call for data blocks. must not be null + * @fd_write - function to call for fd blocks + * @fill_write - function to call for fill blocks + * @skip_write - function to call for skip blocks + * @priv - value that will be passed as the first argument to each write + * + * Writes a sparse file by calling callback functions. If sparse is true, the + * file will be written in the Android sparse file format, and fill and skip blocks + * along with metadata will be written with data_write. If sparse is false, the file + * will be expanded into normal format and fill and skip blocks will be written with + * the given callbacks. + * If a callback function is provided, the library will not unroll data into a buffer, + * and will instead pass it directly to the caller for custom implementation. If a + * callback is not provided, that type of block will be converted into a void* and + * written with data_write. If no callbacks other than data are provided, the behavior + * is the same as sparse_file_callback(). The callback should return negative on error, + * 0 on success. + * + * Returns 0 on success, negative errno on error. + */ +int sparse_file_callback_typed(struct sparse_file* s, bool sparse, + int (*data_write)(void* priv, const void* data, size_t len), + int (*fd_write)(void* priv, int fd, size_t len), + int (*fill_write)(void* priv, uint32_t fill_val, size_t len), + int (*skip_write)(void* priv, int64_t len), void* priv); + +/** * sparse_file_foreach_chunk - call a callback for data blocks in sparse file * * @s - sparse file cookie |