| 98 | } |
| 99 | |
| 100 | std::string save(const std::string& key, const std::string& domain) { |
| 101 | auto domainIt = storage.find(domain.empty() ? app::AppScripting::getFileName() : domain); |
| 102 | if (domainIt == storage.end()) return ""; |
| 103 | auto entryIt = domainIt->second.find(key); |
| 104 | if (entryIt == domainIt->second.end()) return ""; |
| 105 | try { |
| 106 | auto path = this->path(key, domain); |
| 107 | base::FileHandle handle(base::open_file_with_exception(path, "wb")); |
| 108 | auto str = entryIt->second.str(); |
| 109 | fwrite(str.c_str(), str.size(), 1, handle.get()); |
| 110 | return path; |
| 111 | } catch(...) { |
| 112 | return ""; |
| 113 | } |
| 114 | return ""; |
| 115 | } |
| 116 | |
| 117 | bool decodeBase64(const std::string& key, const std::string& domain) { |
| 118 | auto domainIt = storage.find(domain.empty() ? app::AppScripting::getFileName() : domain); |