summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 6a705f4..024356f 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1255,6 +1255,30 @@ void cmSystemTools::ConvertToOutputSlashes(std::string& path)
#endif
}
+void cmSystemTools::ConvertToLongPath(std::string& path)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // Try to convert path to a long path only if the path contains character '~'
+ if (path.find('~') == std::string::npos) {
+ return;
+ }
+
+ std::wstring wPath = cmsys::Encoding::ToWide(path);
+ DWORD ret = GetLongPathNameW(wPath.c_str(), nullptr, 0);
+ std::vector<wchar_t> buffer(ret);
+ if (ret != 0) {
+ ret = GetLongPathNameW(wPath.c_str(), buffer.data(),
+ static_cast<DWORD>(buffer.size()));
+ }
+
+ if (ret != 0) {
+ path = cmsys::Encoding::ToNarrow(buffer.data());
+ }
+#else
+ static_cast<void>(path);
+#endif
+}
+
std::string cmSystemTools::ConvertToRunCommandPath(const std::string& path)
{
#if defined(_WIN32) && !defined(__CYGWIN__)