apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Simonson" <s...@us.ibm.com>
Subject [PATCH] apr_file_time_set() (was: Re: [PATCH] Adding an apr_utime() function)
Date Fri, 22 Mar 2002 16:00:47 GMT

I've taken a shot at redoing this.  Is this more what you're thinking?

Thanks.

Rob Simonson
simo@us.ibm.com



apr/file_io/unix/filestat.c
===================================================================
--- filestat.c.old      Thu Mar 14 11:20:04 2002
+++ filestat.c    Fri Mar 22 09:49:34 2002
@@ -245,3 +245,35 @@
     return apr_stat(finfo, fname, wanted | APR_FINFO_LINK, cont);
 }

+APR_DECLARE(apr_status_t) apr_file_time_set(const char *fname,
+                                            enum apr_time_set_flag flag,
+                                            apr_time_t newtime)
+{
+#if APR_HAVE_UTIME_H
+    struct utimbuf utb;
+    int rc;
+
+    switch(flag) {
+        case APR_TIME_SET_ATIME:
+            utb.actime = (time_t)(newtime / APR_USEC_PER_SEC);
+            break;
+        case APR_TIME_SET_MTIME:
+            utb.modtime = (time_t)(newtime / APR_USEC_PER_SEC);
+            break;
+        case APR_TIME_SET_RESET:
+            rc = utime(fname, NULL);
+            return APR_SUCCESS;
+        case APR_TIME_SET_CTIME:
+        case APR_TIME_SET_CRTIME:
+        default:
+            return APR_ENOTIMPL;
+    }
+
+    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     Fri Mar 22 09:48:42 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 time value to change.
+ * @param newtime The new time value.
+ * @deffunc apr_status_t apr_file_time_set(const char *fname, enum
apr_time_set_flag flag, apr_time_t newtime)
+ * @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, enum
apr_time_set_flag flag, apr_time_t newtime);
+
 /** @} */
 /**
  * @defgroup APR_DIRECTORY Directory Manipulation Functions



apr/include/arch/fileio.h
===================================================================
--- fileio.h.old  Thu Mar 14 11:36:35 2002
+++ fileio.h      Fri Mar 22 09:49:21 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
@@ -148,6 +151,14 @@
     DIR *dirstruct;
     struct dirent *entry;
 };
+
+enum apr_time_set_flag {
+    APR_TIME_SET_RESET,
+    APR_TIME_SET_ATIME,
+    APR_TIME_SET_MTIME,
+    APR_TIME_SET_CTIME,
+    APR_TIME_SET_CRTIME
+};

 apr_status_t apr_unix_file_cleanup(void *);


apr/configure.in
===================================================================
--- configure.in.old    Thu Mar 14 13:26:00 2002
+++ configure.in  Fri Mar 22 09:51:34 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(utimeh)

 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


Mime
View raw message