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