sbase/cp.c

51 lines
821 B
C
Raw Normal View History

2012-01-30 22:41:33 +00:00
/* See LICENSE file for copyright and license details. */
#include <stdbool.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "fs.h"
#include "util.h"
static void
usage(void)
{
2014-07-09 21:28:43 +00:00
eprintf("usage: %s [-adfpRr] 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':
cp_aflag = true; /* implies -dpr */
cp_dflag = true;
cp_pflag = true;
cp_rflag = true;
break;
case 'd':
cp_dflag = true;
break;
case 'p':
cp_pflag = true;
break;
2014-05-05 13:58:14 +00:00
case 'f':
cp_fflag = true;
break;
case 'R':
2013-03-11 00:59:22 +00:00
case 'r':
cp_rflag = true;
break;
default:
usage();
2013-03-11 00:59:22 +00:00
} ARGEND;
if (argc < 2)
usage();
2013-03-11 00:59:22 +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);
2012-01-30 22:41:33 +00:00
return EXIT_SUCCESS;
}