Ticket #3093: mc-4.8.10-initial-dir-from-PWD.patch

File mc-4.8.10-initial-dir-from-PWD.patch, 3.3 KB (added by egmont, 11 years ago)

Patch that implements this feature

  • lib/vfs/vfs.c

    diff -urp mc-4.8.10.orig/lib/vfs/vfs.c mc-4.8.10/lib/vfs/vfs.c
    old new  
    4444#include <config.h> 
    4545 
    4646#include <errno.h> 
     47#include <stdlib.h> 
    4748 
    4849#include "lib/global.h" 
    4950#include "lib/strutil.h" 
    vfs_setup_cwd (void) 
    538539    if (vfs_get_raw_current_dir () == NULL) 
    539540    { 
    540541        char *tmp; 
     542        vfs_path_t *tmp_vpath; 
    541543 
    542544        tmp = g_get_current_dir (); 
    543545        vfs_set_raw_current_dir (vfs_path_from_str (tmp)); 
    544546        g_free (tmp); 
     547 
     548        tmp = getenv ("PWD"); 
     549        tmp_vpath = vfs_path_from_str (tmp); 
     550        if (tmp_vpath != NULL) 
     551        { 
     552            struct stat my_stat, my_stat2; 
     553            if (mc_global.vfs.cd_symlinks 
     554                  && mc_stat (tmp_vpath, &my_stat) == 0 
     555                  && mc_stat (vfs_get_raw_current_dir (), &my_stat2) == 0 
     556                  && my_stat.st_ino == my_stat2.st_ino && my_stat.st_dev == my_stat2.st_dev) 
     557                vfs_set_raw_current_dir (tmp_vpath); 
     558            else 
     559                vfs_path_free (tmp_vpath); 
     560        } 
    545561    } 
    546562 
    547563    path_element = vfs_path_get_by_index (vfs_get_raw_current_dir (), -1); 
  • src/main.c

    diff -urp mc-4.8.10.orig/src/main.c mc-4.8.10/src/main.c
    old new main (int argc, char *argv[]) 
    293293 
    294294    vfs_init (); 
    295295    vfs_plugins_init (); 
    296     vfs_setup_work_dir (); 
    297296 
    298297    /* Set up temporary directory after VFS initialization */ 
    299298    mc_tmpdir (); 
    main (int argc, char *argv[]) 
    341340 
    342341    load_setup (); 
    343342 
     343    /* Must be done after load_setup because depends on mc_global.vfs.cd_symlinks */ 
     344    vfs_setup_work_dir (); 
     345 
     346    /* Resolve the other_dir panel option. Must be done after vfs_setup_work_dir */ 
     347    { 
     348        char *buffer; 
     349        vfs_path_t *vpath; 
     350 
     351        buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", "."); 
     352        vpath = vfs_path_from_str (buffer); 
     353        if (vfs_file_is_local (vpath)) 
     354            saved_other_dir = buffer; 
     355        else 
     356            g_free (buffer); 
     357        vfs_path_free (vpath); 
     358    } 
     359 
    344360    /* start check mc_global.display_codepage and mc_global.source_codepage */ 
    345361    check_codeset (); 
    346362 
  • src/setup.c

    diff -urp mc-4.8.10.orig/src/setup.c mc-4.8.10/src/setup.c
    old new  
    4343#include "lib/util.h" 
    4444#include "lib/widget.h" 
    4545 
    46 #include "lib/vfs/vfs.h" 
    47  
    4846#ifdef ENABLE_VFS_FTP 
    4947#include "src/vfs/ftpfs/ftpfs.h" 
    5048#endif 
    load_setup (void) 
    989987    if (startup_left_mode != view_listing && startup_right_mode != view_listing) 
    990988        startup_left_mode = view_listing; 
    991989 
    992     { 
    993         vfs_path_t *vpath; 
    994  
    995         buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", "."); 
    996         vpath = vfs_path_from_str (buffer); 
    997         if (vfs_file_is_local (vpath)) 
    998             saved_other_dir = buffer; 
    999         else 
    1000             g_free (buffer); 
    1001         vfs_path_free (vpath); 
    1002     } 
    1003  
    1004990    boot_current_is_left = mc_config_get_bool (mc_panels_config, "Dirs", "current_is_left", TRUE); 
    1005991 
    1006992    /* Load time formats */