enhance cp command to accept dest path as an folder
This commit is contained in:
parent
d2ee92da48
commit
f55ae521a0
|
@ -761,7 +761,7 @@
|
||||||
<tDllPa></tDllPa>
|
<tDllPa></tDllPa>
|
||||||
<tDlgDll></tDlgDll>
|
<tDlgDll></tDlgDll>
|
||||||
<tDlgPa></tDlgPa>
|
<tDlgPa></tDlgPa>
|
||||||
<tIfile>.\keil_ram.ini</tIfile>
|
<tIfile>..\..\bsp\lpc43xx\keil_ram.ini</tIfile>
|
||||||
<pMon>Segger\JL2CM3.dll</pMon>
|
<pMon>Segger\JL2CM3.dll</pMon>
|
||||||
</DebugOpt>
|
</DebugOpt>
|
||||||
<TargetDriverDllRegistry>
|
<TargetDriverDllRegistry>
|
||||||
|
@ -1428,7 +1428,7 @@
|
||||||
<Focus>0</Focus>
|
<Focus>0</Focus>
|
||||||
<ColumnNumber>39</ColumnNumber>
|
<ColumnNumber>39</ColumnNumber>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<TopLine>58</TopLine>
|
<TopLine>59</TopLine>
|
||||||
<CurrentLine>63</CurrentLine>
|
<CurrentLine>63</CurrentLine>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\vendor\fatfs\diskio.c</PathWithFileName>
|
<PathWithFileName>..\..\..\vendor\fatfs\diskio.c</PathWithFileName>
|
||||||
|
@ -1444,8 +1444,8 @@
|
||||||
<Focus>0</Focus>
|
<Focus>0</Focus>
|
||||||
<ColumnNumber>11</ColumnNumber>
|
<ColumnNumber>11</ColumnNumber>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<TopLine>2114</TopLine>
|
<TopLine>2115</TopLine>
|
||||||
<CurrentLine>2121</CurrentLine>
|
<CurrentLine>2122</CurrentLine>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\vendor\fatfs\ff.c</PathWithFileName>
|
<PathWithFileName>..\..\..\vendor\fatfs\ff.c</PathWithFileName>
|
||||||
<FilenameWithoutPath>ff.c</FilenameWithoutPath>
|
<FilenameWithoutPath>ff.c</FilenameWithoutPath>
|
||||||
|
@ -1516,7 +1516,7 @@
|
||||||
<Focus>0</Focus>
|
<Focus>0</Focus>
|
||||||
<ColumnNumber>17</ColumnNumber>
|
<ColumnNumber>17</ColumnNumber>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<TopLine>83</TopLine>
|
<TopLine>84</TopLine>
|
||||||
<CurrentLine>90</CurrentLine>
|
<CurrentLine>90</CurrentLine>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName>
|
<PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName>
|
||||||
|
@ -1652,7 +1652,7 @@
|
||||||
<Focus>0</Focus>
|
<Focus>0</Focus>
|
||||||
<ColumnNumber>13</ColumnNumber>
|
<ColumnNumber>13</ColumnNumber>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<TopLine>170</TopLine>
|
<TopLine>171</TopLine>
|
||||||
<CurrentLine>174</CurrentLine>
|
<CurrentLine>174</CurrentLine>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
|
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
|
||||||
|
@ -1868,7 +1868,7 @@
|
||||||
<Focus>0</Focus>
|
<Focus>0</Focus>
|
||||||
<ColumnNumber>0</ColumnNumber>
|
<ColumnNumber>0</ColumnNumber>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<TopLine>140</TopLine>
|
<TopLine>141</TopLine>
|
||||||
<CurrentLine>145</CurrentLine>
|
<CurrentLine>145</CurrentLine>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\bsp\lpc175x_6x\startup_keil\startup_LPC17xx.s</PathWithFileName>
|
<PathWithFileName>..\..\bsp\lpc175x_6x\startup_keil\startup_LPC17xx.s</PathWithFileName>
|
||||||
|
|
|
@ -2462,7 +2462,7 @@
|
||||||
<CpuDllArguments></CpuDllArguments>
|
<CpuDllArguments></CpuDllArguments>
|
||||||
<PeripheralDll></PeripheralDll>
|
<PeripheralDll></PeripheralDll>
|
||||||
<PeripheralDllArguments></PeripheralDllArguments>
|
<PeripheralDllArguments></PeripheralDllArguments>
|
||||||
<InitializationFile>.\keil_ram.ini</InitializationFile>
|
<InitializationFile>..\..\bsp\lpc43xx\keil_ram.ini</InitializationFile>
|
||||||
<Driver>Segger\JL2CM3.dll</Driver>
|
<Driver>Segger\JL2CM3.dll</Driver>
|
||||||
</TargetDlls>
|
</TargetDlls>
|
||||||
</DebugOption>
|
</DebugOption>
|
||||||
|
|
|
@ -396,19 +396,30 @@ cli_error_t cli_cmd_copy(char *p_para)
|
||||||
drive_letter2number(p_para);
|
drive_letter2number(p_para);
|
||||||
drive_letter2number(p_dest);
|
drive_letter2number(p_dest);
|
||||||
|
|
||||||
//------------- Check Existence of source & dest file -------------//
|
//------------- Check Existence of source file -------------//
|
||||||
cli_error_t error = CLI_ERROR_NONE;
|
FIL src_file;
|
||||||
FIL src_file, dest_file;
|
|
||||||
|
|
||||||
if ( FR_OK != f_open(&src_file , p_para, FA_READ) ) return CLI_ERROR_INVALID_PATH;
|
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) )
|
switch ( f_open(&dest_file, p_dest, FA_WRITE | FA_CREATE_NEW) )
|
||||||
{
|
{
|
||||||
case FR_EXIST:
|
case FR_EXIST:
|
||||||
error = CLI_ERROR_FILE_EXISTED;
|
error = CLI_ERROR_FILE_EXISTED;
|
||||||
break;\
|
break;
|
||||||
|
|
||||||
case FR_OK:
|
case FR_OK:
|
||||||
while(1)
|
while(1) // copying
|
||||||
{
|
{
|
||||||
uint32_t bytes_read = 0;
|
uint32_t bytes_read = 0;
|
||||||
uint32_t bytes_write = 0;
|
uint32_t bytes_write = 0;
|
||||||
|
|
Loading…
Reference in New Issue