aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-02-20 01:47:56 -0600
committerRob Landley <rob@landley.net>2008-02-20 01:47:56 -0600
commit6e6871c3b253d26ab31e328dd5f9b6996b75688c (patch)
tree9b6e4916f33fee279b32d2ea787c23ebfd00c2f3 /lib
parent61190a3637a73c73eb6d936f446b2a14f3c9562c (diff)
downloadtoybox-6e6871c3b253d26ab31e328dd5f9b6996b75688c.tar.gz
Add first pass at cp, totally untested, unlikely to work yet. :)
Diffstat (limited to 'lib')
-rw-r--r--lib/dirtree.c5
-rw-r--r--lib/lib.h2
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/dirtree.c b/lib/dirtree.c
index 71f64493..a2647ee2 100644
--- a/lib/dirtree.c
+++ b/lib/dirtree.c
@@ -50,7 +50,7 @@ struct dirtree *dirtree_add_node(char *path)
// structures after use, and return NULL.
struct dirtree *dirtree_read(char *path, struct dirtree *parent,
- int (*callback)(struct dirtree *node))
+ int (*callback)(struct dirtree *node, int after))
{
struct dirtree *dt = NULL, **ddt = &dt;
DIR *dir;
@@ -72,9 +72,10 @@ struct dirtree *dirtree_read(char *path, struct dirtree *parent,
*ddt = dirtree_add_node(path);
if (!*ddt) continue;
(*ddt)->parent = parent;
- if (callback) callback(*ddt);
+ if (callback) callback(*ddt, 0);
if (entry->d_type == DT_DIR)
(*ddt)->child = dirtree_read(path, *ddt, callback);
+ if (callback) callback(*ddt, 1);
if (callback) free(*ddt);
else ddt = &((*ddt)->next);
path[len]=0;
diff --git a/lib/lib.h b/lib/lib.h
index ee073e0c..21ef98ed 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -41,7 +41,7 @@ struct dirtree {
struct dirtree *dirtree_add_node(char *path);
struct dirtree *dirtree_read(char *path, struct dirtree *parent,
- int (*callback)(struct dirtree *node));
+ int (*callback)(struct dirtree *node, int after));
// lib.c
void xstrcpy(char *dest, char *src, size_t size);