]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
fat cp: WIP
authorLeo C <erbl259-lmu@yahoo.de>
Wed, 11 Apr 2018 17:21:59 +0000 (19:21 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Wed, 11 Apr 2018 17:21:59 +0000 (19:21 +0200)
avr/cmd_fat.c

index 633834c136ca06a7be25343e8ac6098474c209dc..b0c889c767f1671f1aa38e6855f88a9388e391e6 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include "cmd_fat.h"
+#include <util/delay.h>
 
 #include "ff.h"
 #include "z80-if.h"
@@ -138,6 +139,7 @@ void err(const char *fmt, ...)
        (void)vfprintf_P(stdout, fmt, ap);
        va_end(ap);
        (void)printf_P(PSTR("\n"));
+       _delay_ms(20);
        command_ret = CMD_RET_FAILURE;
 }
 
@@ -446,7 +448,7 @@ int
 path_set(PATH_T *p, char *string)
 {
        if (strlen(string) > MAX_PATHLEN) {
-               err(PSTR("%s: name too long"), string);
+               err(PSTR("set: '%s': name too long"), string);
                return 0;
        }
 
@@ -477,7 +479,7 @@ path_append(PATH_T *p, char *name, int len)
 
        /* The "+ 1" accounts for the '/' between old path and name. */
        if ((len + p->p_end - p->p_path + 1) > MAX_PATHLEN) {
-               err(PSTR("%s/%s: name too long"), p->p_path, name);
+               err(PSTR("append: '%s/%s': name too long"), p->p_path, name);
                return(0);
        }
 
@@ -487,35 +489,31 @@ path_append(PATH_T *p, char *name, int len)
         */
        if (p->p_end[-1] != '/') {
                *p->p_end++ = '/';
-               *p->p_end = 0;
+               *p->p_end = '\0';
        }
 
        (void)strncat(p->p_end, name, len);
        p->p_end += len;
-       *p->p_end = 0;
+       *p->p_end = '\0';
 
        strip_trailing_slash(p);
-       return(old);
+       return old;
 }
 
 /*
  * Restore path to previous value.  (As returned by path_append.)
  */
 void
-path_restore(p, old)
-       PATH_T *p;
-       char *old;
+path_restore(PATH_T *p, char *old)
 {
        p->p_end = old;
-       *p->p_end = 0;
+       *p->p_end = '\0';
 }
 
 /*
  * Return basename of path.
  */
-char *
-path_basename(p)
-       PATH_T *p;
+char *path_basename(PATH_T *p)
 {
        char *basename;
 
@@ -867,7 +865,8 @@ debug("     from:'%s'  to:'%s'\n", from->p_path, to->p_path);
                 * Case (1).  Target is not a directory.
                 */
                if (argc > 1) {
-                       command_ret = CMD_RET_USAGE;
+                       err(PSTR("target '%s' is not a directory"), to->p_path);
+                       //command_ret = CMD_RET_USAGE;
                        goto cleanup;
                }
                if (!path_set(from, *argv)) {
@@ -888,7 +887,7 @@ debug("     from:'%s'  to:'%s'\n", from->p_path, to->p_path);
                        copy();
                        if (!--argc)
                                break;
-                       path_restore(&to, old_to);
+                       path_restore(to, old_to);
                }
        }