aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-15 15:16:03 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-15 15:16:03 +0200
commit484cd01590ec488cca1f8a5c7c76cd223609e299 (patch)
tree0e3bc268688c2feb8773871a43381a998ce846e7 /include
parent8cf84b4995552bad4e77eb795e36c0b1d65a720a (diff)
Migrate file istream/ostream from libio to libsquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/common.h1
-rw-r--r--include/io/file.h94
-rw-r--r--include/sqfs/io.h74
3 files changed, 74 insertions, 95 deletions
diff --git a/include/common.h b/include/common.h
index d2e3f73..d4827a8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -21,7 +21,6 @@
#include "simple_writer.h"
#include "compress_cli.h"
-#include "io/file.h"
#include "io/std.h"
#include "compat.h"
#include "fstree.h"
diff --git a/include/io/file.h b/include/io/file.h
deleted file mode 100644
index e7ffb0d..0000000
--- a/include/io/file.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * file.h
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#ifndef IO_FILE_H
-#define IO_FILE_H
-
-#include "sqfs/io.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief Create an input stream for an OS native file handle.
- *
- * @memberof sqfs_istream_t
- *
- * The functions takes up ownership of the file handle and takes care
- * of cleaning it up. On failure, the handle remains usable, and ownership
- * remains with the caller.
- *
- * @param out Returns a pointer to an input stream on success.
- * @param path The name to associate with the handle.
- * @param fd A native file handle.
- *
- * @return Zero on success, a negative @ref SQFS_ERROR number on failure
- */
-SQFS_INTERNAL
-int istream_open_handle(sqfs_istream_t **out, const char *path,
- sqfs_file_handle_t fd);
-
-/**
- * @brief Create an output stream that writes to an OS native file handle.
- *
- * @memberof sqfs_ostream_t
- *
- * If the flag SQFS_FILE_OPEN_NO_SPARSE is set, the underlying implementation
- * always writes chunks of zero bytes when passing a NULL pointer to append.
- * Otherwise, it tries to use seek/truncate style APIs to create sparse output
- * files.
- *
- * @param out Returns a pointer to an output stream on success.
- * @param path The name to associate with the handle.
- * @param fd A native file handle.
- * @param flags A combination of flags.
- *
- * @return Zero on success, a negative @ref SQFS_ERROR number on failure
- */
-SQFS_INTERNAL int ostream_open_handle(sqfs_ostream_t **out, const char *path,
- sqfs_file_handle_t hnd, int flags);
-
-/**
- * @brief Create an input stream that reads from a file.
- *
- * @memberof sqfs_istream_t
- *
- * @param out Returns a pointer to an input stream on success.
- * @param path A path to the file to open or create.
- *
- * @return Zero on success, a negative @ref SQFS_ERROR number on failure
- */
-SQFS_INTERNAL int istream_open_file(sqfs_istream_t **out, const char *path);
-
-/**
- * @brief Create an output stream that writes to a file.
- *
- * @memberof sqfs_ostream_t
- *
- * If the file does not yet exist, it is created. If it does exist this
- * function fails, unless the flag SQFS_FILE_OPEN_OVERWRITE is set, in which
- * case the file is opened and its contents are discarded.
- *
- * If the flag SQFS_FILE_OPEN_NO_SPARSE is set, the underlying implementation
- * always writes chunks of zero bytes when passing a NULL pointer to append.
- * Otherwise, it tries to use seek/truncate style APIs to create sparse output
- * files.
- *
- * @param out Returns a pointer to an output stream on success.
- * @param path A path to the file to open or create.
- * @param flags A combination of flags controling how to open/create the file.
- *
- * @return Zero on success, a negative @ref SQFS_ERROR number on failure
- */
-SQFS_INTERNAL int ostream_open_file(sqfs_ostream_t **out,
- const char *path, int flags);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IO_FILE_H */
diff --git a/include/sqfs/io.h b/include/sqfs/io.h
index 1138fc0..eaf74a6 100644
--- a/include/sqfs/io.h
+++ b/include/sqfs/io.h
@@ -330,6 +330,80 @@ SQFS_API int sqfs_open_native_file(sqfs_file_handle_t *out,
SQFS_API sqfs_file_t *sqfs_open_file(const char *filename, sqfs_u32 flags);
/**
+ * @brief Create an input stream for an OS native file handle.
+ *
+ * @memberof sqfs_istream_t
+ *
+ * The functions takes up ownership of the file handle and takes care
+ * of cleaning it up. On failure, the handle remains usable, and ownership
+ * remains with the caller.
+ *
+ * @param out Returns a pointer to an input stream on success.
+ * @param path The name to associate with the handle.
+ * @param fd A native file handle.
+ *
+ * @return Zero on success, a negative @ref SQFS_ERROR number on failure
+ */
+SQFS_API
+int sqfs_istream_open_handle(sqfs_istream_t **out, const char *path,
+ sqfs_file_handle_t fd);
+
+/**
+ * @brief Create an output stream that writes to an OS native file handle.
+ *
+ * @memberof sqfs_ostream_t
+ *
+ * If the flag SQFS_FILE_OPEN_NO_SPARSE is set, the underlying implementation
+ * always writes chunks of zero bytes when passing a NULL pointer to append.
+ * Otherwise, it tries to use seek/truncate style APIs to create sparse output
+ * files.
+ *
+ * @param out Returns a pointer to an output stream on success.
+ * @param path The name to associate with the handle.
+ * @param fd A native file handle.
+ * @param flags A combination of flags.
+ *
+ * @return Zero on success, a negative @ref SQFS_ERROR number on failure
+ */
+SQFS_API int sqfs_ostream_open_handle(sqfs_ostream_t **out, const char *path,
+ sqfs_file_handle_t hnd, int flags);
+
+/**
+ * @brief Create an input stream that reads from a file.
+ *
+ * @memberof sqfs_istream_t
+ *
+ * @param out Returns a pointer to an input stream on success.
+ * @param path A path to the file to open or create.
+ *
+ * @return Zero on success, a negative @ref SQFS_ERROR number on failure
+ */
+SQFS_API int sqfs_istream_open_file(sqfs_istream_t **out, const char *path);
+
+/**
+ * @brief Create an output stream that writes to a file.
+ *
+ * @memberof sqfs_ostream_t
+ *
+ * If the file does not yet exist, it is created. If it does exist this
+ * function fails, unless the flag SQFS_FILE_OPEN_OVERWRITE is set, in which
+ * case the file is opened and its contents are discarded.
+ *
+ * If the flag SQFS_FILE_OPEN_NO_SPARSE is set, the underlying implementation
+ * always writes chunks of zero bytes when passing a NULL pointer to append.
+ * Otherwise, it tries to use seek/truncate style APIs to create sparse output
+ * files.
+ *
+ * @param out Returns a pointer to an output stream on success.
+ * @param path A path to the file to open or create.
+ * @param flags A combination of flags controling how to open/create the file.
+ *
+ * @return Zero on success, a negative @ref SQFS_ERROR number on failure
+ */
+SQFS_API int sqfs_ostream_open_file(sqfs_ostream_t **out,
+ const char *path, int flags);
+
+/**
* @brief Read data from an input stream
*
* @memberof sqfs_istream_t