summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/utimes.c
blob: 3dc47c0000e00585b219c2e69e64c6263df396b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
 *  @file
 *
 *  @brief Change File Last Access and Modification Times 
 *  @ingroup libcsupport
 */

/*
 *  Written by: Vinu Rajashekhar <vinutheraj@gmail.com>
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <sys/types.h>
#include <utime.h>
#include <sys/time.h>

int utimes(
  const char           *path,
  const struct timeval  times[2]
) 
{
  struct utimbuf timeinsecs;

  if ( times == NULL )
    return utime( path, NULL );

  timeinsecs.actime  = times[0].tv_sec;
  timeinsecs.modtime = times[1].tv_sec;

  return utime( path, &timeinsecs );
}