From ab1bdc1429df72551e790bdbba11d57c93de62a4 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 2 May 2009 14:45:48 +0400 Subject: [PATCH] src/main.c (main): create MC home directory (~/.mc) if absent. --- src/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.c b/src/main.c index db4c1c805..7ed08e741 100644 --- a/src/main.c +++ b/src/main.c @@ -2125,6 +2125,9 @@ handle_args (int argc, char *argv[]) int main (int argc, char *argv[]) { + struct stat s; + char *mc_dir; + /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */ setlocale (LC_ALL, ""); bindtextdomain ("mc", LOCALEDIR); @@ -2192,6 +2195,16 @@ main (int argc, char *argv[]) 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 (); #ifdef HAVE_SUBSHELL_SUPPORT