< prev index next >

src/hotspot/os/solaris/os_solaris.cpp

Print this page
rev 50955 : [mq]: readdir


4289   }
4290 }
4291 
4292 // Mark the polling page as readable
4293 void os::make_polling_page_readable(void) {
4294   if (mprotect((char *)_polling_page, page_size, PROT_READ) != 0) {
4295     fatal("Could not enable polling page");
4296   }
4297 }
4298 
4299 // Is a (classpath) directory empty?
4300 bool os::dir_is_empty(const char* path) {
4301   DIR *dir = NULL;
4302   struct dirent *ptr;
4303 
4304   dir = opendir(path);
4305   if (dir == NULL) return true;
4306 
4307   // Scan the directory
4308   bool result = true;
4309   char buf[sizeof(struct dirent) + MAX_PATH];
4310   struct dirent *dbuf = (struct dirent *) buf;
4311   while (result && (ptr = readdir(dir, dbuf)) != NULL) {
4312     if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
4313       result = false;
4314     }
4315   }
4316   closedir(dir);
4317   return result;
4318 }
4319 
4320 // This code originates from JDK's sysOpen and open64_w
4321 // from src/solaris/hpi/src/system_md.c
4322 
4323 int os::open(const char *path, int oflag, int mode) {
4324   if (strlen(path) > MAX_PATH - 1) {
4325     errno = ENAMETOOLONG;
4326     return -1;
4327   }
4328   int fd;
4329 
4330   fd = ::open64(path, oflag, mode);
4331   if (fd == -1) return -1;




4289   }
4290 }
4291 
4292 // Mark the polling page as readable
4293 void os::make_polling_page_readable(void) {
4294   if (mprotect((char *)_polling_page, page_size, PROT_READ) != 0) {
4295     fatal("Could not enable polling page");
4296   }
4297 }
4298 
4299 // Is a (classpath) directory empty?
4300 bool os::dir_is_empty(const char* path) {
4301   DIR *dir = NULL;
4302   struct dirent *ptr;
4303 
4304   dir = opendir(path);
4305   if (dir == NULL) return true;
4306 
4307   // Scan the directory
4308   bool result = true;
4309   while (result && (ptr = readdir(dir)) != NULL) {


4310     if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
4311       result = false;
4312     }
4313   }
4314   closedir(dir);
4315   return result;
4316 }
4317 
4318 // This code originates from JDK's sysOpen and open64_w
4319 // from src/solaris/hpi/src/system_md.c
4320 
4321 int os::open(const char *path, int oflag, int mode) {
4322   if (strlen(path) > MAX_PATH - 1) {
4323     errno = ENAMETOOLONG;
4324     return -1;
4325   }
4326   int fd;
4327 
4328   fd = ::open64(path, oflag, mode);
4329   if (fd == -1) return -1;


< prev index next >