static void f_scandir_cb(uv_work_t* req, int status) { f_t* f = (f_t*)req->loop->data; f_scandir_response_t response = req->data; f->stats.tasks_pending--; if (response->dents == NULL) { f->stats.errors++; } else { set_to_path(f->buf, response->path); size_t root_len = sl_get_length(f->buf); size_t off = 0; while (off < response->dents->length) { struct dirent* dent = (struct dirent*)(response->dents->buf + off); sl_set_length(f->buf, root_len); check_oom(sl_append_f(f->buf, dent->d_name, get_namlen(dent))); check_oom(sl_null_terminate_f(f->buf)); visit(f); switch (dent->d_type) { case DT_UNKNOWN: case DT_DIR: case DT_LNK: if (should_walk(f, f->buf->buf)) { f_scandir(req->loop, strdup(f->buf->buf)); } } off += dent->d_reclen; } sl_free(response->dents); } (void)status; free(req); free(response->path); free(response); }
bool TestExtFile::test_scandir() { VERIFY(!f_scandir("test").toArray().empty()); return Count(true); }