Merge branch 'upstream-KWSys' into update-kwsys
* upstream-KWSys: KWSys 2016-08-01 (560bcdbb)
This commit is contained in:
commit
35995fa6b5
|
@ -84,9 +84,9 @@ void Directory::Clear()
|
||||||
|
|
||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
||||||
// First microsoft compilers
|
// First Windows platforms
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__WATCOMC__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -97,15 +97,25 @@ void Directory::Clear()
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.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
|
namespace KWSYS_NAMESPACE
|
||||||
{
|
{
|
||||||
|
|
||||||
bool Directory::Load(const std::string& name)
|
bool Directory::Load(const std::string& name)
|
||||||
{
|
{
|
||||||
this->Clear();
|
this->Clear();
|
||||||
#if _MSC_VER < 1300
|
#if (defined(_MSC_VER) && _MSC_VER < 1300) || defined(__BORLANDC__)
|
||||||
|
// Older Visual C++ and Embarcadero compilers.
|
||||||
long srchHandle;
|
long srchHandle;
|
||||||
#else
|
#else // Newer Visual C++
|
||||||
intptr_t srchHandle;
|
intptr_t srchHandle;
|
||||||
#endif
|
#endif
|
||||||
char* buf;
|
char* buf;
|
||||||
|
@ -132,7 +142,7 @@ bool Directory::Load(const std::string& name)
|
||||||
struct _wfinddata_t data; // data of current file
|
struct _wfinddata_t data; // data of current file
|
||||||
|
|
||||||
// Now put them into the file array
|
// 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;
|
delete [] buf;
|
||||||
|
|
||||||
if ( srchHandle == -1 )
|
if ( srchHandle == -1 )
|
||||||
|
@ -145,16 +155,17 @@ bool Directory::Load(const std::string& name)
|
||||||
{
|
{
|
||||||
this->Internal->Files.push_back(Encoding::ToNarrow(data.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;
|
this->Internal->Path = name;
|
||||||
return _findclose(srchHandle) != -1;
|
return _findclose(srchHandle) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
|
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;
|
long srchHandle;
|
||||||
#else
|
#else // Newer Visual C++
|
||||||
intptr_t srchHandle;
|
intptr_t srchHandle;
|
||||||
#endif
|
#endif
|
||||||
char* buf;
|
char* buf;
|
||||||
|
@ -172,7 +183,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
|
||||||
struct _wfinddata_t data; // data of current file
|
struct _wfinddata_t data; // data of current file
|
||||||
|
|
||||||
// Now put them into the file array
|
// 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;
|
delete [] buf;
|
||||||
|
|
||||||
if ( srchHandle == -1 )
|
if ( srchHandle == -1 )
|
||||||
|
@ -186,7 +197,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
while ( _wfindnext(srchHandle, &data) != -1 );
|
while ( _wfindnext_func(srchHandle, &data) != -1 );
|
||||||
_findclose(srchHandle);
|
_findclose(srchHandle);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,7 +523,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SystemTools::GetEnv(const char* key)
|
const char* SystemTools::GetEnvImpl(const char* key)
|
||||||
{
|
{
|
||||||
const char *v = 0;
|
const char *v = 0;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -540,9 +540,14 @@ const char* SystemTools::GetEnv(const char* key)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* SystemTools::GetEnv(const char* key)
|
||||||
|
{
|
||||||
|
return SystemTools::GetEnvImpl(key);
|
||||||
|
}
|
||||||
|
|
||||||
const char* SystemTools::GetEnv(const std::string& key)
|
const char* SystemTools::GetEnv(const std::string& key)
|
||||||
{
|
{
|
||||||
return SystemTools::GetEnv(key.c_str());
|
return SystemTools::GetEnvImpl(key.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemTools::GetEnv(const char* key, std::string& result)
|
bool SystemTools::GetEnv(const char* key, std::string& result)
|
||||||
|
|
|
@ -984,6 +984,7 @@ private:
|
||||||
std::vector<std::string>(),
|
std::vector<std::string>(),
|
||||||
bool no_system_path = false);
|
bool no_system_path = false);
|
||||||
|
|
||||||
|
static const char* GetEnvImpl(const char* key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path translation table from dir to refdir
|
* Path translation table from dir to refdir
|
||||||
|
|
Loading…
Reference in New Issue