2 * Macintosh version of UNIX directory access package
3 * (opendir, readdir, closedir).
4 * Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
13 * Open a directory. This means calling PBOpenWD.
14 * The value returned is always the address of opened, or NULL.
15 * (I have as yet no use for multiple open directories; this could
16 * be implemented by allocating memory dynamically.)
30 if (opened
.nextfile
!= 0) {
32 return NULL
; /* A directory is already open. */
34 strncpy(ppath
+1, path
, ppath
[0]= strlen(path
));
35 pb
.d
.ioNamePtr
= (unsigned char *)ppath
;
40 err
= PBOpenWD((WDPBPtr
)&pb
, FALSE
);
44 err
= PBGetVInfo((ParmBlkPtr
)&pb
, FALSE
);
50 opened
.dirid
= pb
.d
.ioVRefNum
;
66 pb
.ioVRefNum
= dirp
->dirid
;
67 (void) PBCloseWD(&pb
, FALSE
);
74 * Read the next directory entry.
87 static struct dirent dir
;
90 pb
.d
.ioNamePtr
= (unsigned char *)dir
.d_name
;
91 pb
.d
.ioVRefNum
= dp
->dirid
;
92 pb
.d
.ioFDirIndex
= dp
->nextfile
++;
95 err
= PBGetCatInfo((CInfoPBPtr
)&pb
, FALSE
);
97 err
= PBGetFInfo((ParmBlkPtr
)&pb
, FALSE
);
102 (void) p2cstr((unsigned char *)dir
.d_name
);