diff options
author | KWSys Upstream <kwrobot@kitware.com> | 2017-04-12 13:08:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-04-12 13:10:22 (GMT) |
commit | 85841e8bd5e678f69271272db7f838f873347812 (patch) | |
tree | eb74d111e23c0b680a97ddb0a24d475983826100 /SystemTools.cxx | |
parent | e9c5505bf9c51c34dea703b86a293ff04475db54 (diff) | |
download | CMake-85841e8bd5e678f69271272db7f838f873347812.zip CMake-85841e8bd5e678f69271272db7f838f873347812.tar.gz CMake-85841e8bd5e678f69271272db7f838f873347812.tar.bz2 |
KWSys 2017-04-12 (23a4c211)
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit 23a4c211e90c1cfd399c3632141dbd549a5db8cf (master).
Upstream Shortlog
-----------------
Brad King (2):
41a9dfef SystemInformation: Fix dynamic loader failure on WinXP SP2
3ead6158 SystemTools: Fix stat() wrapper compilation with Borland
Daniel Pfeifer (1):
ce5b0d34 Disable include-what-you-use
Mathieu Westphal (1):
a2bf6bb3 SystemTools: Add cross-platform stat() wrapper
Diffstat (limited to 'SystemTools.cxx')
-rw-r--r-- | SystemTools.cxx | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/SystemTools.cxx b/SystemTools.cxx index 65b7b26..100a49c 100644 --- a/SystemTools.cxx +++ b/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) { |