sbase/cp.c

54 lines
846 B
C
Raw Normal View History

2012-01-30 22:41:33 +00:00
/* See LICENSE file for copyright and license details. */
#include <sys/stat.h>
2012-01-30 22:41:33 +00:00
#include "fs.h"
#include "util.h"
static void
usage(void)
{
eprintf("usage: %s [-afpv] [-R [-H | -L | -P]] source... dest\n", argv0);
}
2012-01-30 22:41:33 +00:00
int
main(int argc, char *argv[])
{
struct stat st;
2013-03-11 00:59:22 +00:00
ARGBEGIN {
2014-07-09 21:28:43 +00:00
case 'a':
/* implies -dpr */
cp_HLPflag = 'P';
cp_aflag = cp_pflag = cp_rflag = 1;
2014-07-09 21:28:43 +00:00
break;
case 'f':
cp_fflag = 1;
break;
2014-07-09 21:28:43 +00:00
case 'p':
cp_pflag = 1;
2014-07-09 21:28:43 +00:00
break;
case 'v':
cp_vflag = 1;
2014-05-05 13:58:14 +00:00
break;
2013-03-11 00:59:22 +00:00
case 'r':
case 'R':
cp_rflag = 1;
2013-03-11 00:59:22 +00:00
break;
case 'H':
case 'L':
case 'P':
cp_HLPflag = ARGC();
break;
2013-03-11 00:59:22 +00:00
default:
usage();
2013-03-11 00:59:22 +00:00
} ARGEND;
if (argc < 2)
usage();
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]);
enmasse(argc, argv, cp, cp_HLPflag);
return cp_status;
2012-01-30 22:41:33 +00:00
}