MCPcopy Create free account
hub / github.com/Norbyte/bg3se / UpdateManifest

Function UpdateManifest

UpdateSigner/UpdateSigner.cpp:20–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20int UpdateManifest(int argc, char** argv)
21{
22 if (argc != 9) {
23 std::cout << "Usage: UpdateSigner update-manifest <ManifestPath> <ResourceName> <PackagePath> <DllPath> <MinVersion> <MaxVersion> <RootURL>" << std::endl;
24 return 1;
25 }
26
27 auto manifestPath = FromStdUTF8(std::string(argv[2]));
28 auto resource = std::string(argv[3]);
29 auto packagePath = FromStdUTF8(std::string(argv[4]));
30 auto dllPath = FromStdUTF8(std::string(argv[5]));
31 auto minVersion = std::string(argv[6]);
32 auto maxVersion = std::string(argv[7]);
33 auto rootUrl = std::string(argv[8]);
34
35 std::string manifestStr;
36 if (!LoadFile(manifestPath, manifestStr)) {
37 std::cout << "Failed to open manifest: " << ToUTF8(manifestPath) << std::endl;
38 return 2;
39 }
40
41 ManifestSerializer parser;
42 Manifest manifest;
43 auto parseResult = parser.Parse(manifestStr, manifest);
44 if (!parseResult) {
45 std::cout << "Unable to parse manifest: " << parseResult.error().Message << std::endl;
46 return 3;
47 }
48
49 auto resIt = manifest.Resources.find(resource);
50 if (resIt == manifest.Resources.end()) {
51 std::cout << "Resource not found in manifest file: " << resource << std::endl;
52 return 4;
53 }
54
55 Manifest::ResourceVersion version;
56 if (!version.UpdatePackageMetadata(packagePath)) {
57 std::cout << "Failed to load package file for metadata generation: " << ToUTF8(packagePath) << std::endl;
58 return 5;
59 }
60
61 if (!version.UpdateDLLMetadata(dllPath)) {
62 std::cout << "Failed to load DLL file to check version number: " << ToUTF8(dllPath) << std::endl;
63 return 6;
64 }
65
66 if (!minVersion.empty() && minVersion != "-") {
67 auto minVer = VersionNumber::FromString(minVersion.c_str());
68 if (!minVer) {
69 std::cout << "Malformed version number: " << minVersion << std::endl;
70 return 1;
71 }
72
73 version.MinGameVersion = minVer;
74 } else {
75 version.MinGameVersion = {};
76 }
77

Callers 1

SignerMainFunction · 0.85

Calls 14

FromStdUTF8Function · 0.85
LoadFileFunction · 0.85
SaveFileFunction · 0.85
UpdatePackageMetadataMethod · 0.80
UpdateDLLMetadataMethod · 0.80
StringifyMethod · 0.80
ToUTF8Function · 0.50
ParseMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected