3472 3473 bool os::message_box(const char* title, const char* message) { 3474 int i; 3475 fdStream err(defaultStream::error_fd()); 3476 for (i = 0; i < 78; i++) err.print_raw("="); 3477 err.cr(); 3478 err.print_raw_cr(title); 3479 for (i = 0; i < 78; i++) err.print_raw("-"); 3480 err.cr(); 3481 err.print_raw_cr(message); 3482 for (i = 0; i < 78; i++) err.print_raw("="); 3483 err.cr(); 3484 3485 char buf[16]; 3486 // Prevent process from exiting upon "read error" without consuming all CPU 3487 while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); } 3488 3489 return buf[0] == 'y' || buf[0] == 'Y'; 3490 } 3491 3492 int os::stat(const char *path, struct stat *sbuf) { 3493 char pathbuf[MAX_PATH]; 3494 if (strlen(path) > MAX_PATH - 1) { 3495 errno = ENAMETOOLONG; 3496 return -1; 3497 } 3498 os::native_path(strcpy(pathbuf, path)); 3499 return ::stat(pathbuf, sbuf); 3500 } 3501 3502 static inline struct timespec get_mtime(const char* filename) { 3503 struct stat st; 3504 int ret = os::stat(filename, &st); 3505 assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno)); 3506 #ifdef __APPLE__ 3507 return st.st_mtimespec; 3508 #else 3509 return st.st_mtim; 3510 #endif 3511 } 3512 3513 int os::compare_file_modified_times(const char* file1, const char* file2) { 3514 struct timespec filetime1 = get_mtime(file1); 3515 struct timespec filetime2 = get_mtime(file2); 3516 int diff = filetime1.tv_sec - filetime2.tv_sec; 3517 if (diff == 0) { 3518 return filetime1.tv_nsec - filetime2.tv_nsec; 3519 } 3520 return diff; 3521 } | 3472 3473 bool os::message_box(const char* title, const char* message) { 3474 int i; 3475 fdStream err(defaultStream::error_fd()); 3476 for (i = 0; i < 78; i++) err.print_raw("="); 3477 err.cr(); 3478 err.print_raw_cr(title); 3479 for (i = 0; i < 78; i++) err.print_raw("-"); 3480 err.cr(); 3481 err.print_raw_cr(message); 3482 for (i = 0; i < 78; i++) err.print_raw("="); 3483 err.cr(); 3484 3485 char buf[16]; 3486 // Prevent process from exiting upon "read error" without consuming all CPU 3487 while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); } 3488 3489 return buf[0] == 'y' || buf[0] == 'Y'; 3490 } 3491 3492 static inline struct timespec get_mtime(const char* filename) { 3493 struct stat st; 3494 int ret = os::stat(filename, &st); 3495 assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno)); 3496 #ifdef __APPLE__ 3497 return st.st_mtimespec; 3498 #else 3499 return st.st_mtim; 3500 #endif 3501 } 3502 3503 int os::compare_file_modified_times(const char* file1, const char* file2) { 3504 struct timespec filetime1 = get_mtime(file1); 3505 struct timespec filetime2 = get_mtime(file2); 3506 int diff = filetime1.tv_sec - filetime2.tv_sec; 3507 if (diff == 0) { 3508 return filetime1.tv_nsec - filetime2.tv_nsec; 3509 } 3510 return diff; 3511 } |