131 |
directory_files_internal_unwind (dh) |
directory_files_internal_unwind (dh) |
132 |
Lisp_Object dh; |
Lisp_Object dh; |
133 |
{ |
{ |
134 |
DIR *d = (DIR *) ((XINT (XCAR (dh)) << 16) + XINT (XCDR (dh))); |
DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer; |
135 |
closedir (d); |
closedir (d); |
136 |
return Qnil; |
return Qnil; |
137 |
} |
} |
155 |
int count = SPECPDL_INDEX (); |
int count = SPECPDL_INDEX (); |
156 |
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
157 |
DIRENTRY *dp; |
DIRENTRY *dp; |
|
int retry_p; |
|
158 |
|
|
159 |
/* Because of file name handlers, these functions might call |
/* Because of file name handlers, these functions might call |
160 |
Ffuncall, and cause a GC. */ |
Ffuncall, and cause a GC. */ |
188 |
/* Now *bufp is the compiled form of MATCH; don't call anything |
/* Now *bufp is the compiled form of MATCH; don't call anything |
189 |
which might compile a new regexp until we're done with the loop! */ |
which might compile a new regexp until we're done with the loop! */ |
190 |
|
|
|
/* Do this opendir after anything which might signal an error; if |
|
|
an error is signaled while the directory stream is open, we |
|
|
have to make sure it gets closed, and setting up an |
|
|
unwind_protect to do so would be a pain. */ |
|
|
retry: |
|
|
|
|
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)); |
196 |
file-attributes on filenames, both of which can throw, so we must |
file-attributes on filenames, both of which can throw, so we must |
197 |
do a proper unwind-protect. */ |
do a proper unwind-protect. */ |
198 |
record_unwind_protect (directory_files_internal_unwind, |
record_unwind_protect (directory_files_internal_unwind, |
199 |
Fcons (make_number (((unsigned long) d) >> 16), |
make_save_value (d, 0)); |
|
make_number (((unsigned long) d) & 0xffff))); |
|
200 |
|
|
201 |
directory_nbytes = SBYTES (directory); |
directory_nbytes = SBYTES (directory); |
202 |
re_match_object = Qt; |
re_match_object = Qt; |
214 |
errno = 0; |
errno = 0; |
215 |
dp = readdir (d); |
dp = readdir (d); |
216 |
|
|
217 |
|
if (dp == NULL && (0 |
218 |
#ifdef EAGAIN |
#ifdef EAGAIN |
219 |
if (dp == NULL && errno == EAGAIN) |
|| errno == EAGAIN |
220 |
continue; |
#endif |
221 |
|
#ifdef EINTR |
222 |
|
|| errno == EINTR |
223 |
#endif |
#endif |
224 |
|
)) |
225 |
|
{ QUIT; continue; } |
226 |
|
|
227 |
if (dp == NULL) |
if (dp == NULL) |
228 |
break; |
break; |
313 |
} |
} |
314 |
} |
} |
315 |
|
|
|
retry_p = 0; |
|
|
#ifdef EINTR |
|
|
retry_p |= errno == EINTR; |
|
|
#endif |
|
|
|
|
316 |
closedir (d); |
closedir (d); |
317 |
|
|
318 |
/* Discard the unwind protect. */ |
/* Discard the unwind protect. */ |
319 |
specpdl_ptr = specpdl + count; |
specpdl_ptr = specpdl + count; |
320 |
|
|
|
if (retry_p) |
|
|
{ |
|
|
list = Qnil; |
|
|
goto retry; |
|
|
} |
|
|
|
|
321 |
if (NILP (nosort)) |
if (NILP (nosort)) |
322 |
list = Fsort (Fnreverse (list), |
list = Fsort (Fnreverse (list), |
323 |
attrs ? Qfile_attributes_lessp : Qstring_lessp); |
attrs ? Qfile_attributes_lessp : Qstring_lessp); |
505 |
report_file_error ("Opening directory", Fcons (dirname, Qnil)); |
report_file_error ("Opening directory", Fcons (dirname, Qnil)); |
506 |
|
|
507 |
record_unwind_protect (directory_files_internal_unwind, |
record_unwind_protect (directory_files_internal_unwind, |
508 |
Fcons (make_number (((unsigned long) d) >> 16), |
make_save_value (d, 0)); |
|
make_number (((unsigned long) d) & 0xffff))); |
|
509 |
|
|
510 |
/* Loop reading blocks */ |
/* Loop reading blocks */ |
511 |
/* (att3b compiler bug requires do a null comparison this way) */ |
/* (att3b compiler bug requires do a null comparison this way) */ |
517 |
#ifdef VMS |
#ifdef VMS |
518 |
dp = (*readfunc) (d); |
dp = (*readfunc) (d); |
519 |
#else |
#else |
520 |
|
errno = 0; |
521 |
dp = readdir (d); |
dp = readdir (d); |
522 |
|
if (dp == NULL && (0 |
523 |
|
# ifdef EAGAIN |
524 |
|
|| errno == EAGAIN |
525 |
|
# endif |
526 |
|
# ifdef EINTR |
527 |
|
|| errno == EINTR |
528 |
|
# endif |
529 |
|
)) |
530 |
|
{ QUIT; continue; } |
531 |
#endif |
#endif |
532 |
|
|
533 |
if (!dp) break; |
if (!dp) break; |
534 |
|
|
535 |
len = NAMLEN (dp); |
len = NAMLEN (dp); |