2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* $Id: copytime.c,v 1.2 2006/07/04 04:57:42 hpa Exp $ */
14 /* ----------------------------------------------------------------------- *
16 * Copyright 2004 H. Peter Anvin - All Rights Reserved
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
21 * Bostom MA 02111-1307, USA; either version 2 of the License, or
22 * (at your option) any later version; incorporated herein by reference.
24 * ----------------------------------------------------------------------- */
29 * Copy time(s) from a struct stat
32 #include "mkzftree.h" /* Must be included first! */
36 #include <sys/types.h>
39 int copytime(const char *filename, const struct stat *st)
41 #if defined(HAVE_UTIMES) && (defined(HAVE_STRUCT_STAT_ST_MTIM_TV_USEC) || \
42 defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC))
46 # ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_USEC
50 tv[0].tv_sec = st->st_atim.tv_sec;
51 tv[0].tv_usec = st->st_atim.tv_nsec / 1000;
52 tv[1].tv_sec = st->st_mtim.tv_sec;
53 tv[1].tv_usec = st->st_mtim.tv_nsec / 1000;
55 return utimes(filename, tv);
61 ut.actime = st->st_atime;
62 ut.modtime = st->st_mtime;
63 return utime(filename, &ut);