21#ifndef G_SMTP_FILE_STORE_H
22#define G_SMTP_FILE_STORE_H
42 class DirectoryReader ;
58 G_EXCEPTION( InvalidDirectory ,
tx(
"invalid spool directory") )
59 G_EXCEPTION( EnvelopeReadError ,
tx(
"cannot read envelope file") )
60 G_EXCEPTION( GetError ,
tx(
"error getting message") )
70 std::size_t max_size {0U} ;
71 unsigned long seq {0UL} ;
72 Config & set_max_size( std::size_t ) noexcept ;
73 Config & set_seq(
unsigned long ) noexcept ;
78 static int & errno_() noexcept ;
81 static bool remove(
const G::Path & ) noexcept ;
82 static bool exists(
const G::Path & ) ;
83 static int fdopen(
const G::Path & ) ;
86 static bool copy(
const G::Path & ,
const G::Path & ,
bool hardlink ) ;
87 static bool mkdir(
const G::Path & ) ;
89 static std::ifstream & openIn( std::ifstream & ,
const G::Path & ) ;
90 static std::ofstream & openOut( std::ofstream & ,
const G::Path & ) ;
91 static std::ofstream & openAppend( std::ofstream & ,
const G::Path & ) ;
113 static std::unique_ptr<std::ofstream>
stream(
const G::Path & path ) ;
123 static std::string
x() ;
126 static std::string
format(
int generation = 0 ) ;
140 bool empty()
const override ;
141 std::string location(
const MessageId & )
const override ;
142 std::unique_ptr<StoredMessage> get(
const MessageId & )
override ;
143 std::unique_ptr<MessageStore::Iterator> iterator(
bool lock )
override ;
144 std::unique_ptr<NewMessage> newMessage(
const std::string & ,
const MessageStore::SmtpInfo & ,
const std::string & )
override ;
145 void updated()
override ;
147 G::Slot::Signal<> & messageStoreRescanSignal() noexcept override ;
150 void unfailAll() override ;
151 void rescan() override ;
161 static
void checkPath( const
G::Path & dir ) ;
162 static
void osinit() ;
163 G::Path fullPath( const
std::
string & filename ) const ;
164 std::
string getline(
std::istream & ) const ;
165 std::
string value( const
std::
string & ) const ;
166 static const
std::
string & crlf() ;
167 bool emptyCore() const ;
172 unsigned long m_seq ;
174 G::Path m_delivery_dir ;
176 G::Slot::Signal<> m_update_signal ;
177 G::Slot::Signal<> m_rescan_signal ;
246inline GStore::FileStore::Config & GStore::FileStore::Config::set_max_size( std::size_t n )
noexcept { max_size = n ;
return *this ; }
247inline GStore::FileStore::Config & GStore::FileStore::Config::set_seq(
unsigned long n )
noexcept { seq = n ;
return *this ; }
Used by GStore::FileStore, GStore::NewFile and GStore::StoredFile to claim read permissions for readi...
DirectoryReader()
Default constructor.
~DirectoryReader()
Destructor. Switches identity back.
A structure containing the contents of an envelope file, with support for file reading,...
Used by GStore::FileStore, GStore::NewFile and GStore::StoredFile to claim read permissions for readi...
FileReader()
Default constructor.
~FileReader()
Destructor. Switches identity back.
A concrete implementation of the MessageStore interface dealing in paired flat files.
G::Path deliveryDir() const
Returns the base directory for local delivery.
static std::string x()
Returns the prefix for envelope header lines.
FileStore(const G::Path &spool_dir, const G::Path &delivery_dir, const Config &config)
Constructor.
G::Path directory() const
Returns the spool directory path, as passed in to the constructor.
MessageId newId()
Hands out a new unique message id.
G::Path envelopePath(const MessageId &id, State=State::Normal) const
Returns the path for an envelope file.
static std::unique_ptr< std::ofstream > stream(const G::Path &path)
Opens an output stream to a message file using the appropriate effective userid and umask.
static Envelope readEnvelope(const G::Path &, std::ifstream *=nullptr)
Used by FileStore sibling classes to read an envelope file.
static std::string format(int generation=0)
Returns an identifier for the storage format implemented by this class, or some older generation of i...
G::Path contentPath(const MessageId &id) const
Returns the path for a content file.
static bool knownFormat(const std::string &format)
Returns true if the storage format string is recognised and supported for reading.
static G::Path defaultDirectory()
Returns a default spool directory, such as "/var/spool/emailrelay".
Used by GStore::FileStore, GStore::NewFile and GStore::StoredFile to claim write permissions.
~FileWriter()
Destructor. Switches identity back.
A somewhat opaque identifer for a GStore::MessageStore message id.
A class which allows SMTP messages to be stored and retrieved.
A Path object represents a file system path.
Used to temporarily modify the process umask.
A class which acquires the process's special privileges on construction and releases them on destruct...
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
Configuration structure for GStore::FileStore.
Low-level file-system operations for GStore::FileStore.
Information on the SMTP options used when submitted.
A slot holder, with connect() and emit() methods.