51
51
bool CachedDirectory::open(const string &in_path)
53
DIR *dirp= opendir(in_path.c_str());
56
if ((dirp= opendir(in_path.c_str())) == NULL)
63
* The readdir_r() call on Solaris operates a bit differently from other
64
* systems in that the dirent structure must be allocated along with enough
65
* space to contain the filename (see man page for readdir_r on Solaris).
69
size= sizeof(dirent) + pathconf(in_path.c_str(), _PC_NAME_MAX);
65
* The readdir_r() call on Solaris operates a bit differently from other
66
* systems in that the dirent structure must be allocated along with enough
67
* space to contain the filename (see man page for readdir_r on Solaris).
68
* Instead of dynamically try to allocate this buffer, just set the max
69
* name for a path instead.
71
char space[sizeof(dirent) + PATH_MAX + 1];
74
dirent *entry= (dirent *) malloc(size);
86
retcode= readdir_r(dirp, entry, &result);
87
while ((retcode == 0) && (result != NULL))
89
entries.push_back(new Entry(entry->d_name));
90
retcode= readdir_r(dirp, entry, &result);
78
while ((retcode= readdir_r(dirp, &buffer.entry, &result)) == 0 &&
80
entries.push_back(new Entry(result->d_name));