Merge topic 'update-kwsys'
9d38db5
bootstrap: Compile KWSys SystemTools with UTIME(S|NSAT) values884e3ed
Merge branch 'upstream-kwsys' into update-kwsysd66f6f3
KWSys 2013-05-31 (dccf7725)
This commit is contained in:
commit
1e15db3662
|
@ -569,8 +569,17 @@ IF(KWSYS_USE_SystemTools)
|
||||||
"Checking whether CXX compiler has unsetenv" DIRECT)
|
"Checking whether CXX compiler has unsetenv" DIRECT)
|
||||||
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
|
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
|
||||||
"Checking whether CXX compiler has environ in stdlib.h" DIRECT)
|
"Checking whether CXX compiler has environ in stdlib.h" DIRECT)
|
||||||
SET_SOURCE_FILES_PROPERTIES(SystemTools.cxx PROPERTIES
|
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMES
|
||||||
COMPILE_FLAGS "-DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} -DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV} -DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}")
|
"Checking whether CXX compiler has utimes" DIRECT)
|
||||||
|
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMENSAT
|
||||||
|
"Checking whether CXX compiler has utimensat" 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}
|
||||||
|
)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(KWSYS_USE_SystemInformation)
|
IF(KWSYS_USE_SystemInformation)
|
||||||
|
|
|
@ -1124,22 +1124,58 @@ bool SystemTools::Touch(const char* filename, bool create)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
#define utime _utime
|
HANDLE h = CreateFile(filename, FILE_WRITE_ATTRIBUTES,
|
||||||
#define utimbuf _utimbuf
|
FILE_SHARE_WRITE, 0, OPEN_EXISTING,
|
||||||
|
FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||||
|
if(!h)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
FILETIME mtime;
|
||||||
|
GetSystemTimeAsFileTime(&mtime);
|
||||||
|
if(!SetFileTime(h, 0, 0, &mtime))
|
||||||
|
{
|
||||||
|
CloseHandle(h);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CloseHandle(h);
|
||||||
|
#elif KWSYS_CXX_HAS_UTIMENSAT
|
||||||
|
struct timespec times[2] = {{0,UTIME_OMIT},{0,UTIME_NOW}};
|
||||||
|
if(utimensat(AT_FDCWD, filename, times, 0) < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
struct stat st;
|
||||||
|
if(stat(filename, &st) < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
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 */
|
||||||
|
# else
|
||||||
|
{st.st_atime, 0},
|
||||||
|
# endif
|
||||||
|
mtime
|
||||||
|
};
|
||||||
|
if(utimes(filename, times) < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
struct utimbuf times = {st.st_atime, mtime.tv_sec};
|
||||||
|
if(utime(filename, ×) < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
struct stat fromStat;
|
|
||||||
if(stat(filename, &fromStat) < 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
struct utimbuf buf;
|
|
||||||
buf.actime = fromStat.st_atime;
|
|
||||||
buf.modtime = static_cast<time_t>(SystemTools::GetTime());
|
|
||||||
if(utime(filename, &buf) < 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -494,6 +494,25 @@ int main()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TEST_KWSYS_CXX_HAS_UTIMES
|
||||||
|
#include <sys/time.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
struct timeval* current_time = 0;
|
||||||
|
return utimes("/example", current_time);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TEST_KWSYS_CXX_HAS_UTIMENSAT
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
struct timespec times[2] = {{0,UTIME_OMIT},{0,UTIME_NOW}};
|
||||||
|
return utimensat(AT_FDCWD, "/example", times, AT_SYMLINK_NOFOLLOW);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TEST_KWSYS_CXX_TYPE_INFO
|
#ifdef TEST_KWSYS_CXX_TYPE_INFO
|
||||||
/* Collect fundamental type information and save it to a CMake script. */
|
/* Collect fundamental type information and save it to a CMake script. */
|
||||||
|
|
||||||
|
|
10
bootstrap
10
bootstrap
|
@ -1082,6 +1082,8 @@ KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
|
||||||
KWSYS_CXX_HAS_SETENV=0
|
KWSYS_CXX_HAS_SETENV=0
|
||||||
KWSYS_CXX_HAS_UNSETENV=0
|
KWSYS_CXX_HAS_UNSETENV=0
|
||||||
KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0
|
KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0
|
||||||
|
KWSYS_CXX_HAS_UTIMENSAT=0
|
||||||
|
KWSYS_CXX_HAS_UTIMES=0
|
||||||
KWSYS_CXX_HAS_CSTDDEF=0
|
KWSYS_CXX_HAS_CSTDDEF=0
|
||||||
KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
|
KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
|
||||||
KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
|
KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
|
||||||
|
@ -1466,7 +1468,13 @@ if [ "x${cmake_cxx_flags}" != "x" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmake_c_flags_String="-DKWSYS_STRING_C"
|
cmake_c_flags_String="-DKWSYS_STRING_C"
|
||||||
cmake_cxx_flags_SystemTools="-DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} -DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV} -DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}"
|
cmake_cxx_flags_SystemTools="
|
||||||
|
-DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV}
|
||||||
|
-DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV}
|
||||||
|
-DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}
|
||||||
|
-DKWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT}
|
||||||
|
-DKWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
|
||||||
|
"
|
||||||
cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
|
cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
|
||||||
-I`cmake_escape \"${cmake_bootstrap_dir}\"`"
|
-I`cmake_escape \"${cmake_bootstrap_dir}\"`"
|
||||||
cmake_cxx_flags="${cmake_cxx_flags} -I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
|
cmake_cxx_flags="${cmake_cxx_flags} -I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
|
||||||
|
|
Loading…
Reference in New Issue