koh_stat.h

868 B · raw

1/* Nanosecond-precision lstat for the working-tree walk.2 *3 * V's `os.Stat` exposes mtime and ctime in whole seconds. The file cache in4 * `src/snapshot` decides whether a file may skip hashing by comparing those5 * timestamps, so second precision would let a file edited twice inside one6 * second keep a stale hash — and a save would then record the wrong content.7 * This shim reports nanoseconds, plus the file kind, which the walker needs to8 * skip symlinks and directories without a second stat call.9 */1011#ifndef KOH_STAT_H12#define KOH_STAT_H1314typedef struct koh_stat {15	long long size;16	long long mtime_ns;17	long long ctime_ns;18	unsigned int mode;19	int kind; /* 0 missing, 1 file, 2 dir, 3 symlink, 4 other */20} koh_stat;2122/* Fills `out`; returns 1 on success, 0 when the path cannot be lstat'ed. */23int koh_lstat(const char *path, koh_stat *out);2425#endif