cmCPackComponentGroup.cxx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmCPackComponentGroup.h"
  14. #include "cmSystemTools.h"
  15. #include <vector>
  16. #include <string>
  17. //----------------------------------------------------------------------
  18. unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const
  19. {
  20. if (this->TotalSize != 0)
  21. {
  22. return this->TotalSize;
  23. }
  24. std::vector<std::string>::const_iterator fileIt;
  25. for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt)
  26. {
  27. std::string path = installDir;
  28. path += '/';
  29. path += *fileIt;
  30. this->TotalSize += cmSystemTools::FileLength(path.c_str());
  31. }
  32. return this->TotalSize;
  33. }
  34. //----------------------------------------------------------------------
  35. unsigned long
  36. cmCPackComponent::GetInstalledSizeInKbytes(const char* installDir) const
  37. {
  38. unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
  39. return result? result : 1;
  40. }