MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / AddManifestFile

Method AddManifestFile

tools/rc/ResourceCompiler.cpp:467–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467void
468ZipArchive::AddManifestFile(rapidjson::Document const& manifest)
469{
470 // Check to make sure that the bundleName passed on the command line and the
471 // bundle.symbolic_name in the manifest file match. If the bundleName is not passed in on the
472 // command line, use the name specified in the manifest. If there's a mismatch or if no
473 // bundleName is supplied in either location, it's an error.
474 // RapidJSON has no .get(key, default) — check HasMember first, then access.
475 if (manifest.HasMember("bundle.symbolic_name"))
476 {
477 auto const& bname = manifest["bundle.symbolic_name"];
478 if (bname.IsString())
479 {
480 std::string bnameStr = bname.GetString();
481 if (!bundleName.empty())
482 {
483 if (bnameStr != bundleName)
484 {
485 throw std::runtime_error("Bundle name in manifest " + bnameStr
486 + " does not match value supplied on command line " + bundleName);
487 }
488 }
489 else
490 {
491 bundleName = bnameStr;
492 }
493 }
494 }
495 if (bundleName.empty())
496 {
497 throw std::runtime_error(
498 "Bundle name is required. Make sure that \"bundle.symbolic_name\" is set in the manifest.json file.");
499 }
500 std::string styledManifestJson(toStyledString(manifest));
501 std::string archiveEntry(bundleName + "/manifest.json");
502
503 // Issue 161.1: Check for file exists first and throw a more desriptive runtime error
504 CheckAndAddToArchivedNames(archiveEntry);
505
506 if (MZ_FALSE
507 == mz_zip_writer_add_mem(writeArchive.get(),
508 archiveEntry.c_str(),
509 styledManifestJson.c_str(),
510 styledManifestJson.size(),
511 compressionLevel))
512 {
513 throw std::runtime_error("Error writing manifest.json to archive " + fileName);
514 }
515 AddDirectory(bundleName + "/");
516}
517
518void
519ZipArchive::AddResourceFile(std::string const& resFileName, bool isManifest)

Callers 1

mainFunction · 0.80

Calls 5

toStyledStringFunction · 0.85
getMethod · 0.80
GetStringMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected