12345678module snapshot910#flag -I@VMODROOT/vendor/shim11#flag @VMODROOT/vendor/shim/koh_stat.c12#flag @VMODROOT/vendor/shim/koh_fsync.c13#flag @VMODROOT/vendor/shim/koh_create.c14#include "koh_stat.h"15#include "koh_fsync.h"16#include "koh_create.h"1718pub struct C.koh_stat {19 size i6420 mtime_ns i6421 ctime_ns i6422 mode u3223 kind int24}2526fn C.koh_lstat(path &char, out &C.koh_stat) int2728fn C.koh_fsync_file(path &char) int2930fn C.koh_fsync_dir(path &char) int3132fn C.koh_create_exclusive(path &char, data voidptr, len usize) int3334pub enum Kind {35 missing36 file37 dir38 symlink39 other40}4142pub struct Stat {43pub:44 size i6445 mtime_ns i6446 ctime_ns i6447 mode u3248 kind Kind49}5051pub fn lstat(path string) ?Stat {52 mut raw := C.koh_stat{}53 if C.koh_lstat(unsafe { &char(path.str) }, &raw) == 0 {54 return none55 }56 return Stat{57 size: raw.size58 mtime_ns: raw.mtime_ns59 ctime_ns: raw.ctime_ns60 mode: raw.mode61 kind: match raw.kind {62 1 { .file }63 2 { .dir }64 3 { .symlink }65 else { .other }66 }67 }68}6970pub fn is_executable(mode u32) bool {71 return mode & 0o111 != 072}