X-Git-Url: https://git.saurik.com/ldid.git/blobdiff_plain/4d453c35ba48a83618c19c613100bd899266327f..ee5f55567bd457e4c721267a154b796dc679f458:/ldid.hpp diff --git a/ldid.hpp b/ldid.hpp index 576962d..b603bbd 100644 --- a/ldid.hpp +++ b/ldid.hpp @@ -3,8 +3,10 @@ #include #include +#include #include #include +#include namespace ldid { @@ -47,9 +49,10 @@ 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 Find(const std::string &path, const Functor &)> &)> &code) = 0; + virtual void Save(const std::string &path, const void *flag, const Functor &code) = 0; + virtual bool Look(const std::string &path) = 0; + virtual void Open(const std::string &path, const Functor &code) = 0; + virtual void Find(const std::string &path, const Functor &)> &)> &code, const Functor &)> &link) = 0; }; class DiskFolder : @@ -61,15 +64,16 @@ class DiskFolder : std::string Path(const std::string &path); - void Find(const std::string &root, const std::string &base, const Functor &)> &)>&code); + void Find(const std::string &root, const std::string &base, const Functor &)> &)> &code, const Functor &)> &link); 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); + virtual void Save(const std::string &path, const void *flag, const Functor &code); + virtual bool Look(const std::string &path); + virtual void Open(const std::string &path, const Functor &code); + virtual void Find(const std::string &path, const Functor &)> &)> &code, const Functor &)> &link); }; class SubFolder : @@ -82,9 +86,10 @@ 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 Find(const std::string &path, const Functor &)> &)> &code); + virtual void Save(const std::string &path, const void *flag, const Functor &code); + virtual bool Look(const std::string &path); + virtual void Open(const std::string &path, const Functor &code); + virtual void Find(const std::string &path, const Functor &)> &)> &code, const Functor &)> &link); }; class UnionFolder : @@ -105,25 +110,49 @@ class UnionFolder : }; Folder &parent_; - std::map files_; + 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 Functor &code); - virtual bool Open(const std::string &path, const Functor &code); - virtual void Find(const std::string &path, const Functor &)> &)> &code); + virtual void Save(const std::string &path, const void *flag, const Functor &code); + virtual bool Look(const std::string &path); + virtual void Open(const std::string &path, const Functor &code); + virtual void Find(const std::string &path, const Functor &)> &)> &code, const Functor &)> &link); + + 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 &path) { - return files_[path]; + 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); +struct Bundle { + std::string path; + std::vector hash; +}; + +Bundle Sign(const std::string &root, Folder &folder, const std::string &key, 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); +std::vector 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); }