void handle_dir (char * path, int depth) { DIR * target; struct dirent * entry; char child[PATH_MAX]; execute(path, pred_head); if (depth >= options.maxdepth) return; target = opendir(path); if (!target) { fprintf(stderr, "error accessing %s\n", path); return; } while ((entry = readdir(target))) { dbprintf("read: %s\n", entry->d_name); if (!strcmp(entry->d_name, "..")) continue; if (!strcmp(entry->d_name, ".")) continue; if ((snprintf(child, PATH_MAX, "%s/%s", path, entry->d_name)) >= PATH_MAX) { fprintf(stderr, "filename %s too long\n", entry->d_name); continue; } switch (entry->d_type) { case DT_DIR: queue_dir(child, ++depth); break; case DT_REG: queue_file(child); break; case DT_LNK: queue_file(child); break; default: dbprintf("not handled: %s\n", child); break; } } closedir(target); return; }
void queue_head (CIRCLE_handle * handle) { dbprintf("start: %s\n", options.root); queue_dir(options.root, 0); }
static void queue_dir_item(ttk_menu_item *item) { queue_dir((const char *)item->data); }