summaryrefslogtreecommitdiffstats
path: root/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
blob: a93f89bae83bc829d07a9d51e4ab5d6854859e39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*============================================================================
  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"

cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
  std::string const& filename):
    cmWIXSourceWriter(logger, filename)
{

}

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");
}

size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
  std::string const& programFilesFolderId,
  std::string const& installRootString)
{
  BeginElement("Directory");
  AddAttribute("Id", programFilesFolderId);

  std::vector<std::string> installRoot;

  cmSystemTools::SplitPath(installRootString.c_str(), installRoot);

  if(!installRoot.empty() && installRoot.back().empty())
    {
    installRoot.pop_back();
    }

  for(size_t i = 1; i < installRoot.size(); ++i)
    {
    BeginElement("Directory");

    if(i == installRoot.size() - 1)
      {
      AddAttribute("Id", "INSTALL_ROOT");
      }
    else
      {
      std::stringstream tmp;
      tmp << "INSTALL_PREFIX_" << i;
      AddAttribute("Id", tmp.str());
      }

    AddAttribute("Name", installRoot[i]);
  }

  return installRoot.size();
}

void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
{
  for(size_t i = 0; i < size; ++i)
    {
    EndElement("Directory");
    }
}