comparison src/solaris/native/java/io/UnixFileSystem_md.c @ 10983:935758609767

Added tag jdk8u60-b28 for changeset 48e79820c798
author asaha
date Tue, 13 Oct 2015 08:18:35 -0700
parents ef0c60b93a17
children
comparison
equal deleted inserted replaced
10:fdaca6a8d739 11:b3b83ccb1bab
281 DIR *dir = NULL; 281 DIR *dir = NULL;
282 struct dirent64 *ptr; 282 struct dirent64 *ptr;
283 struct dirent64 *result; 283 struct dirent64 *result;
284 int len, maxlen; 284 int len, maxlen;
285 jobjectArray rv, old; 285 jobjectArray rv, old;
286 jclass str_class;
287
288 str_class = JNU_ClassString(env);
289 CHECK_NULL_RETURN(str_class, NULL);
286 290
287 WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { 291 WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
288 dir = opendir(path); 292 dir = opendir(path);
289 } END_PLATFORM_STRING(env, path); 293 } END_PLATFORM_STRING(env, path);
290 if (dir == NULL) return NULL; 294 if (dir == NULL) return NULL;
297 } 301 }
298 302
299 /* Allocate an initial String array */ 303 /* Allocate an initial String array */
300 len = 0; 304 len = 0;
301 maxlen = 16; 305 maxlen = 16;
302 rv = (*env)->NewObjectArray(env, maxlen, JNU_ClassString(env), NULL); 306 rv = (*env)->NewObjectArray(env, maxlen, str_class, NULL);
303 if (rv == NULL) goto error; 307 if (rv == NULL) goto error;
304 308
305 /* Scan the directory */ 309 /* Scan the directory */
306 while ((readdir64_r(dir, ptr, &result) == 0) && (result != NULL)) { 310 while ((readdir64_r(dir, ptr, &result) == 0) && (result != NULL)) {
307 jstring name; 311 jstring name;
308 if (!strcmp(ptr->d_name, ".") || !strcmp(ptr->d_name, "..")) 312 if (!strcmp(ptr->d_name, ".") || !strcmp(ptr->d_name, ".."))
309 continue; 313 continue;
310 if (len == maxlen) { 314 if (len == maxlen) {
311 old = rv; 315 old = rv;
312 rv = (*env)->NewObjectArray(env, maxlen <<= 1, 316 rv = (*env)->NewObjectArray(env, maxlen <<= 1, str_class, NULL);
313 JNU_ClassString(env), NULL);
314 if (rv == NULL) goto error; 317 if (rv == NULL) goto error;
315 if (JNU_CopyObjectArray(env, rv, old, len) < 0) goto error; 318 if (JNU_CopyObjectArray(env, rv, old, len) < 0) goto error;
316 (*env)->DeleteLocalRef(env, old); 319 (*env)->DeleteLocalRef(env, old);
317 } 320 }
318 #ifdef MACOSX 321 #ifdef MACOSX
327 closedir(dir); 330 closedir(dir);
328 free(ptr); 331 free(ptr);
329 332
330 /* Copy the final results into an appropriately-sized array */ 333 /* Copy the final results into an appropriately-sized array */
331 old = rv; 334 old = rv;
332 rv = (*env)->NewObjectArray(env, len, JNU_ClassString(env), NULL); 335 rv = (*env)->NewObjectArray(env, len, str_class, NULL);
333 if (rv == NULL) { 336 if (rv == NULL) {
334 return NULL; 337 return NULL;
335 } 338 }
336 if (JNU_CopyObjectArray(env, rv, old, len) < 0) { 339 if (JNU_CopyObjectArray(env, rv, old, len) < 0) {
337 return NULL; 340 return NULL;