Chromium Code Reviews| 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 | |
| 8 #include <sys/types.h> | |
| 9 #include <utime.h> | |
| 10 #include <sys/time.h> | |
| 11 #include <errno.h> | |
|
Mark Seaborn
2015/04/07 19:08:43
Sort #includes
Sam Clegg
2015/04/10 21:18:55
Done.
| |
| 12 #include <stdio.h> | |
|
Mark Seaborn
2015/04/07 19:08:43
Not needed
Sam Clegg
2015/04/10 21:18:56
Done.
| |
| 13 | |
| 14 #include "native_client/src/untrusted/nacl/nacl_irt.h" | |
|
Mark Seaborn
2015/04/07 19:08:43
Not needed with the change below...
Sam Clegg
2015/04/10 21:18:55
Done.
| |
| 15 | |
| 16 /* | |
| 17 * Implementation of utime based on the utimes IRT function. utime works | |
| 18 * just like utimes but only support timestamps with a granularity of one | |
| 19 * second (support time_t). This means we we can use utimes to impelement | |
|
Mark Seaborn
2015/04/07 19:08:43
What do you mean by "support time_t"? Can you rem
Sam Clegg
2015/04/10 21:18:56
Done.
| |
| 20 * utime by simply setting tv_sec fields to zero. | |
| 21 */ | |
| 22 int utime(const char *filename, const struct utimbuf *buf) { | |
| 23 if (!__libnacl_irt_init_fn(&__libnacl_irt_dev_filename.utimes, | |
| 24 __libnacl_irt_dev_filename_init)) { | |
| 25 return -1; | |
| 26 } | |
| 27 | |
| 28 struct timeval times[2]; | |
| 29 struct timeval* tv = NULL; | |
|
Mark Seaborn
2015/04/07 19:08:43
Use " *" spacing
Sam Clegg
2015/04/10 21:18:55
Done.
| |
| 30 if (buf != NULL) { | |
| 31 times[0].tv_sec = buf->actime; | |
| 32 times[1].tv_sec = buf->modtime; | |
| 33 times[0].tv_usec = 0; | |
| 34 times[1].tv_usec = 0; | |
| 35 tv = times; | |
| 36 } | |
| 37 | |
| 38 int error = __libnacl_irt_dev_filename.utimes(filename, tv); | |
|
Mark Seaborn
2015/04/07 19:08:43
Just call utimes() instead of getting the IRT inte
Sam Clegg
2015/04/10 21:18:55
Done.
| |
| 39 if (error) { | |
| 40 errno = error; | |
| 41 return -1; | |
| 42 } | |
| 43 | |
| 44 return 0; | |
| 45 } | |
| OLD | NEW |