| 380 | } |
| 381 | |
| 382 | bool 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 | |
| 429 | bool cmCPackPKGGenerator::CopyResourcePlistFile(std::string const& name, |
| 430 | char const* outName) |
no test coverage detected