2016-10-30 18:24:19 +01:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2008-10-12 21:55:53 +03:00
|
|
|
#include "cmCPackComponentGroup.h"
|
2016-07-09 11:21:54 +02:00
|
|
|
|
2008-10-12 21:55:53 +03:00
|
|
|
#include "cmSystemTools.h"
|
2016-07-09 11:21:54 +02:00
|
|
|
|
2008-10-12 21:55:53 +03:00
|
|
|
#include <string>
|
|
|
|
|
2015-04-27 22:25:09 +02:00
|
|
|
unsigned long cmCPackComponent::GetInstalledSize(
|
2016-07-09 11:21:54 +02:00
|
|
|
const std::string& installDir) const
|
2008-10-12 21:55:53 +03:00
|
|
|
{
|
2016-07-09 11:21:54 +02:00
|
|
|
if (this->TotalSize != 0) {
|
2008-10-12 21:55:53 +03:00
|
|
|
return this->TotalSize;
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2008-10-12 21:55:53 +03:00
|
|
|
|
2018-01-26 17:06:56 +01:00
|
|
|
for (std::string const& file : this->Files) {
|
2008-10-12 21:55:53 +03:00
|
|
|
std::string path = installDir;
|
|
|
|
path += '/';
|
2018-01-26 17:06:56 +01:00
|
|
|
path += file;
|
2015-04-27 22:25:09 +02:00
|
|
|
this->TotalSize += cmSystemTools::FileLength(path);
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2008-10-12 21:55:53 +03:00
|
|
|
|
|
|
|
return this->TotalSize;
|
|
|
|
}
|
|
|
|
|
2016-07-09 11:21:54 +02:00
|
|
|
unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
|
|
|
|
const std::string& installDir) const
|
2008-10-12 21:55:53 +03:00
|
|
|
{
|
|
|
|
unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
|
2016-07-09 11:21:54 +02:00
|
|
|
return result ? result : 1;
|
2008-10-12 21:55:53 +03:00
|
|
|
}
|