2016-09-27 15:01:08 -04:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2008-07-09 13:38:56 -04:00
|
|
|
#include "cmCPackComponentGroup.h"
|
2016-04-29 09:40:20 -04:00
|
|
|
|
2008-07-09 13:38:56 -04:00
|
|
|
#include "cmSystemTools.h"
|
2016-04-29 09:40:20 -04:00
|
|
|
|
2008-07-09 13:38:56 -04:00
|
|
|
#include <string>
|
2016-04-29 10:53:13 -04:00
|
|
|
#include <vector>
|
2008-07-09 13:38:56 -04:00
|
|
|
|
2014-02-21 19:05:55 -05:00
|
|
|
unsigned long cmCPackComponent::GetInstalledSize(
|
2016-05-16 10:34:04 -04:00
|
|
|
const std::string& installDir) const
|
2008-07-09 13:38:56 -04:00
|
|
|
{
|
2016-05-16 10:34:04 -04:00
|
|
|
if (this->TotalSize != 0) {
|
2008-07-09 13:38:56 -04:00
|
|
|
return this->TotalSize;
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2008-07-09 13:38:56 -04:00
|
|
|
|
|
|
|
std::vector<std::string>::const_iterator fileIt;
|
2016-05-16 10:34:04 -04:00
|
|
|
for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) {
|
2008-07-09 13:38:56 -04:00
|
|
|
std::string path = installDir;
|
|
|
|
path += '/';
|
|
|
|
path += *fileIt;
|
2014-11-23 11:05:50 +01:00
|
|
|
this->TotalSize += cmSystemTools::FileLength(path);
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2008-07-09 13:38:56 -04:00
|
|
|
|
|
|
|
return this->TotalSize;
|
|
|
|
}
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
|
|
|
|
const std::string& installDir) const
|
2008-07-09 13:38:56 -04:00
|
|
|
{
|
|
|
|
unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
|
2016-05-16 10:34:04 -04:00
|
|
|
return result ? result : 1;
|
2008-07-09 13:38:56 -04:00
|
|
|
}
|