]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
pwd/cd
authorLeo C <erbl259-lmu@yahoo.de>
Thu, 23 Aug 2018 06:53:41 +0000 (08:53 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Thu, 23 Aug 2018 06:53:41 +0000 (08:53 +0200)
avr/cmd_fat.c

index c1d3770096e3acfa196aae45431bd2d9e73625cf..d434cbded1f62a113a91ede3b44b5176b2f5745f 100644 (file)
@@ -135,12 +135,13 @@ command_ret_t do_pwd(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc
        }
 
        res = f_getcwd(buf, BUFFER_SIZE);  /* Get current directory path */
+       debug_fa("### f_getcwd():   buf: '%s', res: %d\n", buf, res);
 
-       if (!res) {
+       if (res == FR_OK) {
                puts(buf);
        }
        free(buf);
-       if (res) {
+       if (res != FR_OK) {
                put_rc(res);
                return CMD_RET_FAILURE;
        }
@@ -166,17 +167,18 @@ command_ret_t do_cd(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc,
        } else
                arg = argv[1];
 
-       if (arg[1] == ':')
+       if (strlen(arg) > 1 && arg[1] == ':') {
                res = f_chdrive(arg);
-debug_fa("### f_chdrive(): arg: '%s', res: %d\n", arg, res);
-       if (res == FR_OK) {
+               debug_fa("### f_chdrive(): arg: '%s', res: %d\n", arg, res);
                if (arg[2] == '\0') {
                        arg[0] = '/';
                        arg[1] = '\0';
                }
+       }
+       if (res == FR_OK) {
                res = f_chdir(arg);
+               debug_fa("### f_chdir():   arg: '%s', res: %d\n", arg, res);
        }
-debug_fa("### f_chdir():   arg: '%s', res: %d\n", arg, res);
        if (res != FR_OK) {
                put_rc(res);
                return CMD_RET_FAILURE;