Durable file operations for MoonBit: atomic write (fsync+rename), mkdir_p, append, chmod, rotation and flock
| 接口 Interface | 说明 Description |
|---|---|
| write_atomic(path, data) | 写 .tmp → fsync → 原子改名;Atomic write via tmp + fsync + rename |
| mkdir_p(path, mode?) | 幂等建目录;Idempotent recursive mkdir |
| append_file / chmod / unlink / file_size | 追加 / 改权限 / 删除 / 大小;Append / chmod / remove / size |
| rotate / copytruncate | 轮转(保留 10 代);Rotation, ten generations kept |
| lock_exclusive(path) | 非阻塞 flock(CLOEXEC);Non-blocking flock, CLOEXEC |
| read_small(path, cap?) | 循环读到 EOF 或 cap;Read to EOF, capped |
pub(all) suberror FileError {
Failed(op~ : String, errno~ : Int)
}fn file_size(path : String) -> Int64?Install
Download zipDurable file operations for MoonBit: atomic write (fsync+rename), mkdir_p, append, chmod, rotation and flock