< prev index next >

src/hotspot/os/linux/os_linux.cpp

Print this page




5361 
5362 bool os::message_box(const char* title, const char* message) {
5363   int i;
5364   fdStream err(defaultStream::error_fd());
5365   for (i = 0; i < 78; i++) err.print_raw("=");
5366   err.cr();
5367   err.print_raw_cr(title);
5368   for (i = 0; i < 78; i++) err.print_raw("-");
5369   err.cr();
5370   err.print_raw_cr(message);
5371   for (i = 0; i < 78; i++) err.print_raw("=");
5372   err.cr();
5373 
5374   char buf[16];
5375   // Prevent process from exiting upon "read error" without consuming all CPU
5376   while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); }
5377 
5378   return buf[0] == 'y' || buf[0] == 'Y';
5379 }
5380 
5381 int os::stat(const char *path, struct stat *sbuf) {
5382   char pathbuf[MAX_PATH];
5383   if (strlen(path) > MAX_PATH - 1) {
5384     errno = ENAMETOOLONG;
5385     return -1;
5386   }
5387   os::native_path(strcpy(pathbuf, path));
5388   return ::stat(pathbuf, sbuf);
5389 }
5390 
5391 // Is a (classpath) directory empty?
5392 bool os::dir_is_empty(const char* path) {
5393   DIR *dir = NULL;
5394   struct dirent *ptr;
5395 
5396   dir = opendir(path);
5397   if (dir == NULL) return true;
5398 
5399   // Scan the directory
5400   bool result = true;
5401   char buf[sizeof(struct dirent) + MAX_PATH];
5402   while (result && (ptr = ::readdir(dir)) != NULL) {
5403     if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
5404       result = false;
5405     }
5406   }
5407   closedir(dir);
5408   return result;
5409 }
5410 




5361 
5362 bool os::message_box(const char* title, const char* message) {
5363   int i;
5364   fdStream err(defaultStream::error_fd());
5365   for (i = 0; i < 78; i++) err.print_raw("=");
5366   err.cr();
5367   err.print_raw_cr(title);
5368   for (i = 0; i < 78; i++) err.print_raw("-");
5369   err.cr();
5370   err.print_raw_cr(message);
5371   for (i = 0; i < 78; i++) err.print_raw("=");
5372   err.cr();
5373 
5374   char buf[16];
5375   // Prevent process from exiting upon "read error" without consuming all CPU
5376   while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); }
5377 
5378   return buf[0] == 'y' || buf[0] == 'Y';
5379 }
5380 










5381 // Is a (classpath) directory empty?
5382 bool os::dir_is_empty(const char* path) {
5383   DIR *dir = NULL;
5384   struct dirent *ptr;
5385 
5386   dir = opendir(path);
5387   if (dir == NULL) return true;
5388 
5389   // Scan the directory
5390   bool result = true;
5391   char buf[sizeof(struct dirent) + MAX_PATH];
5392   while (result && (ptr = ::readdir(dir)) != NULL) {
5393     if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
5394       result = false;
5395     }
5396   }
5397   closedir(dir);
5398   return result;
5399 }
5400 


< prev index next >