diff -urpN mc-4.6.1.org/src/file.c mc-4.6.1.cp/src/file.c
old
|
new
|
enum { |
458 | 458 | DEST_FULL /* Created, fully copied */ |
459 | 459 | }; |
460 | 460 | |
| 461 | static int warn_same_file(const char *fmt, const char *a, const char *b) |
| 462 | { |
| 463 | char *msg; |
| 464 | /* We don't expect %d etc, just %s, so strlen(fmt) should be ok */ |
| 465 | int n = strlen(fmt) + strlen(a) + strlen(b) + 1; |
| 466 | |
| 467 | msg = malloc(n); |
| 468 | if (msg) { |
| 469 | snprintf(msg, n, fmt, a, b); |
| 470 | n = query_dialog (MSG_ERROR, msg, |
| 471 | D_ERROR, 2, _("&Skip"), _("&Abort")); |
| 472 | free(msg); |
| 473 | do_refresh (); |
| 474 | if (n) /* 1 == Abort */ |
| 475 | return FILE_ABORT; |
| 476 | } |
| 477 | return FILE_SKIP; |
| 478 | } |
| 479 | |
461 | 480 | int |
462 | 481 | copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path, |
463 | 482 | int ask_overwrite, off_t *progress_count, |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
512 | 531 | |
513 | 532 | if (dst_exists) { |
514 | 533 | /* Destination already exists */ |
515 | | if (sb.st_dev == sb2.st_dev && sb.st_ino == sb2.st_ino) { |
516 | | message (1, MSG_ERROR, |
517 | | _(" `%s' and `%s' are the same file "), src_path, dst_path); |
518 | | do_refresh (); |
519 | | return FILE_SKIP; |
520 | | } |
| 534 | if (sb.st_dev == sb2.st_dev && sb.st_ino == sb2.st_ino) |
| 535 | return warn_same_file(_(" `%s' and `%s' are the same file "), |
| 536 | src_path, dst_path); |
521 | 537 | |
522 | 538 | /* Should we replace destination? */ |
523 | 539 | if (ask_overwrite) { |
… |
… |
move_file_file (FileOpContext *ctx, cons |
1043 | 1059 | |
1044 | 1060 | if (mc_lstat (d, &dst_stats) == 0) { |
1045 | 1061 | if (src_stats.st_dev == dst_stats.st_dev |
1046 | | && src_stats.st_ino == dst_stats.st_ino) { |
1047 | | int msize = COLS - 36; |
1048 | | char st[MC_MAXPATHLEN]; |
1049 | | char dt[MC_MAXPATHLEN]; |
1050 | | |
1051 | | if (msize < 0) |
1052 | | msize = 40; |
1053 | | msize /= 2; |
1054 | | |
1055 | | strcpy (st, path_trunc (s, msize)); |
1056 | | strcpy (dt, path_trunc (d, msize)); |
1057 | | message (1, MSG_ERROR, |
1058 | | _(" `%s' and `%s' are the same file "), st, dt); |
1059 | | do_refresh (); |
1060 | | return FILE_SKIP; |
1061 | | } |
| 1062 | && src_stats.st_ino == dst_stats.st_ino) |
| 1063 | return warn_same_file(_(" `%s' and `%s' are the same file "), s, d); |
1062 | 1064 | |
1063 | 1065 | if (S_ISDIR (dst_stats.st_mode)) { |
1064 | 1066 | message (1, MSG_ERROR, |
… |
… |
move_dir_dir (FileOpContext *ctx, const |
1161 | 1163 | } else |
1162 | 1164 | destdir = concat_dir_and_file (d, x_basename (s)); |
1163 | 1165 | |
1164 | | if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino) { |
1165 | | int msize = COLS - 36; |
1166 | | char st[MC_MAXPATHLEN]; |
1167 | | char dt[MC_MAXPATHLEN]; |
1168 | | |
1169 | | if (msize < 0) |
1170 | | msize = 40; |
1171 | | msize /= 2; |
1172 | | |
1173 | | strcpy (st, path_trunc (s, msize)); |
1174 | | strcpy (dt, path_trunc (d, msize)); |
1175 | | message (1, MSG_ERROR, |
1176 | | _(" `%s' and `%s' are the same directory "), st, dt); |
1177 | | do_refresh (); |
1178 | | return FILE_SKIP; |
1179 | | } |
| 1166 | if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino) |
| 1167 | return warn_same_file(_(" `%s' and `%s' are the same directory "), s, d); |
1180 | 1168 | |
1181 | 1169 | /* Check if the user inputted an existing dir */ |
1182 | 1170 | retry_dst_stat: |