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

Method CopyCreateResourceFile

Source/CPack/cmCPackPKGGenerator.cxx:382–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382bool cmCPackPKGGenerator::CopyCreateResourceFile(std::string const& name,
383 std::string const& dirName)
384{
385 std::string uname = cmSystemTools::UpperCase(name);
386 std::string cpackVar = cmStrCat("CPACK_RESOURCE_FILE_", uname);
387 cmValue inFileName = this->GetOption(cpackVar);
388 if (!inFileName) {
389 cmCPackLogger(cmCPackLog::LOG_ERROR,
390 "CPack option: "
391 << cpackVar << " not specified. It should point to "
392 << (!name.empty() ? name : "<empty>") << ".rtf, " << name
393 << ".html, or " << name << ".txt file" << std::endl);
394 return false;
395 }
396 if (!cmSystemTools::FileExists(inFileName)) {
397 cmCPackLogger(cmCPackLog::LOG_ERROR,
398 "Cannot find " << (!name.empty() ? name : "<empty>")
399 << " resource file: " << inFileName
400 << std::endl);
401 return false;
402 }
403 std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
404 if (ext != ".rtfd"_s && ext != ".rtf"_s && ext != ".html"_s &&
405 ext != ".txt"_s) {
406 cmCPackLogger(
407 cmCPackLog::LOG_ERROR,
408 "Bad file extension specified: "
409 << ext
410 << ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
411 << std::endl);
412 return false;
413 }
414
415 std::string destFileName = cmStrCat(dirName, '/', name, ext);
416
417 // Set this so that distribution.dist gets the right name (without
418 // the path).
419 this->SetOption(cmStrCat("CPACK_RESOURCE_FILE_", uname, "_NOPATH"),
420 cmStrCat(name, ext));
421
422 cmCPackLogger(cmCPackLog::LOG_VERBOSE,
423 "Configure file: " << (inFileName ? *inFileName : "(NULL)")
424 << " to " << destFileName << std::endl);
425 this->ConfigureFile(inFileName, destFileName);
426 return true;
427}
428
429bool cmCPackPKGGenerator::CopyResourcePlistFile(std::string const& name,
430 char const* outName)

Callers 1

PackageFilesMethod · 0.80

Calls 6

cmStrCatFunction · 0.50
FileExistsFunction · 0.50
GetOptionMethod · 0.45
emptyMethod · 0.45
SetOptionMethod · 0.45
ConfigureFileMethod · 0.45

Tested by

no test coverage detected