The open file handle. More...
#include "handle-fs.hpp"
Public Types | |
using | uv_t = ::uv_fs_t |
using | on_open_t = std::function< void(file) > |
The function type of the callback called after the asynchronous file open/create operation has been completed. | |
Public Types inherited from uv::io | |
using | uv_t = void |
using | on_read_t = std::function< void(io _handle, ssize_t _nread, buffer _buffer, int64_t _offset, void *_info) > |
The function type of the callback called by read_start() when data was read from an I/O endpoint. More... | |
Public Types inherited from uv::handle | |
using | uv_t = ::uv_handle_t |
using | on_destroy_t = std::function< void(void *_data) > |
The function type of the callback called when the handle has been closed and about to be destroyed. More... | |
Public Member Functions | |
file (const file &)=default | |
file & | operator= (const file &)=default |
file (file &&) noexcept=default | |
file & | operator= (file &&) noexcept=default |
std::size_t | write_queue_size () const noexcept |
The amount of bytes waiting to be written to the file. | |
::uv_file | fd () const noexcept |
Get the cross platform representation of the file handle. More... | |
const char * | path () const noexcept |
The file path. More... | |
operator const uv_t * () const noexcept | |
operator uv_t * () noexcept | |
File handle constructors - open and possibly create a file: | |
The file descriptor will be closed automatically when the file handle reference count has became zero. | |
file (uv::loop &_loop, const char *_path, int _flags, int _mode) | |
Open and possibly create a file synchronously. | |
file (uv::loop &_loop, const char *_path, int _flags, int _mode, const on_open_t &_open_cb) | |
Open and possibly create a file asynchronously. More... | |
file (uv::loop &_loop, ::uv_file _fd) | |
Create a file object from an existing file descriptor. | |
Public Member Functions inherited from uv::io | |
io (const io &)=default | |
io & | operator= (const io &)=default |
io (io &&) noexcept=default | |
io & | operator= (io &&) noexcept=default |
std::size_t | write_queue_size () const noexcept |
The amount of queued bytes waiting to be written/sent to the I/O endpoint. More... | |
on_buffer_alloc_t & | on_alloc () const noexcept |
Set the input buffer allocation callback. | |
on_read_t & | on_read () const noexcept |
Set the read callback function. | |
int | read_start (std::size_t _size=0, int64_t _offset=-1) const |
Start reading incoming data from the I/O endpoint. More... | |
int | read_start (const on_buffer_alloc_t &_alloc_cb, const on_read_t &_read_cb, std::size_t _size=0, int64_t _offset=-1) const |
Start reading incoming data from the I/O endpoint with provided input buffer allocation callback (_alloc_cb ) and read callback function (_read_cb ). More... | |
int | read_stop () const |
Stop reading data from the I/O endpoint. More... | |
int | read_pause (bool _trigger_condition) const |
Pause reading data from the I/O endpoint. More... | |
int | read_resume (bool _trigger_condition) |
Resume reading data from the I/O endpoint after having been paused. More... | |
operator const uv_t * () const noexcept | |
operator uv_t * () noexcept | |
Public Member Functions inherited from uv::handle | |
handle (const handle &_that) | |
handle & | operator= (const handle &_that) |
handle (handle &&_that) noexcept | |
handle & | operator= (handle &&_that) noexcept |
void | swap (handle &_that) noexcept |
std::uintptr_t | id () const noexcept |
The unique ID of the instance managed by this handle variable or 0 if the handle is void. | |
long | nrefs () const noexcept |
The current number of existing references to the same object as this handle variable refers to. | |
int | uv_status () const noexcept |
The status value returned by the last executed libuv API function on this handle. | |
on_destroy_t & | on_destroy () const noexcept |
::uv_handle_type | type () const noexcept |
The tag indicating the libuv type of the handle. | |
const char * | type_name () const noexcept |
A string containing the name of the handle type. | |
uv::loop | loop () const noexcept |
The libuv loop where the handle is running on. More... | |
void *& | data () const noexcept |
The pointer to the user-defined arbitrary data. libuv and uvcc does not use this field. | |
int | is_active () const noexcept |
Check if the handle is active. More... | |
int | is_closing () const noexcept |
Check if the handle is closing or closed. More... | |
::uv_os_fd_t | fileno () const noexcept |
Get the platform dependent handle/file descriptor. More... | |
operator const uv_t * () const noexcept | |
operator uv_t * () noexcept | |
operator bool () const noexcept | |
Equivalent to (id() and uv_status() >= 0) . | |
void | attached (bool _state) const noexcept |
bool | attached () const noexcept |
Additional Inherited Members | |
Static Public Member Functions inherited from uv::io | |
static io | guess_handle (uv::loop &, ::uv_file) |
Create an io handle object which actual type is derived from an existing file descriptor. More... | |
The open file handle.
Definition at line 29 of file handle-fs.hpp.
|
inline |
Open and possibly create a file asynchronously.
_open_cb
callback is empty the operation is completed synchronously. Definition at line 142 of file handle-fs.hpp.
|
inlinenoexcept |
Get the cross platform representation of the file handle.
On Windows this function returns a C run-time file descriptor which differs from the operating-system file handle that is returned by handle::fileno()
function. On Unix-like systems both functions return the same value.
_open_osfhandle()
. Definition at line 203 of file handle-fs.hpp.
|
inlinenoexcept |
The file path.
uv_fs_t.path
. Definition at line 207 of file handle-fs.hpp.