Skip to content

Commit

Permalink
8286869: unify os::dir_is_empty across posix platforms
Browse files Browse the repository at this point in the history
Backport-of: 9ab29b6c07d0995127ba647b2eab1c694e236661
  • Loading branch information
MBaesken committed Jun 14, 2022
1 parent ad18525 commit 83d4426
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 57 deletions.
19 changes: 0 additions & 19 deletions src/hotspot/os/aix/os_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2573,25 +2573,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

Expand Down
19 changes: 0 additions & 19 deletions src/hotspot/os/bsd/os_bsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2302,25 +2302,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

Expand Down
19 changes: 0 additions & 19 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4926,25 +4926,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

Expand Down
19 changes: 19 additions & 0 deletions src/hotspot/os/posix/os_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,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;
Expand Down

1 comment on commit 83d4426

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.