#include "toys.h"
+// NOTE: This uses toybuf. Possibly it shouldn't do that.
+
// Create a dirtree node from a path.
struct dirtree *dirtree_add_node(char *path)
}
dt = xzalloc(sizeof(struct dirtree)+strlen(name)+1);
- xstat(path, &(dt->st));
+ if (lstat(path, &(dt->st))) {
+ error_msg("Skipped '%s'",name);
+ free(dt);
+ return 0;
+ }
strcpy(dt->name, name);
return dt;
snprintf(path+len, sizeof(toybuf)-len, "/%s", entry->d_name);
*ddt = dirtree_add_node(path);
+ if (!*ddt) continue;
(*ddt)->parent = parent;
if (callback) callback(*ddt);
if (entry->d_type == DT_DIR)