]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
fat cp: more on flags
authorLeo C <erbl259-lmu@yahoo.de>
Thu, 12 Apr 2018 06:37:31 +0000 (08:37 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Thu, 12 Apr 2018 06:37:31 +0000 (08:37 +0200)
avr/cmd_fat.c

index 303cf7a7a3b2d363095c2702cf20d7069e7d8265..456447ac1e98741a1a6b5f72b3bc86373e2484f4 100644 (file)
@@ -526,11 +526,11 @@ static uint8_t flags;
 PATH_T *from;
 PATH_T *to;
 
-#define R_FLAG (1<<0)  // copy directories recursively
+#define F_FLAG (1<<3)  // overwrite existing file ignoring write protection
 #define I_FLAG (1<<1)  // prompt before overwrite (overrides a previous -n option)
 #define N_FLAG (1<<2)  // do not overwrite an existing file (overrides a previous -i option)
-#define F_FLAG (1<<3)  // if an existing destination file cannot be opened, remove it and try again (this option is ignored when the -n option is also used)
 #define P_FLAG (1<<4)  // preserve attributes and timestamps
+#define R_FLAG (1<<0)  // copy directories recursively
 #define V_FLAG (1<<5)  // explain what is being done
 
 static void
@@ -762,17 +762,9 @@ debug("     from:'%s'  to:'%s'\n", from->p_path, to->p_path);
                        return;
                }
                copy_dir();
-               /*
-                * If not -p and directory didn't exist, set it to be the
-                * same as the from directory, umodified by the umask;
-                * arguably wrong, but it's been that way forever.
-                */
-#if 0
                if (flags & P_FLAG)
                        setfile(&from_stat, 0);
-               else if (dne)
-                       (void)chmod(to->p_path, from_stat.st_mode);
-#endif
+
                return;
        }
        copy_file(&from_stat, dne);
@@ -794,16 +786,21 @@ command_ret_t do_cp(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc,
        optind = 0;
 
        int opt;
-       while ((opt = getopt(argc, argv, PSTR("rfipv"))) != -1) {
+//     while ((opt = getopt(argc, argv, PSTR("fiprv"))) != -1) {
+       while ((opt = getopt(argc, argv, PSTR("fiprv"))) != -1) {
                switch (opt) {
                        case 'f':
-                               tflags &= ~I_FLAG;
+                               tflags &= ~(I_FLAG | N_FLAG);
                                tflags |=  F_FLAG;
                                break;
                        case 'i':
-                               tflags &= ~F_FLAG;
+                               tflags &= ~(F_FLAG | N_FLAG);
                                tflags |=  I_FLAG;
                                break;
+                       case 'n':
+                               tflags &= ~(F_FLAG | I_FLAG);
+                               tflags |=  N_FLAG;
+                               break;
                        case 'p':
                                tflags |= P_FLAG;
                                break;
@@ -1212,7 +1209,8 @@ CMD_TBL_ITEM(
        cp,     CONFIG_SYS_MAXARGS,     CTBL_DBG,       do_cp,
        "copy files",
        "[-f | -i | -n] [-prv] source_file target_file\n"
-       "cp [-f | -i | -n] [-prv] source_file ... target_dir\n"
+//     "[-f | -i | -n] [-prv] source_file target_file\n"
+//     "cp [-f | -i | -n] [-prv] source_file ... target_dir\n"
        "    -f overwrite existing file ignoring write protection\n"
        "       this option is ignored when the -n option is also used\n"
        "    -i prompt before overwrite (overrides a previous -n option)\n"