morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base.git
Log | Files | Refs

cp.c (799B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdlib.h>
      3 #include <sys/stat.h>
      4 
      5 #include "fs.h"
      6 #include "util.h"
      7 
      8 static void
      9 usage(void)
     10 {
     11 	eprintf("usage: %s [-adfpRrv] source... dest\n", argv0);
     12 }
     13 
     14 int
     15 main(int argc, char *argv[])
     16 {
     17 	struct stat st;
     18 
     19 	ARGBEGIN {
     20 	case 'a':
     21 		/* implies -dpr */
     22 		cp_aflag = cp_Pflag = cp_pflag = cp_rflag = 1;
     23 		break;
     24 	case 'P':
     25 		cp_Pflag = 1;
     26 		break;
     27 	case 'p':
     28 		cp_pflag = 1;
     29 		break;
     30 	case 'f':
     31 		cp_fflag = 1;
     32 		break;
     33 	case 'R':
     34 	case 'r':
     35 		cp_rflag = 1;
     36 		break;
     37 	case 'v':
     38 		cp_vflag = 1;
     39 		break;
     40 	default:
     41 		usage();
     42 	} ARGEND;
     43 
     44 	if (argc < 2)
     45 		usage();
     46 
     47 	if (argc > 2 && !(stat(argv[argc-1], &st) == 0 && S_ISDIR(st.st_mode)))
     48 		eprintf("%s: not a directory\n", argv[argc-1]);
     49 	enmasse(argc, argv, cp);
     50 	return cp_status;
     51 }