cmCPackComponentGroup.cxx 896 B

123456789101112131415161718192021222324252627282930313233
  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. #include <vector>
  7. unsigned long cmCPackComponent::GetInstalledSize(
  8. const std::string& installDir) const
  9. {
  10. if (this->TotalSize != 0) {
  11. return this->TotalSize;
  12. }
  13. std::vector<std::string>::const_iterator fileIt;
  14. for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) {
  15. std::string path = installDir;
  16. path += '/';
  17. path += *fileIt;
  18. this->TotalSize += cmSystemTools::FileLength(path);
  19. }
  20. return this->TotalSize;
  21. }
  22. unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
  23. const std::string& installDir) const
  24. {
  25. unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
  26. return result ? result : 1;
  27. }