natFile.cc (get_entry): Removed functions.

* natFile.cc (get_entry): Removed functions.
(performList): Call readdir or readdir_r if HAVE_READDIR_R defined.
Allocate enough storage for d_name if using readdir_r.

From-SVN: r42767
This commit is contained in:
Jeff Sturm 2001-06-01 04:04:10 +00:00 committed by Jeff Sturm
parent 195590126a
commit e2f3946854
2 changed files with 15 additions and 25 deletions

View file

@ -1,3 +1,9 @@
2001-05-31 Jeff Sturm <jsturm@one-point.com>
* natFile.cc (get_entry): Removed functions.
(performList): Call readdir or readdir_r if HAVE_READDIR_R defined.
Allocate enough storage for d_name if using readdir_r.
2001-05-31 Tom Tromey <tromey@redhat.com>
* java/io/natFileDescriptorPosix.cc (open): Allocate buffer to

View file

@ -130,29 +130,6 @@ java::io::File::isAbsolute (void)
return path->charAt(0) == '/';
}
#ifdef HAVE_DIRENT_H
#if defined(__JV_POSIX_THREADS__) && defined(HAVE_READDIR_R)
static struct dirent *
get_entry (DIR *dir, struct dirent *e)
{
struct dirent *r;
if (readdir_r (dir, e, &r) || r == NULL)
return NULL;
return e;
}
#else /* defined(__JV_POSIX_THREADS__) && defined(HAVE_READDIR_R) */
static struct dirent *
get_entry (DIR *dir, struct dirent *)
{
return readdir (dir);
}
#endif /* defined(__JV_POSIX_THREADS__) && defined(HAVE_READDIR_R) */
#endif /* HAVE_DIRENT_H */
jobjectArray
java::io::File::performList (java::io::FilenameFilter *filter,
java::io::FileFilter *fileFilter,
@ -168,9 +145,16 @@ java::io::File::performList (java::io::FilenameFilter *filter,
if (! dir)
return NULL;
java::util::ArrayList *list = new java::util::ArrayList ();
struct dirent *d, d2;
while ((d = get_entry (dir, &d2)) != NULL)
struct dirent *d;
#ifdef HAVE_READDIR_R
int name_max = pathconf (buf, _PC_NAME_MAX);
char dbuf[sizeof (struct dirent) + name_max + 1];
while (readdir_r (dir, (struct dirent *) dbuf, &d) == 0 && d != NULL)
#else /* HAVE_READDIR_R */
while ((d = readdir (dir)) != NULL)
#endif /* HAVE_READDIR_R */
{
// Omit "." and "..".
if (d->d_name[0] == '.'