-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0001-Denis-Vlasenko-posted-a-patch-which-would-fix-issue.patch
110 lines (101 loc) · 3.67 KB
/
0001-Denis-Vlasenko-posted-a-patch-which-would-fix-issue.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
From a589863ae8feb0bc64757b55a9c2fb5ea8ed5f64 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.
rework warn_same_file for more usage glib. ... msg = g_strdup_printf() ...
---
src/file.c | 62 ++++++++++++++++++++++-------------------------------------
1 files changed, 23 insertions(+), 39 deletions(-)
diff --git a/src/file.c b/src/file.c
index 9e0e8c2..42b8cee 100644
--- a/src/file.c
+++ b/src/file.c
@@ -462,6 +462,22 @@ enum {
DEST_FULL /* Created, fully copied */
};
+static int warn_same_file(const char *fmt, const char *a, const char *b)
+{
+ char *msg;
+ /* We don't expect %d etc, just %s, so strlen(fmt) should be ok */
+ int result = 0;
+ msg = g_strdup_printf (fmt, a, b);
+ result = query_dialog (MSG_ERROR, msg, D_ERROR, 2, _("&Skip"), _("&Abort"));
+ g_free(msg);
+ do_refresh ();
+ if ( result ) { /* 1 == Abort */
+ return FILE_ABORT;
+ } else {
+ return FILE_SKIP;
+ }
+}
+
int
copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
int ask_overwrite, off_t *progress_count,
@@ -516,13 +532,9 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
if (dst_exists) {
/* Destination already exists */
- if (sb.st_dev == sb2.st_dev && sb.st_ino == sb2.st_ino) {
- message (D_ERROR, MSG_ERROR,
- _(" `%s' and `%s' are the same file "), src_path, dst_path);
- do_refresh ();
- return FILE_SKIP;
- }
-
+ if (sb.st_dev == sb2.st_dev && sb.st_ino == sb2.st_ino)
+ return warn_same_file(_(" `%s' and `%s' are the same file "),
+ src_path, dst_path);
/* Should we replace destination? */
if (ask_overwrite) {
ctx->do_reget = 0;
@@ -1048,22 +1060,8 @@ move_file_file (FileOpContext *ctx, const char *s, const char *d,
if (mc_lstat (d, &dst_stats) == 0) {
if (src_stats.st_dev == dst_stats.st_dev
- && src_stats.st_ino == dst_stats.st_ino) {
- int msize = COLS - 36;
- char st[MC_MAXPATHLEN];
- char dt[MC_MAXPATHLEN];
-
- if (msize < 0)
- msize = 40;
- msize /= 2;
-
- strcpy (st, path_trunc (s, msize));
- strcpy (dt, path_trunc (d, msize));
- message (D_ERROR, MSG_ERROR,
- _(" `%s' and `%s' are the same file "), st, dt);
- do_refresh ();
- return FILE_SKIP;
- }
+ && src_stats.st_ino == dst_stats.st_ino)
+ return warn_same_file(_(" `%s' and `%s' are the same file "), s, d);
if (S_ISDIR (dst_stats.st_mode)) {
message (D_ERROR, MSG_ERROR,
@@ -1171,22 +1169,8 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
} else
destdir = concat_dir_and_file (d, x_basename (s));
- if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino) {
- int msize = COLS - 36;
- char st[MC_MAXPATHLEN];
- char dt[MC_MAXPATHLEN];
-
- if (msize < 0)
- msize = 40;
- msize /= 2;
-
- strcpy (st, path_trunc (s, msize));
- strcpy (dt, path_trunc (d, msize));
- message (D_ERROR, MSG_ERROR,
- _(" `%s' and `%s' are the same directory "), st, dt);
- do_refresh ();
- return FILE_SKIP;
- }
+ if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino)
+ return warn_same_file(_(" `%s' and `%s' are the same directory "), s, d);
/* Check if the user inputted an existing dir */
retry_dst_stat:
--
1.6.1.1