aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/cp.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-03-07 16:02:47 -0600
committerRob Landley <rob@landley.net>2016-03-07 16:02:47 -0600
commit8d95074b7d034188af8542aaea0306d3670d71be (patch)
treef2cc98fa718becc2b6379dc7c724ea35f266cd6a /toys/posix/cp.c
parent2a26ba451a605c185242de50e1d91eeac0a2430e (diff)
downloadtoybox-8d95074b7d034188af8542aaea0306d3670d71be.tar.gz
Cleanup pass on the dirtree infrastructure, in preparation for making rm -r
handle infinite depth. Fix docs, tweak dirtree_handle_callback() semantics, remove dirtree_start() and don't export dirtree_handle_callback(), instead offer dirtree_flagread(). (dirtree_read() is a wrapper around dirtree_flagread passing 0 for flags.)
Diffstat (limited to 'toys/posix/cp.c')
-rw-r--r--toys/posix/cp.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index cb7e6e3b..0e6a2efa 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -430,12 +430,11 @@ void cp_main(void)
if (rc) rc = rename(src, TT.destname);
}
- // Skip nonexistent sources
+ // Copy if we didn't mv, skipping nonexistent sources
if (rc) {
- if (errno!=EXDEV ||
- !(new = dirtree_start(src, toys.optflags&(FLAG_H|FLAG_L))))
+ if (errno!=EXDEV || dirtree_flagread(src, DIRTREE_SHUTUP+
+ DIRTREE_SYMFOLLOW*!!(toys.optflags&(FLAG_H|FLAG_L)), TT.callback))
perror_msg("bad '%s'", src);
- else dirtree_handle_callback(new, TT.callback);
}
if (destdir) free(TT.destname);
}