aboutsummaryrefslogtreecommitdiff
path: root/toys/cp.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-04-14 22:30:41 -0500
committerRob Landley <rob@landley.net>2012-04-14 22:30:41 -0500
commiteb7ea22c7505f10928e104a9df39edc70a8f7036 (patch)
treebc928711030e2378298c8e5012c7c76b9b606661 /toys/cp.c
parent43e9d331c8055dff7e243bd19d2d06df826d6f38 (diff)
downloadtoybox-eb7ea22c7505f10928e104a9df39edc70a8f7036.tar.gz
Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Diffstat (limited to 'toys/cp.c')
-rw-r--r--toys/cp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/toys/cp.c b/toys/cp.c
index c3153e0a..a53d5fe0 100644
--- a/toys/cp.c
+++ b/toys/cp.c
@@ -10,8 +10,8 @@
USE_CP(NEWTOY(cp, "<2vslrR+rdpa+d+p+rHLPif", TOYFLAG_BIN))
config CP
- bool "cp"
- default y
+ bool "cp (broken by dirtree changes)"
+ default n
help
usage: cp -fiprdal SOURCE... DEST
@@ -128,8 +128,9 @@ void cp_file(char *src, char *dst, struct stat *srcst)
// Callback from dirtree_read() for each file/directory under a source dir.
-int cp_node(char *path, struct dirtree *node)
+int cp_node(struct dirtree *node)
{
+ char *path = dirtree_path(node, 0); // TODO: use openat() instead
char *s = path+strlen(path);
struct dirtree *n;
@@ -148,6 +149,7 @@ int cp_node(char *path, struct dirtree *node)
s = xmsprintf("%s/%s", TT.destname, s);
cp_file(path, s, &(node->st));
free(s);
+ free(path); // redo this whole darn function.
return 0;
}
@@ -209,7 +211,7 @@ void cp_main(void)
TT.keep_symlinks++;
strncpy(toybuf, src, sizeof(toybuf)-1);
toybuf[sizeof(toybuf)-1]=0;
- dirtree_read(toybuf, NULL, cp_node);
+ dirtree_read(toybuf, cp_node);
} else error_msg("Skipped dir '%s'", src);
} else cp_file(src, dst, &st);
if (TT.destisdir) free(dst);