class

Maildir

Inherits Comparable / Reference / Object

Class for generating unique file names for new messages

Constants

DEFAULT_SERIALIZER = Maildir::Serializer::Base.new

Default serializer.

FOLDER_MARKER = "maildirfolder"
FOLDER_PREFIX = "."

Maildir++ folders live in the root maildir as sibling directories whose name is the folder name prefixed with a dot; nesting is expressed by joining the name components with a dot too (".Parent.Child"). Every folder also carries an empty "maildirfolder" file, so that other tools recognize it as a folder rather than as a maildir in its own right.

FOLDER_SEPARATOR = "."
SUBDIRS = {"tmp", "new", "cur"}
VERSION = "6.1.0"

Constructors

new(path, create = true)

Create a new maildir at +path+. If +create+ is true, will ensure that the required subdirectories exist.

Source

Class methods

fsync=(fsync : Bool)

Sets whether messages are fsynced before delivery. Turning this off trades the crash-safety guarantee above for throughput, which can be worth it on rotational or network storage when the data is reproducible anyway.

Source
fsync?

Returns true if messages are fsynced before delivery.

Source
maildir?(path) : Bool

Returns true if +path+ holds a maildir, i.e. has the tmp, new and cur subdirectories.

Source
serializer

Gets the default serializer.

Source
serializer=(serializer : Maildir::Serializer::Base)

Sets the default serializer.

Source

Instance methods

<=>(other : self)

Compare maildirs by their paths. Returns 1, 0, or -1.

Source
add(data)

Writes data object out as a new message. Returns a Maildir::Message. See Maildir::Message.create for more.

Source
create_directories

Ensure subdirectories exist. This can safely be called multiple times and from several processes at once, but must hit the disk. Avoid calling this if you're certain the directories exist.

Source
cur_path
Source
delete(key)

Deletes the message for key by calling destroy() on the message.

Source
folder(name : String, create = true) : Maildir

Returns the maildir for the named subfolder of this one, creating the directories of the whole chain unless +create+ is false. Names nest with a dot, so these two are the same folder: maildir.folder("a.x") maildir.folder("a").folder("x")

Source
folder?

Returns true if this maildir is a Maildir++ folder of another maildir: its directory name is dot-prefixed and it sits inside a maildir. The second condition is what keeps a root maildir which merely lives at a dot-path (say "~/.maildir") from being taken for a folder of its parent directory.

The answer is settled once, on first use, so a maildir doesn't change its mind halfway through if the surrounding directories change.

Source
folder_name

The Maildir++ name of this folder ("a", "a.x"), or nil for a root maildir.

Source
folders

Returns this maildir's immediate subfolders, sorted by path. Deeper descendants are reached by asking those folders in turn.

Source
get(key)

Returns a message object for key

Source
get_stale_tmp(time : Time = Time.utc - 36.hours)

Finds messages in the tmp folder that have not been modified since +time+. +time+ defaults to 36 hours ago.

Source
hash(hasher)

See Object#hash(hasher)

Source
inspect(io : IO) : Nil

Friendly inspect method

Source
list(dir : String, options = {} of Symbol => String | Int32 | ::Nil)

Returns an array of messages from the "new" or "cur" directory, sorted by key. If options[:flags] is specified and dir is "cur", returns only the messages carrying exactly those flags.

E.g. maildir.list("cur", {:flags => "F"}) # => lists all messages with flag "F" maildir.list("cur", {:flags => "FS"}) # => lists all messages with flags "F" and "S"; flags must be specified in ascending ASCII order ("FS" and not "SF") maildir.list("cur", {:flags => ""}) # => lists all messages without any flags This option does not work for the "new" directory

If options[:limit] is specified, returns only so many keys.

E.g. maildir.list("new") # => all new messages maildir.list("cur", {:limit => 10}) # => 10 oldest messages in cur

Source
new_path
Source
parent

The maildir this folder is nested in, or nil for a root maildir.

Source
path
Source
root

The root maildir this folder belongs to. Returns self if this maildir is already a root.

Source
serializer

Returns own serializer or falls back to the default one. Deliberately does not memoize, so that a later change of Maildir.serializer is picked up by maildirs which don't have a serializer of their own.

Source
serializer=(serializer : Maildir::Serializer::Base | Nil)
Source
tmp_path

define methods tmp_path, new_path, & cur_path

Source

Nested types