X-Git-Url: https://git.saurik.com/ldid.git/blobdiff_plain/addc31c59c7f9c8eb3644fa7671ae1f9f2bffa31..043e30006254b050f5a5628bfaa84a0abf888e7a:/ldid.hpp diff --git a/ldid.hpp b/ldid.hpp index 13b69da..503ebc5 100644 --- a/ldid.hpp +++ b/ldid.hpp @@ -48,11 +48,16 @@ FunctorImpl fun(const Function_ &value) { return value; } +struct Progress { + virtual void operator()(const std::string &value) const = 0; + virtual void operator()(double value) const = 0; +}; + class Folder { public: virtual void Save(const std::string &path, bool edit, const void *flag, const Functor &code) = 0; virtual bool Look(const std::string &path) const = 0; - virtual void Open(const std::string &path, const Functor &code) const = 0; + virtual void Open(const std::string &path, const Functor &code) const = 0; virtual void Find(const std::string &path, const Functor &code, const Functor &)> &link) const = 0; }; @@ -63,8 +68,10 @@ class DiskFolder : const std::string path_; std::map commit_; + protected: std::string Path(const std::string &path) const; + private: void Find(const std::string &root, const std::string &base, const Functor &code, const Functor &)> &link) const; public: @@ -73,7 +80,7 @@ class DiskFolder : virtual void Save(const std::string &path, bool edit, const void *flag, const Functor &code); virtual bool Look(const std::string &path) const; - virtual void Open(const std::string &path, const Functor &code) const; + virtual void Open(const std::string &path, const Functor &code) const; virtual void Find(const std::string &path, const Functor &code, const Functor &)> &link) const; }; @@ -89,7 +96,7 @@ class SubFolder : virtual void Save(const std::string &path, bool edit, const void *flag, const Functor &code); virtual bool Look(const std::string &path) const; - virtual void Open(const std::string &path, const Functor &code) const; + virtual void Open(const std::string &path, const Functor &code) const; virtual void Find(const std::string &path, const Functor &code, const Functor &)> &link) const; }; @@ -97,34 +104,26 @@ class UnionFolder : public Folder { private: - class StringBuffer : - public std::stringbuf - { - public: - StringBuffer() { - } - - StringBuffer(const StringBuffer &rhs) : - std::stringbuf(rhs.str()) - { - } + struct Reset { + const void *flag_; + std::streambuf *data_; }; Folder &parent_; std::set deletes_; std::map remaps_; - mutable std::map> resets_; + mutable std::map resets_; std::string Map(const std::string &path) const; - void Map(const std::string &path, const Functor &code, const std::string &file, const Functor &)> &save) const; + void Map(const std::string &path, const Functor &code, const std::string &file, const Functor &)> &save) const; public: UnionFolder(Folder &parent); virtual void Save(const std::string &path, bool edit, const void *flag, const Functor &code); virtual bool Look(const std::string &path) const; - virtual void Open(const std::string &path, const Functor &code) const; + virtual void Open(const std::string &path, const Functor &code) const; virtual void Find(const std::string &path, const Functor &code, const Functor &)> &link) const; void operator ()(const std::string &from) { @@ -136,24 +135,29 @@ class UnionFolder : remaps_[to] = from; } - std::stringbuf &operator ()(const std::string &from, const void *flag) { + void operator ()(const std::string &from, const void *flag, std::streambuf &data) { operator ()(from); auto &reset(resets_[from]); - reset.second = flag; - return reset.first; + reset.flag_ = flag; + reset.data_ = &data; } }; +struct Hash { + uint8_t sha1_[0x14]; + uint8_t sha256_[0x20]; +}; + struct Bundle { std::string path; - std::vector hash; + Hash hash; }; -Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &requirement, const Functor &alter); +Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &requirements, const Functor &alter, const Progress &progress); -typedef std::map> Slots; +typedef std::map 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); +Hash Sign(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, const std::string &requirements, const std::string &key, const Slots &slots, uint32_t flags, bool platform, const Progress &progress); }