Replaced Popscren with a custom pop-up list for selecting public screen. Now it conta...
[tangerine.git] / compiler / clib / utimes.c
blob3e8de69aace5ed7fbdeaf62050a2d60d805097fc
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/dos.h>
7 #include <proto/dos.h>
9 #include <sys/time.h>
10 #include <errno.h>
12 #include "__errno.h"
13 #include "__upath.h"
15 /*****************************************************************************
17 NAME */
19 int utimes(
20 /* SYNOPSIS */
22 const char *file,
23 struct timeval tvp[2])
25 /* FUNCTION
26 Change last access and last modification time of the given file to
27 times specified in tvp array. If tvp is NULL, the current time will be
28 used instead.
30 INPUTS
31 filename - Name of the file
32 buf - Pointer to an array of two timeval structures. First structure
33 specifies the last access time, second specifies the last
34 modification 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 The timeval structure has microsecond resolution, but in reality
42 this function has time resolution of 1 tick.
44 EXAMPLE
46 BUGS
47 Since AROS has no notion of last access time, it's silently ignored
48 and only modification time of the file is set.
50 SEE ALSO
51 utime()
53 INTERNALS
55 ******************************************************************************/
57 struct DateStamp ds;
59 if (!file) /*safety check */
61 errno = EFAULT;
62 return -1;
65 file = __path_u2a(file);
66 if (!file)
67 return -1;
69 if(tvp != NULL)
71 ULONG t = (ULONG)tvp[1].tv_sec - 2922 * 1440 * 60;
73 ds.ds_Days = t / (60*60*24);
74 ds.ds_Minute = (t / 60) % (60*24);
75 ds.ds_Tick = (t % 60) * TICKS_PER_SECOND;
77 else
78 DateStamp(&ds);
80 if (SetFileDate(file, &ds))
81 return 0;
82 else
83 errno = IoErr2errno(IoErr());
85 return -1;