2014-02-25 02:21:12 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2014 Kitware, Inc.
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
|
|
|
|
#include "cmWIXDirectoriesSourceWriter.h"
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
|
|
|
|
cmCPackLog* logger, std::string const& filename)
|
|
|
|
: cmWIXSourceWriter(logger, filename)
|
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
|
|
|
}
|