130 |
return Qnil; |
return Qnil; |
131 |
} |
} |
132 |
|
|
133 |
/* Function shared by Fdirectory_files and Fdirectory_files_and_attributes. |
/* Function shared by Fdirectory_files and Fdirectory_files_and_attributes. |
134 |
When ATTRS is zero, return a list of directory filenames; when |
When ATTRS is zero, return a list of directory filenames; when |
135 |
non-zero, return a list of directory filenames and their attributes. */ |
non-zero, return a list of directory filenames and their attributes. */ |
136 |
|
|
187 |
have to make sure it gets closed, and setting up an |
have to make sure it gets closed, and setting up an |
188 |
unwind_protect to do so would be a pain. */ |
unwind_protect to do so would be a pain. */ |
189 |
retry: |
retry: |
190 |
|
|
191 |
d = opendir (SDATA (dirfilename)); |
d = opendir (SDATA (dirfilename)); |
192 |
if (d == NULL) |
if (d == NULL) |
193 |
report_file_error ("Opening directory", Fcons (directory, Qnil)); |
report_file_error ("Opening directory", Fcons (directory, Qnil)); |
219 |
if (dp == NULL && errno == EAGAIN) |
if (dp == NULL && errno == EAGAIN) |
220 |
continue; |
continue; |
221 |
#endif |
#endif |
222 |
|
|
223 |
if (dp == NULL) |
if (dp == NULL) |
224 |
break; |
break; |
225 |
|
|
233 |
len = NAMLEN (dp); |
len = NAMLEN (dp); |
234 |
name = finalname = make_unibyte_string (dp->d_name, len); |
name = finalname = make_unibyte_string (dp->d_name, len); |
235 |
GCPRO2 (finalname, name); |
GCPRO2 (finalname, name); |
236 |
|
|
237 |
/* Note: ENCODE_FILE can GC; it should protect its argument, |
/* Note: ENCODE_FILE can GC; it should protect its argument, |
238 |
though. */ |
though. */ |
239 |
name = DECODE_FILE (name); |
name = DECODE_FILE (name); |
261 |
fullname = make_uninit_multibyte_string (nbytes, nbytes); |
fullname = make_uninit_multibyte_string (nbytes, nbytes); |
262 |
bcopy (SDATA (directory), SDATA (fullname), |
bcopy (SDATA (directory), SDATA (fullname), |
263 |
directory_nbytes); |
directory_nbytes); |
264 |
|
|
265 |
if (needsep) |
if (needsep) |
266 |
SSET (fullname, directory_nbytes, DIRECTORY_SEP); |
SSET (fullname, directory_nbytes, DIRECTORY_SEP); |
267 |
|
|
268 |
bcopy (SDATA (name), |
bcopy (SDATA (name), |
269 |
SDATA (fullname) + directory_nbytes + needsep, |
SDATA (fullname) + directory_nbytes + needsep, |
270 |
len); |
len); |
271 |
|
|
272 |
nchars = chars_in_text (SDATA (fullname), nbytes); |
nchars = chars_in_text (SDATA (fullname), nbytes); |
273 |
|
|
274 |
/* Some bug somewhere. */ |
/* Some bug somewhere. */ |
275 |
if (nchars > nbytes) |
if (nchars > nbytes) |
276 |
abort (); |
abort (); |
277 |
|
|
278 |
STRING_SET_CHARS (fullname, nchars); |
STRING_SET_CHARS (fullname, nchars); |
279 |
if (nchars == nbytes) |
if (nchars == nbytes) |
280 |
STRING_SET_UNIBYTE (fullname); |
STRING_SET_UNIBYTE (fullname); |
281 |
|
|
282 |
finalname = fullname; |
finalname = fullname; |
283 |
} |
} |
284 |
else |
else |
328 |
if (NILP (nosort)) |
if (NILP (nosort)) |
329 |
list = Fsort (Fnreverse (list), |
list = Fsort (Fnreverse (list), |
330 |
attrs ? Qfile_attributes_lessp : Qstring_lessp); |
attrs ? Qfile_attributes_lessp : Qstring_lessp); |
331 |
|
|
332 |
RETURN_UNGCPRO (list); |
RETURN_UNGCPRO (list); |
333 |
} |
} |
334 |
|
|
686 |
/* This tests that the current file is an exact match |
/* This tests that the current file is an exact match |
687 |
but BESTMATCH is not (it is too long). */ |
but BESTMATCH is not (it is too long). */ |
688 |
if ((matchsize == len |
if ((matchsize == len |
689 |
&& matchsize + !!directoryp |
&& matchsize + !!directoryp |
690 |
< SCHARS (bestmatch)) |
< SCHARS (bestmatch)) |
691 |
|| |
|| |
692 |
/* If there is no exact match ignoring case, |
/* If there is no exact match ignoring case, |
699 |
either both or neither are exact. */ |
either both or neither are exact. */ |
700 |
(((matchsize == len) |
(((matchsize == len) |
701 |
== |
== |
702 |
(matchsize + !!directoryp |
(matchsize + !!directoryp |
703 |
== SCHARS (bestmatch))) |
== SCHARS (bestmatch))) |
704 |
&& !bcmp (p2, SDATA (encoded_file), SCHARS (encoded_file)) |
&& !bcmp (p2, SDATA (encoded_file), SCHARS (encoded_file)) |
705 |
&& bcmp (p1, SDATA (encoded_file), SCHARS (encoded_file)))) |
&& bcmp (p1, SDATA (encoded_file), SCHARS (encoded_file)))) |