diff options
author | Brad King <brad.king@kitware.com> | 2016-08-04 14:11:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-08-04 14:11:07 (GMT) |
commit | 8abca14034c22014aead0fd4f3be737cd3835ce4 (patch) | |
tree | c8a7b6f16feb152f58c949e84971c502e38221ed /Source/kwsys/SystemTools.cxx | |
parent | 995b54256ede7752b5d6fde049097d15aa16c405 (diff) | |
parent | 6c0820a8748e24155d3b7ce6991a90f5a396f524 (diff) | |
download | CMake-8abca14034c22014aead0fd4f3be737cd3835ce4.zip CMake-8abca14034c22014aead0fd4f3be737cd3835ce4.tar.gz CMake-8abca14034c22014aead0fd4f3be737cd3835ce4.tar.bz2 |
Merge branch 'upstream-KWSys' into update-kwsys
* upstream-KWSys:
KWSys 2016-08-03 (6d23dd7e)
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index d479ee1..eb2bec6 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1292,6 +1292,32 @@ bool SystemTools::SameFile(const std::string& file1, const std::string& file2) } //---------------------------------------------------------------------------- +bool SystemTools::PathExists(const std::string& path) +{ + if(path.empty()) + { + return false; + } +#if defined(__CYGWIN__) + // Convert path to native windows path if possible. + char winpath[MAX_PATH]; + if(SystemTools::PathCygwinToWin32(path.c_str(), winpath)) + { + return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES); + } + struct stat st; + return lstat(path.c_str(), &st) == 0; +#elif defined(_WIN32) + return (GetFileAttributesW( + SystemTools::ConvertToWindowsExtendedPath(path).c_str()) + != INVALID_FILE_ATTRIBUTES); +#else + struct stat st; + return lstat(path.c_str(), &st) == 0; +#endif +} + +//---------------------------------------------------------------------------- bool SystemTools::FileExists(const char* filename) { if(!filename) |