This patch adds apr_utime() to the APR. I did this against the unix
directories.
I don't know how this affects (if at all) other platforms.
Thanks.
Rob Simonson
[EMAIL PROTECTED]
apr/file_io/unix/filestat.c
===================================================================
--- filestat.c.old Thu Mar 14 11:20:04 2002
+++ filestat.c Thu Mar 14 12:13:49 2002
@@ -245,3 +245,24 @@
return apr_stat(finfo, fname, wanted | APR_FINFO_LINK, cont);
}
+APR_DECLARE(apr_status_t) apr_utime(const char *fname, apr_utimbuf_t *buf)
+{
+#if APR_HAVE_UTIME_H
+ struct utimbuf utb;
+ int rc;
+
+ if (buf != NULL) {
+ utb.actime = (time_t)(buf->atime / APR_USEC_PER_SEC);
+ utb.modtime = (time_t)(buf->mtime / APR_USEC_PER_SEC);
+ rc = utime(fname, &utb);
+ }
+ else {
+ rc = utime(fname, NULL);
+ }
+ if(rc != 0)
+ return errno;
+ return APR_SUCCESS;
+#else
+ return APR_ENOTIMPL;
+#endif
+}
apr/include/apr_file_info.h
===================================================================
--- apr_file_info.h.old Thu Mar 14 11:21:06 2002
+++ apr_file_info.h Thu Mar 14 11:47:26 2002
@@ -144,6 +144,12 @@
#endif
/**
+ * @defgroup APR_utime struture
+ * @{
+ */
+typedef struct apr_utimbuf_t apr_utimbuf_t;
+
+/**
* @defgroup APR_File_Info Stat Functions
* @{
*/
@@ -219,6 +225,16 @@
};
/**
+ * The utimbuf structure analogous to POSIX.1 definition.
+ */
+struct apr_utimbuf_t {
+ /** The new access time */
+ apr_time_t atime;
+ /** The new modification time */
+ apr_time_t mtime;
+};
+
+/**
* get the specified file's stats. The file is specified by filename,
* instead of using a pre-opened file.
* @param finfo Where to store the information about the file, which is
@@ -244,6 +260,21 @@
*/
APR_DECLARE(apr_status_t) apr_lstat(apr_finfo_t *finfo, const char *fname,
apr_int32_t wanted, apr_pool_t *cont);
+
+/**
+ * Set the specified file's access and modification times. The file is
+ * specified by filename, instead of using a pre-opened file. If the file
is a
+ * symlink, this function will resolve the link and set times for the file
the
+ * symlink refers to.
+ * @param fname The name of the file to set times.
+ * @param buf The desired access and modification times. If buf is a NULL
+ * pointer, the access and modification times are set to the current time.
+ * @deffunc apr_status_t apr_utime(const char *fname, apr_utimbuf_t *buf)
+ * @tip This function returns APR_ENOTIMPL if the platform does not
support
+ * change of file access and modification times.
+ */
+APR_DECLARE(apr_status_t) apr_utime(const char *fname, apr_utimbuf_t
*buf);
+
/** @} */
/**
* @defgroup APR_DIRECTORY Directory Manipulation Functions
apr/include/arch/fileio.h
===================================================================
--- fileio.h.old Thu Mar 14 11:36:35 2002
+++ fileio.h Thu Mar 14 12:07:19 2002
@@ -105,6 +105,9 @@
#ifdef BEOS
#include <kernel/OS.h>
#endif
+#if APR_HAVE_UTIME_H
+#include <utime.h>
+#endif
#if BEOS_BONE
#ifndef BONE7
apr/include/apr.h.in
===================================================================
--- apr_h.in.old Thu Mar 14 12:20:25 2002
+++ apr_h.in Thu Mar 14 12:21:59 2002
@@ -63,6 +63,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@