Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/branches/SMLNJ/src/runtime/c-libs/posix-filesys/readdir.c
ViewVC logotype

Annotation of /sml/branches/SMLNJ/src/runtime/c-libs/posix-filesys/readdir.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (view) (download) (as text)

1 : monnier 2 /* readdir.c
2 :     *
3 :     * COPYRIGHT (c) 1995 by AT&T Bell Laboratories.
4 :     */
5 :    
6 :     #include "ml-unixdep.h"
7 :     #include <sys/types.h>
8 :     #include <dirent.h>
9 :     #include <errno.h>
10 :     #include "ml-base.h"
11 :     #include "ml-values.h"
12 :     #include "tags.h"
13 :     #include "ml-objects.h"
14 :     #include "ml-c.h"
15 :     #include "cfun-proto-list.h"
16 :    
17 :     /* _ml_P_FileSys_readdir : object -> string
18 :     *
19 :     * Return the next filename from the directory stream.
20 :     */
21 :     ml_val_t _ml_P_FileSys_readdir (ml_state_t *msp, ml_val_t arg)
22 :     {
23 :     struct dirent *dirent;
24 :    
25 : monnier 8 while (TRUE) {
26 :     errno = 0;
27 :     dirent = readdir(PTR_MLtoC(DIR, arg));
28 :     if (dirent == NIL(struct dirent *)) {
29 :     if (errno != 0) /* Error occurred */
30 :     return RAISE_SYSERR(msp, -1);
31 :     else /* End of stream */
32 :     return ML_string0;
33 :     }
34 :     else {
35 :     char *cp = dirent->d_name;
36 :     if ((cp[0] == '.')
37 :     && ((cp[1] == '\0') || ((cp[1] == '.') && (cp[2] == '\0'))))
38 :     continue;
39 :     else
40 :     return ML_CString (msp, cp);
41 :     }
42 : monnier 2 }
43 :    
44 :     } /* end of _ml_P_FileSys_readdir */

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0