source: rtems/cpukit/libcsupport/src/utime.c @ e02d5dd9

4.115
Last change on this file since e02d5dd9 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Set File Access and Modification Times
5 *  @ingroup libcsupport
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18  #include "config.h"
19#endif
20
21/* FIXME: This include is a workaround for a broken <utime.h> in Newlib */
22#include <sys/types.h>
23
24#include <utime.h>
25
26#include <rtems/libio_.h>
27
28/**
29 *  POSIX 1003.1b 5.5.6 - Set File Access and Modification Times
30 */
31int utime( const char *path, const struct utimbuf *times )
32{
33  int rv = 0;
34  rtems_filesystem_eval_path_context_t ctx;
35  int eval_flags = RTEMS_FS_FOLLOW_LINK;
36  const rtems_filesystem_location_info_t *currentloc =
37    rtems_filesystem_eval_path_start( &ctx, path, eval_flags );
38  struct utimbuf now_times;
39
40  if ( times == NULL ) {
41    time_t now = time( NULL );
42
43    now_times.actime = now;
44    now_times.modtime = now;
45
46    times = &now_times;
47  }
48
49  rv = (*currentloc->mt_entry->ops->utime_h)(
50    currentloc,
51    times->actime,
52    times->modtime
53  );
54
55  rtems_filesystem_eval_path_cleanup( &ctx );
56
57  return rv;
58}
Note: See TracBrowser for help on using the repository browser.