Mercurial > hg > toybox
diff toys/cp.c @ 565:44abf4d901f3
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.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 14 Apr 2012 22:30:41 -0500 |
parents | 878b94b32866 |
children | 9802b2afbce8 |
line wrap: on
line diff
--- a/toys/cp.c Sat Apr 14 21:43:24 2012 -0500 +++ b/toys/cp.c Sat Apr 14 22:30:41 2012 -0500 @@ -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 @@ // 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 @@ 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 @@ 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);