URING++
|
An opened file. More...
#include <uringpp/file.h>
Public Member Functions | |
int | fd () const |
Get the file descriptor of the file. More... | |
file (file &&other) noexcept | |
Move construct a new file object. More... | |
file (std::shared_ptr< event_loop > loop, int fd) | |
Construct a new file object using the given event loop and file descriptor. The fd will be closed when the file object is destroyed. More... | |
task< void > | close () |
Close the file. More... | |
~file () | |
Destroy the file object. If the fd is still open, it will be closed. More... | |
sqe_awaitable | read (void *buf, size_t count, off_t offset=0) |
Read data from the file. More... | |
sqe_awaitable | write (void const *buf, size_t count, off_t offset=0) |
Write data to the file. More... | |
sqe_awaitable | readv (struct iovec const *iov, int iovcnt, off_t offset=0) |
Vectorized read from the file. More... | |
sqe_awaitable | writev (struct iovec const *iov, int iovcnt, off_t offset=0) |
Vectorized write to the file. More... | |
sqe_awaitable | read_fixed (void *buf, size_t count, off_t offset, int buf_index) |
Read data to a preregistered buffer from the file. More... | |
sqe_awaitable | write_fixed (void const *buf, size_t count, off_t offset, int buf_index) |
Write data from a preregistered buffer to the file. More... | |
sqe_awaitable | fsync (int flags) |
Asynchronously flush the file. More... | |
sqe_awaitable | sync_file_range (off_t offset, off_t nbytes, unsigned sync_range_flags) |
Asynchronously flush a range of the file. More... | |
sqe_awaitable | tee (file const &out, size_t count, unsigned int flags) |
Tee data from the file to another file. More... | |
sqe_awaitable | tee (socket const &out, size_t count, unsigned int flags) |
Tee data from the file to a socket. More... | |
sqe_awaitable | splice_to (loff_t off_in, size_t nbytes, pipe const &out, unsigned flags) |
Splice data from the file to a pipe. More... | |
sqe_awaitable | splice_from (pipe const &in, loff_t off_out, size_t nbytes, unsigned flags) |
Splice data from a pipe to the file. More... | |
![]() | |
noncopyable (noncopyable &&)=default | |
noncopyable (noncopyable const &)=delete | |
noncopyable & | operator= (noncopyable const &)=delete |
noncopyable & | operator= (noncopyable &&)=default |
Static Public Member Functions | |
static task< file > | open (std::shared_ptr< event_loop > loop, char const *path, int flags, mode_t mode) |
Opens a file in the current working directory. More... | |
static task< file > | openat (std::shared_ptr< event_loop > loop, dir const &dir, char const *path, int flags, mode_t mode) |
Open a file in the given directory. More... | |
static task< file > | openat2 (std::shared_ptr< event_loop > loop, dir const &dir, char const *path, struct open_how *how) |
Open a file in the given directory. More... | |
Protected Attributes | |
std::shared_ptr< event_loop > | loop_ |
int | fd_ |
An opened file.
|
inlinenoexcept |
Move construct a new file object.
other | The file object to move from. |
|
inline |
Construct a new file object using the given event loop and file descriptor. The fd will be closed when the file object is destroyed.
loop | The event loop. |
fd | The file descriptor. |
|
inline |
Destroy the file object. If the fd is still open, it will be closed.
|
inline |
Close the file.
|
inline |
Get the file descriptor of the file.
|
inline |
Asynchronously flush the file.
flags | The flags to use when flushing the file. |
|
inlinestatic |
Opens a file in the current working directory.
loop | The event loop. |
path | The path to the file. |
flags | The flags to use when opening the file. |
mode | The mode to use when opening the file. |
|
inlinestatic |
Open a file in the given directory.
loop | The event loop. |
dir | The directory to open the file in. |
path | The path to the file. |
flags | The flags to use when opening the file. |
mode | The mode to use when opening the file. |
|
inlinestatic |
Open a file in the given directory.
loop | The event loop. |
dir | The directory to open the file in. |
path | The path to the file. |
how | The open_how struct to use when opening the file. |
|
inline |
Read data from the file.
buf | The buffer to read into. |
count | The number of bytes to read. |
offset | The offset to start reading from. |
|
inline |
Read data to a preregistered buffer from the file.
buf | The preregistered buffer to read into. |
count | The number of bytes to read. |
offset | The offset to start reading from. |
buf_index | The index of the preregistered buffer to read into. |
|
inline |
Vectorized read from the file.
iov | The iovec to read into. |
iovcnt | The number of iovecs to read. |
offset | The offset to start reading from. |
|
inline |
Splice data from a pipe to the file.
off_out | The offset to start splicing to. |
in | The pipe to splice data from. |
nbytes | The number of bytes to splice. |
flags | The flags to use when splicing the data. |
|
inline |
Splice data from the file to a pipe.
off_in | The offset to start splicing from. |
nbytes | The number of bytes to splice. |
out | The pipe to splice data to. |
flags | The flags to use when splicing the data. |
|
inline |
Asynchronously flush a range of the file.
offset | The offset to start flushing from. |
nbytes | The number of bytes to flush. |
sync_range_flags | The flags to use when flushing the file. |
|
inline |
Tee data from the file to another file.
out | The file to tee data to. |
count | The number of bytes to tee. |
flags | The flags to use when teeing the data. |
|
inline |
Tee data from the file to a socket.
out | The socket to tee data to. |
count | The number of bytes to tee. |
flags | The flags to use when teeing the data. |
|
inline |
Write data to the file.
buf | The buffer to write from. |
count | The number of bytes to write. |
offset | The offset to start writing from. |
|
inline |
Write data from a preregistered buffer to the file.
buf | The preregistered buffer to write from. |
count | The number of bytes to write. |
offset | The offset to start writing from. |
buf_index | The index of the preregistered buffer to write from. |
|
inline |
Vectorized write to the file.
iov | The iovec to write from. |
iovcnt | The number of iovecs to write. |
offset | The offset to start writing from. |