+void SubFolder::Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) {
+ return parent_.Find(path_ + path, code, link);
+}
+
+std::string UnionFolder::Map(const std::string &path) {
+ auto remap(remaps_.find(path));
+ if (remap == remaps_.end())
+ return path;
+ return remap->second;
+}
+
+void UnionFolder::Map(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code, const std::string &file, const Functor<void (const Functor<void (std::streambuf &, const void *)> &)> &save) {
+ if (file.size() >= path.size() && file.substr(0, path.size()) == path)
+ code(file.substr(path.size()), fun([&](const Functor<void (std::streambuf &, std::streambuf &)> &code) {
+ save(fun([&](std::streambuf &data, const void *flag) {
+ parent_.Save(file, flag, fun([&](std::streambuf &save) {
+ code(data, save);
+ }));
+ }));
+ }));
+}
+
+UnionFolder::UnionFolder(Folder &parent) :
+ parent_(parent)
+{
+}
+
+void UnionFolder::Save(const std::string &path, const void *flag, const Functor<void (std::streambuf &)> &code) {
+ return parent_.Save(Map(path), flag, code);
+}
+
+bool UnionFolder::Look(const std::string &path) {
+ auto file(resets_.find(path));
+ if (file != resets_.end())
+ return true;
+ return parent_.Look(Map(path));
+}
+
+void UnionFolder::Open(const std::string &path, const Functor<void (std::streambuf &, const void *)> &code) {
+ auto file(resets_.find(path));
+ if (file == resets_.end())
+ return parent_.Open(Map(path), code);
+ auto &entry(file->second);
+
+ auto &data(entry.first);
+ data.pubseekpos(0, std::ios::in);
+ code(data, entry.second);