mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-05 14:11:00 +00:00
Add check for statbuf.st_mtim if available and use statbuf.st_mtim to get nanosecond precision in modification date, also fix conversion of nanoseconds in creation date.
This commit is contained in:
parent
625e8541a9
commit
ece6fc97ff
5 changed files with 39 additions and 8 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2021-02-02 Riccardo Mottola <rm@gnu.org>
|
||||
|
||||
* configure
|
||||
* configure.ac
|
||||
Add check for statbuf.st_mtim if available
|
||||
|
||||
* Source/NSFileManager.m
|
||||
Use statbuf.st_mtim to get nanosecond precision in modification
|
||||
date, also fix conversion of nanoseconds in creation date.
|
||||
|
||||
2021-01-21 Fred Kiefer <fredkiefer@gmx.de>
|
||||
|
||||
* Tools/pl2link.m (main): Set key StartupWMClass and allow file
|
||||
|
|
|
@ -592,6 +592,9 @@
|
|||
/* Define to 1 if `st_birthtimespec' is a member of `struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC
|
||||
|
||||
/* Define to 1 if `st_mtim' is a member of `struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_MTIM
|
||||
|
||||
/* Define to 1 if you have the `symlink' function. */
|
||||
#undef HAVE_SYMLINK
|
||||
|
||||
|
|
|
@ -611,8 +611,8 @@ static NSStringEncoding defaultEncoding;
|
|||
struct timespec ub[2];
|
||||
ub[0].tv_sec = 0;
|
||||
ub[0].tv_nsec = UTIME_OMIT; // we don't touch access time
|
||||
ub[1].tv_sec = truncl(ti);
|
||||
ub[1].tv_nsec = (ti - (double)ub[1].tv_sec) * 1.0e6;
|
||||
ub[1].tv_sec = (time_t)trunc(ti);
|
||||
ub[1].tv_nsec = (long)trunc((ti - trunc(ti)) * 1.0e9);
|
||||
|
||||
ok = (utimensat(AT_FDCWD, lpath, ub, 0) == 0);
|
||||
#elif defined(_POSIX_VERSION)
|
||||
|
@ -661,8 +661,8 @@ static NSStringEncoding defaultEncoding;
|
|||
struct timespec ub[2];
|
||||
ub[0].tv_sec = 0;
|
||||
ub[0].tv_nsec = UTIME_OMIT; // we don't touch access time
|
||||
ub[1].tv_sec = truncl(ti);
|
||||
ub[1].tv_nsec = (ti - (double)ub[1].tv_sec) * 1.0e6;
|
||||
ub[1].tv_sec = (time_t)trunc(ti);
|
||||
ub[1].tv_nsec = (long)trunc((ti - trunc(ti)) * 1.0e9);
|
||||
|
||||
ok = (utimensat(AT_FDCWD, lpath, ub, 0) == 0);
|
||||
#elif defined(_WIN32) || defined(_POSIX_VERSION)
|
||||
|
@ -3874,7 +3874,15 @@ static NSSet *fileKeys = nil;
|
|||
|
||||
- (NSDate*) fileModificationDate
|
||||
{
|
||||
return [NSDate dateWithTimeIntervalSince1970: statbuf.st_mtime];
|
||||
NSTimeInterval ti;
|
||||
|
||||
#if defined (HAVE_STRUCT_STAT_ST_MTIM)
|
||||
ti = statbuf.st_mtim.tv_sec + (double)statbuf.st_mtim.tv_nsec / 1.0e9;
|
||||
#else
|
||||
ti = (double)statbuf.st_mtime;
|
||||
#endif
|
||||
|
||||
return [NSDate dateWithTimeIntervalSince1970: ti];
|
||||
}
|
||||
|
||||
- (NSUInteger) filePosixPermissions
|
||||
|
|
12
configure
vendored
12
configure
vendored
|
@ -9492,7 +9492,17 @@ fi
|
|||
fi
|
||||
|
||||
|
||||
# Look for file creation date on NetBSD, FreeBSD, Darwin
|
||||
# Look for file creation and modification date on NetBSD, FreeBSD, Darwin
|
||||
ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat_st_mtim" "#include <sys/stat.h>
|
||||
"
|
||||
if test "x$ac_cv_member_struct_stat_st_mtim" = xyes; then :
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_STRUCT_STAT_ST_MTIM 1
|
||||
_ACEOF
|
||||
|
||||
|
||||
fi
|
||||
ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtime" "ac_cv_member_struct_stat_st_birthtime" "#include <sys/stat.h>
|
||||
"
|
||||
if test "x$ac_cv_member_struct_stat_st_birthtime" = xyes; then :
|
||||
|
|
|
@ -2399,8 +2399,8 @@ fi
|
|||
AC_CHECK_FUNCS(getcwd)
|
||||
AC_HEADER_DIRENT
|
||||
|
||||
# Look for file creation date on NetBSD, FreeBSD, Darwin
|
||||
AC_CHECK_MEMBERS([struct stat.st_birthtime, struct stat.st_birthtimespec, struct stat.st_birthtim, struct stat64.st_birthtimespec],
|
||||
# Look for file creation and modification date on NetBSD, FreeBSD, Darwin
|
||||
AC_CHECK_MEMBERS([struct stat.st_mtim, struct stat.st_birthtime, struct stat.st_birthtimespec, struct stat.st_birthtim, struct stat64.st_birthtimespec],
|
||||
,,[#include <sys/stat.h>])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue