message/flags: add flags_from_path

Borrow from mu-maildir, to which we cannot link.
This commit is contained in:
Dirk-Jan C. Binnema
2022-03-28 22:14:05 +03:00
parent 27ebfb3b3c
commit 9f062ae482
3 changed files with 99 additions and 3 deletions

View File

@ -278,7 +278,7 @@ flags_from_delta_expr(std::string_view expr, Flags flags,
* @return either messages flags or Nothing in case of error.
*/
constexpr Option<Flags>
flags_from_expr(std::string_view expr,
flags_from_expr(std::string_view expr,
Option<Flags> flags = Nothing)
{
if (expr.empty())
@ -291,6 +291,19 @@ flags_from_expr(std::string_view expr,
return flags_from_absolute_expr(expr, true);
}
/**
* Get the Maildir flags from the full path of a mailfile. The flags are as
* specified in http://cr.yp.to/proto/maildir.html, plus MU_MSG_FLAG_NEW for new
* messages, ie the ones that live in new/. The flags are logically OR'ed. Note
* that the file does not have to exist; the flags are based on the path only.
*
* @param pathname of a mailfile; it does not have to refer to an existing
* file/message
*
* @return the message flags or Nothing
*/
Option<Flags> flags_from_path(const std::string& path);
/**
* Filter out flags which are not in the given category
*