cmake/Source/CPack/cmCPackComponentGroup.cxx

31 lines
818 B
C++
Raw Normal View History

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. */
#include "cmCPackComponentGroup.h"
2016-07-09 11:21:54 +02:00
#include <string>
2020-02-01 23:06:01 +01:00
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
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
{
2016-07-09 11:21:54 +02:00
if (this->TotalSize != 0) {
return this->TotalSize;
2016-07-09 11:21:54 +02:00
}
2018-01-26 17:06:56 +01:00
for (std::string const& file : this->Files) {
2020-02-01 23:06:01 +01:00
std::string path = cmStrCat(installDir, '/', file);
2015-04-27 22:25:09 +02:00
this->TotalSize += cmSystemTools::FileLength(path);
2016-07-09 11:21:54 +02:00
}
return this->TotalSize;
}
2016-07-09 11:21:54 +02:00
unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
const std::string& installDir) const
{
2021-09-14 00:13:48 +02:00
unsigned long result = (this->GetInstalledSize(installDir) + 512) / 1024;
2016-07-09 11:21:54 +02:00
return result ? result : 1;
}