2 * wrappers around low-level operations to provide a simpler interface
3 * to the operations that Lisp needs
5 * The functions in this file are typically called directly from Lisp.
6 * Thus, when their signature changes, they don't need updates in a .h
7 * file somewhere, but they do need updates in the Lisp code. FIXME:
8 * It would be nice to enforce this at compile time. It mighn't even
9 * be all that hard: make the cross-compiler versions of DEF-ALIEN-FOO
10 * macros accumulate strings in a list which then gets written out at
11 * the end of sbcl2.h at the end of cross-compilation, then rerun
12 * 'make' in src/runtime/ using the new sbcl2.h as sbcl.h (and make
13 * sure that all the files in src/runtime/ include sbcl.h). */
16 * This software is part of the SBCL system. See the README file for
19 * This software is derived from the CMU CL system, which was
20 * written at Carnegie Mellon University and released into the
21 * public domain. The software is in the public domain and is
22 * provided with absolutely no warranty. See the COPYING and CREDITS
23 * files for more information.
26 #include <sys/types.h>
33 * stuff needed by CL:DIRECTORY and other Lisp directory operations
36 /* Unix directory operations think of "." and ".." as filenames, but
37 * Lisp directory operations do not. */
39 is_lispy_filename(const char *filename)
41 return strcmp(filename, ".") && strcmp(filename, "..");
44 /* Return a zero-terminated array of strings holding the Lispy filenames
45 * (i.e. excluding the Unix magic "." and "..") in the named directory. */
47 alloc_directory_lispy_filenames(const char *directory_name)
52 if (dir_ptr = opendir(directory_name)) { /* if opendir success */
56 if (0 == voidacc_ctor(&va)) { /* if voidacc_ctor success */
57 struct dirent *dirent_ptr;
59 while (dirent_ptr = readdir(dir_ptr)) { /* until end of data */
60 char* original_name = dirent_ptr->d_name;
61 if (is_lispy_filename(original_name)) {
62 /* strdup(3) is in Linux and *BSD. If you port
63 * somewhere else that doesn't have it, it's easy
65 char* dup_name = strdup(original_name);
66 if (!dup_name) { /* if strdup failure */
69 if (voidacc_acc(&va, dup_name)) { /* if acc failure */
74 result = (char**)voidacc_give_away_result(&va);
79 /* ignoring closedir(3) return code, since what could we do?
81 * "Never ask questions you don't want to know the answer to."
82 * -- William Irving Zumwalt (Rich Cook, _The Wizardry Quested_) */
89 /* Free a result returned by alloc_directory_lispy_filenames. */
91 free_directory_lispy_filenames(char** directory_lispy_filenames)
95 /* Free the strings. */
96 for (p = directory_lispy_filenames; *p; ++p) {
100 /* Free the table of strings. */
101 free(directory_lispy_filenames);