From 7913cf997a14e28cb5cb8367ac34e1526032ac84 Mon Sep 17 00:00:00 2001 From: bjh Date: Sat, 16 Jul 2005 08:10:49 +0000 Subject: OS/2: Implement apr_file_mtime_set(). Backport from trunk of r219295. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.1.x@219296 13f79535-47bb-0310-9956-ffa450edef68 --- file_io/os2/filestat.c | 13 ++++++++++++- include/arch/os2/apr_arch_file_io.h | 2 ++ time/unix/time.c | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/file_io/os2/filestat.c b/file_io/os2/filestat.c index 0414c7150..e6410e254 100644 --- a/file_io/os2/filestat.c +++ b/file_io/os2/filestat.c @@ -225,5 +225,16 @@ APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, apr_time_t mtime, apr_pool_t *pool) { - return APR_ENOTIMPL; + FILESTATUS3 fs3; + ULONG rc; + rc = DosQueryPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3)); + + if (rc) { + return APR_FROM_OS_ERROR(rc); + } + + apr_apr_time_to_os2_time(&fs3.fdateLastWrite, &fs3.ftimeLastWrite, mtime); + + rc = DosSetPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3), 0); + return APR_FROM_OS_ERROR(rc); } diff --git a/include/arch/os2/apr_arch_file_io.h b/include/arch/os2/apr_arch_file_io.h index 26045c1f6..ff3b3145b 100644 --- a/include/arch/os2/apr_arch_file_io.h +++ b/include/arch/os2/apr_arch_file_io.h @@ -66,6 +66,8 @@ struct apr_dir_t { apr_status_t apr_file_cleanup(void *); apr_status_t apr_os2_time_to_apr_time(apr_time_t *result, FDATE os2date, FTIME os2time); +apr_status_t apr_apr_time_to_os2_time(FDATE *os2date, FTIME *os2time, + apr_time_t aprtime); /* see win32/fileio.h for description of these */ extern const char c_is_fnchar[256]; diff --git a/time/unix/time.c b/time/unix/time.c index b005cf67b..713226203 100644 --- a/time/unix/time.c +++ b/time/unix/time.c @@ -266,6 +266,23 @@ APR_DECLARE(apr_status_t) apr_os2_time_to_apr_time(apr_time_t *result, *result = mktime(&tmpdate) * APR_USEC_PER_SEC; return APR_SUCCESS; } + +APR_DECLARE(apr_status_t) apr_apr_time_to_os2_time(FDATE *os2date, + FTIME *os2time, + apr_time_t aprtime) +{ + time_t ansitime = aprtime / APR_USEC_PER_SEC; + struct tm *lt; + lt = localtime(&ansitime); + os2time->hours = lt->tm_hour; + os2time->minutes = lt->tm_min; + os2time->twosecs = lt->tm_sec / 2; + + os2date->day = lt->tm_mday; + os2date->month = lt->tm_mon + 1; + os2date->year = lt->tm_year - 80; + return APR_SUCCESS; +} #endif #ifdef NETWARE -- cgit v1.2.1