Commit df5c96fe authored by Kitware Robot's avatar Kitware Robot Committed by Brad King
Browse files

KWSys 2015-12-09 (cdcf4c47)

Code extracted from:

    http://public.kitware.com/KWSys.git

at commit cdcf4c4753d8e90895f1fb2cb6ab622342bcaaa8 (master).
parent 40f6ed4a
......@@ -124,7 +124,6 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET(KWSYS_USE_FStream 1)
SET(KWSYS_USE_String 1)
SET(KWSYS_USE_SystemInformation 1)
SET(KWSYS_USE_CPU 1)
ENDIF()
# Enforce component dependencies.
......@@ -342,11 +341,6 @@ ENDIF()
# capabilities and parent project's request. Enforce 0/1 as only
# possible values for configuration into Configure.hxx.
IF(UNIX)
KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM
"Checking whether struct stat has st_mtim member" DIRECT)
ENDIF()
# Check existence and uniqueness of long long and __int64.
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG
"Checking whether C++ compiler has 'long long'" DIRECT)
......@@ -430,13 +424,6 @@ IF(KWSYS_USE_FundamentalType)
ENDIF()
ENDFOREACH()
IF(KWSYS_USE___INT64)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE
"Checking whether unsigned __int64 can convert to double" DIRECT)
ELSE()
SET(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE 1)
ENDIF()
# Check signedness of "char" type.
KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_CHAR_IS_SIGNED
"Checking whether char is signed" DIRECT)
......@@ -511,12 +498,18 @@ IF(KWSYS_USE_SystemTools)
"Checking whether CXX compiler has utimes" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMENSAT
"Checking whether CXX compiler has utimensat" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIM
"Checking whether CXX compiler struct stat has st_mtim member" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
"Checking whether CXX compiler struct stat has st_mtimespec member" DIRECT)
SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
KWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV}
KWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV}
KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}
KWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
KWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT}
KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM}
KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC}
)
ENDIF()
......@@ -748,7 +741,7 @@ ENDFOREACH()
# Add selected C components.
FOREACH(c
Process Base64 Encoding FundamentalType MD5 Terminal System String CPU
Process Base64 Encoding FundamentalType MD5 Terminal System String
)
IF(KWSYS_USE_${c})
# Use the corresponding header file.
......
/*============================================================================
KWSys - Kitware System Library
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef @KWSYS_NAMESPACE@_CPU_h
#define @KWSYS_NAMESPACE@_CPU_h
#include <@KWSYS_NAMESPACE@/Configure.h>
/* Identify possible endian cases. The macro
@KWSYS_NAMESPACE@_CPU_ENDIAN_ID will be defined to one of these, or
0 if unknown. */
#define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG 4321
#define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE 1234
/* Apple always defines one of these. */
#if defined(__LITTLE_ENDIAN__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
#elif defined(__BIG_ENDIAN__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* Alpha */
#elif defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
/* Arm */
#elif defined(__arm__)
# if !defined(__ARMEB__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
# else
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
# endif
/* Intel x86 */
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
#elif defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
#elif defined(__MWERKS__) && defined(__INTEL__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
/* Intel x86-64 */
#elif defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
#elif defined(__amd64) || defined(__amd64__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
/* Intel Architecture-64 (Itanium) */
#elif defined(__ia64) || defined(__ia64__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
#elif defined(_IA64) || defined(__IA64__) || defined(_M_IA64)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
/* PowerPC */
#elif defined(__powerpc) || defined(__powerpc__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
#elif defined(__ppc) || defined(__ppc__) || defined(__POWERPC__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* SPARC */
#elif defined(__sparc) || defined(__sparc__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* HP/PA RISC */
#elif defined(__hppa) || defined(__hppa__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* Motorola 68k */
#elif defined(__m68k__) || defined(M68000)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* MIPSel (MIPS little endian) */
#elif defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
/* MIPSeb (MIPS big endian) */
#elif defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* MIPS (fallback, big endian) */
#elif defined(__mips) || defined(__mips__) || defined(__MIPS__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* OpenRISC 1000 */
#elif defined(__or1k__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* RS/6000 */
#elif defined(__THW_RS600) || defined(_IBMR2) || defined(_POWER)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
#elif defined(_ARCH_PWR) || defined(_ARCH_PWR2)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* System/370 */
#elif defined(__370__) || defined(__THW_370__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* System/390 */
#elif defined(__s390__) || defined(__s390x__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* z/Architecture */
#elif defined(__SYSC_ZARCH__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
/* Aarch64 */
#elif defined(__aarch64__)
# if !defined(__AARCH64EB__)
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
# else
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
# endif
/* Unknown CPU */
#else
# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID 0
# if !defined(@KWSYS_NAMESPACE@_CPU_UNKNOWN_OKAY)
# error "The target CPU architecture is not known."
# endif
#endif
/* If building a C or C++ file in kwsys itself, give the source file
access to the macros without a configured namespace. */
#if defined(KWSYS_NAMESPACE)
# define KWSYS_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID
# define KWSYS_CPU_ENDIAN_ID_BIG @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG
# define KWSYS_CPU_ENDIAN_ID_LITTLE @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE
#endif
#endif
......@@ -9,7 +9,6 @@
# resulting memory leaks are not logged by valgrind anyway. Therefore, we
# don't have to exclude it.
set(CTEST_CUSTOM_MEMCHECK_IGNORE
${CTEST_CUSTOM_MEMCHECK_IGNORE}
list(APPEND CTEST_CUSTOM_MEMCHECK_IGNORE
kwsys.testProcess-10
)
......@@ -18,9 +18,6 @@
/* Whether wstring is available. */
#define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@
/* Whether struct stat has the st_mtim member for high resolution times. */
#define @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM @KWSYS_STAT_HAS_ST_MTIM@
/* If building a C++ file in kwsys itself, give the source file
access to the macros without a configured namespace. */
#if defined(KWSYS_NAMESPACE)
......@@ -28,7 +25,6 @@
# define kwsys @KWSYS_NAMESPACE@
# endif
# define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define KWSYS_STAT_HAS_ST_MTIM @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM
# define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING
#endif
......
......@@ -38,6 +38,7 @@
// Windows API.
#if defined(_WIN32)
# include <windows.h>
# include <shellapi.h>
#endif
namespace KWSYS_NAMESPACE
......
......@@ -90,18 +90,12 @@ typedef unsigned long kwsysFundamentalType_UInt32;
#if @KWSYS_NAMESPACE@_SIZEOF_LONG == 8
typedef signed long kwsysFundamentalType_Int64;
typedef unsigned long kwsysFundamentalType_UInt64;
/* Whether UInt64 can be converted to double. */
# define @KWSYS_NAMESPACE@_CAN_CONVERT_UI64_TO_DOUBLE 1
#elif @KWSYS_NAMESPACE@_USE_LONG_LONG && @KWSYS_NAMESPACE@_SIZEOF_LONG_LONG == 8
typedef signed long long kwsysFundamentalType_Int64;
typedef unsigned long long kwsysFundamentalType_UInt64;
/* Whether UInt64 can be converted to double. */
# define @KWSYS_NAMESPACE@_CAN_CONVERT_UI64_TO_DOUBLE 1
#elif @KWSYS_NAMESPACE@_USE___INT64 && @KWSYS_NAMESPACE@_SIZEOF___INT64 == 8
typedef signed __int64 kwsysFundamentalType_Int64;
typedef unsigned __int64 kwsysFundamentalType_UInt64;
/* Whether UInt64 can be converted to double. */
# define @KWSYS_NAMESPACE@_CAN_CONVERT_UI64_TO_DOUBLE @KWSYS_CAN_CONVERT_UI64_TO_DOUBLE@
#else
# error "No native data type can represent a 64-bit integer."
#endif
......@@ -140,7 +134,6 @@ typedef unsigned __int64 kwsysFundamentalType_UInt64;
# define KWSYS_USE_LONG_LONG @KWSYS_NAMESPACE@_USE_LONG_LONG
# define KWSYS_USE___INT64 @KWSYS_NAMESPACE@_USE___INT64
# define KWSYS_CHAR_IS_SIGNED @KWSYS_NAMESPACE@_CHAR_IS_SIGNED
# define KWSYS_CAN_CONVERT_UI64_TO_DOUBLE @KWSYS_NAMESPACE@_CAN_CONVERT_UI64_TO_DOUBLE
#endif
#endif
......@@ -2241,7 +2241,7 @@ static kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1, kwsysProcessTi
kwsysProcessTime out;
out.tv_sec = in1.tv_sec + in2.tv_sec;
out.tv_usec = in1.tv_usec + in2.tv_usec;
if(out.tv_usec > 1000000)
if(out.tv_usec >= 1000000)
{
out.tv_usec -= 1000000;
out.tv_sec += 1;
......
......@@ -408,6 +408,7 @@ class SystemToolsPathCaseMap:
// adds the elements of the env variable path to the arg passed in
void SystemTools::GetPath(std::vector<std::string>& path, const char* env)
{
size_t const old_size = path.size();
#if defined(_WIN32) && !defined(__CYGWIN__)
const char pathSep = ';';
#else
......@@ -445,7 +446,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env)
done = true;
}
}
for(std::vector<std::string>::iterator i = path.begin();
for(std::vector<std::string>::iterator i = path.begin() + old_size;
i != path.end(); ++i)
{
SystemTools::ConvertToUnixSlashes(*i);
......@@ -1365,15 +1366,18 @@ bool SystemTools::Touch(const std::string& filename, bool create)
struct timeval mtime;
gettimeofday(&mtime, 0);
# if KWSYS_CXX_HAS_UTIMES
struct timeval times[2] =
{
# if KWSYS_STAT_HAS_ST_MTIM
{st.st_atim.tv_sec, st.st_atim.tv_nsec/1000}, /* tv_sec, tv_usec */
struct timeval atime;
# if KWSYS_CXX_STAT_HAS_ST_MTIM
atime.tv_sec = st.st_atim.tv_sec;
atime.tv_usec = st.st_atim.tv_nsec/1000;
# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
atime.tv_sec = st.st_atimespec.tv_sec;
atime.tv_usec = st.st_atimespec.tv_nsec/1000;
# else
{st.st_atime, 0},
atime.tv_sec = st.st_atime;
atime.tv_usec = 0;
# endif
mtime
};
struct timeval times[2] = { atime, mtime };
if(utimes(filename.c_str(), times) < 0)
{
return false;
......@@ -1407,7 +1411,7 @@ bool SystemTools::FileTimeCompare(const std::string& f1,
{
return false;
}
# if KWSYS_STAT_HAS_ST_MTIM
# if KWSYS_CXX_STAT_HAS_ST_MTIM
// Compare using nanosecond resolution.
if(s1.st_mtim.tv_sec < s2.st_mtim.tv_sec)
{
......@@ -1425,6 +1429,24 @@ bool SystemTools::FileTimeCompare(const std::string& f1,
{
*result = 1;
}
# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
// Compare using nanosecond resolution.
if(s1.st_mtimespec.tv_sec < s2.st_mtimespec.tv_sec)
{
*result = -1;
}
else if(s1.st_mtimespec.tv_sec > s2.st_mtimespec.tv_sec)
{
*result = 1;
}
else if(s1.st_mtimespec.tv_nsec < s2.st_mtimespec.tv_nsec)
{
*result = -1;
}
else if(s1.st_mtimespec.tv_nsec > s2.st_mtimespec.tv_nsec)
{
*result = 1;
}
# else
// Compare using 1 second resolution.
if(s1.st_mtime < s2.st_mtime)
......@@ -2365,95 +2387,101 @@ bool SystemTools::CopyFileAlways(const std::string& source, const std::string& d
}
mode_t perm = 0;
bool perms = SystemTools::GetPermissions(source, perm);
const int bufferSize = 4096;
char buffer[bufferSize];
// If destination is a directory, try to create a file with the same
// name as the source in that directory.
std::string real_destination = destination;
std::string destination_dir;
if(SystemTools::FileExists(destination) &&
SystemTools::FileIsDirectory(destination))
if(SystemTools::FileIsDirectory(source))
{
destination_dir = real_destination;
SystemTools::ConvertToUnixSlashes(real_destination);
real_destination += '/';
std::string source_name = source;
real_destination += SystemTools::GetFilenameName(source_name);
SystemTools::MakeDirectory(destination);
}
else
{
destination_dir = SystemTools::GetFilenamePath(destination);
}
const int bufferSize = 4096;
char buffer[bufferSize];
// Create destination directory
// If destination is a directory, try to create a file with the same
// name as the source in that directory.
SystemTools::MakeDirectory(destination_dir);
std::string destination_dir;
if(SystemTools::FileIsDirectory(destination))
{
destination_dir = real_destination;
SystemTools::ConvertToUnixSlashes(real_destination);
real_destination += '/';
std::string source_name = source;
real_destination += SystemTools::GetFilenameName(source_name);
}
else
{
destination_dir = SystemTools::GetFilenamePath(destination);
}
// Open files
// Create destination directory
SystemTools::MakeDirectory(destination_dir);
// Open files
#if defined(_WIN32)
kwsys::ifstream fin(Encoding::ToNarrow(
SystemTools::ConvertToWindowsExtendedPath(source)).c_str(),
std::ios::in | std::ios::binary);
kwsys::ifstream fin(Encoding::ToNarrow(
SystemTools::ConvertToWindowsExtendedPath(source)).c_str(),
std::ios::in | std::ios::binary);
#else
kwsys::ifstream fin(source.c_str(),
std::ios::in | std::ios::binary);
kwsys::ifstream fin(source.c_str(),
std::ios::in | std::ios::binary);
#endif
if(!fin)
{
return false;
}
if(!fin)
{
return false;
}
// try and remove the destination file so that read only destination files
// can be written to.
// If the remove fails continue so that files in read only directories
// that do not allow file removal can be modified.
SystemTools::RemoveFile(real_destination);
// try and remove the destination file so that read only destination files
// can be written to.
// If the remove fails continue so that files in read only directories
// that do not allow file removal can be modified.
SystemTools::RemoveFile(real_destination);
#if defined(_WIN32)
kwsys::ofstream fout(Encoding::ToNarrow(
SystemTools::ConvertToWindowsExtendedPath(real_destination)).c_str(),
kwsys::ofstream fout(Encoding::ToNarrow(
SystemTools::ConvertToWindowsExtendedPath(real_destination)).c_str(),
std::ios::out | std::ios::trunc | std::ios::binary);
#else
kwsys::ofstream fout(real_destination.c_str(),
kwsys::ofstream fout(real_destination.c_str(),
std::ios::out | std::ios::trunc | std::ios::binary);
#endif
if(!fout)
{
return false;
}
// This copy loop is very sensitive on certain platforms with
// slightly broken stream libraries (like HPUX). Normally, it is
// incorrect to not check the error condition on the fin.read()
// before using the data, but the fin.gcount() will be zero if an
// error occurred. Therefore, the loop should be safe everywhere.
while(fin)
{
fin.read(buffer, bufferSize);
if(fin.gcount())
if(!fout)
{
fout.write(buffer, fin.gcount());
return false;
}
else
// This copy loop is very sensitive on certain platforms with
// slightly broken stream libraries (like HPUX). Normally, it is
// incorrect to not check the error condition on the fin.read()
// before using the data, but the fin.gcount() will be zero if an
// error occurred. Therefore, the loop should be safe everywhere.
while(fin)
{
break;
fin.read(buffer, bufferSize);
if(fin.gcount())
{
fout.write(buffer, fin.gcount());
}
else
{
break;
}
}
}
// Make sure the operating system has finished writing the file
// before closing it. This will ensure the file is finished before
// the check below.
fout.flush();
// Make sure the operating system has finished writing the file
// before closing it. This will ensure the file is finished before
// the check below.
fout.flush();
fin.close();
fout.close();
fin.close();
fout.close();
if(!fout)
{
return false;
if(!fout)
{
return false;
}
}
if ( perms )
{
......@@ -2940,42 +2968,36 @@ std::string SystemTools::FindProgram(
const std::vector<std::string>& userPaths,
bool no_system_path)
{
std::vector<std::string> extensions;
std::string tryPath;
#if defined (_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
bool hasExtension = false;
std::vector<std::string> extensions;
// check to see if the name already has a .xxx at
// the end of it
if(name.size() > 3 && name[name.size()-4] == '.')
{
hasExtension = true;
}
// on windows try .com then .exe
if(!hasExtension)
if(name.size() <= 3 || name[name.size()-4] != '.')
{
extensions.push_back(".com");
extensions.push_back(".exe");
}
#endif
std::string tryPath;
// first try with extensions if the os supports them
for(std::vector<std::string>::iterator i =
extensions.begin(); i != extensions.end(); ++i)
{
tryPath = name;
tryPath += *i;
if(SystemTools::FileExists(tryPath) &&
!SystemTools::FileIsDirectory(tryPath))
// first try with extensions if the os supports them
for(std::vector<std::string>::iterator i =
extensions.begin(); i != extensions.end(); ++i)
{
return SystemTools::CollapseFullPath(tryPath);
tryPath = name;
tryPath += *i;
if(SystemTools::FileExists(tryPath, true))
{
return SystemTools::CollapseFullPath(tryPath);
}
}
}
#endif
// now try just the name
tryPath = name;
if(SystemTools::FileExists(tryPath) &&
!SystemTools::FileIsDirectory(tryPath))
if(SystemTools::FileExists(name, true))
{
return SystemTools::CollapseFullPath(tryPath);
return SystemTools::CollapseFullPath(name);
}
// now construct the path
std::vector<std::string> path;
......@@ -3012,6 +3034,7 @@ std::string SystemTools::FindProgram(
// Remove double quotes from the path on windows
SystemTools::ReplaceString(*p, "\"", "");
#endif
#if defined (_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
// first try with extensions
for(std::vector<std::string>::iterator ext
= extensions.begin(); ext != extensions.end(); ++ext)
......@@ -3019,17 +3042,16 @@ std::string SystemTools::FindProgram(
tryPath = *p;
tryPath += name;
tryPath += *ext;
if(SystemTools::FileExists(tryPath) &&
!SystemTools::FileIsDirectory(tryPath))
if(SystemTools::FileExists(tryPath, true))
{
return SystemTools::CollapseFullPath(tryPath);
}
}
#endif
// now try it without them
tryPath = *p;
tryPath += name;
if(SystemTools::FileExists(tryPath) &&
!SystemTools::FileIsDirectory(tryPath))
if(SystemTools::FileExists(tryPath, true))
{
return SystemTools::CollapseFullPath(tryPath);
}
......@@ -3068,8 +3090,7 @@ std::string SystemTools
const std::vector<std::string>& userPaths)
{
// See if the executable exists as written.
if(SystemTools::FileExists(name) &&
!SystemTools::FileIsDirectory(name))
if(SystemTools::FileExists(name, true))
{
return SystemTools::CollapseFullPath(name);
}
......@@ -3105,8 +3126,7 @@ std::string SystemTools
tryPath = *p;
tryPath += name;
tryPath += ".framework";
if(SystemTools::FileExists(tryPath)
&& SystemTools::FileIsDirectory(tryPath))
if(SystemTools::FileIsDirectory(tryPath))
{
return SystemTools::CollapseFullPath(tryPath);
}
......@@ -3115,8 +3135,7 @@ std::string SystemTools
tryPath = *p;
tryPath += name;
tryPath += ".lib";
if(SystemTools::FileExists(tryPath)
&& !SystemTools::FileIsDirectory(tryPath))
if(SystemTools::FileExists(tryPath, true))
{
return SystemTools::CollapseFullPath(tryPath);
}
......@@ -3125,8 +3144,7 @@ std::string SystemTools
tryPath += "lib";
tryPath += name;
tryPath += ".so";
if(SystemTools::FileExists(tryPath)
&& !SystemTools::FileIsDirectory(tryPath))
if(SystemTools::FileExists(tryPath, true))
{
return SystemTools::CollapseFullPath(tryPath);