comparison src/dired.c @ 14067:afef050ad4e6

(Fdirectory_files, Ffile_name_completion, Ffile_name_all_completions, Ffile_name_all_versions): Harmonize arguments with documentation.
author Erik Naggum <erik@naggum.no>
date Tue, 09 Jan 1996 00:31:07 +0000
parents 621a575db6f7
children ee40177f6c68
comparison
equal deleted inserted replaced
14066:2c6db67067ac 14067:afef050ad4e6
107 There are three optional arguments:\n\ 107 There are three optional arguments:\n\
108 If FULL is non-nil, absolute pathnames of the files are returned.\n\ 108 If FULL is non-nil, absolute pathnames of the files are returned.\n\
109 If MATCH is non-nil, only pathnames containing that regexp are returned.\n\ 109 If MATCH is non-nil, only pathnames containing that regexp are returned.\n\
110 If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\ 110 If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\
111 NOSORT is useful if you plan to sort the result yourself.") 111 NOSORT is useful if you plan to sort the result yourself.")
112 (dirname, full, match, nosort) 112 (directory, full, match, nosort)
113 Lisp_Object dirname, full, match, nosort; 113 Lisp_Object directory, full, match, nosort;
114 { 114 {
115 DIR *d; 115 DIR *d;
116 int dirnamelen; 116 int dirnamelen;
117 Lisp_Object list, name, dirfilename; 117 Lisp_Object list, name, dirfilename;
118 Lisp_Object handler; 118 Lisp_Object handler;
119 struct re_pattern_buffer *bufp; 119 struct re_pattern_buffer *bufp;
120 120
121 /* If the file name has special constructs in it, 121 /* If the file name has special constructs in it,
122 call the corresponding file handler. */ 122 call the corresponding file handler. */
123 handler = Ffind_file_name_handler (dirname, Qdirectory_files); 123 handler = Ffind_file_name_handler (directory, Qdirectory_files);
124 if (!NILP (handler)) 124 if (!NILP (handler))
125 { 125 {
126 Lisp_Object args[6]; 126 Lisp_Object args[6];
127 127
128 args[0] = handler; 128 args[0] = handler;
129 args[1] = Qdirectory_files; 129 args[1] = Qdirectory_files;
130 args[2] = dirname; 130 args[2] = directory;
131 args[3] = full; 131 args[3] = full;
132 args[4] = match; 132 args[4] = match;
133 args[5] = nosort; 133 args[5] = nosort;
134 return Ffuncall (6, args); 134 return Ffuncall (6, args);
135 } 135 }
138 struct gcpro gcpro1, gcpro2; 138 struct gcpro gcpro1, gcpro2;
139 139
140 /* Because of file name handlers, these functions might call 140 /* Because of file name handlers, these functions might call
141 Ffuncall, and cause a GC. */ 141 Ffuncall, and cause a GC. */
142 GCPRO1 (match); 142 GCPRO1 (match);
143 dirname = Fexpand_file_name (dirname, Qnil); 143 directory = Fexpand_file_name (directory, Qnil);
144 UNGCPRO; 144 UNGCPRO;
145 GCPRO2 (match, dirname); 145 GCPRO2 (match, directory);
146 dirfilename = Fdirectory_file_name (dirname); 146 dirfilename = Fdirectory_file_name (directory);
147 UNGCPRO; 147 UNGCPRO;
148 } 148 }
149 149
150 if (!NILP (match)) 150 if (!NILP (match))
151 { 151 {
169 an error is signaled while the directory stream is open, we 169 an error is signaled while the directory stream is open, we
170 have to make sure it gets closed, and setting up an 170 have to make sure it gets closed, and setting up an
171 unwind_protect to do so would be a pain. */ 171 unwind_protect to do so would be a pain. */
172 d = opendir (XSTRING (dirfilename)->data); 172 d = opendir (XSTRING (dirfilename)->data);
173 if (! d) 173 if (! d)
174 report_file_error ("Opening directory", Fcons (dirname, Qnil)); 174 report_file_error ("Opening directory", Fcons (directory, Qnil));
175 175
176 list = Qnil; 176 list = Qnil;
177 dirnamelen = XSTRING (dirname)->size; 177 dirnamelen = XSTRING (directory)->size;
178 178
179 /* Loop reading blocks */ 179 /* Loop reading blocks */
180 while (1) 180 while (1)
181 { 181 {
182 DIRENTRY *dp = readdir (d); 182 DIRENTRY *dp = readdir (d);
196 int needsep = 0; 196 int needsep = 0;
197 197
198 /* Decide whether we need to add a directory separator. */ 198 /* Decide whether we need to add a directory separator. */
199 #ifndef VMS 199 #ifndef VMS
200 if (dirnamelen == 0 200 if (dirnamelen == 0
201 || !IS_ANY_SEP (XSTRING (dirname)->data[dirnamelen - 1])) 201 || !IS_ANY_SEP (XSTRING (directory)->data[dirnamelen - 1]))
202 needsep = 1; 202 needsep = 1;
203 #endif /* VMS */ 203 #endif /* VMS */
204 204
205 name = make_uninit_string (total + needsep); 205 name = make_uninit_string (total + needsep);
206 bcopy (XSTRING (dirname)->data, XSTRING (name)->data, 206 bcopy (XSTRING (directory)->data, XSTRING (name)->data,
207 dirnamelen); 207 dirnamelen);
208 if (needsep) 208 if (needsep)
209 XSTRING (name)->data[afterdirindex++] = DIRECTORY_SEP; 209 XSTRING (name)->data[afterdirindex++] = DIRECTORY_SEP;
210 bcopy (dp->d_name, 210 bcopy (dp->d_name,
211 XSTRING (name)->data + afterdirindex, len); 211 XSTRING (name)->data + afterdirindex, len);
224 224
225 Lisp_Object file_name_completion (); 225 Lisp_Object file_name_completion ();
226 226
227 DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion, 227 DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion,
228 2, 2, 0, 228 2, 2, 0,
229 "Complete file name FILE in directory DIR.\n\ 229 "Complete file name FILE in directory DIRECTORY.\n\
230 Returns the longest string\n\ 230 Returns the longest string\n\
231 common to all filenames in DIR that start with FILE.\n\ 231 common to all filenames in DIRECTORY that start with FILE.\n\
232 If there is only one and FILE matches it exactly, returns t.\n\ 232 If there is only one and FILE matches it exactly, returns t.\n\
233 Returns nil if DIR contains no name starting with FILE.") 233 Returns nil if DIR contains no name starting with FILE.")
234 (file, dirname) 234 (file, directory)
235 Lisp_Object file, dirname; 235 Lisp_Object file, directory;
236 { 236 {
237 Lisp_Object handler; 237 Lisp_Object handler;
238 238
239 /* If the directory name has special constructs in it, 239 /* If the directory name has special constructs in it,
240 call the corresponding file handler. */ 240 call the corresponding file handler. */
241 handler = Ffind_file_name_handler (dirname, Qfile_name_completion); 241 handler = Ffind_file_name_handler (directory, Qfile_name_completion);
242 if (!NILP (handler)) 242 if (!NILP (handler))
243 return call3 (handler, Qfile_name_completion, file, dirname); 243 return call3 (handler, Qfile_name_completion, file, directory);
244 244
245 /* If the file name has special constructs in it, 245 /* If the file name has special constructs in it,
246 call the corresponding file handler. */ 246 call the corresponding file handler. */
247 handler = Ffind_file_name_handler (file, Qfile_name_completion); 247 handler = Ffind_file_name_handler (file, Qfile_name_completion);
248 if (!NILP (handler)) 248 if (!NILP (handler))
249 return call3 (handler, Qfile_name_completion, file, dirname); 249 return call3 (handler, Qfile_name_completion, file, directory);
250 250
251 return file_name_completion (file, dirname, 0, 0); 251 return file_name_completion (file, directory, 0, 0);
252 } 252 }
253 253
254 DEFUN ("file-name-all-completions", Ffile_name_all_completions, 254 DEFUN ("file-name-all-completions", Ffile_name_all_completions,
255 Sfile_name_all_completions, 2, 2, 0, 255 Sfile_name_all_completions, 2, 2, 0,
256 "Return a list of all completions of file name FILE in directory DIR.\n\ 256 "Return a list of all completions of file name FILE in directory DIRECTORY.\n\
257 These are all file names in directory DIR which begin with FILE.") 257 These are all file names in directory DIRECTORY which begin with FILE.")
258 (file, dirname) 258 (file, directory)
259 Lisp_Object file, dirname; 259 Lisp_Object file, directory;
260 { 260 {
261 Lisp_Object handler; 261 Lisp_Object handler;
262 262
263 /* If the directory name has special constructs in it, 263 /* If the directory name has special constructs in it,
264 call the corresponding file handler. */ 264 call the corresponding file handler. */
265 handler = Ffind_file_name_handler (dirname, Qfile_name_all_completions); 265 handler = Ffind_file_name_handler (directory, Qfile_name_all_completions);
266 if (!NILP (handler)) 266 if (!NILP (handler))
267 return call3 (handler, Qfile_name_all_completions, file, dirname); 267 return call3 (handler, Qfile_name_all_completions, file, directory);
268 268
269 /* If the file name has special constructs in it, 269 /* If the file name has special constructs in it,
270 call the corresponding file handler. */ 270 call the corresponding file handler. */
271 handler = Ffind_file_name_handler (file, Qfile_name_all_completions); 271 handler = Ffind_file_name_handler (file, Qfile_name_all_completions);
272 if (!NILP (handler)) 272 if (!NILP (handler))
273 return call3 (handler, Qfile_name_all_completions, file, dirname); 273 return call3 (handler, Qfile_name_all_completions, file, directory);
274 274
275 return file_name_completion (file, dirname, 1, 0); 275 return file_name_completion (file, directory, 1, 0);
276 } 276 }
277 277
278 Lisp_Object 278 Lisp_Object
279 file_name_completion (file, dirname, all_flag, ver_flag) 279 file_name_completion (file, dirname, all_flag, ver_flag)
280 Lisp_Object file, dirname; 280 Lisp_Object file, dirname;
534 534
535 #ifdef VMS 535 #ifdef VMS
536 536
537 DEFUN ("file-name-all-versions", Ffile_name_all_versions, 537 DEFUN ("file-name-all-versions", Ffile_name_all_versions,
538 Sfile_name_all_versions, 2, 2, 0, 538 Sfile_name_all_versions, 2, 2, 0,
539 "Return a list of all versions of file name FILE in directory DIR.") 539 "Return a list of all versions of file name FILE in directory DIRECTORY.")
540 (file, dirname) 540 (file, directory)
541 Lisp_Object file, dirname; 541 Lisp_Object file, directory;
542 { 542 {
543 return file_name_completion (file, dirname, 1, 1); 543 return file_name_completion (file, directory, 1, 1);
544 } 544 }
545 545
546 DEFUN ("file-version-limit", Ffile_version_limit, Sfile_version_limit, 1, 1, 0, 546 DEFUN ("file-version-limit", Ffile_version_limit, Sfile_version_limit, 1, 1, 0,
547 "Return the maximum number of versions allowed for FILE.\n\ 547 "Return the maximum number of versions allowed for FILE.\n\
548 Returns nil if the file cannot be opened or if there is no version limit.") 548 Returns nil if the file cannot be opened or if there is no version limit.")