diff options
author | Carl Worth <cworth@cworth.org> | 2010-11-11 00:07:24 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-11-11 03:40:19 -0800 |
commit | 1d02dd64afe245a2b5a8461feeba975e61f0c233 (patch) | |
tree | 53ac99ecf481c27709e2d0f26b9c7d8d6d246b02 /lib/directory.cc | |
parent | d87db8843266caf6b11c1f2f1874328830b23878 (diff) |
lib: Add new, public notmuch_message_get_filenames
This augments the existing notmuch_message_get_filename by allowing
the caller access to all filenames in the case of multiple files for a
single message.
To support this, we split the iterator (notmuch_filenames_t) away from
the list storage (notmuch_filename_list_t) where previously these were
a single object (notmuch_filenames_t). Then, whenever the user asks
for a file or filename, the message object lazily creates a complete
notmuch_filename_list_t and then:
For notmuch_message_get_filename, returns the first filename
in the list.
For notmuch_message_get_filenames, creates and returns a new
iterator for the filename list.
Diffstat (limited to 'lib/directory.cc')
-rw-r--r-- | lib/directory.cc | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/directory.cc b/lib/directory.cc index 16492c0d..946be4f4 100644 --- a/lib/directory.cc +++ b/lib/directory.cc @@ -33,12 +33,12 @@ _create_filenames_for_terms_with_prefix (void *ctx, notmuch_database_t *notmuch, const char *prefix) { - notmuch_filenames_t *filenames; + notmuch_filename_list_t *filename_list; Xapian::TermIterator i, end; int prefix_len = strlen (prefix); - filenames = _notmuch_filenames_create (ctx); - if (unlikely (filenames == NULL)) + filename_list = _notmuch_filename_list_create (ctx); + if (unlikely (filename_list == NULL)) return NULL; end = notmuch->xapian_db->allterms_end (prefix); @@ -47,13 +47,11 @@ _create_filenames_for_terms_with_prefix (void *ctx, { std::string term = *i; - _notmuch_filenames_add_filename (filenames, term.c_str () + - prefix_len); + _notmuch_filename_list_add_filename (filename_list, term.c_str () + + prefix_len); } - _notmuch_filenames_move_to_first (filenames); - - return filenames; + return _notmuch_filenames_create (ctx, filename_list); } struct _notmuch_directory { |