diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-07-08 08:32:30 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-07-08 08:32:30 -0700 |
commit | dc73df1834c98dc13ba9c22bc3d009f604c07af7 (patch) | |
tree | 1dcf1acbb9c7b0825e460b01feef7d5d7b410647 /stream.c | |
parent | 107242691ea0317095bcb42378128de0eb4bbe57 (diff) | |
download | txr-dc73df1834c98dc13ba9c22bc3d009f604c07af7.tar.gz txr-dc73df1834c98dc13ba9c22bc3d009f604c07af7.tar.bz2 txr-dc73df1834c98dc13ba9c22bc3d009f604c07af7.zip |
Expose low-level opendir/readdir dir traversal.
* stream.c (UTF_DECL_OPENDIR): Macro defined, to enable
w_opendir declaration in utf8.h.
(w_opendir): Static function removed.
* sysif.c (UTF_DECL_OPENDIR): Macro defined.
(dir_s): Symbol defined unconditionally now, regardless of
HAVE_PWUID.
(dirent_s): New symbol.
(dirent_st): New static variable.
(struct dir): New struct type.
(opendir_free, opendir_mark opendir_wrap, readdir_wrap): New
static functions.
(opendir_ops): New static structure.
(sysif_init): Intern dirent symbol. Create dirent structure
type. Register opendir and readdir intrinsic functions.
Register variables dt-blk, dt-chr, dt-dir, dt-fifo, dt-lnk,
dt-reg, dt-sock and dt-unknown.
* utf8.c (UTF8_DECL_OPENDIR): Macro defined.
(w_opendir): Function moved here from stream.c, and turned
external.
* utf8.h (w_opendir): Declared, conditionally on
UTF8_DECL_OPENDIR being defined, so that most modules that
include utf8.h don't have to include <dirent.h>.
* txr.1: Documented.
diff --git a/sysif.c b/sysif.c
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 10 |
1 files changed, 1 insertions, 9 deletions
@@ -25,6 +25,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define UTF8_DECL_OPENDIR #include <stdio.h> #include <string.h> #include <stddef.h> @@ -4052,15 +4053,6 @@ val get_string(val stream_in, val nchars, val close_after_p) return get_string_from_stream(strstream); } -static DIR *w_opendir(const wchar_t *wname) -{ - char *name = utf8_dup_to(wname); - DIR *d = opendir(name); - free(name); - return d; -} - - val open_directory(val path) { DIR *d = w_opendir(c_str(path)); |