return;
}
+void ff_move(const TCHAR* path_old, const TCHAR* path_new)
+{
+ FRESULT res;
+
+ if (cmd_flags & V_FLAG)
+ printf_P(PSTR("'%s' -> '%s'\n"), path_old, path_new);
+ if ((res = f_rename(path_old, path_new)) != FR_OK)
+ cmd_error(0, res, PSTR("error copying '%s' to '%s'"), path_old, path_new);
+
+ exit_val = (res != FR_OK);
+ return;
+}
+
void ff_iterate(fatfunc_t fatfunc, int count, char* const file[], char* dest)
{
FRESULT res = 0;
return exit_val;
}
-command_ret_t do_cp(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc, char * const argv[])
+command_ret_t do_cp_or_mv(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc, char * const argv[])
{
exit_val = CMD_RET_SUCCESS;
cmd_flags = 0;
+ fatfunc_t func = (argv[0][0] == 'c') ? ff_copy : ff_move;
int opt;
while ((opt = getopt(argc, argv, PSTR("v"))) != -1) {
if (argc < 2)
return CMD_RET_USAGE;
- ff_iterate(ff_copy, argc - 1, argv, argv[argc - 1]);
+ ff_iterate(func, argc - 1, argv, argv[argc - 1]);
return exit_val;
}
" -v explain what is being done"
),
CMD_TBL_ITEM(
- cp, CONFIG_SYS_MAXARGS, 0, do_cp,
+ cp, CONFIG_SYS_MAXARGS, 0, do_cp_or_mv,
"Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.",
"[OPTION]... SOURCE... DEST\n"
// " -f overwrite existing file ignoring write protection\n"
// " -p preserve attributes and timestamps\n"
" -v explain what is being done"
),
+CMD_TBL_ITEM(
+ mv, CONFIG_SYS_MAXARGS, 0, do_cp_or_mv,
+ "Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.",
+ "[OPTION]... SOURCE DEST\n"
+ " -v explain what is being done"
+),
CMD_TBL_ITEM(
load, 5, 0, do_rw,