aboutsummaryrefslogtreecommitdiff
path: root/include/io
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-05-13 17:18:43 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-05-13 17:18:43 +0200
commite501c9a4bc230dab034571c2078a12a8a856c67a (patch)
tree028c149597a194ec2220a60dc12db90a62c64669 /include/io
parent7ce4b36d517ac5fade36240d293ff784ef6a9305 (diff)
Move directory iterator from libutil to libio
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/io')
-rw-r--r--include/io/dir_iterator.h47
-rw-r--r--include/io/dir_tree_iterator.h54
2 files changed, 101 insertions, 0 deletions
diff --git a/include/io/dir_iterator.h b/include/io/dir_iterator.h
new file mode 100644
index 0000000..7080d65
--- /dev/null
+++ b/include/io/dir_iterator.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
+/*
+ * dir_iterator.h
+ *
+ * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef IO_DIR_ITERATOR_H
+#define IO_DIR_ITERATOR_H
+
+#include "sqfs/predef.h"
+
+typedef struct {
+ sqfs_s64 mtime;
+ sqfs_u64 dev;
+ sqfs_u64 rdev;
+ sqfs_u32 uid;
+ sqfs_u32 gid;
+ sqfs_u16 mode;
+
+ char name[];
+} dir_entry_t;
+
+typedef struct dir_iterator_t {
+ sqfs_object_t obj;
+
+ sqfs_u64 dev;
+
+ int (*next)(struct dir_iterator_t *it,
+ dir_entry_t **out);
+
+ int (*read_link)(struct dir_iterator_t *it, char **out);
+
+ int (*open_subdir)(struct dir_iterator_t *it,
+ struct dir_iterator_t **out);
+} dir_iterator_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+dir_iterator_t *dir_iterator_create(const char *path);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IO_DIR_ITERATOR_H */
diff --git a/include/io/dir_tree_iterator.h b/include/io/dir_tree_iterator.h
new file mode 100644
index 0000000..557178b
--- /dev/null
+++ b/include/io/dir_tree_iterator.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
+/*
+ * dir_tree_iterator.h
+ *
+ * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef IO_DIR_TREE_ITERATOR_H
+#define IO_DIR_TREE_ITERATOR_H
+
+#include "io/dir_iterator.h"
+
+enum {
+ DIR_SCAN_NO_SOCK = 0x0001,
+ DIR_SCAN_NO_SLINK = 0x0002,
+ DIR_SCAN_NO_FILE = 0x0004,
+ DIR_SCAN_NO_BLK = 0x0008,
+ DIR_SCAN_NO_DIR = 0x0010,
+ DIR_SCAN_NO_CHR = 0x0020,
+ DIR_SCAN_NO_FIFO = 0x0040,
+
+ DIR_SCAN_KEEP_TIME = 0x0100,
+ DIR_SCAN_KEEP_UID = 0x0200,
+ DIR_SCAN_KEEP_GID = 0x0400,
+ DIR_SCAN_KEEP_MODE = 0x0800,
+
+ DIR_SCAN_ONE_FILESYSTEM = 0x1000,
+ DIR_SCAN_NO_RECURSION = 0x2000,
+ DIR_SCAN_MATCH_FULL_PATH = 0x4000,
+};
+
+typedef struct {
+ sqfs_u32 flags;
+ sqfs_u32 def_uid;
+ sqfs_u32 def_gid;
+ sqfs_u32 def_mode;
+ sqfs_s64 def_mtime;
+ const char *prefix;
+ const char *name_pattern;
+} dir_tree_cfg_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+dir_iterator_t *dir_tree_iterator_create(const char *path,
+ const dir_tree_cfg_t *cfg);
+
+void dir_tree_iterator_skip(dir_iterator_t *it);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IO_DIR_TREE_ITERATOR_H */