X-Git-Url: https://git.saurik.com/ldid.git/blobdiff_plain/23c11ee8bcbc98bcaa3bc3682ab123f8a44d0b01..7c49f771048db99041e5544530282df07f4b0bae:/ldid.hpp?ds=sidebyside diff --git a/ldid.hpp b/ldid.hpp index 4ae4950..5b2efda 100644 --- a/ldid.hpp +++ b/ldid.hpp @@ -3,8 +3,10 @@ #include #include +#include #include #include +#include namespace ldid { @@ -61,6 +63,8 @@ class DiskFolder : 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(); @@ -74,17 +78,67 @@ class SubFolder : public Folder { private: - Folder *parent_; + Folder &parent_; std::string path_; public: - SubFolder(Folder *parent, const std::string &path); + 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::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); + + 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) { + operator ()(path); + return resets_[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(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, const std::string &key, const Slots &slots);