X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mx%2Fmx.c;h=38edb8ac5a01cc5ac909f4854e68af28e1df5f8f;hp=b41a079cc802acbcec484a2971401240d9d9b0be;hb=1d76b29d79137330c8f42d489fe3f67a23f2390b;hpb=07066d3ea19865d08c4a8fd98b5e87eeace810da diff --git a/lib-mx/mx.c b/lib-mx/mx.c index b41a079..38edb8a 100644 --- a/lib-mx/mx.c +++ b/lib-mx/mx.c @@ -157,23 +157,6 @@ int mx_is_local (int m) { return (mxfmts[m]->local); } -/* - * set DefaultMagic to the given value - */ -int mx_set_magic (const char *s) -{ - if (ascii_strcasecmp (s, "mbox") == 0) - DefaultMagic = M_MBOX; - else if (ascii_strcasecmp (s, "mh") == 0) - DefaultMagic = M_MH; - else if (ascii_strcasecmp (s, "maildir") == 0) - DefaultMagic = M_MAILDIR; - else - return (-1); - - return 0; -} - /* mx_access: Wrapper for access, checks permissions on a given mailbox. * We may be interested in using ACL-style flags at some point, currently * we use the normal access() flags. */ @@ -212,9 +195,8 @@ static int mx_open_mailbox_append (CONTEXT * ctx, int flags) } } else if (errno == ENOENT) { - ctx->magic = DefaultMagic; - - if (ctx->magic == M_MH || ctx->magic == M_MAILDIR) { + int len = m_strlen(ctx->path); + if (len > 0 && ctx->path[len - 1] == '/') { char tmp[_POSIX_PATH_MAX]; if (mkdir (ctx->path, S_IRWXU)) { @@ -222,47 +204,36 @@ static int mx_open_mailbox_append (CONTEXT * ctx, int flags) return (-1); } - if (ctx->magic == M_MAILDIR) { - snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); - if (mkdir (tmp, S_IRWXU)) { - mutt_perror (tmp); - rmdir (ctx->path); - return (-1); - } - - snprintf (tmp, sizeof (tmp), "%s/new", ctx->path); - if (mkdir (tmp, S_IRWXU)) { - mutt_perror (tmp); - snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); - rmdir (tmp); - rmdir (ctx->path); - return (-1); - } - snprintf (tmp, sizeof (tmp), "%s/tmp", ctx->path); - if (mkdir (tmp, S_IRWXU)) { - mutt_perror (tmp); - snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); - rmdir (tmp); - snprintf (tmp, sizeof (tmp), "%s/new", ctx->path); - rmdir (tmp); - rmdir (ctx->path); - return (-1); - } + snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); + if (mkdir (tmp, S_IRWXU)) { + mutt_perror (tmp); + rmdir (ctx->path); + return (-1); } - else { - int i; - snprintf (tmp, sizeof (tmp), "%s/.mh_sequences", ctx->path); - if ((i = creat (tmp, S_IRWXU)) == -1) { - mutt_perror (tmp); - rmdir (ctx->path); - return (-1); - } - close (i); + snprintf (tmp, sizeof (tmp), "%s/new", ctx->path); + if (mkdir (tmp, S_IRWXU)) { + mutt_perror (tmp); + snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); + rmdir (tmp); + rmdir (ctx->path); + return (-1); } + snprintf (tmp, sizeof (tmp), "%s/tmp", ctx->path); + if (mkdir (tmp, S_IRWXU)) { + mutt_perror (tmp); + snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); + rmdir (tmp); + snprintf (tmp, sizeof (tmp), "%s/new", ctx->path); + rmdir (tmp); + rmdir (ctx->path); + return (-1); + } + ctx->magic = M_MAILDIR; + } else { + ctx->magic = M_MBOX; } - } - else { + } else { mutt_perror (ctx->path); return (-1); }