mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* file.c (utime_internal): fallback utimensat to utimes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
81f0bb309e
commit
63a297994b
2 changed files with 23 additions and 11 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Nov 19 18:46:49 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* file.c (utime_internal): fallback utimensat to utimes.
|
||||
|
||||
Mon Nov 19 17:51:27 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* configure.in: check struct timespec, clock_gettime, utimensat,
|
||||
|
|
30
file.c
30
file.c
|
@ -2041,23 +2041,31 @@ rb_file_s_lchown(int argc, VALUE *argv)
|
|||
|
||||
struct timespec rb_time_timespec(VALUE time);
|
||||
|
||||
#if defined(HAVE_UTIMENSAT)
|
||||
|
||||
static void
|
||||
utime_internal(const char *path, void *arg)
|
||||
{
|
||||
struct timespec *tsp = arg;
|
||||
if (utimensat(AT_FDCWD, path, tsp, 0) < 0)
|
||||
rb_sys_fail(path);
|
||||
}
|
||||
|
||||
#elif defined(HAVE_UTIMES)
|
||||
#if defined(HAVE_UTIMES)
|
||||
|
||||
static void
|
||||
utime_internal(const char *path, void *arg)
|
||||
{
|
||||
struct timespec *tsp = arg;
|
||||
struct timeval tvbuf[2], *tvp = arg;
|
||||
|
||||
#ifdef HAVE_UTIMENSAT
|
||||
static int try_utimensat = 1;
|
||||
|
||||
if (try_utimensat) {
|
||||
struct timespec *tsp = arg;
|
||||
if (utimensat(AT_FDCWD, path, tsp, 0) < 0) {
|
||||
if (errno == ENOSYS) {
|
||||
try_utimensat = 0;
|
||||
goto no_utimensat;
|
||||
}
|
||||
rb_sys_fail(path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
no_utimensat:
|
||||
#endif
|
||||
|
||||
if (tsp) {
|
||||
tvbuf[0].tv_sec = tsp[0].tv_sec;
|
||||
tvbuf[0].tv_usec = tsp[0].tv_nsec / 1000;
|
||||
|
|
Loading…
Reference in a new issue