X-Git-Url: https://git.saurik.com/ldid.git/blobdiff_plain/e6a376fc606bd28796dd1733af079d5a825c1b52..35229d065ce164cc3d8a3b37446f27c9d85deddc:/ldid.hpp diff --git a/ldid.hpp b/ldid.hpp index 331c4b0..40b1c8b 100644 --- a/ldid.hpp +++ b/ldid.hpp @@ -3,8 +3,10 @@ #include #include +#include #include #include +#include namespace ldid { @@ -45,9 +47,85 @@ FunctorImpl fun(const Function_ &value) { return value; } -typedef std::map Slots; +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 Find(const std::string &path, const Functor &)> &)> &code) = 0; +}; + +class DiskFolder : + public Folder +{ + private: + const std::string path_; + std::map commit_; + + std::string Path(const std::string &path); + + void Find(const std::string &root, const std::string &base, const Functor &)> &)>&code); + + public: + 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 Find(const std::string &path, const Functor &)> &)> &code); +}; + +class SubFolder : + public Folder +{ + private: + Folder &parent_; + std::string path_; + + 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 Find(const std::string &path, const Functor &)> &)> &code); +}; + +class UnionFolder : + public Folder +{ + private: + class StringBuffer : + public std::stringbuf + { + public: + StringBuffer() { + } + + StringBuffer(const StringBuffer &rhs) : + std::stringbuf(rhs.str()) + { + } + }; + + Folder &parent_; + std::map files_; + + public: + UnionFolder(Folder &parent); + + virtual void Save(const std::string &path, const Functor &code); + virtual bool Open(const std::string &path, const Functor &code); + virtual void Find(const std::string &path, const Functor &)> &)> &code); + + std::stringbuf &operator [](const std::string &path) { + return files_[path]; + } +}; + +std::string Bundle(const std::string &root, Folder &folder, const std::string &key, std::map> &remote, const std::string &entitlements); + +typedef std::map> Slots; -void Sign(void *idata, size_t isize, std::streambuf &output, const std::string &name, 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 &key, const Slots &slots); }