]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/cmd_fat.c
error handling: improved cmd_error() - print fatfs error strings
[z180-stamp.git] / avr / cmd_fat.c
index ab16fa581c20ebc805ba0a34a3bd2d3106c9776f..7cc9e46ee9ae942691c38f7edd1923fa051cd817 100644 (file)
@@ -76,26 +76,26 @@ static bool check_abort(void)
 
 
 static const FLASH char * const FLASH rc_strings[] = {
-                       FSTR("OK"),
-                       FSTR("disk error"),
-                       FSTR("internal error"),
-                       FSTR("not ready"),
-                       FSTR("no file"),
-                       FSTR("no path"),
-                       FSTR("invalid name"),
-                       FSTR("denied"),
-                       FSTR("exist"),
-                       FSTR("invalid object"),
-                       FSTR("write protected"),
-                       FSTR("invalid drive"),
-                       FSTR("not enabled"),
-                       FSTR("no file system"),
-                       FSTR("mkfs aborted"),
-                       FSTR("timeout"),
-                       FSTR("locked"),
-                       FSTR("not enough core"),
-                       FSTR("too many open files"),
-                       FSTR("invalid parameter")
+                       FSTR("Success"),
+                       FSTR("Disk error"),
+                       FSTR("Internal error"),
+                       FSTR("Not ready"),
+                       FSTR("No file"),
+                       FSTR("No path"),
+                       FSTR("Invalid name"),
+                       FSTR("Denied"),
+                       FSTR("Exist"),
+                       FSTR("Invalid object"),
+                       FSTR("Write protected"),
+                       FSTR("Invalid drive"),
+                       FSTR("Not enabled"),
+                       FSTR("No file system"),
+                       FSTR("Mkfs aborted"),
+                       FSTR("Timeout"),
+                       FSTR("Locked"),
+                       FSTR("Not enough core"),
+                       FSTR("Too many open files"),
+                       FSTR("Invalid parameter")
                };
 
 static const FLASH char * const FLASH rc_names[] = {
@@ -135,7 +135,7 @@ void put_rc (FRESULT rc)
 }
 
 
-const FLASH char * rctostr(FRESULT rc)
+const FLASH char * fat_rctostr(FRESULT rc)
 {
        return  rc < ARRAY_SIZE(rc_strings) ? rc_strings[rc] : PSTR(" Unknown Error");
 }
@@ -198,13 +198,13 @@ static void strip_trailing_slash(PATH_T *p)
 static PATH_T *path_setup(char *string)
 {
        if (strlen(string) > PATH_MAX) {
-               cmd_error(PSTR("'%s': name too long"), string);
+               cmd_error(0, 0, PSTR("'%s': Name too long"), string);
                return NULL;
        }
 
        PATH_T *p = (PATH_T *) malloc(sizeof *p);
        if (p == NULL) {
-               cmd_error(PSTR("'%s': Out of Memory"), string);
+               cmd_error(0, 0, PSTR("'%s': Out of Memory"), string);
                return NULL;
        }
 
@@ -216,7 +216,7 @@ static PATH_T *path_setup(char *string)
                        p->p_path[2] = '/';
                        len += 1;
                } else {
-                       cmd_error(PSTR("'%s': Out of Memory"), string);
+                       cmd_error(0, 0, PSTR("'%s': Out of Memory"), string);
                        return NULL;
                }
        }
@@ -255,8 +255,9 @@ command_ret_t do_pwd(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc
        }
        free(buf);
        if (res != FR_OK) {
-               put_rc(res);
-               return CMD_RET_FAILURE;
+               cmd_error(CMD_RET_FAILURE, res, NULL);
+               //put_rc(res);
+               //return CMD_RET_FAILURE;
        }
        return CMD_RET_SUCCESS;
 }