From fffd6138972832b8c6c5e12724ed43159e27122c Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 1 Oct 2013 16:36:52 +0700 Subject: [PATCH] enhance cd command --- demos/host/host_os_none/host_os_none.uvopt | 16 ++++++++-------- demos/host/src/cli.c | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/demos/host/host_os_none/host_os_none.uvopt b/demos/host/host_os_none/host_os_none.uvopt index 89f85a6c..937f1c34 100644 --- a/demos/host/host_os_none/host_os_none.uvopt +++ b/demos/host/host_os_none/host_os_none.uvopt @@ -492,7 +492,7 @@ 0 25 0 - 153 + 154 160 0 ..\src\main.c @@ -844,7 +844,7 @@ 0 21 0 - 2 + 3 8 0 ..\..\..\tinyusb\host\usbh.c @@ -1092,7 +1092,7 @@ 0 3 0 - 574 + 575 580 0 ..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_cgu.c @@ -1148,7 +1148,7 @@ 0 10 0 - 145 + 146 147 0 ..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s @@ -1172,7 +1172,7 @@ 0 23 0 - 107 + 108 113 0 ..\..\..\vendor\fatfs\diskio.c @@ -1186,10 +1186,10 @@ 1 0 0 - 66 + 32 0 - 2021 - 2037 + 2029 + 2043 0 ..\..\..\vendor\fatfs\ff.c ff.c diff --git a/demos/host/src/cli.c b/demos/host/src/cli.c index 31ecbbdf..8eca90e7 100644 --- a/demos/host/src/cli.c +++ b/demos/host/src/cli.c @@ -313,17 +313,17 @@ cli_error_t cli_cmd_changedir(char * p_para) { if ( strlen(p_para) == 0 ) return CLI_ERROR_INVALID_PARA; - if ( (p_para[1] == ':') && (strlen(p_para) == 2) ) - { // change drive - p_para[0] -= 'E'; - if ( ! ( disk_is_ready(p_para[0]) && FR_OK == f_chdrive(p_para[0]) )) return CLI_ERROR_INVALID_PARA; - f_getlabel(NULL, volume_label, NULL); - }else + drive_letter2number(p_para); + + if ( FR_OK != f_chdir(p_para) ) { - if ( FR_OK != f_chdir(p_para) ) - { - return CLI_ERROR_INVALID_PATH; - } + return CLI_ERROR_INVALID_PATH; + } + + if ( p_para[1] == ':') + { // path has drive letter --> change drive, update volume label + f_chdrive(p_para[0] - '0'); + f_getlabel(NULL, volume_label, NULL); } return CLI_ERROR_NONE;