X-Git-Url: https://git.saurik.com/ldid.git/blobdiff_plain/2443500c8f002df2641e55c26a6a7882906a42da..476c5012c24d4d65a2d217f3f11d409c3bb090a8:/ldid.hpp?ds=inline diff --git a/ldid.hpp b/ldid.hpp index 4320bef..3ca939c 100644 --- a/ldid.hpp +++ b/ldid.hpp @@ -3,8 +3,10 @@ #include #include +#include #include #include +#include namespace ldid { @@ -47,8 +49,8 @@ FunctorImpl fun(const Function_ &value) { class Folder { public: - virtual void Save(const std::string &path, const Functor &code) = 0; - virtual bool Open(const std::string &path, const Functor &code) = 0; + virtual void Save(const std::string &path, const void *flag, const Functor &code) = 0; + virtual bool Open(const std::string &path, const Functor &code) = 0; virtual void Find(const std::string &path, const Functor &)> &)> &code) = 0; }; @@ -67,8 +69,8 @@ class DiskFolder : DiskFolder(const std::string &path); ~DiskFolder(); - virtual void Save(const std::string &path, const Functor &code); - virtual bool Open(const std::string &path, const Functor &code); + virtual void Save(const std::string &path, const void *flag, const Functor &code); + virtual bool Open(const std::string &path, const Functor &code); virtual void Find(const std::string &path, const Functor &)> &)> &code); }; @@ -82,16 +84,66 @@ class SubFolder : public: SubFolder(Folder &parent, const std::string &path); - virtual void Save(const std::string &path, const Functor &code); - virtual bool Open(const std::string &path, const Functor &code); + virtual void Save(const std::string &path, const void *flag, const Functor &code); + virtual bool Open(const std::string &path, const Functor &code); virtual void Find(const std::string &path, const Functor &)> &)> &code); }; -std::string Bundle(const std::string &root, Folder &folder, const std::string &key, std::map> &remote); +class UnionFolder : + public Folder +{ + private: + class StringBuffer : + public std::stringbuf + { + public: + StringBuffer() { + } + + StringBuffer(const StringBuffer &rhs) : + std::stringbuf(rhs.str()) + { + } + }; + + Folder &parent_; + std::set deletes_; + + std::map remaps_; + std::map> resets_; + + std::string Map(const std::string &path); + void Map(const std::string &path, const Functor &)> &)> &code, const std::string &file, const Functor &)> &save); + + public: + UnionFolder(Folder &parent); + + virtual void Save(const std::string &path, const void *flag, const Functor &code); + virtual bool Open(const std::string &path, const Functor &code); + virtual void Find(const std::string &path, const Functor &)> &)> &code); + + void operator ()(const std::string &from) { + deletes_.insert(from); + } + + void operator ()(const std::string &from, const std::string &to) { + operator ()(from); + remaps_[to] = from; + } + + std::stringbuf &operator ()(const std::string &from, const void *flag) { + operator ()(from); + auto &reset(resets_[from]); + reset.second = flag; + return reset.first; + } +}; + +std::string Bundle(const std::string &root, Folder &folder, const std::string &key, std::map> &remote, const std::string &entitlements, const std::string &requirement); typedef std::map> Slots; -void Sign(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, const std::string &key, const Slots &slots); +void Sign(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, const std::string &requirement, const std::string &key, const Slots &slots); }