1
0
mirror of git://git.suckless.org/sbase synced 2024-12-27 01:12:19 +00:00
sbase/cp.c

52 lines
799 B
C
Raw Normal View History

2012-01-30 22:41:33 +00:00
/* See LICENSE file for copyright and license details. */
#include <stdlib.h>
#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 [-adfpRrv] 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_aflag = cp_Pflag = cp_pflag = cp_rflag = 1;
2014-07-09 21:28:43 +00:00
break;
case 'P':
cp_Pflag = 1;
2014-07-09 21:28:43 +00:00
break;
case 'p':
cp_pflag = 1;
2014-07-09 21:28:43 +00:00
break;
2014-05-05 13:58:14 +00:00
case 'f':
cp_fflag = 1;
2014-05-05 13:58:14 +00:00
break;
case 'R':
2013-03-11 00:59:22 +00:00
case 'r':
cp_rflag = 1;
2013-03-11 00:59:22 +00:00
break;
case 'v':
cp_vflag = 1;
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]);
2013-03-11 00:59:22 +00:00
enmasse(argc, argv, cp);
return cp_status;
2012-01-30 22:41:33 +00:00
}