xref: /freebsd/contrib/elftoolchain/libelftc/elftc_set_timestamps.3 (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1.\" Copyright (c) 2011 Joseph Koshy.  All rights reserved.
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\" 1. Redistributions of source code must retain the above copyright
7.\"    notice, this list of conditions and the following disclaimer.
8.\" 2. Redistributions in binary form must reproduce the above copyright
9.\"    notice, this list of conditions and the following disclaimer in the
10.\"    documentation and/or other materials provided with the distribution.
11.\"
12.\" This software is provided by Joseph Koshy ``as is'' and
13.\" any express or implied warranties, including, but not limited to, the
14.\" implied warranties of merchantability and fitness for a particular purpose
15.\" are disclaimed.  in no event shall Joseph Koshy be liable
16.\" for any direct, indirect, incidental, special, exemplary, or consequential
17.\" damages (including, but not limited to, procurement of substitute goods
18.\" or services; loss of use, data, or profits; or business interruption)
19.\" however caused and on any theory of liability, whether in contract, strict
20.\" liability, or tort (including negligence or otherwise) arising in any way
21.\" out of the use of this software, even if advised of the possibility of
22.\" such damage.
23.\"
24.\" $Id$
25.\"
26.Dd December 15, 2011
27.Dt ELFTC_SET_TIMESTAMPS 3
28.Os
29.Sh NAME
30.Nm elftc_set_timestamps
31.Nd set file timestamps
32.Sh LIBRARY
33.Lb libelftc
34.Sh SYNOPSIS
35.In libelftc.h
36.Ft int
37.Fn elftc_set_timestamps "const char *filename" "struct stat *sb"
38.Sh DESCRIPTION
39The
40.Fn elftc_set_timestamps
41function is used to set the access and modified time stamps on a file
42based on the contents of a
43.Vt "struct stat"
44descriptor.
45.Pp
46Argument
47.Ar filename
48names an existing file in the file system.
49.Pp
50Argument
51.Ar sb
52points to structure of type
53.Vt "struct stat"
54populated by a prior call to
55.Xr fstat 2
56or
57.Xr stat 2 .
58.Sh IMPLEMENTATION NOTES
59This function will invoke the high-resolution
60.Xr utimes 2
61system call if the underlying operating system supports it.
62On operating systems lacking support for
63.Xr utimes 2 ,
64the function will use lower resolution
65.Xr utime 2
66system call.
67.Sh EXAMPLES
68To set the access and modified times for a new file to those of an
69existing file, use:
70.Bd -literal -offset indent
71struct stat sb;
72const char *existing_filename, *new_filename;
73
74if (stat(existing_filename, &sb) < 0)
75	err(EXIT_FAILURE, "stat failed");
76
77if (elftc_set_timestamps(new_filename, &sb) < 0)
78	err(EXIT_FAILURE, "timestamps could not be set");
79.Ed
80.Sh SEE ALSO
81.Xr fstat 2 ,
82.Xr stat 2 ,
83.Xr utime 2 ,
84.Xr utimes 2
85