2012-01-30 22:41:33 +00:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/stat.h>
|
2014-11-13 17:29:30 +00:00
|
|
|
|
2012-01-30 22:41:33 +00:00
|
|
|
#include "fs.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
2013-08-31 22:04:49 +00:00
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
2014-07-10 20:30:30 +00:00
|
|
|
eprintf("usage: %s [-adfpRrv] source... dest\n", argv0);
|
2013-08-31 22:04:49 +00:00
|
|
|
}
|
|
|
|
|
2012-01-30 22:41:33 +00:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct stat st;
|
2013-07-20 05:27:42 +00:00
|
|
|
|
2013-03-11 00:59:22 +00:00
|
|
|
ARGBEGIN {
|
2014-07-09 21:28:43 +00:00
|
|
|
case 'a':
|
2014-11-13 20:24:47 +00:00
|
|
|
/* implies -dpr */
|
|
|
|
cp_aflag = cp_dflag = cp_pflag = cp_rflag = 1;
|
2014-07-09 21:28:43 +00:00
|
|
|
break;
|
|
|
|
case 'd':
|
2014-11-13 20:24:47 +00:00
|
|
|
cp_dflag = 1;
|
2014-07-09 21:28:43 +00:00
|
|
|
break;
|
|
|
|
case 'p':
|
2014-11-13 20:24:47 +00:00
|
|
|
cp_pflag = 1;
|
2014-07-09 21:28:43 +00:00
|
|
|
break;
|
2014-05-05 13:58:14 +00:00
|
|
|
case 'f':
|
2014-11-13 20:24:47 +00:00
|
|
|
cp_fflag = 1;
|
2014-05-05 13:58:14 +00:00
|
|
|
break;
|
2013-12-12 13:27:49 +00:00
|
|
|
case 'R':
|
2013-03-11 00:59:22 +00:00
|
|
|
case 'r':
|
2014-11-13 20:24:47 +00:00
|
|
|
cp_rflag = 1;
|
2013-03-11 00:59:22 +00:00
|
|
|
break;
|
2014-07-10 20:30:30 +00:00
|
|
|
case 'v':
|
2014-11-13 20:24:47 +00:00
|
|
|
cp_vflag = 1;
|
2014-07-10 20:30:30 +00:00
|
|
|
break;
|
2013-03-11 00:59:22 +00:00
|
|
|
default:
|
2013-12-12 13:29:30 +00:00
|
|
|
usage();
|
2013-03-11 00:59:22 +00:00
|
|
|
} ARGEND;
|
2013-07-20 05:27:42 +00:00
|
|
|
|
2013-08-31 22:04:49 +00:00
|
|
|
if (argc < 2)
|
|
|
|
usage();
|
|
|
|
|
2014-11-13 17:29:30 +00:00
|
|
|
if (argc > 2 && !(stat(argv[argc-1], &st) == 0 && S_ISDIR(st.st_mode)))
|
2012-01-30 22:41:33 +00:00
|
|
|
eprintf("%s: not a directory\n", argv[argc-1]);
|
2013-03-11 00:59:22 +00:00
|
|
|
enmasse(argc, argv, cp);
|
2014-07-21 16:27:20 +00:00
|
|
|
return cp_status;
|
2012-01-30 22:41:33 +00:00
|
|
|
}
|