Introduction¶
Any problem in Computer Science can be solved with another level of indirection
Layered file protocols is a high-level interface for byte-oriented file handles with layering. File descriptors are composed and stacked at run-time, adding features such as pre-fetching, indices, cloud access, and file format support at each level.
Layered file protocols, lfp, provides
A simple interface for application and library developers
Multiple protocols for different file implementations and formats
A developer interface for adding new protocols with C++
License¶
Layered file protocols is licensed under the LGPL. See the LICENSE file for details.
- API design
- Functions
- Status codes
lfp_status
lfp_status::LFP_OK
lfp_status::LFP_OKINCOMPLETE
lfp_status::LFP_NOTIMPLEMENTED
lfp_status::LFP_LEAF_PROTOCOL
lfp_status::LFP_NOTSUPPORTED
lfp_status::LFP_UNHANDLED_EXCEPTION
lfp_status::LFP_IOERROR
lfp_status::LFP_RUNTIME_ERROR
lfp_status::LFP_INVALID_ARGS
lfp_status::LFP_PROTOCOL_FATAL_ERROR
lfp_status::LFP_PROTOCOL_TRYRECOVERY
lfp_status::LFP_PROTOCOL_FAILEDRECOVERY
lfp_status::LFP_EOF
lfp_status::LFP_UNEXPECTED_EOF
Why not use FILE?¶
Layered file protocols was design to scratch our own itch - we want to deal with files that sometimes use the tapeimage protocol, but not always. With lfp, our applications can have a simple and straight-forward code path, and not really notice the presence of tape markers and other such nonsense. There is no standard way to add new drivers to FILE, except really being on the inside of libc.
Technical details¶
The interface is deliberately different from the C file library. While it does make porting from FILE slightly more work, there are subtle differences in guarantees and usage, which means it is necessary for lfp to detach itself from the FILE interface.
The consumer interface is a C API. This is to provide the best and most ergonomic experience for creating bindings for other languages, and to have an easier time maintaing binary compatibility. Public functions will never be removed, but may be deprecated.
Protocols are layered with dependency injection, and are implemented in C++. For an API reference, a description, and rationale, see the Writing protocols section.
Many protocols are provided and bundled with lfp, and while it is sometimes useful for very application-specific protocols to be implemented and maintained in-application, the most sustainable approach is to contribute them upstream and maintain them in the lfp tree.