alsa.audio: disable building of alsa-bridge linklib until complete driver is ready
[AROS.git] / compiler / posixc / utime.c
blob8c9a97c50c70bb30fae348e3de6f739fd3d7a3e5
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX.1-2008 function utime().
6 */
8 #include <errno.h>
9 #include <time.h>
10 #include <sys/time.h>
12 /*****************************************************************************
14 NAME */
16 #include <utime.h>
18 int utime(
20 /* SYNOPSIS */
21 const char *filename,
22 const struct utimbuf *buf)
24 /* FUNCTION
25 Change last access and last modification time of the given file to
26 times specified in given utimbuf structure. If buf is NULL, the
27 current time will be used instead.
29 The utimbuf structure contains of two fields:
31 time_t actime; - last access time
32 time_t modtime; - last modification time
34 INPUTS
35 filename - Name of the file
36 buf - Pointer to utimbuf structure describing specified time.
38 RESULT
39 0 on success and -1 on error. If an error occurred, the global
40 variable errno is set.
42 NOTES
43 This function can be used to set access and modification times with
44 a resolution of 1 second, use utimes() if you need better precision.
46 EXAMPLE
48 BUGS
49 Since AROS has no notion of last access time, actime field is silently
50 ignored, only modification time of the file is set.
52 SEE ALSO
53 utimes()
55 INTERNALS
57 ******************************************************************************/
59 struct timeval ts[2];
61 if( buf == NULL )
63 time_t tt = time( NULL );
65 ts[0].tv_sec = tt;
66 ts[1].tv_sec = tt;
68 else
70 ts[0].tv_sec = buf->actime;
71 ts[1].tv_sec = buf->modtime;
74 ts[0].tv_usec = 0;
75 ts[1].tv_usec = 0;
77 return utimes(filename, ts);