2016-09-27 22:01:08 +03: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 21:38:56 +04:00
|
|
|
#include "cmCPackComponentGroup.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2008-07-09 21:38:56 +04:00
|
|
|
#include "cmSystemTools.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2008-07-09 21:38:56 +04:00
|
|
|
#include <string>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <vector>
|
2008-07-09 21:38:56 +04:00
|
|
|
|
2014-02-22 04:05:55 +04:00
|
|
|
unsigned long cmCPackComponent::GetInstalledSize(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& installDir) const
|
2008-07-09 21:38:56 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->TotalSize != 0) {
|
2008-07-09 21:38:56 +04:00
|
|
|
return this->TotalSize;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-07-09 21:38:56 +04:00
|
|
|
|
|
|
|
std::vector<std::string>::const_iterator fileIt;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) {
|
2008-07-09 21:38:56 +04:00
|
|
|
std::string path = installDir;
|
|
|
|
path += '/';
|
|
|
|
path += *fileIt;
|
2014-11-23 13:05:50 +03:00
|
|
|
this->TotalSize += cmSystemTools::FileLength(path);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-07-09 21:38:56 +04:00
|
|
|
|
|
|
|
return this->TotalSize;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
|
|
|
|
const std::string& installDir) const
|
2008-07-09 21:38:56 +04:00
|
|
|
{
|
|
|
|
unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
|
2016-05-16 17:34:04 +03:00
|
|
|
return result ? result : 1;
|
2008-07-09 21:38:56 +04:00
|
|
|
}
|