summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackDragNDropGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-07-26 19:40:26 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-07-30 22:33:07 (GMT)
commite1b70d7286d8a53b5046b1fb5e2b042333f5b736 (patch)
tree705fc3714be27fe74e47d80fa16d0ec1d83dd5bb /Source/CPack/cmCPackDragNDropGenerator.cxx
parentf5d04b5bf0c1b610ab80209f313996f050cd5979 (diff)
downloadCMake-e1b70d7286d8a53b5046b1fb5e2b042333f5b736.zip
CMake-e1b70d7286d8a53b5046b1fb5e2b042333f5b736.tar.gz
CMake-e1b70d7286d8a53b5046b1fb5e2b042333f5b736.tar.bz2
cmCPackDragNDropGenerator: use a string instead of a stream for commands
Diffstat (limited to 'Source/CPack/cmCPackDragNDropGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx97
1 files changed, 54 insertions, 43 deletions
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index 82f58a2..3beba64 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -243,18 +243,18 @@ bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target,
return true;
}
-bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
+bool cmCPackDragNDropGenerator::RunCommand(std::string const& command,
std::string* output)
{
int exit_code = 1;
bool result = cmSystemTools::RunSingleCommand(
- command.str(), output, output, &exit_code, nullptr, this->GeneratorVerbose,
+ command, output, output, &exit_code, nullptr, this->GeneratorVerbose,
cmDuration::zero());
if (!result || exit_code) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error executing: " << command.str() << std::endl);
+ "Error executing: " << command << std::endl);
return false;
}
@@ -412,15 +412,21 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/temp.dmg");
std::string create_error;
- std::ostringstream temp_image_command;
- temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
- temp_image_command << " create";
- temp_image_command << " -ov";
- temp_image_command << " -srcfolder \"" << staging.str() << "\"";
- temp_image_command << " -volname \"" << cpack_dmg_volume_name << "\"";
- temp_image_command << " -fs \"" << cpack_dmg_filesystem << "\"";
- temp_image_command << " -format " << temp_image_format;
- temp_image_command << " \"" << temp_image << "\"";
+ auto temp_image_command =
+ cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
+ " create"
+ " -ov"
+ " -srcfolder \"",
+ staging.str(),
+ "\""
+ " -volname \"",
+ cpack_dmg_volume_name,
+ "\""
+ " -fs \"",
+ cpack_dmg_filesystem,
+ "\""
+ " -format ",
+ temp_image_format, " \"", temp_image, "\"");
if (!this->RunCommand(temp_image_command, &create_error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -436,10 +442,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// before we exit.
bool had_error = false;
- std::ostringstream attach_command;
- attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
- attach_command << " attach";
- attach_command << " \"" << temp_image << "\"";
+ auto attach_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
+ " attach"
+ " \"",
+ temp_image, "\"");
std::string attach_output;
if (!this->RunCommand(attach_command, &attach_output)) {
@@ -468,10 +474,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Optionally set the custom icon flag for the image ...
if (!had_error && !cpack_package_icon->empty()) {
std::string error;
- std::ostringstream setfile_command;
- setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
- setfile_command << " -a C";
- setfile_command << " \"" << temp_mount << "\"";
+ auto setfile_command = cmStrCat(this->GetOption("CPACK_COMMAND_SETFILE"),
+ " -a C"
+ " \"",
+ temp_mount, "\"");
if (!this->RunCommand(setfile_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -486,10 +492,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Optionally we can execute a custom apple script to generate
// the .DS_Store for the volume folder ...
if (!had_error && !cpack_dmg_ds_store_setup_script->empty()) {
- std::ostringstream setup_script_command;
- setup_script_command << "osascript"
- << " \"" << cpack_dmg_ds_store_setup_script << "\""
- << " \"" << temp_mount_name << "\"";
+ auto setup_script_command = cmStrCat("osascript"
+ " \"",
+ cpack_dmg_ds_store_setup_script,
+ "\""
+ " \"",
+ temp_mount_name, "\"");
std::string error;
if (!this->RunCommand(setup_script_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -501,10 +509,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
}
}
- std::ostringstream detach_command;
- detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
- detach_command << " detach";
- detach_command << " \"" << temp_mount << "\"";
+ auto detach_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
+ " detach"
+ " \"",
+ temp_mount, '\"');
if (!this->RunCommand(detach_command)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -519,14 +527,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
}
// Create the final compressed read-only disk image ...
- std::ostringstream final_image_command;
- final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
- final_image_command << " convert \"" << temp_image << "\"";
- final_image_command << " -format ";
- final_image_command << cpack_dmg_format;
- final_image_command << " -imagekey";
- final_image_command << " zlib-level=9";
- final_image_command << " -o \"" << output_file << "\"";
+ auto final_image_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
+ " convert \"", temp_image,
+ "\""
+ " -format ",
+ cpack_dmg_format,
+ " -imagekey"
+ " zlib-level=9"
+ " -o \"",
+ output_file, "\"");
std::string convert_error;
@@ -667,13 +676,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
this->WriteRezXML(sla_xml, rez);
// Create the final compressed read-only disk image ...
- std::ostringstream embed_sla_command;
- embed_sla_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
- embed_sla_command << " udifrez";
- embed_sla_command << " -xml";
- embed_sla_command << " \"" << sla_xml << "\"";
- embed_sla_command << " FIXME_WHY_IS_THIS_ARGUMENT_NEEDED";
- embed_sla_command << " \"" << output_file << "\"";
+ auto embed_sla_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"),
+ " udifrez"
+ " -xml"
+ " \"",
+ sla_xml,
+ "\""
+ " FIXME_WHY_IS_THIS_ARGUMENT_NEEDED"
+ " \"",
+ output_file, "\"");
std::string embed_error;
if (!this->RunCommand(embed_sla_command, &embed_error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,