🟩 Synchronous Disk File I/O
SaneCppFile.h is a library implementing synchronous I/O operations on files and pipes.
| SC::FileDescriptor | [UniqueHandleDeclaration2Snippet] |
|---|---|
| SC::FileDescriptor::read | Reads bytes at offset into user supplied span. |
| SC::FileDescriptor::write | Writes bytes at offset from start of the file descriptor. |
| SC::FileDescriptor::seek | Changes the current position in the file descriptor, if seekable. |
| SC::FileDescriptor::open | Opens a file descriptor handle from a file system path. |
| SC::FileDescriptor::openStdInDuplicate | Opens a duplicated file descriptor handle for reading from stdin. |
| SC::FileDescriptor::openStdOutDuplicate | Opens a duplicated file descriptor handle for reading from stdout. |
| SC::FileDescriptor::openStdErrDuplicate | Opens a duplicated file descriptor handle for reading from stderr. |
| SC::FileDescriptor::readUntilEOF | Reads into a given dynamic buffer until End of File (EOF) is signaled. |
| SC::PipeDescriptor | Read / Write pipe (Process stdin/stdout and IPC communication) |
|---|---|
| SC::PipeDescriptor::readPipe | The read side of the pipe. |
| SC::PipeDescriptor::writePipe | The write side of the pipe. |
| SC::NamedPipeServer | Named pipe server endpoint. |
|---|---|
| SC::NamedPipeServer::create | Creates a named pipe server endpoint. |
| SC::NamedPipeServer::accept | Accept one client connection and return it as a connected PipeDescriptor. |
| SC::NamedPipeServer::close | Closes the listening endpoint. |
| SC::NamedPipeServerOptions | |
| SC::NamedPipeClient | Named pipe client endpoint creator. |
| SC::NamedPipeClient::connect | Connects to an existing named pipe server endpoint. |
| SC::NamedPipeClientOptions | |
| SC::NamedPipeName | Utility for building platform-native named pipe endpoint names from logical names. |
| SC::NamedPipeName::build | Builds a platform-native named pipe endpoint path. |
| SC::NamedPipeNameOptions |
🟩 Usable
This library has a relatively limited scope and it should not need many additional features compared to now.
Will consider bumping to Complete in the future.
Some relevant blog posts are:
SC::FileDescriptor object can be created by SC::FileDescriptor::open-ing a path on file system and it can be SC::FileDescriptor::read or SC::FileDescriptor::write.
Also non-blocking mode can be controlled with SC::FileDescriptor::setBlocking.
A file can be marked as inheritable with SC::FileDescriptor::setInheritable so that in can be accessed by child processes. SC::PipeDescriptor creates a pipe for InterProcess communication.
A pipe has read and write SC::FileDescriptor endpoints and it's used by Process library to redirect standard input, output or error to other processes.
It can also be used to read or write the standard input, output or error from current process into a binary buffer or a string (as done by SC::ProcessChain::readStdOutUntilEOFSync or other similar methods).
SC::NamedPipeServer and SC::NamedPipeClient provide named endpoint creation and connection. Accepted/connected named pipe endpoints are exposed as SC::PipeDescriptor, so they can be used with the same read/write APIs and with Async / Async Streams compositions. SC::NamedPipeName::build can be used to compose platform-native endpoint names from a logical pipe name, avoiding platform-specific #if path conventions at call sites.
Open, read and write to/from a file descriptor (like a file or pipe).
🟦 Complete Features:
💡 Unplanned Features:
| Type | Lines Of Code | Comments | Sum |
|---|---|---|---|
| Headers | 144 | 172 | 316 |
| Sources | 1087 | 173 | 1260 |
| Sum | 1231 | 345 | 1576 |