aboutsummaryrefslogtreecommitdiff
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
parent7ce4b36d517ac5fade36240d293ff784ef6a9305 (diff)
Move directory iterator from libutil to libio
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--bin/gensquashfs/src/mkfs.h2
-rw-r--r--include/io/dir_iterator.h (renamed from include/util/dir_iterator.h)14
-rw-r--r--include/io/dir_tree_iterator.h (renamed from include/util/dir_tree_iterator.h)16
-rw-r--r--lib/io/Makemodule.am29
-rw-r--r--lib/io/src/dir_tree_iterator.c (renamed from lib/util/src/dir_tree_iterator.c)2
-rw-r--r--lib/io/src/unix/dir_iterator.c (renamed from lib/util/src/unix_dir_iterator.c)4
-rw-r--r--lib/io/src/win32/dir_iterator.c (renamed from lib/util/src/w32_dir_iterator.c)4
-rw-r--r--lib/io/test/dir_iterator.c (renamed from lib/util/test/dir_iterator.c)2
-rw-r--r--lib/io/test/dir_tree_iterator.c (renamed from lib/util/test/dir_tree_iterator.c)2
-rw-r--r--lib/io/test/dir_tree_iterator2.c (renamed from lib/util/test/dir_tree_iterator2.c)2
-rw-r--r--lib/io/test/dir_tree_iterator3.c (renamed from lib/util/test/dir_tree_iterator3.c)2
-rw-r--r--lib/io/test/testdir/dira/file_a0 (renamed from lib/util/test/testdir/dira/file_a0)0
-rw-r--r--lib/io/test/testdir/dira/file_a1 (renamed from lib/util/test/testdir/dira/file_a1)0
-rw-r--r--lib/io/test/testdir/dira/file_a2 (renamed from lib/util/test/testdir/dira/file_a2)0
-rw-r--r--lib/io/test/testdir/dirb/dirx/file_x0 (renamed from lib/util/test/testdir/dirb/dirx/file_x0)0
-rw-r--r--lib/io/test/testdir/dirb/dirx/file_x1 (renamed from lib/util/test/testdir/dirb/dirx/file_x1)0
-rw-r--r--lib/io/test/testdir/dirb/dirx/file_x2 (renamed from lib/util/test/testdir/dirb/dirx/file_x2)0
-rw-r--r--lib/io/test/testdir/dirb/file_b0 (renamed from lib/util/test/testdir/dirb/file_b0)0
-rw-r--r--lib/io/test/testdir/dirb/file_b1 (renamed from lib/util/test/testdir/dirb/file_b1)0
-rw-r--r--lib/io/test/testdir/dirb/file_b2 (renamed from lib/util/test/testdir/dirb/file_b2)0
-rw-r--r--lib/io/test/testdir/dirc/file_c0 (renamed from lib/util/test/testdir/dirc/file_c0)0
-rw-r--r--lib/io/test/testdir/dirc/file_c1 (renamed from lib/util/test/testdir/dirc/file_c1)0
-rw-r--r--lib/io/test/testdir/dirc/file_c2 (renamed from lib/util/test/testdir/dirc/file_c2)0
-rw-r--r--lib/util/Makemodule.am31
24 files changed, 62 insertions, 48 deletions
diff --git a/bin/gensquashfs/src/mkfs.h b/bin/gensquashfs/src/mkfs.h
index 81ad038..f9eadc6 100644
--- a/bin/gensquashfs/src/mkfs.h
+++ b/bin/gensquashfs/src/mkfs.h
@@ -12,7 +12,7 @@
#include "common.h"
#include "fstree.h"
-#include "util/dir_tree_iterator.h"
+#include "io/dir_tree_iterator.h"
#include "util/util.h"
#include "io/file.h"
diff --git a/include/util/dir_iterator.h b/include/io/dir_iterator.h
index 4d7607f..7080d65 100644
--- a/include/util/dir_iterator.h
+++ b/include/io/dir_iterator.h
@@ -4,8 +4,8 @@
*
* Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
*/
-#ifndef UTIL_DIR_ITERATOR_H
-#define UTIL_DIR_ITERATOR_H
+#ifndef IO_DIR_ITERATOR_H
+#define IO_DIR_ITERATOR_H
#include "sqfs/predef.h"
@@ -34,6 +34,14 @@ typedef struct dir_iterator_t {
struct dir_iterator_t **out);
} dir_iterator_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
dir_iterator_t *dir_iterator_create(const char *path);
-#endif /* UTIL_DIR_ITERATOR_H */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IO_DIR_ITERATOR_H */
diff --git a/include/util/dir_tree_iterator.h b/include/io/dir_tree_iterator.h
index 204f609..557178b 100644
--- a/include/util/dir_tree_iterator.h
+++ b/include/io/dir_tree_iterator.h
@@ -4,10 +4,10 @@
*
* Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
*/
-#ifndef UTIL_DIR_TREE_ITERATOR_H
-#define UTIL_DIR_TREE_ITERATOR_H
+#ifndef IO_DIR_TREE_ITERATOR_H
+#define IO_DIR_TREE_ITERATOR_H
-#include "util/dir_iterator.h"
+#include "io/dir_iterator.h"
enum {
DIR_SCAN_NO_SOCK = 0x0001,
@@ -38,9 +38,17 @@ typedef struct {
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);
-#endif /* UTIL_DIR_TREE_ITERATOR_H */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IO_DIR_TREE_ITERATOR_H */
diff --git a/lib/io/Makemodule.am b/lib/io/Makemodule.am
index 0480ae1..9f97540 100644
--- a/lib/io/Makemodule.am
+++ b/lib/io/Makemodule.am
@@ -1,22 +1,26 @@
libio_a_SOURCES = include/io/istream.h include/io/ostream.h include/io/xfrm.h \
include/io/file.h include/io/std.h \
+ include/io/dir_iterator.h include/io/dir_tree_iterator.h \
lib/io/src/internal.h lib/io/src/ostream.c \
lib/io/src/istream.c lib/io/src/get_line.c lib/io/src/xfrm/ostream.c \
- lib/io/src/xfrm/istream.c
+ lib/io/src/xfrm/istream.c lib/io/src/dir_tree_iterator.c
libio_a_CFLAGS = $(AM_CFLAGS) $(ZLIB_CFLAGS) $(XZ_CFLAGS)
libio_a_CFLAGS += $(ZSTD_CFLAGS) $(BZIP2_CFLAGS)
if WINDOWS
libio_a_SOURCES += lib/io/src/win32/ostream.c lib/io/src/win32/istream.c
+libio_a_SOURCES += lib/io/src/win32/dir_iterator.c
libio_a_CFLAGS += -DWINVER=0x0600 -D_WIN32_WINNT=0x0600
else
libio_a_SOURCES += lib/io/src/unix/ostream.c lib/io/src/unix/istream.c
+libio_a_SOURCES += lib/io/src/unix/dir_iterator.c
endif
noinst_LIBRARIES += libio.a
LIBIO_TESTS = test_get_line test_sparse_fb test_istream_read \
- test_istream_skip test_stream_splice
+ test_istream_skip test_stream_splice test_dir_iterator \
+ test_dir_tree_iterator test_dir_tree_iterator2 test_dir_tree_iterator3
test_get_line_SOURCES = lib/io/test/get_line.c
test_get_line_LDADD = libio.a libcompat.a
@@ -35,6 +39,26 @@ test_istream_skip_LDADD = libio.a libutil.a libcompat.a
test_stream_splice_SOURCES = lib/io/test/stream_splice.c
test_stream_splice_LDADD = libio.a libutil.a libcompat.a
+test_dir_iterator_SOURCES = lib/io/test/dir_iterator.c
+test_dir_iterator_LDADD = libio.a libutil.a libcompat.a
+test_dir_iterator_CPPFLAGS = $(AM_CPPFLAGS)
+test_dir_iterator_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/io/test/testdir
+
+test_dir_tree_iterator_SOURCES = lib/io/test/dir_tree_iterator.c
+test_dir_tree_iterator_LDADD = libio.a libutil.a libcompat.a
+test_dir_tree_iterator_CPPFLAGS = $(AM_CPPFLAGS)
+test_dir_tree_iterator_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/io/test/testdir
+
+test_dir_tree_iterator2_SOURCES = lib/io/test/dir_tree_iterator2.c
+test_dir_tree_iterator2_LDADD = libio.a libutil.a libcompat.a
+test_dir_tree_iterator2_CPPFLAGS = $(AM_CPPFLAGS)
+test_dir_tree_iterator2_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/io/test/testdir
+
+test_dir_tree_iterator3_SOURCES = lib/io/test/dir_tree_iterator3.c
+test_dir_tree_iterator3_LDADD = libio.a libutil.a libcompat.a
+test_dir_tree_iterator3_CPPFLAGS = $(AM_CPPFLAGS)
+test_dir_tree_iterator3_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/io/test/testdir
+
if WITH_XZ
test_io_xfrm_xz_SOURCES = lib/io/test/xfrm.c
test_io_xfrm_xz_LDADD = libio.a libxfrm.a libcompat.a $(XZ_LIBS)
@@ -73,3 +97,4 @@ check_PROGRAMS += $(LIBIO_TESTS)
TESTS += $(LIBIO_TESTS)
EXTRA_DIST += $(top_srcdir)/lib/io/test/get_line.txt
+EXTRA_DIST += $(top_srcdir)/lib/io/test/testdir
diff --git a/lib/util/src/dir_tree_iterator.c b/lib/io/src/dir_tree_iterator.c
index a63209b..b05eeb3 100644
--- a/lib/util/src/dir_tree_iterator.c
+++ b/lib/io/src/dir_tree_iterator.c
@@ -5,7 +5,7 @@
* Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "util/dir_tree_iterator.h"
+#include "io/dir_tree_iterator.h"
#include "util/util.h"
#include "sqfs/error.h"
diff --git a/lib/util/src/unix_dir_iterator.c b/lib/io/src/unix/dir_iterator.c
index 87cf516..d67fe83 100644
--- a/lib/util/src/unix_dir_iterator.c
+++ b/lib/io/src/unix/dir_iterator.c
@@ -1,11 +1,11 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
- * unix_dir_iterator.c
+ * dir_iterator.c
*
* Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "util/dir_iterator.h"
+#include "io/dir_iterator.h"
#include "util/util.h"
#include "sqfs/error.h"
diff --git a/lib/util/src/w32_dir_iterator.c b/lib/io/src/win32/dir_iterator.c
index f931a26..23d00f4 100644
--- a/lib/util/src/w32_dir_iterator.c
+++ b/lib/io/src/win32/dir_iterator.c
@@ -1,11 +1,11 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
- * w32_dir_iterator.c
+ * dir_iterator.c
*
* Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "util/dir_iterator.h"
+#include "io/dir_iterator.h"
#include "util/util.h"
#include "sqfs/error.h"
diff --git a/lib/util/test/dir_iterator.c b/lib/io/test/dir_iterator.c
index 5ebdaf7..57e76ab 100644
--- a/lib/util/test/dir_iterator.c
+++ b/lib/io/test/dir_iterator.c
@@ -6,7 +6,7 @@
*/
#include "config.h"
-#include "util/dir_iterator.h"
+#include "io/dir_iterator.h"
#include "sqfs/error.h"
#include "util/test.h"
#include "compat.h"
diff --git a/lib/util/test/dir_tree_iterator.c b/lib/io/test/dir_tree_iterator.c
index a45cc30..75e32fb 100644
--- a/lib/util/test/dir_tree_iterator.c
+++ b/lib/io/test/dir_tree_iterator.c
@@ -6,7 +6,7 @@
*/
#include "config.h"
-#include "util/dir_tree_iterator.h"
+#include "io/dir_tree_iterator.h"
#include "sqfs/error.h"
#include "util/test.h"
#include "compat.h"
diff --git a/lib/util/test/dir_tree_iterator2.c b/lib/io/test/dir_tree_iterator2.c
index aac7765..d3c4990 100644
--- a/lib/util/test/dir_tree_iterator2.c
+++ b/lib/io/test/dir_tree_iterator2.c
@@ -6,7 +6,7 @@
*/
#include "config.h"
-#include "util/dir_tree_iterator.h"
+#include "io/dir_tree_iterator.h"
#include "sqfs/error.h"
#include "util/test.h"
#include "compat.h"
diff --git a/lib/util/test/dir_tree_iterator3.c b/lib/io/test/dir_tree_iterator3.c
index 7b14190..6fce085 100644
--- a/lib/util/test/dir_tree_iterator3.c
+++ b/lib/io/test/dir_tree_iterator3.c
@@ -6,7 +6,7 @@
*/
#include "config.h"
-#include "util/dir_tree_iterator.h"
+#include "io/dir_tree_iterator.h"
#include "sqfs/error.h"
#include "util/test.h"
#include "compat.h"
diff --git a/lib/util/test/testdir/dira/file_a0 b/lib/io/test/testdir/dira/file_a0
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dira/file_a0
+++ b/lib/io/test/testdir/dira/file_a0
diff --git a/lib/util/test/testdir/dira/file_a1 b/lib/io/test/testdir/dira/file_a1
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dira/file_a1
+++ b/lib/io/test/testdir/dira/file_a1
diff --git a/lib/util/test/testdir/dira/file_a2 b/lib/io/test/testdir/dira/file_a2
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dira/file_a2
+++ b/lib/io/test/testdir/dira/file_a2
diff --git a/lib/util/test/testdir/dirb/dirx/file_x0 b/lib/io/test/testdir/dirb/dirx/file_x0
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dirb/dirx/file_x0
+++ b/lib/io/test/testdir/dirb/dirx/file_x0
diff --git a/lib/util/test/testdir/dirb/dirx/file_x1 b/lib/io/test/testdir/dirb/dirx/file_x1
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dirb/dirx/file_x1
+++ b/lib/io/test/testdir/dirb/dirx/file_x1
diff --git a/lib/util/test/testdir/dirb/dirx/file_x2 b/lib/io/test/testdir/dirb/dirx/file_x2
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dirb/dirx/file_x2
+++ b/lib/io/test/testdir/dirb/dirx/file_x2
diff --git a/lib/util/test/testdir/dirb/file_b0 b/lib/io/test/testdir/dirb/file_b0
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dirb/file_b0
+++ b/lib/io/test/testdir/dirb/file_b0
diff --git a/lib/util/test/testdir/dirb/file_b1 b/lib/io/test/testdir/dirb/file_b1
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dirb/file_b1
+++ b/lib/io/test/testdir/dirb/file_b1
diff --git a/lib/util/test/testdir/dirb/file_b2 b/lib/io/test/testdir/dirb/file_b2
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dirb/file_b2
+++ b/lib/io/test/testdir/dirb/file_b2
diff --git a/lib/util/test/testdir/dirc/file_c0 b/lib/io/test/testdir/dirc/file_c0
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dirc/file_c0
+++ b/lib/io/test/testdir/dirc/file_c0
diff --git a/lib/util/test/testdir/dirc/file_c1 b/lib/io/test/testdir/dirc/file_c1
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dirc/file_c1
+++ b/lib/io/test/testdir/dirc/file_c1
diff --git a/lib/util/test/testdir/dirc/file_c2 b/lib/io/test/testdir/dirc/file_c2
index e69de29..e69de29 100644
--- a/lib/util/test/testdir/dirc/file_c2
+++ b/lib/io/test/testdir/dirc/file_c2
diff --git a/lib/util/Makemodule.am b/lib/util/Makemodule.am
index 15c5b88..0a0e50e 100644
--- a/lib/util/Makemodule.am
+++ b/lib/util/Makemodule.am
@@ -2,23 +2,18 @@ libutil_a_SOURCES = include/util/util.h include/util/str_table.h \
include/util/hash_table.h include/util/test.h include/util/rbtree.h \
include/util/array.h include/util/threadpool.h \
include/util/w32threadwrap.h include/util/mempool.h \
- include/util/dir_iterator.h include/util/dir_tree_iterator.h \
lib/util/src/str_table.c lib/util/src/alloc.c lib/util/src/rbtree.c \
lib/util/src/array.c lib/util/src/xxhash.c lib/util/src/hash_table.c \
lib/util/src/fast_urem_by_const.h lib/util/src/threadpool_serial.c \
lib/util/src/is_memory_zero.c lib/util/src/mkdir_p.c \
lib/util/src/canonicalize_name.c lib/util/src/filename_sane.c \
lib/util/src/source_date_epoch.c lib/util/src/file_cmp.c \
- lib/util/src/hex_decode.c lib/util/src/base64_decode.c \
- lib/util/src/dir_tree_iterator.c
+ lib/util/src/hex_decode.c lib/util/src/base64_decode.c
libutil_a_CFLAGS = $(AM_CFLAGS)
libutil_a_CPPFLAGS = $(AM_CPPFLAGS)
if WINDOWS
libutil_a_CFLAGS += -DWINVER=0x0600 -D_WIN32_WINNT=0x0600
-libutil_a_SOURCES += lib/util/src/w32_dir_iterator.c
-else
-libutil_a_SOURCES += lib/util/src/unix_dir_iterator.c
endif
if HAVE_PTHREAD
@@ -81,33 +76,11 @@ test_hex_decode_LDADD = libutil.a libcompat.a
test_base64_decode_SOURCES = lib/util/test/base64_decode.c
test_base64_decode_LDADD = libutil.a libcompat.a
-test_dir_iterator_SOURCES = lib/util/test/dir_iterator.c
-test_dir_iterator_LDADD = libutil.a libcompat.a
-test_dir_iterator_CPPFLAGS = $(AM_CPPFLAGS)
-test_dir_iterator_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/util/test/testdir
-
-test_dir_tree_iterator_SOURCES = lib/util/test/dir_tree_iterator.c
-test_dir_tree_iterator_LDADD = libutil.a libcompat.a
-test_dir_tree_iterator_CPPFLAGS = $(AM_CPPFLAGS)
-test_dir_tree_iterator_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/util/test/testdir
-
-test_dir_tree_iterator2_SOURCES = lib/util/test/dir_tree_iterator2.c
-test_dir_tree_iterator2_LDADD = libutil.a libcompat.a
-test_dir_tree_iterator2_CPPFLAGS = $(AM_CPPFLAGS)
-test_dir_tree_iterator2_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/util/test/testdir
-
-test_dir_tree_iterator3_SOURCES = lib/util/test/dir_tree_iterator3.c
-test_dir_tree_iterator3_LDADD = libutil.a libcompat.a
-test_dir_tree_iterator3_CPPFLAGS = $(AM_CPPFLAGS)
-test_dir_tree_iterator3_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/util/test/testdir
-
LIBUTIL_TESTS = \
test_str_table test_rbtree test_xxhash test_threadpool test_ismemzero \
test_canonicalize_name test_filename_sane test_filename_sane_w32 \
- test_sdate_epoch test_hex_decode test_base64_decode test_dir_iterator \
- test_dir_tree_iterator test_dir_tree_iterator2 test_dir_tree_iterator3
+ test_sdate_epoch test_hex_decode test_base64_decode
check_PROGRAMS += $(LIBUTIL_TESTS)
TESTS += $(LIBUTIL_TESTS)
EXTRA_DIST += $(top_srcdir)/lib/util/test/words.txt
-EXTRA_DIST += $(top_srcdir)/lib/util/test/testdir