src/main.c (main): create MC home directory (~/.mc) if absent.

This commit is contained in:
Andrew Borodin 2009-05-02 14:45:48 +04:00
parent 3da14e7f8f
commit ab1bdc1429

View File

@ -2125,6 +2125,9 @@ handle_args (int argc, char *argv[])
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
struct stat s;
char *mc_dir;
/* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */ /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
bindtextdomain ("mc", LOCALEDIR); bindtextdomain ("mc", LOCALEDIR);
@ -2192,6 +2195,16 @@ main (int argc, char *argv[])
init_curses (); init_curses ();
/* create home directory */
/* do it after the screen library initialization to show the error message */
mc_dir = concat_dir_and_file (home_dir, MC_BASE);
canonicalize_pathname (mc_dir);
if ((stat (mc_dir, &s) != 0) && (errno == ENOENT)
&& mkdir (mc_dir, 0755) != 0)
message (D_ERROR, _("Warning"),
_("Cannot create %s directory"), mc_dir);
g_free (mc_dir);
init_xterm_support (); init_xterm_support ();
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef HAVE_SUBSHELL_SUPPORT