void Manifest::parseVersion(const std::string& versionUrl) { loadJson(versionUrl); if (_json.IsObject()) { loadVersion(_json); } }
void WalletSerializerV1::load(const Crypto::chacha8_key& key, Common::IInputStream& source) { CryptoNote::BinaryInputStreamSerializer s(source); s.beginObject("wallet"); uint32_t version = loadVersion(source); if (version > SERIALIZATION_VERSION) { throw std::system_error(make_error_code(error::WRONG_VERSION)); } else if (version != 1) { loadWallet(source, key, version); } else { loadWalletV1(source, key); } s.endObject(); }
void WalletSerializer::load(const std::string& password, Common::IInputStream& source) { CryptoNote::BinaryInputStreamSerializer s(source); s.beginObject("wallet"); uint32_t version = loadVersion(source); if (version == SERIALIZATION_VERSION) { loadCurrentVersion(source, password); } else if (version == 1) { loadWalletV1(source, password); } else { throw std::system_error(make_error_code(error::WRONG_VERSION)); } s.endObject(); }
void Manifest::loadManifest(const rapidjson::Document &json) { loadVersion(json); // Retrieve package url if ( json.HasMember(KEY_PACKAGE_URL) && json[KEY_PACKAGE_URL].IsString() ) { _packageUrl = json[KEY_PACKAGE_URL].GetString(); // Append automatically "/" if (_packageUrl.size() > 0 && _packageUrl[_packageUrl.size() - 1] != '/') { _packageUrl.append("/"); } } // Retrieve all assets if ( json.HasMember(KEY_ASSETS) ) { const rapidjson::Value& assets = json[KEY_ASSETS]; if (assets.IsObject()) { for (rapidjson::Value::ConstMemberIterator itr = assets.MemberBegin(); itr != assets.MemberEnd(); ++itr) { std::string key = itr->name.GetString(); Asset asset = parseAsset(key, itr->value); _assets.emplace(key, asset); } } } // Retrieve all search paths if ( json.HasMember(KEY_SEARCH_PATHS) ) { const rapidjson::Value& paths = json[KEY_SEARCH_PATHS]; if (paths.IsArray()) { for (rapidjson::SizeType i = 0; i < paths.Size(); ++i) { if (paths[i].IsString()) { _searchPaths.push_back(paths[i].GetString()); } } } } _loaded = true; }
void ConfigFile::loadConfig() { loadVersion(); //Loads data depending on the file's version if (conf_file_ver >= 1) { loadProjects(); } else { //File may be invalid generateFile(); } //Updates the file if (conf_file_ver < CONFIG_FILE_VER) { updateFile(); } }
void ClientVersion::loadVersions() { // Clean up old stuff ClientVersion::unloadVersions(); // Locate the clients.xml file wxFileName file_to_load; wxFileName exec_dir_client_xml; exec_dir_client_xml.Assign(gui.GetExecDirectory()); exec_dir_client_xml.SetFullName(wxT("clients.xml")); wxFileName data_dir_client_xml; data_dir_client_xml.Assign(gui.GetDataDirectory()); data_dir_client_xml.SetFullName(wxT("clients.xml")); file_to_load = exec_dir_client_xml; if (!file_to_load.FileExists()) { file_to_load = data_dir_client_xml; if (!file_to_load.FileExists()) { file_to_load.Clear(); } } if (!file_to_load.FileExists()) { wxLogError(wxString() + wxT("Could not load clients.xml, editor will NOT be able to load any client data files.\n") + wxT("Checked paths:\n") + exec_dir_client_xml.GetFullPath() + "\n" + data_dir_client_xml.GetFullPath() ); return; } // Parse the file pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file(file_to_load.GetFullPath().mb_str()); if (result) { pugi::xml_node node = doc.child("client_config"); if (!node) { wxLogError(wxT("Could not load clients.xml (syntax error), editor will NOT be able to load any client data files.")); return; } for (pugi::xml_node childNode = node.first_child(); childNode; childNode = childNode.next_sibling()) { const std::string& childName = as_lower_str(childNode.name()); if (childName == "otbs") { for (pugi::xml_node otbNode = childNode.first_child(); otbNode; otbNode = otbNode.next_sibling()) { if (as_lower_str(otbNode.name()) == "otb") { loadOTBInfo(otbNode); } } } else if (childName == "clients") { for (pugi::xml_node versionNode = childNode.first_child(); versionNode; versionNode = versionNode.next_sibling()) { if (as_lower_str(versionNode.name()) == "client") { loadVersionExtensions(versionNode); } } } } for (pugi::xml_node childNode = node.first_child(); childNode; childNode = childNode.next_sibling()) { if (as_lower_str(childNode.name()) != "clients") { continue; } for (pugi::xml_node versionNode = childNode.first_child(); versionNode; versionNode = versionNode.next_sibling()) { if (as_lower_str(versionNode.name()) == "client") { loadVersion(versionNode); } } } } // Assign a default if there isn't one. if (!latest_version && !client_versions.empty()) { latest_version = client_versions.begin()->second; } // Load the data directory info try { json::mValue read_obj; json::read_or_throw(settings.getString(Config::TIBIA_DATA_DIRS), read_obj); json::mArray& vers_obj = read_obj.get_array(); for(json::mArray::iterator ver_iter = vers_obj.begin(); ver_iter != vers_obj.end(); ++ver_iter) { json::mObject& ver_obj = ver_iter->get_obj(); ClientVersion* version = get(ver_obj["id"].get_str()); if (version == nullptr) continue; version->setClientPath(wxstr(ver_obj["path"].get_str())); } } catch (std::runtime_error&) { // pass ; } }