Move-only seekable sink for a newly created or truncated POSIX file.
More...
#include <file_output_sink.h>
|
| | FileOutputSink (const std::filesystem::path &path) |
| | Open path for binary output, creating or truncating it.
|
| |
|
| FileOutputSink (const FileOutputSink &)=delete |
| |
|
FileOutputSink & | operator= (const FileOutputSink &)=delete |
| |
|
| FileOutputSink (FileOutputSink &&other) noexcept |
| | Transfer ownership of an open output file.
|
| |
|
FileOutputSink & | operator= (FileOutputSink &&other) noexcept |
| | Close the current file and transfer ownership from other.
|
| |
|
| ~FileOutputSink () |
| | Close the output file without reporting errors.
|
| |
|
std::size_t | size_bytes () const noexcept |
| | Return the number of bytes appended to the output.
|
| |
| void | write (std::span< const std::byte > bytes) |
| | Append all bytes to the file.
|
| |
| void | write_at (std::size_t position, std::span< const std::byte > bytes) |
| | Replace already-written bytes beginning at position.
|
| |
| void | finish () |
| | Close the file and report any close error.
|
| |
Move-only seekable sink for a newly created or truncated POSIX file.
Sequential writes use write(), while backpatches use pwrite() without changing the append position. finish() closes the descriptor and reports close errors, but does not provide durable fsync() semantics.
◆ FileOutputSink()
| pixie::io::FileOutputSink::FileOutputSink |
( |
const std::filesystem::path & | path | ) |
|
|
inlineexplicit |
Open path for binary output, creating or truncating it.
- Exceptions
-
| std::system_error | if the file cannot be opened. |
◆ finish()
| void pixie::io::FileOutputSink::finish |
( |
| ) |
|
|
inline |
Close the file and report any close error.
This operation is idempotent after success.
- Exceptions
-
| std::system_error | if closing the file fails. |
◆ write()
| void pixie::io::FileOutputSink::write |
( |
std::span< const std::byte > | bytes | ) |
|
|
inline |
Append all bytes to the file.
- Exceptions
-
| std::system_error | for an operating-system write failure. |
| std::length_error | if the resulting file offset is unsupported. |
| std::logic_error | if the sink is already finished. |
◆ write_at()
| void pixie::io::FileOutputSink::write_at |
( |
std::size_t | position, |
|
|
std::span< const std::byte > | bytes ) |
|
inline |
Replace already-written bytes beginning at position.
- Exceptions
-
| std::out_of_range | if the range is outside the written file. |
| std::system_error | for an operating-system write failure. |
| std::length_error | if the file offset is unsupported. |
| std::logic_error | if the sink is already finished. |
The documentation for this class was generated from the following file: