diff --git a/modules/os_save.cpp b/modules/os_save.cpp new file mode 100644 index 0000000..09206d8 --- /dev/null +++ b/modules/os_save.cpp @@ -0,0 +1,45 @@ +#include "module.h" + +class CommandOSSave : public Command +{ +public: + CommandOSSave(Module *creator) : Command(creator, "operserv/save", 0, 0) + { + this->SetDesc(_("Write all objects to the database.")); + } + + void Execute(CommandSource &source, const std::vector ¶ms) anope_override + { + Log(LOG_ADMIN, source, this); + source.Reply(_("Writing objects.")); + const std::list &items = Serializable::GetItems(); + for (std::list::const_iterator it = items.begin(), it_end = items.end(); it != it_end; it++) + { + (*it)->QueueUpdate(); + } + + source.Reply(_("%d writes queued."), items.size()); + return; + } + + bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + { + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Forces all changes to be written immediately.")); + return true; + } +}; + +class OSSave : public Module +{ + CommandOSSave commandossave; + +public: + OSSave(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, THIRD), + commandossave(this) + { + } +}; + +MODULE_INIT(OSSave)