Thanks for your input Jeff. I've revised this patch some. Here it is...
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 13:19:02 2002 @@ -245,3 +245,26 @@ return apr_stat(finfo, fname, wanted | APR_FINFO_LINK, cont); } +APR_DECLARE(apr_status_t) apr_file_time_set(const char *fname, + apr_time_t atime, + apr_time_t mtime) +{ +#if APR_HAVE_UTIME_H + struct utimbuf utb; + int rc; + + if ((atime == 0) && (mtime == 0)) { + rc = utime(fname, NULL); + } + else { + utb.actime = (time_t)(atime / APR_USEC_PER_SEC); + utb.modtime = (time_t)(mtime / APR_USEC_PER_SEC); + rc = utime(fname, &utb); + } + 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 13:14:45 2002 @@ -244,6 +244,22 @@ */ 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. If atime and mtime are zero, the access and modification + * times are set to the current time. + * @param fname The name of the file to set times. + * @param atime The desired access time. + * @param mtime The desired modification time. + * @deffunc apr_status_t apr_file_time_set(const char *fname, apr_time_t atime, apr_time_t mtime) + * @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_file_time_set(const char *fname, apr_time_t atime, apr_time_t mtime); + /** @} */ /** * @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/configure.in =================================================================== --- configure.in.old Thu Mar 14 13:26:00 2002 +++ configure.in Thu Mar 14 13:42:05 2002 @@ -854,7 +854,8 @@ sys/types.h \ sys/uio.h \ sys/un.h \ - sys/wait.h) + sys/utime.h \ + sys/wait.h) dnl IRIX 6.5 has a problem in <netinet/tcp.h> which prevents it from dnl being included by itself. Check for <netinet/tcp.h> manually, @@ -903,6 +904,7 @@ AC_SUBST(signalh) AC_SUBST(sys_waith) AC_SUBST(pthreadh) +AC_SUBST(utime) dnl #----------------------------- Checking for h_errno in <netdb.h> if test "$netdbh" = "1"; then 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@ apr/include/apr.hw =================================================================== --- apr.hw.old Thu Mar 14 13:26:30 2002 +++ apr.hw Thu Mar 14 13:28:55 2002 @@ -129,6 +129,7 @@ #define APR_HAVE_STDDEF_H 1 #define APR_HAVE_PROCESS_H 1 #define APR_HAVE_TIME_H 1 +#define APR_HAVE_UTIME_H 0 #else #define APR_HAVE_ARPA_INET_H 0 #define APR_HAVE_CONIO_H 0 @@ -162,6 +163,7 @@ #define APR_HAVE_STDDEF_H 0 #define APR_HAVE_PROCESS_H 0 #define APR_HAVE_TIME_H 0 +#define APR_HAVE_UTIME_H 0 #endif #define APR_USE_FLOCK_SERIALIZE 0 apr/include/apr.hnw =================================================================== --- apr.hnw.old Thu Mar 14 13:26:18 2002 +++ apr.hnw Thu Mar 14 13:28:11 2002 @@ -128,6 +128,7 @@ #define APR_HAVE_SYS_WAIT_H 0 #define APR_HAVE_TIME_H 1 #define APR_HAVE_UNISTD_H 1 +#define APR_HAVE_UTIME_H 0 #define APR_HAVE_SHMEM_MMAP_TMP 0 #define APR_HAVE_SHMEM_MMAP_SHM 0 "Robert Simonson" <[EMAIL PROTECTED]> writes: > This patch adds apr_utime() to the APR. I did this against the unix > directories. A missing piece for unix is detecting the presence of utime.h and setting the utimeh variable. I think you just need to add utime.h to the APR_FLAG_HEADERS invocation in configure.in, then add an AC_SUBST(utimeh) invocation with the rest of them. > I don't know how this affects (if at all) other platforms. If somebody cares they will implement; if not, then it will be missing until somebody starts caring. I wonder if a feature test macro is needed. Initially we'd need to set APR_HAVE_UTIME_H to 0 in apr.hw (Win32) and apr.hnw (Netware). As far as the name apr_utime(): no freakin' way :) I'd suggest something like apr_file_time_set(). As far as which times to set (atime, ctime, mtime): I don't care about ctime either. I wonder if anybody else cares. As far as how to specify those times: I'd vote for separate parameters instead of stuffing them in a structure. I don't see the benefit to the structure. -- Jeff Trawick | [EMAIL PROTECTED] Born in Roswell... married an alien...