Porting to OS/2: Case #12 readdir_r() and struct dirent
readdir() and readdir_r() are used to read directory entries. And readdir_r() is a re-entrant version of readdir(). Because of this, readdir_r() requires additional arguments. Let's see prototypes of them. struct dirent *readdir(DIR * dirp ); int readdir_r(DIR * dirp , struct dirent * entry , struct dirent ** result ); As you see, readdir_r() requires [struct dirent *entry]. And entry should be large enough for a dirent. For this, the recommended portable codes are like this. Colored By Color Scripter ™ 1 2 3 4 5 name_max = pathconf(dirpath, _PC_NAME_MAX); if (name_max == -1) /* Limit not defined, or error */ name_max = 255; /* Take a guess */ len = offsetof( struct dirent, d_name) + name_max + 1; entryp...