Mercurial > hg > octave-lojdl > gnulib-hg
changeset 12161:c4a167621772
utimens: introduce fdutimens
at-func.c wants the file name argument first. This also paves the
way to add fdutimensat(dfd,name,fd,times,flag).
* lib/utimens.h (fdutimens): New prototype.
* lib/utimens.c (gl_futimens): Move guts...
(fdutimens): ...to new interface.
* tests/test-utimens.c (do_fdutimens): Use it.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Thu, 08 Oct 2009 06:40:08 -0600 |
parents | d0732ed2dd55 |
children | fe82ecf4f214 |
files | ChangeLog lib/utimens.c lib/utimens.h tests/test-utimens.c |
diffstat | 4 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-10-10 Eric Blake <ebb9@byu.net> + utimens: introduce fdutimens + * lib/utimens.h (fdutimens): New prototype. + * lib/utimens.c (gl_futimens): Move guts... + (fdutimens): ...to new interface. + * tests/test-utimens.c (do_fdutimens): Use it. + utimens: add UTIME_NOW and UTIME_OMIT support * lib/utimens.c (validate_timespec, update_timespec): New helper functions.
--- a/lib/utimens.c +++ b/lib/utimens.c @@ -132,7 +132,7 @@ Return 0 on success, -1 (setting errno) on failure. */ int -gl_futimens (int fd, char const *file, struct timespec const timespec[2]) +fdutimens (char const *file, int fd, struct timespec const timespec[2]) { struct timespec adjusted_timespec[2]; struct timespec *ts = timespec ? adjusted_timespec : NULL; @@ -300,6 +300,22 @@ } } +/* Set the access and modification time stamps of FD (a.k.a. FILE) to be + TIMESPEC[0] and TIMESPEC[1], respectively. + FD must be either negative -- in which case it is ignored -- + or a file descriptor that is open on FILE. + If FD is nonnegative, then FILE can be NULL, which means + use just futimes (or equivalent) instead of utimes (or equivalent), + and fail if on an old system without futimes (or equivalent). + If TIMESPEC is null, set the time stamps to the current time. + Return 0 on success, -1 (setting errno) on failure. */ + +int +gl_futimens (int fd, char const *file, struct timespec const timespec[2]) +{ + return fdutimens (file, fd, timespec); +} + /* Set the access and modification time stamps of FILE to be TIMESPEC[0] and TIMESPEC[1], respectively. */ int
--- a/lib/utimens.h +++ b/lib/utimens.h @@ -1,4 +1,5 @@ #include <time.h> +int fdutimens (char const *, int, struct timespec const [2]); int gl_futimens (int, char const *, struct timespec const [2]); int utimens (char const *, struct timespec const [2]); int lutimens (char const *, struct timespec const [2]);