MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / load

Method load

rpcs3/util/bin_patch.cpp:166–669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164};
165
166bool patch_engine::load(patch_map& patches_map, const std::string& path, std::string content, bool importing, std::stringstream* log_messages)
167{
168 if (content.empty())
169 {
170 // Load patch file
171 fs::file file{path};
172
173 if (!file)
174 {
175 // Do nothing
176 return true;
177 }
178
179 content = file.to_string();
180 }
181
182 // Interpret yaml nodes
183 auto [root, error] = yaml_load(content);
184
185 if (!error.empty() || !root)
186 {
187 append_log_message(log_messages, "Fatal Error: Failed to load file!");
188 patch_log.fatal("Failed to load patch file %s:\n%s", path, error);
189 return false;
190 }
191
192 // Load patch config to determine which patches are enabled
193 patch_map patch_config;
194
195 if (!importing)
196 {
197 patch_config = load_config();
198 }
199
200 std::string version;
201
202 if (const auto version_node = root[patch_key::version])
203 {
204 version = version_node.Scalar();
205
206 if (version != patch_engine_version)
207 {
208 append_log_message(log_messages, fmt::format("Error: File version %s does not match patch engine target version %s (location: %s, file: %s)", version, patch_engine_version, get_yaml_node_location(version_node), path), &patch_log.error);
209 return false;
210 }
211
212 // We don't need the Version node in local memory anymore
213 root.remove(patch_key::version);
214 }
215 else
216 {
217 append_log_message(log_messages, fmt::format("Error: No '%s' entry found. Patch engine version = %s (file: %s)", patch_key::version, patch_engine_version, path), &patch_log.error);
218 return false;
219 }
220
221 bool is_valid = true;
222
223 // Go through each main key in the file

Callers

nothing calls this directly

Calls 14

yaml_loadFunction · 0.85
append_log_messageFunction · 0.85
get_yaml_node_locationFunction · 0.85
compare_versionsFunction · 0.85
push_backMethod · 0.80
formatFunction · 0.70
emptyMethod · 0.45
to_stringMethod · 0.45
removeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected