File: utimes.c

package info (click to toggle)
gbuffy 0.2.4-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 500 kB
  • ctags: 506
  • sloc: ansic: 5,934; sh: 195; makefile: 160; perl: 44; awk: 2
file content (27 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (7)
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
/* 
 * utimes (BSD Equivalent of utime() 
 * - set file mod and access times)
 * (No attempt to reproduce same error code expect that they 
 * both do return -1 on error and 0 on success) 
 * 
 * From: corrigan@weber.ucsd.edu (Michael J. Corrigan) 
 */

#include <sys/types.h>
#include <sys/time.h>
#include <utime.h>
    
int utimes(file,tvp) char *file; struct timeval *tvp; 
{ 
    struct utimbuf ut;
    time_t now;
	
	now = time((time_t *)NULL);
	if (tvp == (struct timeval *)NULL) {
	    ut.actime = now;
	    ut.modtime = now; 
	} else {
	    ut.actime = tvp++->tv_sec;
	    ut.modtime = tvp->tv_sec; 
	} return(utime(file,&ut)); 
}