On Sat, Jan 25, 2003 at 08:11:17AM -0800, Justin Erenkrantz wrote:
> --On Friday, January 24, 2003 3:53 PM -0800 Matt Kraai
> <[EMAIL PROTECTED]> wrote:
>
> >Subversion needs to change the files' modification times. The
> >appended patch adds apr_file_mtime_set, which does so. It also
> >adds apr_time_ansi_get, which is used to convert an apr_time_t to
> >a time_t.
>
> Most of the manpages I read say that we should use utimes() not
> utime(). It seems it'd be good to get away from using the utimbuf
> structure if at all possible. I'm not sure about the general
> availability of utimes() though (autoconf test?).
I switched to utimes, though I didn't add an autoconf test.
> I would think it would be best to have apr_time_ansi_get as a macro
> rather than a function. (And that macro should just use the
> apr_time_as_sec macro with an appropriate cast.)
I avoided apr_time_ansi_get altogether.
> I would also suggest reviewing the style guidelines. You have tabs
> and no braces around if statements. -- justin
Fixed.
How about the following patch?
Index: file_io/unix/filestat.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/unix/filestat.c,v
retrieving revision 1.65
diff -u -r1.65 filestat.c
--- file_io/unix/filestat.c 6 Mar 2003 09:21:24 -0000 1.65
+++ file_io/unix/filestat.c 4 Apr 2003 03:58:25 -0000
@@ -208,6 +208,30 @@
return apr_file_perms_set(fname, finfo.protection);
}
+APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname,
+ apr_time_t mtime,
+ apr_pool_t *pool)
+{
+ apr_status_t status;
+ apr_finfo_t finfo;
+ struct timeval tvp[2];
+
+ status = apr_stat(&finfo, fname, APR_FINFO_ATIME, pool);
+ if (!APR_STATUS_IS_SUCCESS(status)) {
+ return status;
+ }
+
+ tvp[0].tv_sec = apr_time_sec(finfo.atime);
+ tvp[0].tv_usec = apr_time_usec(finfo.atime);
+ tvp[1].tv_sec = apr_time_sec(mtime);
+ tvp[1].tv_usec = apr_time_usec(mtime);
+
+ if (utimes(fname, tvp) == -1) {
+ return errno;
+ }
+ return APR_SUCCESS;
+}
+
APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo,
const char *fname,
apr_int32_t wanted, apr_pool_t *pool)
Index: include/apr_file_io.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_file_io.h,v
retrieving revision 1.138
diff -u -r1.138 apr_file_io.h
--- include/apr_file_io.h 3 Apr 2003 23:20:05 -0000 1.138
+++ include/apr_file_io.h 4 Apr 2003 03:58:27 -0000
@@ -658,6 +658,18 @@
apr_pool_t *cont);
/**
+ * Set the mtime of the specified file.
+ * @param fname The full path to the file (using / on all systems)
+ * @param mtime The mtime to apply to the file.
+ * @param pool The pool to use.
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname,
+ apr_time_t mtime,
+ apr_pool_t *pool);
+
+/**
* Create a new directory on the file system.
* @param path the path for the directory to be created. (use / on all
systems)
* @param perm Permissions for the new direcoty.
Matt
--
It's most certainly GNU/Linux, not Linux. Read more at
http://www.gnu.org/gnu/why-gnu-linux.html.