aboutsummaryrefslogtreecommitdiff
path: root/include/io
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-12 18:32:12 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-15 13:38:25 +0200
commiteb9a4b9034453ae3093d678a6f3898303dc5a5a0 (patch)
treecd024b5ff5e1c77400a561adee50522f10fdadcd /include/io
parent63bc750fecb00fc5878ca889204fc65510893778 (diff)
libio: remove ostream_append_sparse and fallback implementation
Instead of a separate append-sparse function, simply accept NULL as an input for append. For both Unix and Win32, a fallback needs to be implemented. For XFRM, we can just memset the input buffer to zero, same for the libsquashfs data writer. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/io')
-rw-r--r--include/io/file.h5
-rw-r--r--include/io/ostream.h34
2 files changed, 7 insertions, 32 deletions
diff --git a/include/io/file.h b/include/io/file.h
index f3723b2..44fd224 100644
--- a/include/io/file.h
+++ b/include/io/file.h
@@ -18,6 +18,11 @@ typedef HANDLE os_file_t;
typedef int os_file_t;
#endif
+enum {
+ OSTREAM_OPEN_OVERWRITE = 0x01,
+ OSTREAM_OPEN_SPARSE = 0x02,
+};
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/include/io/ostream.h b/include/io/ostream.h
index 8fc8cef..7a57e48 100644
--- a/include/io/ostream.h
+++ b/include/io/ostream.h
@@ -23,15 +23,14 @@ typedef struct ostream_t {
* @brief Append a block of data to an output stream.
*
* @param strm A pointer to an output stream.
- * @param data A pointer to the data block to append.
+ * @param data A pointer to the data block to append. If NULL,
+ * synthesize a chunk of zero bytes.
* @param size The number of bytes to append.
*
* @return Zero on success, -1 on failure.
*/
int (*append)(struct ostream_t *strm, const void *data, size_t size);
- int (*append_sparse)(struct ostream_t *strm, size_t size);
-
/**
* @brief Process all pending, buffered data and flush it to disk.
*
@@ -56,33 +55,4 @@ typedef struct ostream_t {
const char *(*get_filename)(struct ostream_t *strm);
} ostream_t;
-enum {
- OSTREAM_OPEN_OVERWRITE = 0x01,
- OSTREAM_OPEN_SPARSE = 0x02,
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief Append a number of zero bytes to an output stream.
- *
- * @memberof ostream_t
- *
- * If the unerlying implementation supports sparse files, this function can be
- * used to create a "hole". If the implementation does not support it, a
- * fallback is used that just appends a block of zeros manualy.
- *
- * @param strm A pointer to an output stream.
- * @param size The number of zero bytes to append.
- *
- * @return Zero on success, -1 on failure.
- */
-SQFS_INTERNAL int ostream_append_sparse(ostream_t *strm, size_t size);
-
-#ifdef __cplusplus
-}
-#endif
-
#endif /* IO_OSTREAM_H */