+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);
+}
+
+void UnionFolder::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) {
+ parent_.Find(path, fun([&](const std::string &name, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &save) {
+ if (deletes_.find(path + name) == deletes_.end())
+ code(name, save);
+ }), fun([&](const std::string &name, const Functor<std::string ()> &read) {
+ if (deletes_.find(path + name) == deletes_.end())
+ link(name, read);
+ }));
+
+ for (auto &reset : resets_)
+ Map(path, code, reset.first, fun([&](const Functor<void (std::streambuf &, const void *)> &code) {
+ auto &entry(reset.second);
+ entry.first.pubseekpos(0, std::ios::in);
+ code(entry.first, entry.second);
+ }));
+
+ for (auto &remap : remaps_)
+ Map(path, code, remap.first, fun([&](const Functor<void (std::streambuf &, const void *)> &code) {
+ parent_.Open(remap.second, fun([&](std::streambuf &data, const void *flag) {
+ code(data, flag);
+ }));
+ }));
+}
+
+#ifndef LDID_NOTOOLS