]> git.notmuchmail.org Git - notmuch/commitdiff
lib: Move _filename_is_in_maildir
authorAustin Clements <amdragon@MIT.EDU>
Sat, 9 Jun 2012 19:14:15 +0000 (15:14 -0400)
committerDavid Bremner <bremner@debian.org>
Sun, 10 Jun 2012 23:13:45 +0000 (20:13 -0300)
This way notmuch_message_maildir_flags_to_tags can call it.  It makes
more sense for this to be just above all of the maildir
synchronization code rather than mixed in the middle.

lib/message.cc

index 67875065f5c93f01edbad2387172d3767be59364..ed96477f98b7773d6905dd5325fe3d38ec28de3d 100644 (file)
@@ -1027,6 +1027,47 @@ notmuch_message_remove_tag (notmuch_message_t *message, const char *tag)
     return NOTMUCH_STATUS_SUCCESS;
 }
 
     return NOTMUCH_STATUS_SUCCESS;
 }
 
+/* Is the given filename within a maildir directory?
+ *
+ * Specifically, is the final directory component of 'filename' either
+ * "cur" or "new". If so, return a pointer to that final directory
+ * component within 'filename'. If not, return NULL.
+ *
+ * A non-NULL return value is guaranteed to be a valid string pointer
+ * pointing to the characters "new/" or "cur/", (but not
+ * NUL-terminated).
+ */
+static const char *
+_filename_is_in_maildir (const char *filename)
+{
+    const char *slash, *dir = NULL;
+
+    /* Find the last '/' separating directory from filename. */
+    slash = strrchr (filename, '/');
+    if (slash == NULL)
+       return NULL;
+
+    /* Jump back 4 characters to where the previous '/' will be if the
+     * directory is named "cur" or "new". */
+    if (slash - filename < 4)
+       return NULL;
+
+    slash -= 4;
+
+    if (*slash != '/')
+       return NULL;
+
+    dir = slash + 1;
+
+    if (STRNCMP_LITERAL (dir, "cur/") == 0 ||
+       STRNCMP_LITERAL (dir, "new/") == 0)
+    {
+       return dir;
+    }
+
+    return NULL;
+}
+
 notmuch_status_t
 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
 {
 notmuch_status_t
 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
 {
@@ -1083,47 +1124,6 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
     return status;
 }
 
     return status;
 }
 
-/* Is the given filename within a maildir directory?
- *
- * Specifically, is the final directory component of 'filename' either
- * "cur" or "new". If so, return a pointer to that final directory
- * component within 'filename'. If not, return NULL.
- *
- * A non-NULL return value is guaranteed to be a valid string pointer
- * pointing to the characters "new/" or "cur/", (but not
- * NUL-terminated).
- */
-static const char *
-_filename_is_in_maildir (const char *filename)
-{
-    const char *slash, *dir = NULL;
-
-    /* Find the last '/' separating directory from filename. */
-    slash = strrchr (filename, '/');
-    if (slash == NULL)
-       return NULL;
-
-    /* Jump back 4 characters to where the previous '/' will be if the
-     * directory is named "cur" or "new". */
-    if (slash - filename < 4)
-       return NULL;
-
-    slash -= 4;
-
-    if (*slash != '/')
-       return NULL;
-
-    dir = slash + 1;
-
-    if (STRNCMP_LITERAL (dir, "cur/") == 0 ||
-       STRNCMP_LITERAL (dir, "new/") == 0)
-    {
-       return dir;
-    }
-
-    return NULL;
-}
-
 /* From the set of tags on 'message' and the flag2tag table, compute a
  * set of maildir-flag actions to be taken, (flags that should be
  * either set or cleared).
 /* From the set of tags on 'message' and the flag2tag table, compute a
  * set of maildir-flag actions to be taken, (flags that should be
  * either set or cleared).