cmCPackComponentGroup.cxx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCPackComponentGroup.h"
  11. #include "cmSystemTools.h"
  12. #include <string>
  13. #include <vector>
  14. unsigned long cmCPackComponent::GetInstalledSize(
  15. const std::string& installDir) const
  16. {
  17. if (this->TotalSize != 0) {
  18. return this->TotalSize;
  19. }
  20. std::vector<std::string>::const_iterator fileIt;
  21. for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) {
  22. std::string path = installDir;
  23. path += '/';
  24. path += *fileIt;
  25. this->TotalSize += cmSystemTools::FileLength(path);
  26. }
  27. return this->TotalSize;
  28. }
  29. unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
  30. const std::string& installDir) const
  31. {
  32. unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
  33. return result ? result : 1;
  34. }