36 class StoreLockEntry ;
47 G_EXCEPTION( InvalidDirectory ,
"invalid spool directory" ) ;
49 Store(
const G::Path & spool_dir ,
bool by_name ,
bool allow_delete ) ;
66 void operator=(
const Store & ) = delete ;
67 void operator=(
Store && ) = delete ;
70 static void checkPath(
const G::Path & ,
bool ,
bool ) ;
71 static bool valid(
const G::Path & ,
bool ) ;
87 using Size =
unsigned long ;
90 StoreLockEntry(
int id_ , Size size_ ,
const std::string & uidl_ ) :
105 G_EXCEPTION( CannotDelete ,
"cannot delete message file" ) ;
106 G_EXCEPTION( CannotRead ,
"cannot read message file" ) ;
107 using Size = StoreLockEntry::Size ;
109 using List = std::list<Entry> ;
110 using Fn = void (*)(std::ostream &,
const std::string &) ;
117 void lock(
const std::string & user ) ;
138 std::string
uidl(
int id )
const ;
141 bool valid(
int id )
const ;
144 List
list(
int id = -1 )
const ;
147 std::unique_ptr<std::istream>
get(
int id )
const ;
167 StoreLockEntry::Size size ;
168 explicit File(
const G::Path & ) ;
169 File(
const std::string & name_ ,
const std::string & size_string ) ;
170 bool operator<(
const File & )
const ;
171 static StoreLockEntry::Size toSize(
const std::string & s ) ;
173 using Set = std::set<File> ;
178 void operator=(
const StoreLock & ) = delete ;
179 void operator=(
StoreLock && ) = delete ;
182 Set::iterator find(
const std::string & ) ;
183 Set::const_iterator find(
int id )
const ;
184 Set::iterator find(
int id ) ;
185 void doCommit(
Store & )
const ;
187 G::Path path(
const std::string & ,
bool fallback )
const ;
188 std::string envelopeName(
const std::string & )
const ;
189 std::string contentName(
const std::string & )
const ;
190 G::Path contentPath(
const std::string & )
const ;
191 G::Path contentPath(
const File & )
const ;
192 G::Path envelopePath(
const File & )
const ;
193 void deleteFile(
const G::Path & ,
bool & )
const ;
194 bool unlinked(
Store & ,
const File & )
const ;
Represents a file in the GPop::Store.
Represents an exclusive lock on the message store.
Size byteCount(int id) const
Returns a message size.
bool valid(int id) const
Validates a message number.
std::string uidl(int id) const
Returns a message's unique id.
std::unique_ptr< std::istream > get(int id) const
Retrieves the message content.
List list(int id=-1) const
Lists messages in the store.
void rollback()
Rolls back remove()als but retains the lock.
void commit()
Commits remove()als.
void lock(const std::string &user)
Initialisation.
StoreLock(Store &store)
Constructor.
Size messageCount() const
Returns the store's message count.
void remove(int)
Marks the message for removal.
Size totalByteCount() const
Returns the store's total byte count.
bool locked() const
Returns true if locked.
bool allowDelete() const
Returns true if files can be deleted.
bool byName() const
Returns true if the spool directory is affected by the user name.
G::Path dir() const
Returns the spool directory path.
Store(const G::Path &spool_dir, bool by_name, bool allow_delete)
Constructor.
A Path object represents a file system path.