Ticket #2625: mc-4.7.5.5-sshutime-perl.patch

File mc-4.7.5.5-sshutime-perl.patch, 5.5 KB (added by sergem, 13 years ago)

Same patch, but using perl utime and fallback to touch if no perl found

  • lib/fileloc.h

    diff -urN mc-4.7.5.5.orig/lib/fileloc.h mc-4.7.5.5/lib/fileloc.h
    old new  
    3838#define FISH_UNLINK_FILE        "unlink" 
    3939#define FISH_CHOWN_FILE         "chown" 
    4040#define FISH_CHMOD_FILE         "chmod" 
     41#define FISH_UTIME_FILE         "utime" 
    4142#define FISH_RMDIR_FILE         "rmdir" 
    4243#define FISH_LN_FILE            "ln" 
    4344#define FISH_MV_FILE            "mv" 
  • lib/vfs/mc-vfs/fish.c

    diff -urN mc-4.7.5.5.orig/lib/vfs/mc-vfs/fish.c mc-4.7.5.5/lib/vfs/mc-vfs/fish.c
    old new  
    275275    g_free (SUP.scr_unlink); 
    276276    g_free (SUP.scr_chown); 
    277277    g_free (SUP.scr_chmod); 
     278    g_free (SUP.scr_utime); 
    278279    g_free (SUP.scr_rmdir); 
    279280    g_free (SUP.scr_ln); 
    280281    g_free (SUP.scr_mv); 
     
    575576    SUP.scr_unlink = fish_load_script_from_file (host, FISH_UNLINK_FILE, FISH_UNLINK_DEF_CONTENT); 
    576577    SUP.scr_chown = fish_load_script_from_file (host, FISH_CHOWN_FILE, FISH_CHOWN_DEF_CONTENT); 
    577578    SUP.scr_chmod = fish_load_script_from_file (host, FISH_CHMOD_FILE, FISH_CHMOD_DEF_CONTENT); 
     579    SUP.scr_utime = fish_load_script_from_file (host, FISH_UTIME_FILE, FISH_UTIME_DEF_CONTENT); 
    578580    SUP.scr_rmdir = fish_load_script_from_file (host, FISH_RMDIR_FILE, FISH_RMDIR_DEF_CONTENT); 
    579581    SUP.scr_ln = fish_load_script_from_file (host, FISH_LN_FILE, FISH_LN_DEF_CONTENT); 
    580582    SUP.scr_mv = fish_load_script_from_file (host, FISH_MV_FILE, FISH_MV_DEF_CONTENT); 
     
    12721274/* --------------------------------------------------------------------------------------------- */ 
    12731275 
    12741276static int 
     1277fish_utime (struct vfs_class *me, const char *path, struct utimbuf *times) 
     1278{ 
     1279    gchar *shell_commands = NULL; 
     1280    char utcmtime[16], utcatime[16]; 
     1281    struct tm *gmt; 
     1282 
     1283    PREFIX; 
     1284 
     1285    gmt = gmtime(&times->modtime); 
     1286    g_snprintf (utcmtime, sizeof (utcmtime), "%04d%02d%02d%02d%02d.%02d", 
     1287                gmt->tm_year+1900, gmt->tm_mon+1, gmt->tm_mday, 
     1288                gmt->tm_hour, gmt->tm_min, gmt->tm_sec); 
     1289 
     1290    gmt = gmtime(&times->actime); 
     1291    g_snprintf (utcatime, sizeof (utcatime), "%04d%02d%02d%02d%02d.%02d", 
     1292                gmt->tm_year+1900, gmt->tm_mon+1, gmt->tm_mday, 
     1293                gmt->tm_hour, gmt->tm_min, gmt->tm_sec); 
     1294 
     1295    shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_FILEATIME=%ld FISH_FILEMTIME=%ld ", 
     1296                                  "FISH_TOUCHATIME=%s FISH_TOUCHMTIME=%s;\n", 
     1297                                  SUP.scr_utime, (char *) NULL); 
     1298    g_snprintf (buf, sizeof (buf), shell_commands, 
     1299                rpath, (long)times->actime, (long)times->modtime, utcatime, utcmtime); 
     1300    g_free (shell_commands); 
     1301    g_free (rpath); 
     1302    return fish_send_command (me, super, buf, OPT_FLUSH); 
     1303} 
     1304 
     1305/* --------------------------------------------------------------------------------------------- */ 
     1306 
     1307static int 
    12751308fish_unlink (struct vfs_class *me, const char *path) 
    12761309{ 
    12771310    gchar *shell_commands = NULL; 
     
    14581491    vfs_fish_ops.fill_names = fish_fill_names; 
    14591492    vfs_fish_ops.chmod = fish_chmod; 
    14601493    vfs_fish_ops.chown = fish_chown; 
     1494    vfs_fish_ops.utime = fish_utime; 
    14611495    vfs_fish_ops.open = fish_open; 
    14621496    vfs_fish_ops.symlink = fish_symlink; 
    14631497    vfs_fish_ops.link = fish_link; 
  • lib/vfs/mc-vfs/fishdef.h

    diff -urN mc-4.7.5.5.orig/lib/vfs/mc-vfs/fishdef.h mc-4.7.5.5/lib/vfs/mc-vfs/fishdef.h
    old new  
    7474"    echo \"### 500\"\n"                                                    \ 
    7575"fi\n" 
    7676 
     77/* default 'utime' script */ 
     78#define FISH_UTIME_DEF_CONTENT ""                                                                         \ 
     79"#UTIME $FISH_FILEATIME $FISH_FILEMTIME $FISH_FILENAME\n"                                                 \ 
     80"if [ -n \"$FISH_HAVE_PERL\" ] && \\\n"                                                                   \ 
     81"   perl -e 'utime '$FISH_FILEATIME','$FISH_FILEMTIME',@ARGV;' \"/${FISH_FILENAME}\" 2>/dev/null; then\n" \ 
     82"  echo \"### 000\"\n"                                                                                    \ 
     83"elif TZ=UTC touch -m -t $FISH_TOUCHMTIME \"/${FISH_FILENAME}\" 2>/dev/null && \\\n"                      \ 
     84"     TZ=UTC touch -a -t $FISH_TOUCHATIME \"/${FISH_FILENAME}\" 2>/dev/null; then\n"                      \ 
     85"  echo \"### 000\"\n"                                                                                    \ 
     86"else\n"                                                                                                  \ 
     87"  echo \"### 500\"\n"                                                                                    \ 
     88"fi\n" 
     89 
    7790/* default 'rmdir' script */ 
    7891#define FISH_RMDIR_DEF_CONTENT ""                                           \ 
    7992"#RMD $FISH_FILENAME\n"                                                     \ 
  • lib/vfs/mc-vfs/xdirentry.h

    diff -urN mc-4.7.5.5.orig/lib/vfs/mc-vfs/xdirentry.h mc-4.7.5.5/lib/vfs/mc-vfs/xdirentry.h
    old new  
    7272            int flags; 
    7373            char *scr_ls; 
    7474            char *scr_chmod; 
     75            char *scr_utime; 
    7576            char *scr_exists; 
    7677            char *scr_mkdir; 
    7778            char *scr_unlink;