summaryrefslogtreecommitdiff
path: root/nt/inc/dirent.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-11-22 23:48:43 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2012-11-22 23:48:43 -0800
commit95ef7787fb0a5786a2e4f150649aadfa687a15f2 (patch)
treec109235849121c6909c8dd5075ddf63ed847ee82 /nt/inc/dirent.h
parent6f6b82d66f73e65545865b72f109dbf695934aea (diff)
Assume POSIX 1003.1-1988 or later for dirent.h.
* admin/CPP-DEFINES (HAVE_CLOSEDIR, HAVE_DIRENT_H): Remove. * admin/notes/copyright: Adjust to src/ndir.h -> nt/inc/dirent.h renaming. * configure.ac: Do not check for dirent.h or closdir. * nt/inc/dirent.h: Rename from ../src/ndir.h, with these changes: (struct dirent): Rename from struct direct. All uses changed. * nt/inc/sys/dir.h: Remove. * src/dired.c: Assume HAVE_DIRENT_H. (NAMLEN): Remove, replacing with ... (dirent_namelen): New function. All uses changed. Use the GNU macro _D_EXACT_NAMELEN if available, as it's faster than strlen. (DIRENTRY): Remove, replacing all uses with 'struct dirent'. (DIRENTRY_NONEMPTY): Remove. All callers now assume it's nonzero. * src/makefile.w32-in (DIR_H): Remove. All uses replaced with $(NT_INC)/dirent.h. ($(BLD)/w32.$(O)): Do not depend on $(SRC)/ndir.h. * src/ndir.h: Rename to ../nt/inc/dirent.h. * src/sysdep.h (closedir) [!HAVE_CLOSEDIR]: Remove. Do not include <dirent.h>; no longer needed. * src/w32.c: Include <dirent.h> rather than "ndir.h". Fixes: debbugs:12958
Diffstat (limited to 'nt/inc/dirent.h')
-rw-r--r--nt/inc/dirent.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/nt/inc/dirent.h b/nt/inc/dirent.h
new file mode 100644
index 0000000000..618f3beddf
--- /dev/null
+++ b/nt/inc/dirent.h
@@ -0,0 +1,38 @@
+/*
+ <dirent.h> -- definitions for POSIX-compatible directory access
+
+ * The code here is forced by the interface, and is not subject to
+ * copyright, constituting the only possible expression of the
+ * algorithm in this format.
+ */
+
+#define DIRBLKSIZ 512 /* size of directory block */
+#ifdef WINDOWSNT
+#define MAXNAMLEN 255
+#else /* not WINDOWSNT */
+#define MAXNAMLEN 15 /* maximum filename length */
+#endif /* not WINDOWSNT */
+ /* NOTE: MAXNAMLEN must be one less than a multiple of 4 */
+
+struct dirent /* data from readdir() */
+ {
+ long d_ino; /* inode number of entry */
+ unsigned short d_reclen; /* length of this record */
+ unsigned short d_namlen; /* length of string in d_name */
+ char d_name[MAXNAMLEN+1]; /* name of file */
+ };
+
+typedef struct
+ {
+ int dd_fd; /* file descriptor */
+ int dd_loc; /* offset in block */
+ int dd_size; /* amount of valid data */
+ char dd_buf[DIRBLKSIZ]; /* directory block */
+ } DIR; /* stream data from opendir() */
+
+extern DIR *opendir (char *);
+extern struct dirent *readdir (DIR *);
+extern void seekdir (DIR *, long);
+extern void closedir (DIR *);
+
+#define rewinddir( dirp ) seekdir( dirp, 0L )