cmCPackComponentGroup.cxx 812 B

123456789101112131415161718192021222324252627282930
  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 "cmStringAlgorithms.h"
  5. #include "cmSystemTools.h"
  6. #include <string>
  7. unsigned long cmCPackComponent::GetInstalledSize(
  8. const std::string& installDir) const
  9. {
  10. if (this->TotalSize != 0) {
  11. return this->TotalSize;
  12. }
  13. for (std::string const& file : this->Files) {
  14. std::string path = cmStrCat(installDir, '/', file);
  15. this->TotalSize += cmSystemTools::FileLength(path);
  16. }
  17. return this->TotalSize;
  18. }
  19. unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
  20. const std::string& installDir) const
  21. {
  22. unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
  23. return result ? result : 1;
  24. }