2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Add isc_file_settime() set access and modification times.

This commit is contained in:
Mark Andrews
2000-05-16 02:13:08 +00:00
parent b04adaa782
commit 5273184ae1
2 changed files with 18 additions and 0 deletions

View File

@@ -25,6 +25,9 @@
ISC_LANG_BEGINDECLS
isc_result_t
isc_file_settime(const char *file, isc_time_t *time);
isc_result_t
isc_file_getmodtime(const char *file, isc_time_t *time);
/*

View File

@@ -67,6 +67,21 @@ isc_file_getmodtime(const char *file, isc_time_t *time) {
return (result);
}
isc_result_t
isc_file_settime(const char *file, isc_time_t *time) {
struct timeval times[2];
REQUIRE(file != NULL && time != NULL);
times[0].tv_sec = times[1].tv_sec = isc_time_seconds(time);
times[0].tv_usec = times[1].tv_usec = isc_time_nanoseconds(time)/1000;
if (utimes(file, times) < 0)
return (isc__errno2result(errno));
return (ISC_R_SUCCESS);
}
#undef TEMPLATE
#define TEMPLATE "tmp-XXXXXXXXXX" /* 14 characters. */