Ejemplo n.º 1
0
int readdir_r(DIR* d, dirent* entry, dirent** result) {
  ErrnoRestorer errno_restorer;
  ErrnoRestorer_init(&errno_restorer);

  *result = NULL;
  errno = 0;

  ScopedPthreadMutexLocker locker;
  ScopedPthreadMutexLocker_init(&locker, &d->mutex_);

  dirent* next = __readdir_locked(d);
  if (errno != 0 && next == NULL) {
    int ret = errno;
    ScopedPthreadMutexLocker_fini(&locker);
    ErrnoRestorer_fini(&errno_restorer);
    return ret;
  }

  if (next != NULL) {
    memcpy(entry, next, next->d_reclen);
    *result = entry;
  }
  ScopedPthreadMutexLocker_fini(&locker);
  ErrnoRestorer_fini(&errno_restorer);
  return 0;
}
Ejemplo n.º 2
0
dirent* readdir(DIR* d) {
  ScopedPthreadMutexLocker locker;
  ScopedPthreadMutexLocker_init(&locker, &d->mutex_);
  dirent *ret = __readdir_locked(d);
  ScopedPthreadMutexLocker_fini(&locker);
  return ret;
}
Ejemplo n.º 3
0
int readdir_r(DIR* d, dirent* entry, dirent** result) {
  ErrnoRestorer errno_restorer;

  *result = NULL;
  errno = 0;

  ScopedPthreadMutexLocker locker(&d->mutex_);

  dirent* next = __readdir_locked(d);
  if (errno != 0 && next == NULL) {
    return errno;
  }

  if (next != NULL) {
    memcpy(entry, next, next->d_reclen);
    *result = entry;
  }
  return 0;
}
Ejemplo n.º 4
0
dirent* readdir(DIR* d) {
  ScopedPthreadMutexLocker locker(&d->mutex_);
  return __readdir_locked(d);
}