diff options
author | Brad King <brad.king@kitware.com> | 2016-08-02 13:21:52 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-08-02 13:21:52 (GMT) |
commit | 35995fa6b5872b58f086d16b16ca90d7d259d9b0 (patch) | |
tree | 820632c7a1a055b1ec611ecfb918191b9a39295d /Source/kwsys/Directory.cxx | |
parent | fd59f9ad519c1c311c54569133797d9061e90558 (diff) | |
parent | 6bc3073e23af70bde3e8a7659aa51a784deeec9c (diff) | |
download | CMake-35995fa6b5872b58f086d16b16ca90d7d259d9b0.zip CMake-35995fa6b5872b58f086d16b16ca90d7d259d9b0.tar.gz CMake-35995fa6b5872b58f086d16b16ca90d7d259d9b0.tar.bz2 |
Merge branch 'upstream-KWSys' into update-kwsys
* upstream-KWSys:
KWSys 2016-08-01 (560bcdbb)
Diffstat (limited to 'Source/kwsys/Directory.cxx')
-rw-r--r-- | Source/kwsys/Directory.cxx | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx index c549792..15480e1 100644 --- a/Source/kwsys/Directory.cxx +++ b/Source/kwsys/Directory.cxx @@ -84,9 +84,9 @@ void Directory::Clear() } // namespace KWSYS_NAMESPACE -// First microsoft compilers +// First Windows platforms -#if defined(_MSC_VER) || defined(__WATCOMC__) +#if defined(_WIN32) && !defined(__CYGWIN__) #include <windows.h> #include <io.h> #include <ctype.h> @@ -97,15 +97,25 @@ void Directory::Clear() #include <sys/stat.h> #include <sys/types.h> +// Wide function names can vary depending on compiler: +#ifdef __BORLANDC__ +# define _wfindfirst_func __wfindfirst +# define _wfindnext_func __wfindnext +#else +# define _wfindfirst_func _wfindfirst +# define _wfindnext_func _wfindnext +#endif + namespace KWSYS_NAMESPACE { bool Directory::Load(const std::string& name) { this->Clear(); -#if _MSC_VER < 1300 +#if (defined(_MSC_VER) && _MSC_VER < 1300) || defined(__BORLANDC__) + // Older Visual C++ and Embarcadero compilers. long srchHandle; -#else +#else // Newer Visual C++ intptr_t srchHandle; #endif char* buf; @@ -132,7 +142,7 @@ bool Directory::Load(const std::string& name) struct _wfinddata_t data; // data of current file // Now put them into the file array - srchHandle = _wfindfirst((wchar_t*)Encoding::ToWide(buf).c_str(), &data); + srchHandle = _wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data); delete [] buf; if ( srchHandle == -1 ) @@ -145,16 +155,17 @@ bool Directory::Load(const std::string& name) { this->Internal->Files.push_back(Encoding::ToNarrow(data.name)); } - while ( _wfindnext(srchHandle, &data) != -1 ); + while ( _wfindnext_func(srchHandle, &data) != -1 ); this->Internal->Path = name; return _findclose(srchHandle) != -1; } unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name) { -#if _MSC_VER < 1300 +#if (defined(_MSC_VER) && _MSC_VER < 1300) || defined(__BORLANDC__) + // Older Visual C++ and Embarcadero compilers. long srchHandle; -#else +#else // Newer Visual C++ intptr_t srchHandle; #endif char* buf; @@ -172,7 +183,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name) struct _wfinddata_t data; // data of current file // Now put them into the file array - srchHandle = _wfindfirst((wchar_t*)Encoding::ToWide(buf).c_str(), &data); + srchHandle = _wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data); delete [] buf; if ( srchHandle == -1 ) @@ -186,7 +197,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name) { count++; } - while ( _wfindnext(srchHandle, &data) != -1 ); + while ( _wfindnext_func(srchHandle, &data) != -1 ); _findclose(srchHandle); return count; } |