Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 22831 invoked by uid 500); 7 Apr 2003 07:22:51 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Delivered-To: moderator for dev@apr.apache.org Received: (qmail 67572 invoked from network); 4 Apr 2003 04:06:29 -0000 Date: Thu, 3 Apr 2003 20:08:25 -0800 From: Matt Kraai To: Justin Erenkrantz Cc: dev@apr.apache.org Subject: Re: [PATCH] create apr_file_mtime_set Message-ID: <20030404040825.GA194@ftbfs.org> References: <20030124235348.GC242@catalunya> <2147483647.1043482277@[10.0.1.9]> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2147483647.1043482277@[10.0.1.9]> User-Agent: Mutt/1.3.28i Sender: Matt Kraai X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Sat, Jan 25, 2003 at 08:11:17AM -0800, Justin Erenkrantz wrote: > --On Friday, January 24, 2003 3:53 PM -0800 Matt Kraai > wrote: > > >Subversion needs to change the files' modification times. The > >appended patch adds apr_file_mtime_set, which does so. It also > >adds apr_time_ansi_get, which is used to convert an apr_time_t to > >a time_t. > > Most of the manpages I read say that we should use utimes() not > utime(). It seems it'd be good to get away from using the utimbuf > structure if at all possible. I'm not sure about the general > availability of utimes() though (autoconf test?). I switched to utimes, though I didn't add an autoconf test. > I would think it would be best to have apr_time_ansi_get as a macro > rather than a function. (And that macro should just use the > apr_time_as_sec macro with an appropriate cast.) I avoided apr_time_ansi_get altogether. > I would also suggest reviewing the style guidelines. You have tabs > and no braces around if statements. -- justin Fixed. How about the following patch? Index: file_io/unix/filestat.c =================================================================== RCS file: /home/cvspublic/apr/file_io/unix/filestat.c,v retrieving revision 1.65 diff -u -r1.65 filestat.c --- file_io/unix/filestat.c 6 Mar 2003 09:21:24 -0000 1.65 +++ file_io/unix/filestat.c 4 Apr 2003 03:58:25 -0000 @@ -208,6 +208,30 @@ return apr_file_perms_set(fname, finfo.protection); } +APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, + apr_time_t mtime, + apr_pool_t *pool) +{ + 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) { + return errno; + } + return APR_SUCCESS; +} + APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, apr_int32_t wanted, apr_pool_t *pool) Index: include/apr_file_io.h =================================================================== RCS file: /home/cvspublic/apr/include/apr_file_io.h,v retrieving revision 1.138 diff -u -r1.138 apr_file_io.h --- include/apr_file_io.h 3 Apr 2003 23:20:05 -0000 1.138 +++ include/apr_file_io.h 4 Apr 2003 03:58:27 -0000 @@ -658,6 +658,18 @@ apr_pool_t *cont); /** + * Set the mtime of the specified file. + * @param fname The full path to the file (using / on all systems) + * @param mtime The mtime to apply to the file. + * @param pool The pool to use. + * @warning Platforms which do not implement this feature will return + * APR_ENOTIMPL. + */ +APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, + apr_time_t mtime, + apr_pool_t *pool); + +/** * Create a new directory on the file system. * @param path the path for the directory to be created. (use / on all systems) * @param perm Permissions for the new direcoty. Matt -- It's most certainly GNU/Linux, not Linux. Read more at http://www.gnu.org/gnu/why-gnu-linux.html.