| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright 2015 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 #include <errno.h> |
| 8 #include <sys/types.h> |
| 9 #include <sys/time.h> |
| 10 #include <utime.h> |
| 11 |
| 12 /* |
| 13 * TODO(sbc): remove this once utimes declaration gets added to the newlib |
| 14 * headers. |
| 15 */ |
| 16 int utimes(const char *filename, const struct timeval tv[2]); |
| 17 |
| 18 /* |
| 19 * Implementation of utime() based on utimes(). utime() works just like |
| 20 * utimes() but only supports timestamps with a granularity of one second |
| 21 * (time_t). This means we we can use utimes() to implement utime() by simply |
| 22 * setting tv_usec fields to zero. |
| 23 */ |
| 24 int utime(const char *filename, const struct utimbuf *buf) { |
| 25 struct timeval times[2]; |
| 26 struct timeval *tv = NULL; |
| 27 if (buf != NULL) { |
| 28 times[0].tv_sec = buf->actime; |
| 29 times[1].tv_sec = buf->modtime; |
| 30 times[0].tv_usec = 0; |
| 31 times[1].tv_usec = 0; |
| 32 tv = times; |
| 33 } |
| 34 |
| 35 return utimes(filename, tv); |
| 36 } |
| OLD | NEW |