summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/SystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-04-12 13:10:22 (GMT)
committerBrad King <brad.king@kitware.com>2017-04-12 13:10:22 (GMT)
commitada8e0cac4b50d07f4d07ecd584bf00e7afd3ac5 (patch)
treec336973c11619343de55064f40353059ad010fcf /Source/kwsys/SystemTools.cxx
parentfddd559406558a2037733e5b760e9dd04e9edfd1 (diff)
parent85841e8bd5e678f69271272db7f838f873347812 (diff)
downloadCMake-ada8e0cac4b50d07f4d07ecd584bf00e7afd3ac5.zip
CMake-ada8e0cac4b50d07f4d07ecd584bf00e7afd3ac5.tar.gz
CMake-ada8e0cac4b50d07f4d07ecd584bf00e7afd3ac5.tar.bz2
Merge branch 'upstream-KWSys' into update-kwsys
* upstream-KWSys: KWSys 2017-04-12 (23a4c211)
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r--Source/kwsys/SystemTools.cxx33
1 files changed, 32 insertions, 1 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 65b7b26..100a49c 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -54,7 +54,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/stat.h>
#include <time.h>
#if defined(_WIN32) && !defined(_MSC_VER) && defined(__GNUC__)
@@ -1258,6 +1257,38 @@ bool SystemTools::TestFileAccess(const std::string& filename,
}
//----------------------------------------------------------------------------
+int SystemTools::Stat(const char* path, SystemTools::Stat_t* buf)
+{
+ if (!path) {
+ errno = EFAULT;
+ return -1;
+ }
+ return SystemTools::Stat(std::string(path), buf);
+}
+
+//----------------------------------------------------------------------------
+int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf)
+{
+ if (path.empty()) {
+ errno = ENOENT;
+ return -1;
+ }
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // Ideally we should use ConvertToWindowsExtendedPath to support
+ // long paths, but _wstat64 rejects paths with '?' in them, thinking
+ // they are wildcards.
+ std::wstring const& wpath = Encoding::ToWide(path);
+#if defined(__BORLANDC__)
+ return _wstati64(wpath.c_str(), buf);
+#else
+ return _wstat64(wpath.c_str(), buf);
+#endif
+#else
+ return stat(path.c_str(), buf);
+#endif
+}
+
+//----------------------------------------------------------------------------
#ifdef __CYGWIN__
bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path)
{