]> granicus.if.org Git - neomutt/commitdiff
move realpath
authorRichard Russon <rich@flatcap.org>
Wed, 29 Aug 2018 16:58:41 +0000 (17:58 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 4 Sep 2018 00:14:16 +0000 (01:14 +0100)
12 files changed:
browser.c
commands.c
compress.c
context.h
curs_main.c
imap/browse.c
imap/imap.c
monitor.c
mx.c
pop/pop.c
sidebar.c
status.c

index f0ce3d76420f5290a3f50372878115744cfa88a8..f4989c1b058948b2f9dc4aaecc22ea2dc325ecae 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -885,7 +885,7 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
           break;
       }
 
-      if (np && Context && (mutt_str_strcmp(np->b->realpath, Context->realpath) == 0))
+      if (np && Context && (mutt_str_strcmp(np->b->realpath, Context->mailbox->realpath) == 0))
       {
         np->b->msg_count = Context->msgcount;
         np->b->msg_unread = Context->unread;
@@ -971,7 +971,7 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state)
     struct MailboxNode *np = NULL;
     STAILQ_FOREACH(np, &AllMailboxes, entries)
     {
-      if (Context && (mutt_str_strcmp(np->b->realpath, Context->realpath) == 0))
+      if (Context && (mutt_str_strcmp(np->b->realpath, Context->mailbox->realpath) == 0))
       {
         np->b->msg_count = Context->msgcount;
         np->b->msg_unread = Context->unread;
index 4ed8ab5df0512310e0ca40ac33ffe0335c04933c..5424eaa8798273c67e3b7af849c286612dcdcc03 100644 (file)
@@ -995,7 +995,9 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt)
      * until the next open.  Until then, improvise. */
     struct Mailbox *cm = NULL;
     if (savectx->compress_info)
-      cm = mutt_find_mailbox(savectx->realpath);
+    {
+      cm = mutt_find_mailbox(savectx->mailbox->realpath);
+    }
     /* We probably haven't been opened yet */
     if (cm && (cm->msg_count == 0))
       cm = NULL;
index 8dfd8f3d8f8082527093eed70cc06af8d398e602..e00446799e3571a01cd3ae07bdcebb32eddf080f 100644 (file)
@@ -42,6 +42,7 @@
 #include "format_flags.h"
 #include "globals.h"
 #include "hook.h"
+#include "mailbox.h"
 #include "mutt_curses.h"
 #include "muttlib.h"
 #include "mx.h"
@@ -95,12 +96,12 @@ static int lock_realpath(struct Context *ctx, int excl)
     return 1;
 
   if (excl)
-    ci->lockfp = fopen(ctx->realpath, "a");
+    ci->lockfp = fopen(ctx->mailbox->realpath, "a");
   else
-    ci->lockfp = fopen(ctx->realpath, "r");
+    ci->lockfp = fopen(ctx->mailbox->realpath, "r");
   if (!ci->lockfp)
   {
-    mutt_perror(ctx->realpath);
+    mutt_perror(ctx->mailbox->realpath);
     return 0;
   }
 
@@ -160,8 +161,8 @@ static int setup_paths(struct Context *ctx)
   char tmppath[PATH_MAX];
 
   /* Setup the right paths */
-  FREE(&ctx->realpath);
-  ctx->realpath = ctx->path;
+  FREE(&ctx->mailbox->realpath);
+  mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
 
   /* We will uncompress to /tmp */
   mutt_mktemp(tmppath, sizeof(tmppath));
@@ -208,7 +209,7 @@ static void store_size(const struct Context *ctx)
   if (!ci)
     return;
 
-  ci->size = get_size(ctx->realpath);
+  ci->size = get_size(ctx->mailbox->realpath);
 }
 
 /**
@@ -357,7 +358,7 @@ static const char *compress_format_str(char *buf, size_t buflen, size_t col, int
   {
     case 'f':
       /* Compressed file */
-      snprintf(buf, buflen, "%s", NONULL(escape_path(ctx->realpath)));
+      snprintf(buf, buflen, "%s", NONULL(escape_path(ctx->mailbox->realpath)));
       break;
     case 't':
       /* Plaintext, temporary file */
@@ -413,7 +414,9 @@ static int execute_command(struct Context *ctx, const char *command, const char
     return 0;
 
   if (!ctx->quiet)
-    mutt_message(progress, ctx->realpath);
+  {
+    mutt_message(progress, ctx->mailbox->realpath);
+  }
 
   mutt_sig_block();
   endwin();
@@ -530,7 +533,7 @@ static int comp_mbox_open_append(struct Context *ctx, int flags)
   }
 
   /* Open the existing mailbox, unless we are appending */
-  if (!ci->append && (get_size(ctx->realpath) > 0))
+  if (!ci->append && (get_size(ctx->mailbox->realpath) > 0))
   {
     int rc = execute_command(ctx, ci->open, _("Decompressing %s"));
     if (rc == 0)
@@ -602,7 +605,7 @@ static int comp_mbox_close(struct Context *ctx)
     /* If the file was removed, remove the compressed folder too */
     if ((access(ctx->path, F_OK) != 0) && !SaveEmpty)
     {
-      remove(ctx->realpath);
+      remove(ctx->mailbox->realpath);
     }
     else
     {
@@ -615,7 +618,7 @@ static int comp_mbox_close(struct Context *ctx)
     const char *msg = NULL;
 
     /* The file exists and we can append */
-    if ((access(ctx->realpath, F_OK) == 0) && ci->append)
+    if ((access(ctx->mailbox->realpath, F_OK) == 0) && ci->append)
     {
       append = ci->append;
       msg = _("Compressed-appending to %s...");
@@ -671,7 +674,7 @@ static int comp_mbox_check(struct Context *ctx, int *index_hint)
   if (!ops)
     return -1;
 
-  int size = get_size(ctx->realpath);
+  int size = get_size(ctx->mailbox->realpath);
   if (size == ci->size)
     return 0;
 
index 031f04ca7fb4d900f4e63c89cbbcd63c5cbdb9d5..29a7da7f9c713c8113cd75babb39b6e52e1bac66 100644 (file)
--- a/context.h
+++ b/context.h
@@ -54,7 +54,6 @@ enum AclRights
 struct Context
 {
   char *path;
-  char *realpath; /**< used for mailbox comparison and the sidebar */
   FILE *fp;
   struct timespec atime;
   struct timespec mtime;
index 8bec68a0d8a58edbe15f52ab25a76f5c6150f22c..f2ffbd601691fcb3dc12561138e51d42978802c4 100644 (file)
@@ -572,8 +572,8 @@ static int main_change_folder(struct Menu *menu, int op, char *buf,
     int monitor_remove_rc = mutt_monitor_remove(NULL);
 #endif
 #ifdef USE_COMPRESSED
-    if (Context->compress_info && Context->realpath)
-      new_last_folder = mutt_str_strdup(Context->realpath);
+    if (Context->compress_info && Context->mailbox->realpath)
+      new_last_folder = mutt_str_strdup(Context->mailbox->realpath);
     else
 #endif
       new_last_folder = mutt_str_strdup(Context->path);
index 495a8233913136963e27aaddc81d930e414ab28d..37ddeb3127621e5efd1d5cfb25b46eb5350d10c0 100644 (file)
@@ -122,7 +122,7 @@ static void add_folder(char delim, char *folder, bool noselect, bool noinferiors
 
   if (np)
   {
-    if (Context && (mutt_str_strcmp(np->b->realpath, Context->realpath) == 0))
+    if (Context && (mutt_str_strcmp(np->b->realpath, Context->mailbox->realpath) == 0))
     {
       np->b->msg_count = Context->msgcount;
       np->b->msg_unread = Context->unread;
index b11f6f40f082560c9f35ba0263209740fc0d973b..bc1220bb7fc89f7691b5381bb030fb7d1ffd770f 100644 (file)
@@ -2027,9 +2027,8 @@ static int imap_mbox_open(struct Context *ctx)
   imap_qualify_path(buf, sizeof(buf), &mx, idata->mailbox);
 
   FREE(&(ctx->path));
-  FREE(&(ctx->realpath));
   ctx->path = mutt_str_strdup(buf);
-  ctx->realpath = mutt_str_strdup(ctx->path);
+  mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
 
   idata->ctx = ctx;
 
index de43a866f0c034c89832e699563c751518e9525f..8d128926885cb6b8141f2859c8776095d512f663 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -295,7 +295,7 @@ static int monitor_resolve(struct MonitorInfo *info, struct Mailbox *mailbox)
   else if (Context)
   {
     info->magic = Context->magic;
-    info->path = Context->realpath;
+    info->path = Context->mailbox->realpath;
   }
   else
   {
@@ -495,7 +495,7 @@ int mutt_monitor_remove(struct Mailbox *mailbox)
     }
     else
     {
-      if (mutt_find_mailbox(Context->realpath))
+      if (mutt_find_mailbox(Context->mailbox->realpath))
         return 1;
     }
   }
diff --git a/mx.c b/mx.c
index a5d110dad0c72186ebf76c63587c5e88d9e69704..17143267373ffe8066f0a6fb8ddff88e7ac1df93 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -253,10 +253,6 @@ struct Context *mx_mbox_open(const char *path, int flags)
     FREE(&ctx);
     return NULL;
   }
-  ctx->realpath = realpath(ctx->path, NULL);
-  if (!ctx->realpath)
-    ctx->realpath = mutt_str_strdup(ctx->path);
-
   ctx->mailbox = mutt_find_mailbox(ctx->path);
   if (!ctx->mailbox)
   {
@@ -264,6 +260,9 @@ struct Context *mx_mbox_open(const char *path, int flags)
     ctx->mailbox->flags = MB_HIDDEN;
   }
 
+  if (!realpath(ctx->path, ctx->mailbox->realpath))
+    mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
+
   ctx->msgnotreadyet = -1;
   ctx->collapsed = false;
 
@@ -390,7 +389,6 @@ void mx_fastclose_mailbox(struct Context *ctx)
   FREE(&ctx->hdrs);
   FREE(&ctx->v2r);
   FREE(&ctx->path);
-  FREE(&ctx->realpath);
   FREE(&ctx->pattern);
   if (ctx->limit_pattern)
     mutt_pattern_free(&ctx->limit_pattern);
index 62fc18f7c319990c6f647f38c04b0ba5642e3a0c..a7b9841db07d78f51fb934b81895aa3efa3eeb97 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -46,6 +46,7 @@
 #include "bcache.h"
 #include "context.h"
 #include "globals.h"
+#include "mailbox.h"
 #include "mutt_account.h"
 #include "mutt_header.h"
 #include "mutt_logging.h"
@@ -501,9 +502,8 @@ static int pop_mbox_open(struct Context *ctx)
     return -1;
 
   FREE(&ctx->path);
-  FREE(&ctx->realpath);
   ctx->path = mutt_str_strdup(buf);
-  ctx->realpath = mutt_str_strdup(ctx->path);
+  mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
 
   pop_data = mutt_mem_calloc(1, sizeof(struct PopData));
   pop_data->conn = conn;
index 490fb61d6cbc9bc3623376630e2a9f5cceca4333..1ed5184697e1d4a74b2cbef9b5cb7b5d641d7e6a 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -139,7 +139,7 @@ static const char *sidebar_format_str(char *buf, size_t buflen, size_t col, int
   if (!b)
     return src;
 
-  int c = Context && (mutt_str_strcmp(Context->realpath, b->realpath) == 0);
+  int c = Context && (mutt_str_strcmp(Context->mailbox->realpath, b->realpath) == 0);
 
   optional = flags & MUTT_FORMAT_OPTIONAL;
 
@@ -384,7 +384,7 @@ static void update_entries_visibility(void)
       continue;
     }
 
-    if (Context && (mutt_str_strcmp(sbe->mailbox->realpath, Context->realpath) == 0))
+    if (Context && (mutt_str_strcmp(sbe->mailbox->realpath, Context->mailbox->realpath) == 0))
     {
       /* Spool directory */
       continue;
@@ -863,8 +863,8 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width)
       col = div_width;
 
     mutt_window_move(MuttSidebarWindow, row, col);
-    if (Context && Context->realpath &&
-        (mutt_str_strcmp(b->realpath, Context->realpath) == 0))
+    if (Context && Context->mailbox->realpath &&
+        (mutt_str_strcmp(b->realpath, Context->mailbox->realpath) == 0))
     {
 #ifdef USE_NOTMUCH
       if (b->magic == MUTT_NOTMUCH)
@@ -1077,7 +1077,7 @@ void mutt_sb_set_mailbox_stats(const struct Context *ctx)
   struct MailboxNode *np = NULL;
   STAILQ_FOREACH(np, &AllMailboxes, entries)
   {
-    if (mutt_str_strcmp(np->b->realpath, ctx->realpath) == 0)
+    if (mutt_str_strcmp(np->b->realpath, ctx->mailbox->realpath) == 0)
     {
       np->b->msg_unread = ctx->unread;
       np->b->msg_count = ctx->msgcount;
@@ -1119,7 +1119,7 @@ void mutt_sb_set_open_mailbox(void)
 
   for (int entry = 0; entry < EntryCount; entry++)
   {
-    if (mutt_str_strcmp(Entries[entry]->mailbox->realpath, Context->realpath) == 0)
+    if (mutt_str_strcmp(Entries[entry]->mailbox->realpath, Context->mailbox->realpath) == 0)
     {
       OpnIndex = entry;
       HilIndex = entry;
@@ -1161,7 +1161,7 @@ void mutt_sb_notify_mailbox(struct Mailbox *b, bool created)
       TopIndex = EntryCount;
     if (BotIndex < 0)
       BotIndex = EntryCount;
-    if ((OpnIndex < 0) && Context && (mutt_str_strcmp(b->realpath, Context->realpath) == 0))
+    if ((OpnIndex < 0) && Context && (mutt_str_strcmp(b->realpath, Context->mailbox->realpath) == 0))
       OpnIndex = EntryCount;
 
     EntryCount++;
index a4c3d2bc553e7ae2e6edc66280077b0e1423010f..4e0c353d130b171b0d6241c967d09ed05455bfee 100644 (file)
--- a/status.c
+++ b/status.c
@@ -130,9 +130,9 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
       else
 #endif
 #ifdef USE_COMPRESSED
-          if (Context && Context->compress_info && Context->realpath)
+          if (Context && Context->compress_info && Context->mailbox->realpath)
       {
-        mutt_str_strfcpy(tmp, Context->realpath, sizeof(tmp));
+        mutt_str_strfcpy(tmp, Context->mailbox->realpath, sizeof(tmp));
         mutt_pretty_mailbox(tmp, sizeof(tmp));
       }
       else