Chromium Code Reviews| Index: src/untrusted/nacl/utime.c |
| diff --git a/src/untrusted/nacl/utime.c b/src/untrusted/nacl/utime.c |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f8ba1af3923f4790d3412f98ce4e98bed27ba545 |
| --- /dev/null |
| +++ b/src/untrusted/nacl/utime.c |
| @@ -0,0 +1,36 @@ |
| +/* |
| + * Copyright 2015 The Native Client Authors. All rights reserved. |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include <errno.h> |
| +#include <sys/types.h> |
| +#include <sys/time.h> |
| +#include <utime.h> |
| + |
| +/* |
| + * TODO(sbc): remove this once utimes declaration get added to the newlib |
|
Mark Seaborn
2015/04/15 18:14:18
"gets"
Sam Clegg
2015/04/15 20:46:39
Done.
|
| + * headers. |
| + */ |
| +int utimes(const char *filename, const struct timeval tv[2]); |
| + |
| +/* |
| + * Implementation of utime based on the utimes. utime works just like utimes |
|
Mark Seaborn
2015/04/15 18:14:18
"the utimes" -> "utimes"
Suggestion: adding "()"
Sam Clegg
2015/04/15 20:46:40
Done.
|
| + * but only support timestamps with a granularity of one second (time_t). This |
|
Mark Seaborn
2015/04/15 18:14:18
"supports"
Sam Clegg
2015/04/15 20:46:40
Done.
|
| + * means we we can use utimes to impelement utime by simply setting tv_sec |
|
Mark Seaborn
2015/04/15 18:14:18
"implement". Also, you mean "tv_usec" not "tv_sec
Sam Clegg
2015/04/15 20:46:40
Done.
|
| + * fields to zero. |
| + */ |
| +int utime(const char *filename, const struct utimbuf *buf) { |
| + struct timeval times[2]; |
| + struct timeval *tv = NULL; |
| + if (buf != NULL) { |
| + times[0].tv_sec = buf->actime; |
| + times[1].tv_sec = buf->modtime; |
| + times[0].tv_usec = 0; |
| + times[1].tv_usec = 0; |
| + tv = times; |
| + } |
| + |
| + return utimes(filename, tv); |
| +} |