3371 fdStream err(defaultStream::error_fd());
3372 for (i = 0; i < 78; i++) err.print_raw("=");
3373 err.cr();
3374 err.print_raw_cr(title);
3375 for (i = 0; i < 78; i++) err.print_raw("-");
3376 err.cr();
3377 err.print_raw_cr(message);
3378 for (i = 0; i < 78; i++) err.print_raw("=");
3379 err.cr();
3380
3381 char buf[16];
3382 // Prevent process from exiting upon "read error" without consuming all CPU
3383 while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); }
3384
3385 return buf[0] == 'y' || buf[0] == 'Y';
3386 }
3387
3388 static inline struct timespec get_mtime(const char* filename) {
3389 struct stat st;
3390 int ret = os::stat(filename, &st);
3391 assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno));
3392 #ifdef __APPLE__
3393 return st.st_mtimespec;
3394 #else
3395 return st.st_mtim;
3396 #endif
3397 }
3398
3399 int os::compare_file_modified_times(const char* file1, const char* file2) {
3400 struct timespec filetime1 = get_mtime(file1);
3401 struct timespec filetime2 = get_mtime(file2);
3402 int diff = filetime1.tv_sec - filetime2.tv_sec;
3403 if (diff == 0) {
3404 return filetime1.tv_nsec - filetime2.tv_nsec;
3405 }
3406 return diff;
3407 }
3408
3409 // Is a (classpath) directory empty?
3410 bool os::dir_is_empty(const char* path) {
3411 DIR *dir = NULL;
|
3371 fdStream err(defaultStream::error_fd());
3372 for (i = 0; i < 78; i++) err.print_raw("=");
3373 err.cr();
3374 err.print_raw_cr(title);
3375 for (i = 0; i < 78; i++) err.print_raw("-");
3376 err.cr();
3377 err.print_raw_cr(message);
3378 for (i = 0; i < 78; i++) err.print_raw("=");
3379 err.cr();
3380
3381 char buf[16];
3382 // Prevent process from exiting upon "read error" without consuming all CPU
3383 while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); }
3384
3385 return buf[0] == 'y' || buf[0] == 'Y';
3386 }
3387
3388 static inline struct timespec get_mtime(const char* filename) {
3389 struct stat st;
3390 int ret = os::stat(filename, &st);
3391 assert(ret == 0, "failed to stat() file '%s': %s", filename, os::strerror(errno));
3392 #ifdef __APPLE__
3393 return st.st_mtimespec;
3394 #else
3395 return st.st_mtim;
3396 #endif
3397 }
3398
3399 int os::compare_file_modified_times(const char* file1, const char* file2) {
3400 struct timespec filetime1 = get_mtime(file1);
3401 struct timespec filetime2 = get_mtime(file2);
3402 int diff = filetime1.tv_sec - filetime2.tv_sec;
3403 if (diff == 0) {
3404 return filetime1.tv_nsec - filetime2.tv_nsec;
3405 }
3406 return diff;
3407 }
3408
3409 // Is a (classpath) directory empty?
3410 bool os::dir_is_empty(const char* path) {
3411 DIR *dir = NULL;
|