2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2014-02-25 02:21:12 +04:00
|
|
|
#include "cmWIXDirectoriesSourceWriter.h"
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
|
2016-09-06 13:11:00 +03:00
|
|
|
cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
|
|
|
|
: cmWIXSourceWriter(logger, filename, componentGuidType)
|
2014-02-25 02:21:12 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
|
|
|
|
std::string const& startMenuFolder)
|
|
|
|
{
|
|
|
|
BeginElement("Directory");
|
|
|
|
AddAttribute("Id", "ProgramMenuFolder");
|
|
|
|
|
|
|
|
BeginElement("Directory");
|
|
|
|
AddAttribute("Id", "PROGRAM_MENU_FOLDER");
|
|
|
|
AddAttribute("Name", startMenuFolder);
|
|
|
|
EndElement("Directory");
|
|
|
|
|
|
|
|
EndElement("Directory");
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmWIXDirectoriesSourceWriter::EmitDesktopFolder()
|
|
|
|
{
|
|
|
|
BeginElement("Directory");
|
|
|
|
AddAttribute("Id", "DesktopFolder");
|
|
|
|
AddAttribute("Name", "Desktop");
|
|
|
|
EndElement("Directory");
|
|
|
|
}
|
|
|
|
|
2015-02-21 20:07:36 +03:00
|
|
|
void cmWIXDirectoriesSourceWriter::EmitStartupFolder()
|
|
|
|
{
|
|
|
|
BeginElement("Directory");
|
|
|
|
AddAttribute("Id", "StartupFolder");
|
|
|
|
AddAttribute("Name", "Startup");
|
|
|
|
EndElement("Directory");
|
|
|
|
}
|
|
|
|
|
2014-02-25 02:21:12 +04:00
|
|
|
size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
|
|
|
|
std::string const& programFilesFolderId,
|
|
|
|
std::string const& installRootString)
|
|
|
|
{
|
2016-07-20 16:32:38 +03:00
|
|
|
size_t offset = 1;
|
|
|
|
if (!programFilesFolderId.empty()) {
|
|
|
|
BeginElement("Directory");
|
|
|
|
AddAttribute("Id", programFilesFolderId);
|
|
|
|
offset = 0;
|
|
|
|
}
|
2014-02-25 02:21:12 +04:00
|
|
|
|
|
|
|
std::vector<std::string> installRoot;
|
|
|
|
|
|
|
|
cmSystemTools::SplitPath(installRootString.c_str(), installRoot);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!installRoot.empty() && installRoot.back().empty()) {
|
2014-02-25 02:21:12 +04:00
|
|
|
installRoot.pop_back();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-25 02:21:12 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 1; i < installRoot.size(); ++i) {
|
2014-02-25 02:21:12 +04:00
|
|
|
BeginElement("Directory");
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i == installRoot.size() - 1) {
|
2014-02-25 02:21:12 +04:00
|
|
|
AddAttribute("Id", "INSTALL_ROOT");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2016-06-14 23:37:36 +03:00
|
|
|
std::ostringstream tmp;
|
2014-02-25 02:21:12 +04:00
|
|
|
tmp << "INSTALL_PREFIX_" << i;
|
|
|
|
AddAttribute("Id", tmp.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-25 02:21:12 +04:00
|
|
|
|
|
|
|
AddAttribute("Name", installRoot[i]);
|
|
|
|
}
|
|
|
|
|
2016-07-20 16:32:38 +03:00
|
|
|
return installRoot.size() - offset;
|
2014-02-25 02:21:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 0; i < size; ++i) {
|
2014-02-25 02:21:12 +04:00
|
|
|
EndElement("Directory");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-25 02:21:12 +04:00
|
|
|
}
|