diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-25 13:50:02 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-25 13:50:02 +0000 |
commit | 9ad5e4f642bdeda83edc17d43f882d50e96936c3 (patch) | |
tree | 9e0d8f413cd7bddabfa2d0958bd32ba60da7bf3a /usr.bin/rcs/rcsprog.c | |
parent | b5132fce78aaef078187dca50dbe9547b87b3c7b (diff) |
add support for `-T' and enable it for co(1);
tested and OK niallo@. "Looks good" joris@.
Diffstat (limited to 'usr.bin/rcs/rcsprog.c')
-rw-r--r-- | usr.bin/rcs/rcsprog.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index d3c261a5fdc..df48069172b 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.46 2005/11/23 09:39:20 xsa Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.47 2005/11/25 13:50:01 xsa Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -83,6 +83,52 @@ rcs_set_rev(const char *str, RCSNUM **rev) } } +/* + * rcs_get_mtime() + * + * Get <filename> last modified time. + * Returns last modified time on success, or -1 on failure. + */ +time_t +rcs_get_mtime(const char *filename) +{ + struct stat st; + time_t mtime; + + if (stat(filename, &st) == -1) { + cvs_log(LP_ERRNO, "failed to stat `%s'", filename); + return (-1); + } + mtime = (time_t)st.st_mtimespec.tv_sec; + + return (mtime); +} + +/* + * rcs_set_mtime() + * + * Set <filename> last modified time to <mtime> if it's not set to -1. + * Returns 0 on success, or -1 on failure. + */ +int +rcs_set_mtime(const char *filename, time_t mtime) +{ + static struct timeval tv[2]; + + if (mtime == -1) + return (0); + + tv[0].tv_sec = mtime; + tv[1].tv_sec = tv[0].tv_sec; + + if (utimes(filename, tv) == -1) { + cvs_log(LP_ERRNO, "error setting utimes"); + return (-1); + } + + return (0); +} + int rcs_init(char *envstr, char **argv, int argvlen) { |