Howdy,
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.
It only implements them on UNIX. If this isn't acceptable, please
let me know what I need to do.
Matt
diff -ur apr.orig/configure.in apr/configure.in
--- apr.orig/configure.in 2003-01-06 16:10:03.000000000 -0800
+++ apr/configure.in 2003-01-24 15:37:29.000000000 -0800
@@ -935,6 +935,7 @@
tpfio.h \
unistd.h \
unix.h \
+ utime.h \
arpa/inet.h \
kernel/OS.h \
net/errno.h \
@@ -1005,6 +1006,7 @@
AC_SUBST(sys_unh)
AC_SUBST(timeh)
AC_SUBST(unistdh)
+AC_SUBST(utimeh)
AC_SUBST(signalh)
AC_SUBST(sys_waith)
AC_SUBST(pthreadh)
diff -ur apr.orig/file_io/unix/filestat.c apr/file_io/unix/filestat.c
--- apr.orig/file_io/unix/filestat.c 2003-01-06 21:28:47.000000000 -0800
+++ apr/file_io/unix/filestat.c 2003-01-24 15:39:31.000000000 -0800
@@ -202,6 +202,26 @@
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 utimbuf ut;
+
+ status = apr_stat(&finfo, fname, APR_FINFO_ATIME, pool);
+ if (!APR_STATUS_IS_SUCCESS(status))
+ return status;
+
+ apr_time_ansi_get(&ut.actime, finfo.atime);
+ apr_time_ansi_get(&ut.modtime, mtime);
+
+ if (utime(fname, &ut) == -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)
diff -ur apr.orig/include/apr.h.in apr/include/apr.h.in
--- apr.orig/include/apr.h.in 2003-01-22 15:54:18.000000000 -0800
+++ apr/include/apr.h.in 2003-01-24 15:36:14.000000000 -0800
@@ -66,6 +66,7 @@
#define APR_HAVE_SYS_WAIT_H @sys_waith@
#define APR_HAVE_TIME_H @timeh@
#define APR_HAVE_UNISTD_H @unistdh@
+#define APR_HAVE_UTIME_H @utimeh@
#define APR_HAVE_SHMEM_MMAP_TMP @havemmaptmp@
#define APR_HAVE_SHMEM_MMAP_SHM @havemmapshm@
diff -ur apr.orig/include/apr_file_io.h apr/include/apr_file_io.h
--- apr.orig/include/apr_file_io.h 2002-12-31 21:22:29.000000000 -0800
+++ apr/include/apr_file_io.h 2003-01-24 14:59:26.000000000 -0800
@@ -628,6 +628,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.
diff -ur apr.orig/include/apr_time.h apr/include/apr_time.h
--- apr.orig/include/apr_time.h 2002-12-31 21:22:29.000000000 -0800
+++ apr/include/apr_time.h 2003-01-24 15:10:24.000000000 -0800
@@ -161,6 +161,14 @@
time_t input);
/**
+ * convert an apr_time_t to an ansi time_t
+ * @param result the resulting time_t
+ * @param input the apr_time_t to convert
+ */
+APR_DECLARE(apr_status_t) apr_time_ansi_get(time_t *result,
+ apr_time_t input);
+
+/**
* convert a time to its human readable components using an offset
* from GMT
* @param result the exploded time
diff -ur apr.orig/include/arch/unix/apr_arch_file_io.h
apr/include/arch/unix/apr_arch_file_io.h
--- apr.orig/include/arch/unix/apr_arch_file_io.h 2003-01-06
16:52:54.000000000 -0800
+++ apr/include/arch/unix/apr_arch_file_io.h 2003-01-24 15:13:08.000000000
-0800
@@ -102,6 +102,9 @@
#if APR_HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
+#if APR_HAVE_UTIME_H
+#include <utime.h>
+#endif
#ifdef BEOS
#include <kernel/OS.h>
#endif
diff -ur apr.orig/time/unix/time.c apr/time/unix/time.c
--- apr.orig/time/unix/time.c 2003-01-06 16:10:20.000000000 -0800
+++ apr/time/unix/time.c 2003-01-24 15:11:47.000000000 -0800
@@ -107,6 +107,13 @@
return APR_SUCCESS;
}
+APR_DECLARE(apr_status_t) apr_time_ansi_get(time_t *result,
+ apr_time_t input)
+{
+ *result = (time_t)(input / APR_USEC_PER_SEC);
+ return APR_SUCCESS;
+}
+
/* NB NB NB NB This returns GMT!!!!!!!!!! */
APR_DECLARE(apr_time_t) apr_time_now(void)
{