calog/libs/calogFs.h
2026-07-03 02:13:23 -05:00

26 lines
1.2 KiB
C

// calogFs.h -- calog filesystem library.
//
// Bridges the POSIX filesystem into calog's value model so any engine can read, write, and
// inspect files without an engine-specific I/O library:
// fsRead(path) -> string (the whole file, binary-safe)
// fsWrite(path, data) -> nil (create/truncate, honoring data's byte length)
// fsAppend(path, data) -> nil (create if absent, append at the end)
// fsExists(path) -> bool
// fsRemove(path) -> nil (unlink a file)
// fsMkdir(path) -> nil (single level, mode 0777 & umask; an existing dir is OK)
// fsList(path) -> list (entry name strings, excluding "." and "..")
// fsStat(path) -> map {size, isDir, isFile, mtime} or nil if the path is absent
// The natives are INLINE (each is a pure function of its arguments over the OS filesystem, no
// shared state), so there is nothing to shut down. A failed operation surfaces as a catchable
// script error carrying strerror(errno).
#ifndef CALOG_FS_H
#define CALOG_FS_H
#include "calog.h"
// Register the filesystem natives on a runtime. Stateless: safe to call on any number of
// runtimes, and there is no matching shutdown.
int32_t calogFsRegister(CalogT *calog);
#endif