From: Richard Russon Date: Mon, 9 Jan 2017 00:53:31 +0000 (+0000) Subject: nntp: use mutt_mkdir X-Git-Tag: neomutt-20170128~14^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6800b2a;p=neomutt nntp: use mutt_mkdir Use mutt_mkdir() to recursively create the directories that NNTP needs. --- diff --git a/newsrc.c b/newsrc.c index 1cd2379f1..38fe9db5c 100644 --- a/newsrc.c +++ b/newsrc.c @@ -872,7 +872,6 @@ NNTP_SERVER *nntp_select_server (char *server, int leave_lock) char file[_POSIX_PATH_MAX]; char *p; int rc; - struct stat sb; ACCOUNT acct; NNTP_SERVER *nserv; NNTP_DATA *nntp_data; @@ -956,25 +955,10 @@ NNTP_SERVER *nntp_select_server (char *server, int leave_lock) if (rc >= 0 && NewsCacheDir && *NewsCacheDir) { cache_expand (file, sizeof (file), &conn->account, NULL); - p = *file == '/' ? file + 1 : file; - while (1) + if (mutt_mkdir (file, S_IRWXU) < 0) { - p = strchr (p, '/'); - if (p) - *p = '\0'; - if ((stat (file, &sb) || (sb.st_mode & S_IFDIR) == 0) && - mkdir (file, 0700)) - { - mutt_error (_("Can't create %s: %s."), file, strerror (errno)); - mutt_sleep (2); - break; - } - if (!p) - { - nserv->cacheable = 1; - break; - } - *p++ = '/'; + mutt_error (_("Can't create %s: %s."), file, strerror (errno)); + mutt_sleep (2); } }