cmCPackComponentGroup.cxx 1.4 KB

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