MCPcopy Create free account
hub / github.com/Kitware/CMake / addOneComponentToArchive

Method addOneComponentToArchive

Source/CPack/cmCPackArchiveGenerator.cxx:324–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324int cmCPackArchiveGenerator::addOneComponentToArchive(
325 cmArchiveWrite& archive, cmCPackComponent* component,
326 Deduplicator* deduplicator)
327{
328 cmCPackLogger(cmCPackLog::LOG_VERBOSE,
329 " - packaging component: " << component->Name << std::endl);
330 // Add the files of this component to the archive
331 std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
332 localToplevel += "/" + this->GetSanitizedDirOrFileName(component->Name);
333 // Change to local toplevel
334 cmWorkingDirectory workdir(localToplevel);
335 if (workdir.Failed()) {
336 cmCPackLogger(cmCPackLog::LOG_ERROR, workdir.GetError() << std::endl);
337 return 0;
338 }
339 std::string filePrefix;
340 if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
341 filePrefix = cmStrCat(this->GetOption("CPACK_PACKAGE_FILE_NAME"), '/');
342 }
343 cmValue installPrefix = this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
344 if (installPrefix && installPrefix->size() > 1 &&
345 (*installPrefix)[0] == '/') {
346 // add to file prefix and remove the leading '/'
347 filePrefix += installPrefix->substr(1);
348 filePrefix += "/";
349 }
350 for (std::string const& file : component->Files) {
351 std::string rp = filePrefix + file;
352
353 DeduplicateStatus status = DeduplicateStatus::Add;
354 if (deduplicator) {
355 status = deduplicator->IsDeduplicate(rp, localToplevel);
356 }
357
358 if (!deduplicator || status == DeduplicateStatus::Add) {
359 cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file: " << rp << std::endl);
360 archive.Add(rp, 0, nullptr, false);
361 } else if (status == DeduplicateStatus::Error) {
362 cmCPackLogger(cmCPackLog::LOG_ERROR,
363 "ERROR The data in files with the "
364 "same filename is different.");
365 return 0;
366 } else {
367 cmCPackLogger(cmCPackLog::LOG_DEBUG,
368 "Passing file: " << rp << std::endl);
369 }
370
371 if (!archive) {
372 cmCPackLogger(cmCPackLog::LOG_ERROR,
373 "ERROR while packaging files: " << archive.GetError()
374 << std::endl);
375 return 0;
376 }
377 }
378 return 1;
379}
380
381/*

Callers 2

PackageComponentsMethod · 0.95

Calls 10

FailedMethod · 0.80
IsDeduplicateMethod · 0.80
cmStrCatFunction · 0.50
GetOptionMethod · 0.45
GetErrorMethod · 0.45
IsOnMethod · 0.45
sizeMethod · 0.45
substrMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected