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. */
}
}
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)) {
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);
}