summaryrefslogtreecommitdiffstats
path: root/Source/CPack/WiX/cmWIXAccessControlList.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CPack/WiX/cmWIXAccessControlList.cxx')
-rw-r--r--Source/CPack/WiX/cmWIXAccessControlList.cxx76
1 files changed, 31 insertions, 45 deletions
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx
index 16a71e0..043cdff 100644
--- a/Source/CPack/WiX/cmWIXAccessControlList.cxx
+++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx
@@ -17,14 +17,12 @@
#include <cmSystemTools.h>
cmWIXAccessControlList::cmWIXAccessControlList(
- cmCPackLog *logger,
- cmInstalledFile const& installedFile,
- cmWIXSourceWriter &sourceWriter):
- Logger(logger),
- InstalledFile(installedFile),
- SourceWriter(sourceWriter)
+ cmCPackLog* logger, cmInstalledFile const& installedFile,
+ cmWIXSourceWriter& sourceWriter)
+ : Logger(logger)
+ , InstalledFile(installedFile)
+ , SourceWriter(sourceWriter)
{
-
}
bool cmWIXAccessControlList::Apply()
@@ -32,23 +30,20 @@ bool cmWIXAccessControlList::Apply()
std::vector<std::string> entries;
this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries);
- for(size_t i = 0; i < entries.size(); ++i)
- {
+ for (size_t i = 0; i < entries.size(); ++i) {
this->CreatePermissionElement(entries[i]);
- }
+ }
return true;
}
-void cmWIXAccessControlList::CreatePermissionElement(
- std::string const& entry)
+void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry)
{
std::string::size_type pos = entry.find('=');
- if(pos == std::string::npos)
- {
+ if (pos == std::string::npos) {
this->ReportError(entry, "Did not find mandatory '='");
return;
- }
+ }
std::string user_and_domain = entry.substr(0, pos);
std::string permission_string = entry.substr(pos + 1);
@@ -56,46 +51,38 @@ void cmWIXAccessControlList::CreatePermissionElement(
pos = user_and_domain.find('@');
std::string user;
std::string domain;
- if(pos != std::string::npos)
- {
+ if (pos != std::string::npos) {
user = user_and_domain.substr(0, pos);
domain = user_and_domain.substr(pos + 1);
- }
- else
- {
+ } else {
user = user_and_domain;
- }
+ }
std::vector<std::string> permissions =
cmSystemTools::tokenize(permission_string, ",");
this->SourceWriter.BeginElement("Permission");
this->SourceWriter.AddAttribute("User", user);
- if(!domain.empty())
- {
+ if (!domain.empty()) {
this->SourceWriter.AddAttribute("Domain", domain);
- }
- for(size_t i = 0; i < permissions.size(); ++i)
- {
+ }
+ for (size_t i = 0; i < permissions.size(); ++i) {
this->EmitBooleanAttribute(entry,
- cmSystemTools::TrimWhitespace(permissions[i]));
- }
+ cmSystemTools::TrimWhitespace(permissions[i]));
+ }
this->SourceWriter.EndElement("Permission");
}
-void cmWIXAccessControlList::ReportError(
- std::string const& entry,
- std::string const& message)
+void cmWIXAccessControlList::ReportError(std::string const& entry,
+ std::string const& message)
{
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Failed processing ACL entry '" << entry <<
- "': " << message << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed processing ACL entry '"
+ << entry << "': " << message << std::endl);
}
bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
{
- static const char* validAttributes[] =
- {
+ static const char* validAttributes[] = {
/* clang-format needs this comment to break after the opening brace */
"Append",
"ChangePermission",
@@ -128,23 +115,22 @@ bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
};
size_t i = 0;
- while(validAttributes[i])
- {
- if(name == validAttributes[i++]) return true;
- }
+ while (validAttributes[i]) {
+ if (name == validAttributes[i++])
+ return true;
+ }
return false;
}
-void cmWIXAccessControlList::EmitBooleanAttribute(
- std::string const& entry, std::string const& name)
+void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry,
+ std::string const& name)
{
- if(!this->IsBooleanAttribute(name))
- {
+ if (!this->IsBooleanAttribute(name)) {
std::stringstream message;
message << "Unknown boolean attribute '" << name << "'";
this->ReportError(entry, message.str());
- }
+ }
this->SourceWriter.AddAttribute(name, "yes");
}