Merge pull request #1920 from felixhandte/fix-mtim-again
Use statbuf->st_mtim Again
This commit is contained in:
@@ -137,6 +137,13 @@ matrix:
|
|||||||
- make arminstall
|
- make arminstall
|
||||||
- make armfuzz
|
- make armfuzz
|
||||||
|
|
||||||
|
# Introduced to check compat with old toolchains, to prevent e.g. #1872
|
||||||
|
- name: ARM Build Test (on Trusty)
|
||||||
|
dist: trusty
|
||||||
|
script:
|
||||||
|
- make arminstall
|
||||||
|
- make armbuild
|
||||||
|
|
||||||
- name: Qemu PPC + Fuzz Test # ~13mn
|
- name: Qemu PPC + Fuzz Test # ~13mn
|
||||||
dist: trusty # it seems ppc cross-compilation fails on "current"
|
dist: trusty # it seems ppc cross-compilation fails on "current"
|
||||||
script:
|
script:
|
||||||
|
|||||||
@@ -109,6 +109,15 @@ extern "C" {
|
|||||||
#endif /* PLATFORM_POSIX_VERSION */
|
#endif /* PLATFORM_POSIX_VERSION */
|
||||||
|
|
||||||
|
|
||||||
|
#if PLATFORM_POSIX_VERSION > 1
|
||||||
|
/* glibc < 2.26 may not expose struct timespec def without this.
|
||||||
|
* See issue #1920. */
|
||||||
|
# ifndef _ATFILE_SOURCE
|
||||||
|
# define _ATFILE_SOURCE
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*-*********************************************
|
/*-*********************************************
|
||||||
* Detect if isatty() and fileno() are available
|
* Detect if isatty() and fileno() are available
|
||||||
************************************************/
|
************************************************/
|
||||||
|
|||||||
+12
-8
@@ -145,20 +145,24 @@ int UTIL_setFileStat(const char *filename, stat_t *statbuf)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* set access and modification times */
|
/* set access and modification times */
|
||||||
#if defined(_WIN32) || (PLATFORM_POSIX_VERSION < 200809L)
|
/* We check that st_mtime is a macro here in order to give us confidence
|
||||||
|
* that struct stat has a struct timespec st_mtim member. We need this
|
||||||
|
* check because there are some platforms that claim to be POSIX 2008
|
||||||
|
* compliant but which do not have st_mtim... */
|
||||||
|
#if (PLATFORM_POSIX_VERSION >= 200809L) && defined(st_mtime)
|
||||||
|
{
|
||||||
|
/* (atime, mtime) */
|
||||||
|
struct timespec timebuf[2] = { {0, UTIME_NOW} };
|
||||||
|
timebuf[1] = statbuf->st_mtim;
|
||||||
|
res += utimensat(AT_FDCWD, filename, timebuf, 0);
|
||||||
|
}
|
||||||
|
#else
|
||||||
{
|
{
|
||||||
struct utimbuf timebuf;
|
struct utimbuf timebuf;
|
||||||
timebuf.actime = time(NULL);
|
timebuf.actime = time(NULL);
|
||||||
timebuf.modtime = statbuf->st_mtime;
|
timebuf.modtime = statbuf->st_mtime;
|
||||||
res += utime(filename, &timebuf);
|
res += utime(filename, &timebuf);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
{
|
|
||||||
/* (atime, mtime) */
|
|
||||||
struct timespec timebuf[2] = { {0, UTIME_NOW} };
|
|
||||||
timebuf[1].tv_sec = statbuf->st_mtime;
|
|
||||||
res += utimensat(AT_FDCWD, filename, timebuf, 0);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
|||||||
Reference in New Issue
Block a user