From eb7ea22c7505f10928e104a9df39edc70a8f7036 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 14 Apr 2012 22:30:41 -0500 Subject: 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.) --- toys/cp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'toys/cp.c') 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); -- cgit v1.2.3