diff --git a/demos/host/host_os_none/host_os_none.uvopt b/demos/host/host_os_none/host_os_none.uvopt
index e65da83b2..397e398f6 100644
--- a/demos/host/host_os_none/host_os_none.uvopt
+++ b/demos/host/host_os_none/host_os_none.uvopt
@@ -761,7 +761,7 @@
- .\keil_ram.ini
+ ..\..\bsp\lpc43xx\keil_ram.ini
Segger\JL2CM3.dll
@@ -1428,7 +1428,7 @@
0
39
0
- 58
+ 59
63
0
..\..\..\vendor\fatfs\diskio.c
@@ -1444,8 +1444,8 @@
0
11
0
- 2114
- 2121
+ 2115
+ 2122
0
..\..\..\vendor\fatfs\ff.c
ff.c
@@ -1516,7 +1516,7 @@
0
17
0
- 83
+ 84
90
0
..\..\bsp\boards\printf_retarget.c
@@ -1652,7 +1652,7 @@
0
13
0
- 170
+ 171
174
0
..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s
@@ -1868,7 +1868,7 @@
0
0
0
- 140
+ 141
145
0
..\..\bsp\lpc175x_6x\startup_keil\startup_LPC17xx.s
diff --git a/demos/host/host_os_none/host_os_none.uvproj b/demos/host/host_os_none/host_os_none.uvproj
index 06cf0f5e9..7990b6fe8 100644
--- a/demos/host/host_os_none/host_os_none.uvproj
+++ b/demos/host/host_os_none/host_os_none.uvproj
@@ -2462,7 +2462,7 @@
- .\keil_ram.ini
+ ..\..\bsp\lpc43xx\keil_ram.ini
Segger\JL2CM3.dll
diff --git a/demos/host/src/cli.c b/demos/host/src/cli.c
index d67379b9b..4cb33e060 100644
--- a/demos/host/src/cli.c
+++ b/demos/host/src/cli.c
@@ -396,19 +396,30 @@ cli_error_t cli_cmd_copy(char *p_para)
drive_letter2number(p_para);
drive_letter2number(p_dest);
- //------------- Check Existence of source & dest file -------------//
- cli_error_t error = CLI_ERROR_NONE;
- FIL src_file, dest_file;
-
+ //------------- Check Existence of source file -------------//
+ FIL src_file;
if ( FR_OK != f_open(&src_file , p_para, FA_READ) ) return CLI_ERROR_INVALID_PATH;
+
+ //------------- Check if dest path is a folder or a non-existing file (overwritten is not allowed) -------------//
+ FILINFO dest_entry;
+ if ( (f_stat(p_dest, &dest_entry) == FR_OK) && (dest_entry.fattrib & AM_DIR) )
+ { // the destination is an existed folder --> auto append dest filename to be the folder
+ strcat(p_dest, "/");
+ strcat(p_dest, p_para);
+ }
+
+ //------------- Open dest file and start the copy -------------//
+ cli_error_t error = CLI_ERROR_NONE;
+ FIL dest_file;
+
switch ( f_open(&dest_file, p_dest, FA_WRITE | FA_CREATE_NEW) )
{
case FR_EXIST:
error = CLI_ERROR_FILE_EXISTED;
- break;\
+ break;
case FR_OK:
- while(1)
+ while(1) // copying
{
uint32_t bytes_read = 0;
uint32_t bytes_write = 0;