FRESULT fr;
debug("==== copy_file(): dne: %u\n", dne);
-debug("==== from:'%s' to:'%s'\n", from->p_path, to->p_path);
+debug(" from:'%s' to:'%s'\n", from->p_path, to->p_path);
if ((fr = f_open(&from_fd, from->p_path, FA_READ)) != FR_OK) {
err(PSTR("%s: %S"), from->p_path, rctostr(fr));
#if 1
static void copy_dir(void)
{
- printf(PSTR("directory copy not supported, ommitting dir '%s'\n"),
+debug("==== copy_dir()");
+debug(" from:'%s' to:'%s'\n", from->p_path, to->p_path);
+
+ printf_P(PSTR("directory copy not supported, ommitting dir '%s'\n"),
from->p_path);
+ command_ret = CMD_RET_FAILURE;
}
#else
static void copy_dir(void)
int dir_cnt, i;
char *old_from, *old_to;
+debug("==== copy_file(): dne: %u\n", dne);
+debug(" from:'%s' to:'%s'\n", from->p_path, to->p_path);
+
dir_cnt = scandir(from->p_path, &dir_list, NULL, NULL);
if (dir_cnt == -1) {
(void)fprintf(stderr, "%s: can't read directory %s.\n",
FRESULT fr;
debug("==== copy()\n");
-debug("==== from:'%s' to:'%s'\n", from->p_path, to->p_path);
+debug(" from:'%s' to:'%s'\n", from->p_path, to->p_path);
fr = f_stat(from->p_path, &from_stat);
- if (fr) {
+ if (fr != FR_OK) {
err(PSTR("%s: %S"), from->p_path, rctostr(fr));
return;
}
if (f_stat(to->p_path, &to_stat) != FR_OK)
dne = 1;
else {
- if (strcmp(to->p_path, from->p_path) !=0) {
+ if (strcmp(to->p_path, from->p_path) == 0) {
(void)printf_P(PSTR("%s and %s are identical (not copied).\n"),
to->p_path, from->p_path);
command_ret = CMD_RET_FAILURE;
if(from_stat.fattrib & AM_DIR) {
if (!(flags & R_FLAG)) {
- (void)printf(PSTR("-r not specified; ommitting dir '%s'\n"),
+ (void)printf_P(PSTR("-r not specified; ommitting dir '%s'\n"),
from->p_path);
command_ret = CMD_RET_FAILURE;
return;
*/
fr = f_stat(to->p_path, &to_stat);
- if (fr != FR_OK && fr != FR_NO_FILE) {
- err(PSTR("%s: %S"), to->p_path, rctostr(fr));
+debug("==== main, stat to: fr: %d, attr: %02x\n", fr, to_stat.fattrib);
+debug(" from:'%s' to:'%s'\n", from->p_path, to->p_path);
+
+ if (fr != FR_OK && fr != FR_NO_FILE && fr != FR_NO_PATH) {
+ err(PSTR("Test1: %s: %S"), to->p_path, rctostr(fr));
command_ret = CMD_RET_FAILURE;
goto cleanup;
}
- if (fr != FR_OK || !(to_stat.fattrib & AM_DIR)) {
+ if (!(fr == FR_OK && (to_stat.fattrib & AM_DIR))) {
/*
* Case (1). Target is not a directory.
*/
command_ret = CMD_RET_USAGE;
goto cleanup;
}
- if (!path_set(from, *argv))
+ if (!path_set(from, *argv)) {
command_ret = CMD_RET_FAILURE;
goto cleanup;
+ }
copy();
}
else {