From 8b6467421c12709ceee6680231e902601de22243 Mon Sep 17 00:00:00 2001
From: admin <admin@holmes.(none)>
Date: Thu, 5 Mar 2009 09:02:02 +0000
Subject: [PATCH] Denis Vlasenko posted a patch which would fix issue when no dialog for break operation. Trouble: recently i accidentally entered '.' instead of '..' in the file copy dialog on a relatively big tree ... for every file in the tree i got the <foo> and <bar> are the same file message box, without any way to escape except killing mc from the outside.
---
src/file.c | 65 ++++++++++++++++++++++++------------------------------------
1 files changed, 26 insertions(+), 39 deletions(-)
diff --git a/src/file.c b/src/file.c
index 9e0e8c2..df0bf58 100644
a
|
b
|
enum { |
462 | 462 | DEST_FULL /* Created, fully copied */ |
463 | 463 | }; |
464 | 464 | |
| 465 | static int warn_same_file(const char *fmt, const char *a, const char *b) |
| 466 | { |
| 467 | char *msg; |
| 468 | /* We don't expect %d etc, just %s, so strlen(fmt) should be ok */ |
| 469 | int n = strlen(fmt) + strlen(a) + strlen(b) + 1; |
| 470 | |
| 471 | msg = malloc(n); |
| 472 | if (msg) { |
| 473 | snprintf(msg, n, fmt, a, b); |
| 474 | n = query_dialog (MSG_ERROR, msg, |
| 475 | D_ERROR, 2, _("&Skip"), _("&Abort")); |
| 476 | free(msg); |
| 477 | do_refresh (); |
| 478 | if (n) /* 1 == Abort */ |
| 479 | return FILE_ABORT; |
| 480 | } |
| 481 | return FILE_SKIP; |
| 482 | } |
| 483 | |
465 | 484 | int |
466 | 485 | copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path, |
467 | 486 | int ask_overwrite, off_t *progress_count, |
… |
… |
copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path, |
516 | 535 | |
517 | 536 | if (dst_exists) { |
518 | 537 | /* Destination already exists */ |
519 | | if (sb.st_dev == sb2.st_dev && sb.st_ino == sb2.st_ino) { |
520 | | message (D_ERROR, MSG_ERROR, |
521 | | _(" `%s' and `%s' are the same file "), src_path, dst_path); |
522 | | do_refresh (); |
523 | | return FILE_SKIP; |
524 | | } |
525 | | |
| 538 | if (sb.st_dev == sb2.st_dev && sb.st_ino == sb2.st_ino) |
| 539 | return warn_same_file(_(" `%s' and `%s' are the same file "), |
| 540 | src_path, dst_path); |
526 | 541 | /* Should we replace destination? */ |
527 | 542 | if (ask_overwrite) { |
528 | 543 | ctx->do_reget = 0; |
… |
… |
move_file_file (FileOpContext *ctx, const char *s, const char *d, |
1048 | 1063 | |
1049 | 1064 | if (mc_lstat (d, &dst_stats) == 0) { |
1050 | 1065 | if (src_stats.st_dev == dst_stats.st_dev |
1051 | | && src_stats.st_ino == dst_stats.st_ino) { |
1052 | | int msize = COLS - 36; |
1053 | | char st[MC_MAXPATHLEN]; |
1054 | | char dt[MC_MAXPATHLEN]; |
1055 | | |
1056 | | if (msize < 0) |
1057 | | msize = 40; |
1058 | | msize /= 2; |
1059 | | |
1060 | | strcpy (st, path_trunc (s, msize)); |
1061 | | strcpy (dt, path_trunc (d, msize)); |
1062 | | message (D_ERROR, MSG_ERROR, |
1063 | | _(" `%s' and `%s' are the same file "), st, dt); |
1064 | | do_refresh (); |
1065 | | return FILE_SKIP; |
1066 | | } |
| 1066 | && src_stats.st_ino == dst_stats.st_ino) |
| 1067 | return warn_same_file(_(" `%s' and `%s' are the same file "), s, d); |
1067 | 1068 | |
1068 | 1069 | if (S_ISDIR (dst_stats.st_mode)) { |
1069 | 1070 | message (D_ERROR, MSG_ERROR, |
… |
… |
move_dir_dir (FileOpContext *ctx, const char *s, const char *d, |
1171 | 1172 | } else |
1172 | 1173 | destdir = concat_dir_and_file (d, x_basename (s)); |
1173 | 1174 | |
1174 | | if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino) { |
1175 | | int msize = COLS - 36; |
1176 | | char st[MC_MAXPATHLEN]; |
1177 | | char dt[MC_MAXPATHLEN]; |
1178 | | |
1179 | | if (msize < 0) |
1180 | | msize = 40; |
1181 | | msize /= 2; |
1182 | | |
1183 | | strcpy (st, path_trunc (s, msize)); |
1184 | | strcpy (dt, path_trunc (d, msize)); |
1185 | | message (D_ERROR, MSG_ERROR, |
1186 | | _(" `%s' and `%s' are the same directory "), st, dt); |
1187 | | do_refresh (); |
1188 | | return FILE_SKIP; |
1189 | | } |
| 1175 | if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino) |
| 1176 | return warn_same_file(_(" `%s' and `%s' are the same directory "), s, d); |
1190 | 1177 | |
1191 | 1178 | /* Check if the user inputted an existing dir */ |
1192 | 1179 | retry_dst_stat: |