8286869: unify os::dir_is_empty across posix platforms

Reviewed-by: iklam, dholmes
This commit is contained in:
Matthias Baesken 2022-05-18 16:45:14 +00:00
parent ee45a0ac63
commit 9ab29b6c07
4 changed files with 19 additions and 57 deletions

View File

@ -2492,25 +2492,6 @@ bool os::message_box(const char* title, const char* message) {
return buf[0] == 'y' || buf[0] == 'Y';
}
// Is a (classpath) directory empty?
bool os::dir_is_empty(const char* path) {
DIR *dir = NULL;
struct dirent *ptr;
dir = opendir(path);
if (dir == NULL) return true;
/* Scan the directory */
bool result = true;
while (result && (ptr = readdir(dir)) != NULL) {
if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
result = false;
}
}
closedir(dir);
return result;
}
// This code originates from JDK's sysOpen and open64_w
// from src/solaris/hpi/src/system_md.c

View File

@ -2207,25 +2207,6 @@ int os::compare_file_modified_times(const char* file1, const char* file2) {
return diff;
}
// Is a (classpath) directory empty?
bool os::dir_is_empty(const char* path) {
DIR *dir = NULL;
struct dirent *ptr;
dir = opendir(path);
if (dir == NULL) return true;
// Scan the directory
bool result = true;
while (result && (ptr = readdir(dir)) != NULL) {
if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
result = false;
}
}
closedir(dir);
return result;
}
// This code originates from JDK's sysOpen and open64_w
// from src/solaris/hpi/src/system_md.c

View File

@ -4832,25 +4832,6 @@ bool os::message_box(const char* title, const char* message) {
return buf[0] == 'y' || buf[0] == 'Y';
}
// Is a (classpath) directory empty?
bool os::dir_is_empty(const char* path) {
DIR *dir = NULL;
struct dirent *ptr;
dir = opendir(path);
if (dir == NULL) return true;
// Scan the directory
bool result = true;
while (result && (ptr = readdir(dir)) != NULL) {
if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
result = false;
}
}
closedir(dir);
return result;
}
// This code originates from JDK's sysOpen and open64_w
// from src/solaris/hpi/src/system_md.c

View File

@ -247,6 +247,25 @@ int os::create_file_for_heap(const char* dir) {
return fd;
}
// Is a (classpath) directory empty?
bool os::dir_is_empty(const char* path) {
DIR *dir = NULL;
struct dirent *ptr;
dir = ::opendir(path);
if (dir == NULL) return true;
// Scan the directory
bool result = true;
while (result && (ptr = ::readdir(dir)) != NULL) {
if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
result = false;
}
}
::closedir(dir);
return result;
}
static char* reserve_mmapped_memory(size_t bytes, char* requested_addr) {
char * addr;
int flags = MAP_PRIVATE NOT_AIX( | MAP_NORESERVE ) | MAP_ANONYMOUS;