summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbnicholes <bnicholes@13f79535-47bb-0310-9956-ffa450edef68>2003-07-14 19:02:11 +0000
committerbnicholes <bnicholes@13f79535-47bb-0310-9956-ffa450edef68>2003-07-14 19:02:11 +0000
commitcaad936e85c9188cc7a1477b61ea59633f35c949 (patch)
tree3d087122d520dfeaf14fc01f46ea2ef4e9dc9ea0
parentea01698431c4f761ee2d18c88431c55b23fe925b (diff)
downloadlibapr-caad936e85c9188cc7a1477b61ea59633f35c949.tar.gz
Implemented apr_file_mtime_set() for NetWare
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64570 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--file_io/netware/filestat.c43
-rw-r--r--include/arch/netware/apr_private.h2
2 files changed, 43 insertions, 2 deletions
diff --git a/file_io/netware/filestat.c b/file_io/netware/filestat.c
index ac3cbaeaf..d02c77a84 100644
--- a/file_io/netware/filestat.c
+++ b/file_io/netware/filestat.c
@@ -62,6 +62,10 @@
#include "apr_hash.h"
#include "apr_thread_rwlock.h"
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif
+
/*#define APR_HAS_PSA*/
static apr_filetype_e filetype_from_mode(mode_t mode)
@@ -388,10 +392,45 @@ APR_DECLARE(apr_status_t) apr_lstat(apr_finfo_t *finfo, const char *fname,
}
-/* ### 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;
+ apr_status_t status;
+ apr_finfo_t finfo;
+
+ status = apr_stat(&finfo, fname, APR_FINFO_ATIME, pool);
+ if (!APR_STATUS_IS_SUCCESS(status)) {
+ return status;
+ }
+
+#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;
}
diff --git a/include/arch/netware/apr_private.h b/include/arch/netware/apr_private.h
index fef19ecbc..6eaf60300 100644
--- a/include/arch/netware/apr_private.h
+++ b/include/arch/netware/apr_private.h
@@ -87,6 +87,7 @@
#define HAVE_SYS_MMAN_H 1
#define HAVE_FCNTL_H 1
#define HAVE_ICONV_H 1
+#define HAVE_UTIME_H 1
#define HAVE_STRICMP 1
#define HAVE_STRNICMP 1
@@ -94,6 +95,7 @@
#define HAVE_STRSTR 1
#define HAVE_MEMCHR 1
#define HAVE_CALLOC 1
+#define HAVE_UTIME 1
/*#define DSO_USE_DLFCN */