diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-10-05 02:44:18 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-10-05 02:44:18 +0000 |
commit | 2799793789d5b66c90efbd1a3eb56e0c1ec57f88 (patch) | |
tree | 9157197f502b6830af9cafe029fd3d47628a7ed6 /native/jni/native-lib/cpio.c | |
parent | 7516107c5abe26f7a4378017344eb9e449ebc28e (diff) | |
download | classpath-2799793789d5b66c90efbd1a3eb56e0c1ec57f88.tar.gz |
2006-10-05 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD-->generics for 2006/09/03-2006/10/04.
Diffstat (limited to 'native/jni/native-lib/cpio.c')
-rw-r--r-- | native/jni/native-lib/cpio.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/native/jni/native-lib/cpio.c b/native/jni/native-lib/cpio.c index eb544dc83..4d23b7a1f 100644 --- a/native/jni/native-lib/cpio.c +++ b/native/jni/native-lib/cpio.c @@ -448,14 +448,28 @@ int cpio_closeDir (void *handle) } -int cpio_readDir (void *handle, const char **filename) +int cpio_readDir (void *handle, char *filename) { +#ifdef HAVE_READDIR_R + struct dirent dent; +#endif /* HAVE_READDIR_R */ struct dirent *dBuf; +#ifdef HAVE_READDIR_R + readdir_r ((DIR *) handle, &dent, &dBuf); +#else dBuf = readdir((DIR *)handle); +#endif /* HAVE_READDIR_R */ + if (dBuf == NULL) - return errno; + { + /* Some OS's (OS X) return NULL on end-of-dir, but + don't set errno to anything. */ + if (errno == 0) + return ENOENT; /* Whatever. */ + return errno; + } - *filename = dBuf->d_name; + strncpy (filename, dBuf->d_name, FILENAME_MAX); return 0; } |