Ticket #19: 0001-Denis-Vlasenko-posted-a-patch-which-would-fix-issue.patch

File 0001-Denis-Vlasenko-posted-a-patch-which-would-fix-issue.patch, 3.7 KB (added by angel_il, 16 years ago)

last version master based

  • src/file.c

    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 b enum { 
    462462    DEST_FULL                   /* Created, fully copied */ 
    463463}; 
    464464 
     465static 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 result = 0; 
     470    msg = g_strdup_printf (fmt, a, b); 
     471    result = query_dialog (MSG_ERROR, msg, D_ERROR, 2, _("&Skip"), _("&Abort")); 
     472    g_free(msg); 
     473    do_refresh (); 
     474    if ( result ) { /* 1 == Abort */ 
     475        return FILE_ABORT; 
     476    } else { 
     477        return FILE_SKIP; 
     478    } 
     479} 
     480 
    465481int 
    466482copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path, 
    467483                int ask_overwrite, off_t *progress_count, 
    copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path, 
    516532 
    517533    if (dst_exists) { 
    518534        /* 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  
     535        if (sb.st_dev == sb2.st_dev && sb.st_ino == sb2.st_ino) 
     536            return warn_same_file(_(" `%s' and `%s' are the same file "), 
     537                                src_path, dst_path); 
    526538        /* Should we replace destination? */ 
    527539        if (ask_overwrite) { 
    528540            ctx->do_reget = 0; 
    move_file_file (FileOpContext *ctx, const char *s, const char *d, 
    10481060 
    10491061    if (mc_lstat (d, &dst_stats) == 0) { 
    10501062        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         } 
     1063            && src_stats.st_ino == dst_stats.st_ino) 
     1064            return warn_same_file(_(" `%s' and `%s' are the same file "), s, d); 
    10671065 
    10681066        if (S_ISDIR (dst_stats.st_mode)) { 
    10691067            message (D_ERROR, MSG_ERROR, 
    move_dir_dir (FileOpContext *ctx, const char *s, const char *d, 
    11711169    } else 
    11721170        destdir = concat_dir_and_file (d, x_basename (s)); 
    11731171 
    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     } 
     1172    if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino) 
     1173        return warn_same_file(_(" `%s' and `%s' are the same directory "), s, d); 
    11901174 
    11911175    /* Check if the user inputted an existing dir */ 
    11921176  retry_dst_stat: