2 * (c) The University of Glasgow 2002
4 * Directory Runtime Support
7 /* needed only for solaris2_HOST_OS */
10 // The following is required on Solaris to force the POSIX versions of
11 // the various _r functions instead of the Solaris versions.
12 #ifdef solaris2_HOST_OS
13 #define _POSIX_PTHREAD_SEMANTICS
18 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
24 * read an entry from the directory stream; opt for the
25 * re-entrant friendly way of doing this, if available.
28 __hscore_readdir( DIR *dirPtr, struct dirent **pDirEnt )
33 static unsigned int nm_max = (unsigned int)-1;
35 if (pDirEnt == NULL) {
38 if (nm_max == (unsigned int)-1) {
40 nm_max = NAME_MAX + 1;
42 nm_max = pathconf(".", _PC_NAME_MAX);
43 if (nm_max == -1) { nm_max = 255; }
47 p = (struct dirent*)malloc(sizeof(struct dirent) + nm_max);
48 if (p == NULL) return -1;
49 res = readdir_r(dirPtr, p, pDirEnt);
54 else if (*pDirEnt == NULL) {
61 if (pDirEnt == NULL) {
65 *pDirEnt = readdir(dirPtr);
66 if (*pDirEnt == NULL) {