summaryrefslogtreecommitdiff
path: root/include/io/file.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-06-26 22:51:27 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-07-08 19:17:35 +0200
commit359d71e90050a8b83f7bc7d2ecd4ff29c477cc22 (patch)
treedf2b7a585b78e6776446d4ca9be62a22db27f0a7 /include/io/file.h
parent2087cc237cd0fe1ed29ebf891648bacb46f4833b (diff)
Cleanup: rename libfstream to libio, split headers
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/io/file.h')
-rw-r--r--include/io/file.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/io/file.h b/include/io/file.h
new file mode 100644
index 0000000..8c6e851
--- /dev/null
+++ b/include/io/file.h
@@ -0,0 +1,52 @@
+/* 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 "io/istream.h"
+#include "io/ostream.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Create an input stream that reads from a file.
+ *
+ * @memberof istream_t
+ *
+ * @param path A path to the file to open or create.
+ *
+ * @return A pointer to an output stream on success, NULL on failure.
+ */
+SQFS_INTERNAL istream_t *istream_open_file(const char *path);
+
+/**
+ * @brief Create an output stream that writes to a file.
+ *
+ * @memberof ostream_t
+ *
+ * If the file does not yet exist, it is created. If it does exist this
+ * function fails, unless the flag OSTREAM_OPEN_OVERWRITE is set, in which
+ * case the file is opened and its contents are discarded.
+ *
+ * If the flag OSTREAM_OPEN_SPARSE is set, the underlying implementation tries
+ * to support sparse output files. If the flag is not set, holes will always
+ * be filled with zero bytes.
+ *
+ * @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 A pointer to an output stream on success, NULL on failure.
+ */
+SQFS_INTERNAL ostream_t *ostream_open_file(const char *path, int flags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IO_FILE_H */