Function created [src]

Returns the time the file was created in nanoseconds since UTC 1970-01-01. Returns null if this is not supported by the OS or filesystem

Prototype

pub fn created(self: Self) ?i128

Parameters

self: Self

Source

pub fn created(self: Self) ?i128 { if (!@hasDecl(@TypeOf(self.stat), "birthtime")) return null; const birthtime = self.stat.birthtime(); // If the filesystem doesn't support this the value *should* be: // On FreeBSD: nsec = 0, sec = -1 // On NetBSD and OpenBSD: nsec = 0, sec = 0 // On MacOS, it is set to ctime -- we cannot detect this!! switch (builtin.os.tag) { .freebsd => if (birthtime.sec == -1 and birthtime.nsec == 0) return null, .netbsd, .openbsd => if (birthtime.sec == 0 and birthtime.nsec == 0) return null, .macos => {}, else => @compileError("Creation time detection not implemented for OS"), } return @as(i128, birthtime.sec) * std.time.ns_per_s + birthtime.nsec; }