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