cmCPackComponentGroup.cxx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 <vector>
  13. #include <string>
  14. //----------------------------------------------------------------------
  15. unsigned long cmCPackComponent::GetInstalledSize(
  16. const std::string& installDir) const
  17. {
  18. if (this->TotalSize != 0)
  19. {
  20. return this->TotalSize;
  21. }
  22. std::vector<std::string>::const_iterator fileIt;
  23. for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt)
  24. {
  25. std::string path = installDir;
  26. path += '/';
  27. path += *fileIt;
  28. this->TotalSize += cmSystemTools::FileLength(path.c_str());
  29. }
  30. return this->TotalSize;
  31. }
  32. //----------------------------------------------------------------------
  33. unsigned long
  34. cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const
  35. {
  36. unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
  37. return result? result : 1;
  38. }