14 // I wish Apple cared about providing quality toolchains :/
16 template <typename Function_>
19 template <typename Type_, typename... Args_>
20 class Functor<Type_ (Args_...)> {
22 virtual Type_ operator ()(Args_... args) const = 0;
25 template <typename Function_>
28 template <typename Value_, typename Type_, typename... Args_>
29 class FunctorImpl<Type_ (Value_::*)(Args_...) const> :
30 public Functor<Type_ (Args_...)>
36 FunctorImpl(const Value_ &value) :
41 virtual Type_ operator ()(Args_... args) const {
42 return (*value_)(args...);
46 template <typename Function_>
47 FunctorImpl<decltype(&Function_::operator())> fun(const Function_ &value) {
52 virtual void operator()(const std::string &value) const = 0;
53 virtual void operator()(double value) const = 0;
58 virtual void Save(const std::string &path, bool edit, const void *flag, const Functor<void (std::streambuf &)> &code) = 0;
59 virtual bool Look(const std::string &path) const = 0;
60 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, size_t, const void *)> &code) const = 0;
61 virtual void Find(const std::string &path, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const = 0;
68 const std::string path_;
69 std::map<std::string, std::string> commit_;
72 std::string Path(const std::string &path) const;
75 void Find(const std::string &root, const std::string &base, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const;
78 DiskFolder(const std::string &path);
81 virtual void Save(const std::string &path, bool edit, const void *flag, const Functor<void (std::streambuf &)> &code);
82 virtual bool Look(const std::string &path) const;
83 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, size_t, const void *)> &code) const;
84 virtual void Find(const std::string &path, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const;
95 SubFolder(Folder &parent, const std::string &path);
97 std::string Path(const std::string &path) const;
99 virtual void Save(const std::string &path, bool edit, const void *flag, const Functor<void (std::streambuf &)> &code);
100 virtual bool Look(const std::string &path) const;
101 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, size_t, const void *)> &code) const;
102 virtual void Find(const std::string &path, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const;
111 std::streambuf *data_;
115 std::set<std::string> deletes_;
117 std::map<std::string, std::string> remaps_;
118 mutable std::map<std::string, Reset> resets_;
120 std::string Map(const std::string &path) const;
121 void Map(const std::string &path, const Functor<void (const std::string &)> &code, const std::string &file, const Functor<void (const Functor<void (std::streambuf &, size_t, const void *)> &)> &save) const;
124 UnionFolder(Folder &parent);
126 virtual void Save(const std::string &path, bool edit, const void *flag, const Functor<void (std::streambuf &)> &code);
127 virtual bool Look(const std::string &path) const;
128 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, size_t, const void *)> &code) const;
129 virtual void Find(const std::string &path, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const;
131 void operator ()(const std::string &from) {
132 deletes_.insert(from);
135 void operator ()(const std::string &from, const std::string &to) {
140 void operator ()(const std::string &from, const void *flag, std::streambuf &data) {
142 auto &reset(resets_[from]);
150 uint8_t sha256_[0x20];
158 Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &requirements, const Functor<std::string (const std::string &, const std::string &)> &alter, const Progress &progress);
160 typedef std::map<uint32_t, Hash> Slots;
162 Hash Sign(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, bool merge, const std::string &requirements, const std::string &key, const Slots &slots, uint32_t flags, bool platform, const Progress &progress);