コード例 #1
0
bool f_hphp_recursiveiteratoriterator_valid(CObjRef obj) {
  RecursiveIteratorIterator *rii = get_recursiveiteratoriterator(obj);
  unsigned int size = rii->m_iterators.size();
  if (!size) return false;
  Object firstIt = rii->m_iterators[size-1].first;
  if (firstIt.is<RecursiveDirectoryIterator>()) {
    RecursiveDirectoryIterator* rdi =
      firstIt.getTyped<RecursiveDirectoryIterator>();
    bool valid = rdi->valid();
    if (valid) {
      if (rii->m_mode == LEAVES_ONLY ||
          rii->m_mode == CHILD_FIRST) {
        String pathName = rdi->getPathName();
        if (f_is_dir(pathName)) {
          if (rii->m_iterators[size-1].second > 0 &&
              rii->m_mode == CHILD_FIRST) {
            return true;
          }
          return false;
        }
      }
    }
    return valid;
  }
  throw NotImplementedException("this type of iterator");
}
コード例 #2
0
ファイル: ext_iterator.cpp プロジェクト: lisek/hiphop-php
bool f_hphp_recursiveiteratoriterator_valid(CObjRef obj) {
  RecursiveIteratorIterator *rii = get_recursiveiteratoriterator(obj);
  unsigned int size = rii->m_iterators.size();
  if (!size) return false;
  if (rii->m_iterators[size-1].first.is<RecursiveDirectoryIterator>()) {
    RecursiveDirectoryIterator *rdi =
      rii->m_iterators[size-1].first.getTyped<RecursiveDirectoryIterator>();
    bool valid = rdi->valid();
    if (valid) {
      if (rii->m_mode == HPHP::q_recursiveiteratoriterator_LEAVES_ONLY ||
          rii->m_mode == HPHP::q_recursiveiteratoriterator_CHILD_FIRST) {
        String pathName = rdi->getPathName();
        if (f_is_dir(pathName)) {
          if (rii->m_iterators[size-1].second > 0 &&
              rii->m_mode == HPHP::q_recursiveiteratoriterator_CHILD_FIRST) {
            return true;
          }
          return false;
        }
      }
    }
    return valid;
  }
  throw InvalidArgumentException("iterator", "unsupported type");
}