Added missing version tags, clean-up
[AROS.git] / compiler / clib / utime.c
blobe54c93846149ae40c3ab82cf67a76db5367a7823
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <errno.h>
7 #include <time.h>
8 #include <sys/time.h>
10 /*****************************************************************************
12 NAME */
14 #include <utime.h>
16 int utime(
18 /* SYNOPSIS */
19 const char *filename,
20 const struct utimbuf *buf)
22 /* FUNCTION
23 Change last access and last modification time of the given file to
24 times specified in given utimbuf structure. If buf is NULL, the
25 current time will be used instead.
27 The utimbuf structure contains of two fields:
29 time_t actime; - last access time
30 time_t modtime; - last modification time
32 INPUTS
33 filename - Name of the file
34 buf - Pointer to utimbuf structure describing specified time.
36 RESULT
37 0 on success and -1 on error. If an error occurred, the global
38 variable errno is set.
40 NOTES
41 This function can be used to set access and modification times with
42 a resolution of 1 second, use utimes() if you need better precision.
44 EXAMPLE
46 BUGS
47 Since AROS has no notion of last access time, actime field is silently
48 ignored, only modification time of the file is set.
50 SEE ALSO
51 utimes()
53 INTERNALS
55 ******************************************************************************/
57 struct timeval ts[2];
59 if( buf == NULL )
61 time_t tt = time( NULL );
63 ts[0].tv_sec = tt;
64 ts[1].tv_sec = tt;
66 else
68 ts[0].tv_sec = buf->actime;
69 ts[1].tv_sec = buf->modtime;
72 ts[0].tv_usec = 0;
73 ts[1].tv_usec = 0;
75 return utimes(filename, ts);