0
|
1 /*
|
|
2 Copyright (C) 1995 Free Software Foundation, Inc.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: Not really in FSF. */
|
|
22
|
|
23 #ifdef SYSV_SYSTEM_DIR
|
|
24 # include <dirent.h>
|
|
25 #elif defined (NONSYSTEM_DIR_LIBRARY)
|
|
26 # include "ndir.h"
|
|
27 #elif defined (MSDOS)
|
|
28 # include <dirent.h>
|
|
29 #else
|
|
30 # include <sys/dir.h>
|
|
31 #endif /* not NONSYSTEM_DIR_LIBRARY */
|
|
32
|
|
33 #ifdef SYSV_SYSTEM_DIR
|
|
34 # define DIRENTRY struct dirent
|
|
35 #else /* not SYSV_SYSTEM_DIR */
|
|
36 # define DIRENTRY struct direct
|
|
37 #endif
|
|
38
|
|
39 /* The d_nameln member of a struct dirent includes the '\0' character
|
|
40 on some systems, but not on others. What's worse, you can't tell
|
|
41 at compile-time which one it will be, since it really depends on
|
|
42 the sort of system providing the filesystem you're reading from,
|
|
43 not the system you are running on. Paul Eggert
|
|
44 <eggert@bi.twinsun.com> says this occurs when Emacs is running on a
|
|
45 SunOS 4.1.2 host, reading a directory that is remote-mounted from a
|
|
46 Solaris 2.1 host and is in a native Solaris 2.1 filesystem.
|
|
47
|
2
|
48 (and Solaris 2 doesn't have a d_nameln member at all! Posix.1
|
|
49 doesn't specify it -- mrb)
|
|
50
|
0
|
51 Since applying strlen to the name always works, we'll just do that. */
|
|
52 #define NAMLEN(p) strlen (p->d_name)
|
|
53
|
|
54 #ifdef MSDOS
|
|
55 #define DIRENTRY_NONEMPTY(p) ((p)->d_name[0] != 0)
|
|
56 #else
|
|
57 #define DIRENTRY_NONEMPTY(p) ((p)->d_ino)
|
|
58 #endif
|
|
59
|
|
60 /* encapsulation: directory calls */
|
|
61
|
|
62 #ifdef ENCAPSULATE_CHDIR
|
|
63 extern int sys_chdir (CONST char *path);
|
|
64 #endif
|
|
65 #if defined (ENCAPSULATE_CHDIR) && !defined (DONT_ENCAPSULATE)
|
|
66 # undef chdir
|
|
67 # define chdir sys_chdir
|
|
68 #endif
|
|
69 #if !defined (ENCAPSULATE_CHDIR) && defined (DONT_ENCAPSULATE)
|
|
70 # define sys_chdir chdir
|
|
71 #endif
|
|
72
|
|
73 #ifdef ENCAPSULATE_MKDIR
|
|
74 extern int sys_mkdir (CONST char *path, int mode);
|
|
75 #endif
|
|
76 #if defined (ENCAPSULATE_MKDIR) && !defined (DONT_ENCAPSULATE)
|
|
77 # undef mkdir
|
|
78 # define mkdir sys_mkdir
|
|
79 #endif
|
|
80 #if !defined (ENCAPSULATE_MKDIR) && defined (DONT_ENCAPSULATE)
|
|
81 # define sys_mkdir mkdir
|
|
82 #endif
|
|
83
|
|
84 #ifdef ENCAPSULATE_OPENDIR
|
|
85 extern DIR *sys_opendir (CONST char *filename);
|
|
86 #endif
|
|
87 #if defined (ENCAPSULATE_OPENDIR) && !defined (DONT_ENCAPSULATE)
|
|
88 # undef opendir
|
|
89 # define opendir sys_opendir
|
|
90 #endif
|
|
91 #if !defined (ENCAPSULATE_OPENDIR) && defined (DONT_ENCAPSULATE)
|
|
92 # define sys_opendir opendir
|
|
93 #endif
|
|
94
|
|
95 #ifdef ENCAPSULATE_READDIR
|
|
96 extern DIRENTRY *sys_readdir (DIR *dirp);
|
|
97 #endif
|
|
98 #if defined (ENCAPSULATE_READDIR) && !defined (DONT_ENCAPSULATE)
|
|
99 # undef readdir
|
|
100 # define readdir sys_readdir
|
|
101 #endif
|
|
102 #if !defined (ENCAPSULATE_READDIR) && defined (DONT_ENCAPSULATE)
|
|
103 # define sys_readdir readdir
|
|
104 #endif
|
|
105
|
|
106 #ifdef ENCAPSULATE_CLOSEDIR
|
|
107 extern int sys_closedir (DIR *dirp);
|
|
108 #endif
|
|
109 #if defined (ENCAPSULATE_CLOSEDIR) && !defined (DONT_ENCAPSULATE)
|
|
110 # undef closedir
|
|
111 # define closedir sys_closedir
|
|
112 #endif
|
|
113 #if !defined (ENCAPSULATE_CLOSEDIR) && defined (DONT_ENCAPSULATE)
|
|
114 # define sys_closedir closedir
|
|
115 #endif
|
|
116
|
|
117 #ifdef ENCAPSULATE_RMDIR
|
|
118 extern int sys_rmdir (CONST char *path);
|
|
119 #endif
|
|
120 #if defined (ENCAPSULATE_RMDIR) && !defined (DONT_ENCAPSULATE)
|
|
121 # undef rmdir
|
|
122 # define rmdir sys_rmdir
|
|
123 #endif
|
|
124 #if !defined (ENCAPSULATE_RMDIR) && defined (DONT_ENCAPSULATE)
|
|
125 # define sys_rmdir rmdir
|
|
126 #endif
|
|
127
|