diff options
author | Carl Worth <cworth@cworth.org> | 2009-12-19 12:32:11 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-01-06 10:32:05 -0800 |
commit | ba12bf1f2625a34f960502a06ba8907445ef5257 (patch) | |
tree | c9a1bcafcf182044280916b01b0d7b67f3b931b0 /lib/message.cc | |
parent | 3a9c3ec9e719f0e5adefe0ceafffeb34c7a3917e (diff) |
lib: Abstract the extraction of a relative path from set_filename
We'll soon be having multiple entry points that accept a filename
path, so we want common code for getting a relative path from a
potentially absolute path.
Diffstat (limited to 'lib/message.cc')
-rw-r--r-- | lib/message.cc | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/lib/message.cc b/lib/message.cc index 49519f1e..7c7ea7a1 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -396,9 +396,7 @@ void _notmuch_message_set_filename (notmuch_message_t *message, const char *filename) { - const char *s; - const char *db_path; - unsigned int db_path_len; + const char *relative; if (message->filename) { talloc_free (message->filename); @@ -408,22 +406,8 @@ _notmuch_message_set_filename (notmuch_message_t *message, if (filename == NULL) INTERNAL_ERROR ("Message filename cannot be NULL."); - s = filename; - - db_path = notmuch_database_get_path (message->notmuch); - db_path_len = strlen (db_path); - - if (*s == '/' && strlen (s) > db_path_len - && strncmp (s, db_path, db_path_len) == 0) - { - s += db_path_len; - while (*s == '/') s++; - - if (!*s) - INTERNAL_ERROR ("Message filename was same as db prefix."); - } - - message->doc.set_data (s); + relative = _notmuch_database_relative_path (message->notmuch, filename); + message->doc.set_data (relative); } const char * |