What problem does it solve?
Writing cross-platform file I/O in Bun's Rust codebase is error-prone when using std::fs or raw libc, leading to lossy errors, missing Windows support, and manual EINTR handling. This Skill enforces a consistent syscall layer.
Core Features & Use Cases
- bun_sys::File wrapper: Owns the file descriptor and closes on Drop, replacing std::fs::File with Node-compatible error metadata.
- Rich Error type: Carries errno, syscall tag, and path so failures can be converted to JS exceptions via ErrorJsc::to_js.
- Path buffer pooling: Uses bun_paths path_buffer_pool to avoid 64 KB stack allocations on Windows.
- Use Case: When implementing a new Bun native module that reads or writes files, follow this Skill to choose the correct open flags, propagate errors with
?, and avoid double-close pitfalls.
Quick Start
Implement file I/O in Bun's Rust code using bun_sys::File with openat and propagate errors via Maybe<T> instead of std::fs.