return Sign(data.data(), data.size(), proxy, identifier, entitlements, merge, requirements, key, slots, flags, platform, progress);
}
-Bundle Sign(const std::string &root, Folder &folder, const std::string &key, std::map<std::string, Hash> &remote, const std::string &requirements, const Functor<std::string (const std::string &, const std::string &)> &alter, const Progress &progress) {
+struct State {
+ std::map<std::string, Hash> files;
+ std::map<std::string, std::string> links;
+
+ void Merge(const std::string &root, const State &state) {
+ for (const auto &entry : state.files)
+ files[root + entry.first] = entry.second;
+ for (const auto &entry : state.links)
+ links[root + entry.first] = entry.second;
+ }
+};
+
+Bundle Sign(const std::string &root, Folder &folder, const std::string &key, State &remote, const std::string &requirements, const Functor<std::string (const std::string &, const std::string &)> &alter, const Progress &progress) {
std::string executable;
std::string identifier;
rules2.insert(Rule{20, NoMode, "^version\\.plist$"});
}
- std::map<std::string, Hash> local;
+ State local;
std::string failure(mac ? "Contents/|Versions/[^/]*/Resources/" : "");
Expression nested("^(Frameworks/[^/]*\\.framework|PlugIns/[^/]*\\.appex(()|/[^/]*.app))/(" + failure + ")Info\\.plist$");
return false;
});
- std::map<std::string, std::string> links;
-
folder.Find("", fun([&](const std::string &name) {
if (exclude(name))
return;
- if (local.find(name) != local.end())
+ if (local.files.find(name) != local.files.end())
return;
- auto &hash(local[name]);
+ auto &hash(local.files[name]);
folder.Open(name, fun([&](std::streambuf &data, size_t length, const void *flag) {
progress(root + name);
if (exclude(name))
return;
- links[name] = read();
+ local.links[name] = read();
}));
auto plist(plist_new_dict());
bool old(&version.second == &rules1);
- for (const auto &hash : local)
+ for (const auto &hash : local.files)
for (const auto &rule : version.second)
if (rule(hash.first)) {
if (!old && mac && excludes.find(hash.first) != excludes.end());
}
folder.Save(signature, true, NULL, fun([&](std::streambuf &save) {
- HashProxy proxy(local[signature], save);
+ HashProxy proxy(local.files[signature], save);
char *xml(NULL);
uint32_t size;
plist_to_xml(plist, &xml, &size);
progress(root + executable);
folder.Save(executable, true, flag, fun([&](std::streambuf &save) {
Slots slots;
- slots[1] = local.at(info);
- slots[3] = local.at(signature);
- bundle.hash = Sign(NULL, 0, buffer, local[executable], save, identifier, entitlements, false, requirements, key, slots, length, 0, false, Progression(progress, root + executable));
+ slots[1] = local.files.at(info);
+ slots[3] = local.files.at(signature);
+ bundle.hash = Sign(NULL, 0, buffer, local.files[executable], save, identifier, entitlements, false, requirements, key, slots, length, 0, false, Progression(progress, root + executable));
}));
}));
- for (const auto &entry : local)
- remote[root + entry.first] = entry.second;
-
+ remote.Merge(root, local);
return bundle;
}
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) {
- std::map<std::string, Hash> local;
+ State local;
return Sign(root, folder, key, local, requirements, alter, progress);
}
#endif