aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-01 14:55:58 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-01 17:28:39 +0200
commit3f7f3654d243275332d964f9ecbb79f9eb83a5d1 (patch)
treee46bfea72edff431092bb124bff948976358918a /include
parent665221e904df597925fc411d443802b20758b71f (diff)
libio: split dir_entry_t from dir_iterator_t, add create helper
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/fstree.h2
-rw-r--r--include/io/dir_entry.h112
-rw-r--r--include/io/dir_iterator.h78
-rw-r--r--include/io/xattr.h35
4 files changed, 114 insertions, 113 deletions
diff --git a/include/fstree.h b/include/fstree.h
index 55f0928..779cd28 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -15,7 +15,7 @@
#include <stdio.h>
#include "sqfs/predef.h"
-#include "io/dir_iterator.h"
+#include "io/dir_entry.h"
#include "io/istream.h"
#include "compat.h"
diff --git a/include/io/dir_entry.h b/include/io/dir_entry.h
new file mode 100644
index 0000000..7546daf
--- /dev/null
+++ b/include/io/dir_entry.h
@@ -0,0 +1,112 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * dir_entry.h
+ *
+ * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef IO_DIR_ENTRY_H
+#define IO_DIR_ENTRY_H
+
+#include "sqfs/predef.h"
+
+typedef enum {
+ DIR_ENTRY_FLAG_MOUNT_POINT = 0x0001,
+
+ DIR_ENTRY_FLAG_HARD_LINK = 0x0002,
+} DIR_ENTRY_FLAG;
+
+/**
+ * @struct dir_entry_t
+ *
+ * @brief A directory entry returned by a @ref dir_iterator_t
+ */
+typedef struct {
+ /**
+ * @brief Total size of file entries
+ */
+ sqfs_u64 size;
+
+ /**
+ * @brief Unix time stamp when the entry was last modified.
+ *
+ * If necessary, the OS native time stamp is converted to Unix time.
+ */
+ sqfs_s64 mtime;
+
+ /**
+ * @brief Device number where the entry is stored on.
+ *
+ * On Windows and other non-Unix OSes, a dummy value is stored here.
+ */
+ sqfs_u64 dev;
+
+ /**
+ * @brief Device number for device special files.
+ *
+ * On Windows and other non-Unix OSes, a dummy value is stored here.
+ */
+ sqfs_u64 rdev;
+
+ /**
+ * @brief ID of the user that owns the entry.
+ *
+ * On Windows and other non-Unix OSes, this always reports user 0.
+ */
+ sqfs_u64 uid;
+
+ /**
+ * @brief ID of the group that owns the entry.
+ *
+ * On Windows and other non-Unix OSes, this always reports group 0.
+ */
+ sqfs_u64 gid;
+
+ /**
+ * @brief Unix style permissions and entry type.
+ *
+ * On Windows and other non-Unix OSes, this is synthesized from the
+ * Unix-like file type, default 0755 permissions for directories or
+ * 0644 for files.
+ */
+ sqfs_u16 mode;
+
+ /**
+ * @brief Combination of DIR_ENTRY_FLAG values
+ */
+ sqfs_u16 flags;
+
+ /**
+ * @brief Name of the entry
+ *
+ * On Unix-like OSes, the name is returned as-is. On systems like
+ * Windows with encoding-aware APIs, the name is converted to UTF-8.
+ */
+ char name[];
+} dir_entry_t;
+
+typedef struct dir_entry_xattr_t {
+ struct dir_entry_xattr_t *next;
+ char *key;
+ sqfs_u8 *value;
+ size_t value_len;
+ char data[];
+} dir_entry_xattr_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+dir_entry_t *dir_entry_create(const char *name);
+
+dir_entry_xattr_t *dir_entry_xattr_create(const char *key, const sqfs_u8 *value,
+ size_t value_len);
+
+dir_entry_xattr_t *dir_entry_xattr_list_copy(const dir_entry_xattr_t *list);
+
+void dir_entry_xattr_list_free(dir_entry_xattr_t *list);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IO_DIR_ENTRY_H */
diff --git a/include/io/dir_iterator.h b/include/io/dir_iterator.h
index 20fcdff..6ae1cd1 100644
--- a/include/io/dir_iterator.h
+++ b/include/io/dir_iterator.h
@@ -7,84 +7,8 @@
#ifndef IO_DIR_ITERATOR_H
#define IO_DIR_ITERATOR_H
-#include "sqfs/predef.h"
+#include "io/dir_entry.h"
#include "io/istream.h"
-#include "io/xattr.h"
-
-typedef enum {
- DIR_ENTRY_FLAG_MOUNT_POINT = 0x0001,
-
- DIR_ENTRY_FLAG_HARD_LINK = 0x0002,
-} DIR_ENTRY_FLAG;
-
-/**
- * @struct dir_entry_t
- *
- * @brief A directory entry returned by a @ref dir_iterator_t
- */
-typedef struct {
- /**
- * @brief Total size of file entries
- */
- sqfs_u64 size;
-
- /**
- * @brief Unix time stamp when the entry was last modified.
- *
- * If necessary, the OS native time stamp is converted to Unix time.
- */
- sqfs_s64 mtime;
-
- /**
- * @brief Device number where the entry is stored on.
- *
- * On Windows and other non-Unix OSes, a dummy value is stored here.
- */
- sqfs_u64 dev;
-
- /**
- * @brief Device number for device special files.
- *
- * On Windows and other non-Unix OSes, a dummy value is stored here.
- */
- sqfs_u64 rdev;
-
- /**
- * @brief ID of the user that owns the entry.
- *
- * On Windows and other non-Unix OSes, this always reports user 0.
- */
- sqfs_u64 uid;
-
- /**
- * @brief ID of the group that owns the entry.
- *
- * On Windows and other non-Unix OSes, this always reports group 0.
- */
- sqfs_u64 gid;
-
- /**
- * @brief Unix style permissions and entry type.
- *
- * On Windows and other non-Unix OSes, this is synthesized from the
- * Unix-like file type, default 0755 permissions for directories or
- * 0644 for files.
- */
- sqfs_u16 mode;
-
- /**
- * @brief Combination of DIR_ENTRY_FLAG values
- */
- sqfs_u16 flags;
-
- /**
- * @brief Name of the entry
- *
- * On Unix-like OSes, the name is returned as-is. On systems like
- * Windows with encoding-aware APIs, the name is converted to UTF-8.
- */
- char name[];
-} dir_entry_t;
/**
* @interface dir_iterator_t
diff --git a/include/io/xattr.h b/include/io/xattr.h
deleted file mode 100644
index d9f3e65..0000000
--- a/include/io/xattr.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * xattr.h
- *
- * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
- */
-#ifndef IO_XATTR_H
-#define IO_XATTR_H
-
-#include "sqfs/predef.h"
-
-typedef struct dir_entry_xattr_t {
- struct dir_entry_xattr_t *next;
- char *key;
- sqfs_u8 *value;
- size_t value_len;
- char data[];
-} dir_entry_xattr_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-dir_entry_xattr_t *dir_entry_xattr_create(const char *key, const sqfs_u8 *value,
- size_t value_len);
-
-dir_entry_xattr_t *dir_entry_xattr_list_copy(const dir_entry_xattr_t *list);
-
-void dir_entry_xattr_list_free(dir_entry_xattr_t *list);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IO_XATTR_H */