cmCMakeToWixPath.cxx 989 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 "cmCMakeToWixPath.h"
  4. #include "cmSystemTools.h"
  5. #include <string>
  6. #include <vector>
  7. #ifdef __CYGWIN__
  8. #include <sys/cygwin.h>
  9. std::string CMakeToWixPath(const std::string& cygpath)
  10. {
  11. std::vector<char> winpath_chars;
  12. ssize_t winpath_size;
  13. // Get the required buffer size.
  14. winpath_size =
  15. cygwin_conv_path(CCP_POSIX_TO_WIN_A, cygpath.c_str(), nullptr, 0);
  16. if (winpath_size <= 0) {
  17. return cygpath;
  18. }
  19. winpath_chars.assign(static_cast<size_t>(winpath_size) + 1, '\0');
  20. winpath_size = cygwin_conv_path(CCP_POSIX_TO_WIN_A, cygpath.c_str(),
  21. winpath_chars.data(), winpath_size);
  22. if (winpath_size < 0) {
  23. return cygpath;
  24. }
  25. return cmSystemTools::TrimWhitespace(winpath_chars.data());
  26. }
  27. #else
  28. std::string CMakeToWixPath(const std::string& path)
  29. {
  30. return path;
  31. }
  32. #endif