554 const char fileSep = *os::file_separator(); |
554 const char fileSep = *os::file_separator(); |
555 if (directory[directory_len - 1] != fileSep) dir_sep[0] = fileSep; |
555 if (directory[directory_len - 1] != fileSep) dir_sep[0] = fileSep; |
556 |
556 |
557 /* Scan the directory for jars/zips, appending them to path. */ |
557 /* Scan the directory for jars/zips, appending them to path. */ |
558 struct dirent *entry; |
558 struct dirent *entry; |
559 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal); |
559 while ((entry = os::readdir(dir)) != NULL) { |
560 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { |
|
561 const char* name = entry->d_name; |
560 const char* name = entry->d_name; |
562 const char* ext = name + strlen(name) - 4; |
561 const char* ext = name + strlen(name) - 4; |
563 bool isJarOrZip = ext > name && |
562 bool isJarOrZip = ext > name && |
564 (os::file_name_strcmp(ext, ".jar") == 0 || |
563 (os::file_name_strcmp(ext, ".jar") == 0 || |
565 os::file_name_strcmp(ext, ".zip") == 0); |
564 os::file_name_strcmp(ext, ".zip") == 0); |
569 jio_snprintf(jarpath, length, "%s%s%s", directory, dir_sep, name); |
568 jio_snprintf(jarpath, length, "%s%s%s", directory, dir_sep, name); |
570 path = add_to_path(path, jarpath, false); |
569 path = add_to_path(path, jarpath, false); |
571 FREE_C_HEAP_ARRAY(char, jarpath, mtInternal); |
570 FREE_C_HEAP_ARRAY(char, jarpath, mtInternal); |
572 } |
571 } |
573 } |
572 } |
574 FREE_C_HEAP_ARRAY(char, dbuf, mtInternal); |
|
575 os::closedir(dir); |
573 os::closedir(dir); |
576 return path; |
574 return path; |
577 } |
575 } |
578 |
576 |
579 // Parses a memory size specification string. |
577 // Parses a memory size specification string. |
3483 static bool has_jar_files(const char* directory) { |
3481 static bool has_jar_files(const char* directory) { |
3484 DIR* dir = os::opendir(directory); |
3482 DIR* dir = os::opendir(directory); |
3485 if (dir == NULL) return false; |
3483 if (dir == NULL) return false; |
3486 |
3484 |
3487 struct dirent *entry; |
3485 struct dirent *entry; |
3488 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal); |
|
3489 bool hasJarFile = false; |
3486 bool hasJarFile = false; |
3490 while (!hasJarFile && (entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { |
3487 while (!hasJarFile && (entry = os::readdir(dir)) != NULL) { |
3491 const char* name = entry->d_name; |
3488 const char* name = entry->d_name; |
3492 const char* ext = name + strlen(name) - 4; |
3489 const char* ext = name + strlen(name) - 4; |
3493 hasJarFile = ext > name && (os::file_name_strcmp(ext, ".jar") == 0); |
3490 hasJarFile = ext > name && (os::file_name_strcmp(ext, ".jar") == 0); |
3494 } |
3491 } |
3495 FREE_C_HEAP_ARRAY(char, dbuf, mtInternal); |
|
3496 os::closedir(dir); |
3492 os::closedir(dir); |
3497 return hasJarFile ; |
3493 return hasJarFile ; |
3498 } |
3494 } |
3499 |
3495 |
3500 // returns the number of directories in the given path containing JAR files |
3496 // returns the number of directories in the given path containing JAR files |
3572 // check if the default lib/ext directory has any non-JDK jar files; if so, error |
3568 // check if the default lib/ext directory has any non-JDK jar files; if so, error |
3573 DIR* dir = os::opendir(extDir); |
3569 DIR* dir = os::opendir(extDir); |
3574 if (dir != NULL) { |
3570 if (dir != NULL) { |
3575 int num_ext_jars = 0; |
3571 int num_ext_jars = 0; |
3576 struct dirent *entry; |
3572 struct dirent *entry; |
3577 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(extDir), mtInternal); |
3573 while ((entry = os::readdir(dir)) != NULL) { |
3578 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { |
|
3579 const char* name = entry->d_name; |
3574 const char* name = entry->d_name; |
3580 const char* ext = name + strlen(name) - 4; |
3575 const char* ext = name + strlen(name) - 4; |
3581 if (ext > name && (os::file_name_strcmp(ext, ".jar") == 0)) { |
3576 if (ext > name && (os::file_name_strcmp(ext, ".jar") == 0)) { |
3582 bool is_jdk_jar = false; |
3577 bool is_jdk_jar = false; |
3583 const char* jarfile = NULL; |
3578 const char* jarfile = NULL; |