uvw 3.1.0
|
The file request. More...
#include <fs.h>
Public Member Functions | |
void | close () |
Async close. | |
bool | close_sync () |
Sync close. | |
void | open (const std::string &path, file_open_flags flags, int mode) |
Async open. | |
bool | open_sync (const std::string &path, file_open_flags flags, int mode) |
Sync open. | |
void | read (int64_t offset, unsigned int len) |
Async read. | |
std::pair< bool, std::pair< std::unique_ptr< const char[]>, std::size_t > > | read_sync (int64_t offset, unsigned int len) |
Sync read. | |
void | write (std::unique_ptr< char[]> buf, unsigned int len, int64_t offset) |
Async write. | |
void | write (char *buf, unsigned int len, int64_t offset) |
Async write. | |
std::pair< bool, std::size_t > | write_sync (std::unique_ptr< char[]> buf, unsigned int len, int64_t offset) |
Sync write. | |
void | stat () |
Async fstat. | |
std::pair< bool, file_info > | stat_sync () |
Sync fstat. | |
void | sync () |
Async fsync. | |
bool | sync_sync () |
Sync fsync. | |
void | datasync () |
Async fdatasync. | |
bool | datasync_sync () |
Sync fdatasync. | |
void | truncate (int64_t offset) |
Async ftruncate. | |
bool | truncate_sync (int64_t offset) |
Sync ftruncate. | |
void | sendfile (file_handle out, int64_t offset, std::size_t length) |
Async sendfile. | |
std::pair< bool, std::size_t > | sendfile_sync (file_handle out, int64_t offset, std::size_t length) |
Sync sendfile. | |
void | chmod (int mode) |
Async fchmod. | |
bool | chmod_sync (int mode) |
Sync fchmod. | |
void | futime (time atime, time mtime) |
Async futime. | |
bool | futime_sync (time atime, time mtime) |
Sync futime. | |
void | chown (uid_type uid, gid_type gid) |
Async fchown. | |
bool | chown_sync (uid_type uid, gid_type gid) |
Sync fchown. | |
operator file_handle () const noexcept | |
Cast operator to file_handle. | |
Public Member Functions inherited from uvw::request< T, U, E > | |
int | cancel () |
Cancels a pending request. | |
std::size_t | size () const noexcept |
Returns the size of the underlying request type. | |
Public Member Functions inherited from uvw::resource< T, U, E... > | |
std::shared_ptr< R > | data () const |
Gets user-defined data. uvw won't use this field in any case. | |
void | data (std::shared_ptr< void > udata) |
Sets arbitrary data. uvw won't use this field in any case. | |
Public Member Functions inherited from uvw::uv_type< U > | |
virtual int | init () |
Initializes the handle. | |
loop & | parent () const noexcept |
Gets the loop from which the resource was originated. | |
const U * | raw () const noexcept |
Gets the underlying raw data structure. | |
U * | raw () noexcept |
Gets the underlying raw data structure. | |
Public Member Functions inherited from uvw::emitter< T, E... > | |
void | on (listener_t< U > f) |
Registers a long-lived listener with the event emitter. | |
void | reset () noexcept |
Disconnects the listener for the given event type. | |
void | reset () noexcept |
Disconnects all listeners. | |
bool | has () const noexcept |
Checks if there is a listener registered for the specific event. | |
The file request.
Cross-platform sync and async filesystem operations.
All file operations are run on the threadpool.
To create a file_req
through a loop
, no arguments are required.
See the official documentation for further details.
void uvw::file_req::chmod | ( | int | mode | ) |
bool uvw::file_req::chmod_sync | ( | int | mode | ) |
Sync fchmod.
mode | Mode, as described in the official documentation. |
Sync fchown.
uid | UID, as described in the official documentation. |
gid | GID, as described in the official documentation. |
bool uvw::file_req::close_sync | ( | ) |
Sync close.
bool uvw::file_req::datasync_sync | ( | ) |
Sync fdatasync.
void uvw::file_req::futime | ( | time | atime, |
time | mtime | ||
) |
bool uvw::file_req::futime_sync | ( | time | atime, |
time | mtime | ||
) |
Sync futime.
atime | std::chrono::duration<double> , having the same meaning as described in the official documentation. |
mtime | std::chrono::duration<double> , having the same meaning as described in the official documentation. |
void uvw::file_req::open | ( | const std::string & | path, |
file_open_flags | flags, | ||
int | mode | ||
) |
Async open.
Emit a fs_event
event when completed.
Available flags are:
file_req::file_open_flags::APPEND
file_req::file_open_flags::CREAT
file_req::file_open_flags::DIRECT
file_req::file_open_flags::DIRECTORY
file_req::file_open_flags::DSYNC
file_req::file_open_flags::EXCL
file_req::file_open_flags::EXLOCK
file_req::file_open_flags::FILEMAP
file_req::file_open_flags::NOATIME
file_req::file_open_flags::NOCTTY
file_req::file_open_flags::NOFOLLOW
file_req::file_open_flags::NONBLOCK
file_req::file_open_flags::RANDOM
file_req::file_open_flags::RDONLY
file_req::file_open_flags::RDWR
file_req::file_open_flags::SEQUENTIAL
file_req::file_open_flags::SHORT_LIVED
file_req::file_open_flags::SYMLINK
file_req::file_open_flags::SYNC
file_req::file_open_flags::TEMPORARY
file_req::file_open_flags::TRUNC
file_req::file_open_flags::WRONLY
See the official documentation for further details.
path | A valid path name for a file. |
flags | Flags made out of underlying constants. |
mode | Mode, as described in the official documentation. |
bool uvw::file_req::open_sync | ( | const std::string & | path, |
file_open_flags | flags, | ||
int | mode | ||
) |
Sync open.
Available flags are:
file_req::file_open_flags::APPEND
file_req::file_open_flags::CREAT
file_req::file_open_flags::DIRECT
file_req::file_open_flags::DIRECTORY
file_req::file_open_flags::DSYNC
file_req::file_open_flags::EXCL
file_req::file_open_flags::EXLOCK
file_req::file_open_flags::FILEMAP
file_req::file_open_flags::NOATIME
file_req::file_open_flags::NOCTTY
file_req::file_open_flags::NOFOLLOW
file_req::file_open_flags::NONBLOCK
file_req::file_open_flags::RANDOM
file_req::file_open_flags::RDONLY
file_req::file_open_flags::RDWR
file_req::file_open_flags::SEQUENTIAL
file_req::file_open_flags::SHORT_LIVED
file_req::file_open_flags::SYMLINK
file_req::file_open_flags::SYNC
file_req::file_open_flags::TEMPORARY
file_req::file_open_flags::TRUNC
file_req::file_open_flags::WRONLY
See the official documentation for further details.
path | A valid path name for a file. |
flags | Flags made out of underlying constants. |
mode | Mode, as described in the official documentation. |
|
noexcept |
Cast operator to file_handle.
Cast operator to an internal representation of the underlying file handle.
void uvw::file_req::read | ( | int64_t | offset, |
unsigned int | len | ||
) |
std::pair< bool, std::pair< std::unique_ptr< const char[]>, std::size_t > > uvw::file_req::read_sync | ( | int64_t | offset, |
unsigned int | len | ||
) |
Sync read.
offset | Offset, as described in the official documentation. |
len | Length, as described in the official documentation. |
std::pair
composed as it follows:std::pair
composed as it follows:void uvw::file_req::sendfile | ( | file_handle | out, |
int64_t | offset, | ||
std::size_t | length | ||
) |
std::pair< bool, std::size_t > uvw::file_req::sendfile_sync | ( | file_handle | out, |
int64_t | offset, | ||
std::size_t | length | ||
) |
Sync sendfile.
out | A valid instance of file_handle. |
offset | Offset, as described in the official documentation. |
length | Length, as described in the official documentation. |
std::pair
composed as it follows:std::pair< bool, file_info > uvw::file_req::stat_sync | ( | ) |
Sync fstat.
std::pair
composed as it follows:bool uvw::file_req::sync_sync | ( | ) |
Sync fsync.
void uvw::file_req::truncate | ( | int64_t | offset | ) |
bool uvw::file_req::truncate_sync | ( | int64_t | offset | ) |
Sync ftruncate.
offset | Offset, as described in the official documentation. |
void uvw::file_req::write | ( | char * | buf, |
unsigned int | len, | ||
int64_t | offset | ||
) |
void uvw::file_req::write | ( | std::unique_ptr< char[]> | buf, |
unsigned int | len, | ||
int64_t | offset | ||
) |
std::pair< bool, std::size_t > uvw::file_req::write_sync | ( | std::unique_ptr< char[]> | buf, |
unsigned int | len, | ||
int64_t | offset | ||
) |
Sync write.
buf | The data to be written. |
len | The lenght of the submitted data. |
offset | Offset, as described in the official documentation. |
std::pair
composed as it follows: