on master help sign in
ghcide/cbits/getmodtime.c
21 lines 475 B history raw
1// Copyright (c) 2019 The DAML Authors. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
4#include <sys/stat.h>
5#include <time.h>
6int getmodtime(const char* pathname, time_t* sec, long* nsec) {
7 struct stat s;
8 int r = stat(pathname, &s);
9 if (r != 0) {
10 return r;
11 }
12#ifdef __APPLE__
13 *sec = s.st_mtimespec.tv_sec;
14 *nsec = s.st_mtimespec.tv_nsec;
15#else
16 *sec = s.st_mtim.tv_sec;
17 *nsec = s.st_mtim.tv_nsec;
18#endif
19 return 0;