summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsussman <sussman@13f79535-47bb-0310-9956-ffa450edef68>2003-07-08 16:03:37 +0000
committersussman <sussman@13f79535-47bb-0310-9956-ffa450edef68>2003-07-08 16:03:37 +0000
commitcdb1cc0907900a44242b27d2b99474e0d0e1d8ba (patch)
treeb27a85dc4db0dc1778dc596888dbda4e19d8ca58
parent7dcd99e6721a196527b774f8228e82b7704106c3 (diff)
downloadlibapr-cdb1cc0907900a44242b27d2b99474e0d0e1d8ba.tar.gz
Finish the new timestamp-setting API, thanks to helpful tips from
Brane and Cliff. Hopefully this will go out in httpd-2.0.48, and then subversion can make use of it. * configure.in: use AC_CHECK_FUNCS to look for utimes() and utime(). * file_io/unix/filestat.c (apr_file_mtime_set): use the new constants. * file_io/netware/filestat.c (apr_file_mtime_set): add dummy placeholder. * file_io/os2/filestat.c (apr_file_mtime_set): add dummy placeholder. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64566 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--configure.in1
-rw-r--r--file_io/netware/filestat.c8
-rw-r--r--file_io/os2/filestat.c9
-rw-r--r--file_io/unix/filestat.c33
4 files changed, 44 insertions, 7 deletions
diff --git a/configure.in b/configure.in
index 2ea66c18e..b60c8cfcb 100644
--- a/configure.in
+++ b/configure.in
@@ -788,6 +788,7 @@ AC_CHECK_FUNCS(writev)
sendfile="0"
AC_CHECK_LIB(sendfile, sendfilev)
AC_CHECK_FUNCS(sendfile send_file sendfilev, [ sendfile="1" ])
+AC_CHECK_FUNCS(utime utimes)
dnl THIS MUST COME AFTER THE THREAD TESTS - FreeBSD doesn't always have a
dnl threaded poll() and we don't want to use sendfile on early FreeBSD
diff --git a/file_io/netware/filestat.c b/file_io/netware/filestat.c
index 55512a912..ac3cbaeaf 100644
--- a/file_io/netware/filestat.c
+++ b/file_io/netware/filestat.c
@@ -387,3 +387,11 @@ APR_DECLARE(apr_status_t) apr_lstat(apr_finfo_t *finfo, const char *fname,
return apr_stat(finfo, fname, wanted | APR_FINFO_LINK, pool);
}
+
+/* ### Somebody please write this! */
+APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname,
+ apr_time_t mtime,
+ apr_pool_t *pool)
+{
+ return APR_ENOTIMPL;
+}
diff --git a/file_io/os2/filestat.c b/file_io/os2/filestat.c
index 747f6e9ce..f1c77ce36 100644
--- a/file_io/os2/filestat.c
+++ b/file_io/os2/filestat.c
@@ -255,3 +255,12 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname,
return APR_FROM_OS_ERROR(rc);
}
+
+
+/* ### Somebody please write this! */
+APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname,
+ apr_time_t mtime,
+ apr_pool_t *pool)
+{
+ return APR_ENOTIMPL;
+}
diff --git a/file_io/unix/filestat.c b/file_io/unix/filestat.c
index 08646f109..54784ddaa 100644
--- a/file_io/unix/filestat.c
+++ b/file_io/unix/filestat.c
@@ -220,21 +220,40 @@ APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname,
{
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) {
+#ifdef HAVE_UTIMES
+ {
+ struct timeval tvp[2];
+
+ 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;
+ }
+ }
+#elif defined(HAVE_UTIME)
+ {
+ struct utimbuf buf;
+
+ buf.actime = (time_t) (finfo.atime / APR_USEC_PER_SEC);
+ buf.modtime = (time_t) (mtime / APR_USEC_PER_SEC);
+
+ if (utime(fname, &buf) == -1) {
return errno;
+ }
}
+#else
+ return APR_ENOTIMPL;
+#endif
+
return APR_SUCCESS;
}