cmCPackComponentGroup.cxx 794 B

12345678910111213141516171819202122232425262728293031
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCPackComponentGroup.h"
  4. #include "cmSystemTools.h"
  5. #include <string>
  6. unsigned long cmCPackComponent::GetInstalledSize(
  7. const std::string& installDir) const
  8. {
  9. if (this->TotalSize != 0) {
  10. return this->TotalSize;
  11. }
  12. for (std::string const& file : this->Files) {
  13. std::string path = installDir;
  14. path += '/';
  15. path += file;
  16. this->TotalSize += cmSystemTools::FileLength(path);
  17. }
  18. return this->TotalSize;
  19. }
  20. unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
  21. const std::string& installDir) const
  22. {
  23. unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
  24. return result ? result : 1;
  25. }