The FileReq request.
More...
#include <fs.hpp>
|
| void | close () |
| | Async close. More...
|
| |
| bool | closeSync () |
| | Sync close. More...
|
| |
| void | open (std::string path, Flags< FileOpen > flags, int mode) |
| | Async open. More...
|
| |
| bool | openSync (std::string path, Flags< FileOpen > flags, int mode) |
| | Sync open. More...
|
| |
| void | read (int64_t offset, unsigned int len) |
| | Async read. More...
|
| |
| std::pair< bool, std::pair< std::unique_ptr< const char[]>, std::size_t > > | readSync (int64_t offset, unsigned int len) |
| | Sync read. More...
|
| |
| void | write (std::unique_ptr< char[]> buf, unsigned int len, int64_t offset) |
| | Async write. More...
|
| |
| void | write (char *buf, unsigned int len, int64_t offset) |
| | Async write. More...
|
| |
| std::pair< bool, std::size_t > | writeSync (std::unique_ptr< char[]> buf, unsigned int len, int64_t offset) |
| | Sync write. More...
|
| |
| void | stat () |
| | Async fstat. More...
|
| |
| std::pair< bool, Stat > | statSync () |
| | Sync fstat. More...
|
| |
| void | sync () |
| | Async fsync. More...
|
| |
| bool | syncSync () |
| | Sync fsync. More...
|
| |
| void | datasync () |
| | Async fdatasync. More...
|
| |
| bool | datasyncSync () |
| | Sync fdatasync. More...
|
| |
| void | truncate (int64_t offset) |
| | Async ftruncate. More...
|
| |
| bool | truncateSync (int64_t offset) |
| | Sync ftruncate. More...
|
| |
| void | sendfile (FileHandle out, int64_t offset, std::size_t length) |
| | Async sendfile. More...
|
| |
| std::pair< bool, std::size_t > | sendfileSync (FileHandle out, int64_t offset, std::size_t length) |
| | Sync sendfile. More...
|
| |
| void | chmod (int mode) |
| | Async fchmod. More...
|
| |
| bool | chmodSync (int mode) |
| | Sync fchmod. More...
|
| |
| void | utime (Time atime, Time mtime) |
| | Async futime. More...
|
| |
| bool | utimeSync (Time atime, Time mtime) |
| | Sync futime. More...
|
| |
| void | chown (Uid uid, Gid gid) |
| | Async fchown. More...
|
| |
| bool | chownSync (Uid uid, Gid gid) |
| | Sync fchown. More...
|
| |
| | operator FileHandle () const noexcept |
| | Cast operator to FileHandle. More...
|
| |
The FileReq request.
Cross-platform sync and async filesystem operations.
All file operations are run on the threadpool.
To create a FileReq through a Loop, no arguments are required.
See the official documentation for further details.
Definition at line 414 of file fs.hpp.
◆ chmod()
| void uvw::FileReq::chmod |
( |
int |
mode | ) |
|
|
inline |
Async fchmod.
Emit a FsEvent<FileReq::Type::FCHMOD> event when completed.
Emit an ErrorEvent event in case of errors.
- Parameters
-
| mode | Mode, as described in the official documentation. |
Definition at line 784 of file fs.hpp.
◆ chmodSync()
| bool uvw::FileReq::chmodSync |
( |
int |
mode | ) |
|
|
inline |
Sync fchmod.
- Parameters
-
| mode | Mode, as described in the official documentation. |
- Returns
- True in case of success, false otherwise.
Definition at line 793 of file fs.hpp.
◆ chown()
| void uvw::FileReq::chown |
( |
Uid |
uid, |
|
|
Gid |
gid |
|
) |
| |
|
inline |
Async fchown.
Emit a FsEvent<FileReq::Type::FCHOWN> event when completed.
Emit an ErrorEvent event in case of errors.
- Parameters
-
| uid | UID, as described in the official documentation. |
| gid | GID, as described in the official documentation. |
Definition at line 837 of file fs.hpp.
◆ chownSync()
| bool uvw::FileReq::chownSync |
( |
Uid |
uid, |
|
|
Gid |
gid |
|
) |
| |
|
inline |
Sync fchown.
- Parameters
-
| uid | UID, as described in the official documentation. |
| gid | GID, as described in the official documentation. |
- Returns
- True in case of success, false otherwise.
Definition at line 847 of file fs.hpp.
◆ close()
| void uvw::FileReq::close |
( |
| ) |
|
|
inline |
◆ closeSync()
| bool uvw::FileReq::closeSync |
( |
| ) |
|
|
inline |
Sync close.
- Returns
- True in case of success, false otherwise.
Definition at line 468 of file fs.hpp.
◆ datasync()
| void uvw::FileReq::datasync |
( |
| ) |
|
|
inline |
◆ datasyncSync()
| bool uvw::FileReq::datasyncSync |
( |
| ) |
|
|
inline |
Sync fdatasync.
- Returns
- True in case of success, false otherwise.
Definition at line 715 of file fs.hpp.
◆ open()
| void uvw::FileReq::open |
( |
std::string |
path, |
|
|
Flags< FileOpen > |
flags, |
|
|
int |
mode |
|
) |
| |
|
inline |
Async open.
Emit a FsEvent<FileReq::Type::OPEN> event when completed.
Emit an ErrorEvent event in case of errors.
Available flags are:
FileReq::FileOpen::APPEND
FileReq::FileOpen::CREAT
FileReq::FileOpen::DIRECT
FileReq::FileOpen::DIRECTORY
FileReq::FileOpen::DSYNC
FileReq::FileOpen::EXCL
FileReq::FileOpen::EXLOCK
FileReq::FileOpen::FILEMAP
FileReq::FileOpen::NOATIME
FileReq::FileOpen::NOCTTY
FileReq::FileOpen::NOFOLLOW
FileReq::FileOpen::NONBLOCK
FileReq::FileOpen::RANDOM
FileReq::FileOpen::RDONLY
FileReq::FileOpen::RDWR
FileReq::FileOpen::SEQUENTIAL
FileReq::FileOpen::SHORT_LIVED
FileReq::FileOpen::SYMLINK
FileReq::FileOpen::SYNC
FileReq::FileOpen::TEMPORARY
FileReq::FileOpen::TRUNC
FileReq::FileOpen::WRONLY
See the official documentation for further details.
- Parameters
-
| path | A valid path name for a file. |
| flags | Flags made out of underlying constants. |
| mode | Mode, as described in the official documentation. |
Definition at line 514 of file fs.hpp.
◆ openSync()
| bool uvw::FileReq::openSync |
( |
std::string |
path, |
|
|
Flags< FileOpen > |
flags, |
|
|
int |
mode |
|
) |
| |
|
inline |
Sync open.
Available flags are:
FileReq::FileOpen::APPEND
FileReq::FileOpen::CREAT
FileReq::FileOpen::DIRECT
FileReq::FileOpen::DIRECTORY
FileReq::FileOpen::DSYNC
FileReq::FileOpen::EXCL
FileReq::FileOpen::EXLOCK
FileReq::FileOpen::FILEMAP
FileReq::FileOpen::NOATIME
FileReq::FileOpen::NOCTTY
FileReq::FileOpen::NOFOLLOW
FileReq::FileOpen::NONBLOCK
FileReq::FileOpen::RANDOM
FileReq::FileOpen::RDONLY
FileReq::FileOpen::RDWR
FileReq::FileOpen::SEQUENTIAL
FileReq::FileOpen::SHORT_LIVED
FileReq::FileOpen::SYMLINK
FileReq::FileOpen::SYNC
FileReq::FileOpen::TEMPORARY
FileReq::FileOpen::TRUNC
FileReq::FileOpen::WRONLY
See the official documentation for further details.
- Parameters
-
| path | A valid path name for a file. |
| flags | Flags made out of underlying constants. |
| mode | Mode, as described in the official documentation. |
- Returns
- True in case of success, false otherwise.
Definition at line 555 of file fs.hpp.
◆ operator FileHandle()
Cast operator to FileHandle.
Cast operator to an internal representation of the underlying file handle.
- Returns
- A valid instance of FileHandle (the descriptor can be invalid).
Definition at line 861 of file fs.hpp.
◆ read()
| void uvw::FileReq::read |
( |
int64_t |
offset, |
|
|
unsigned int |
len |
|
) |
| |
|
inline |
Async read.
Emit a FsEvent<FileReq::Type::READ> event when completed.
Emit an ErrorEvent event in case of errors.
- Parameters
-
| offset | Offset, as described in the official documentation. |
| len | Length, as described in the official documentation. |
Definition at line 571 of file fs.hpp.
◆ readSync()
| std::pair<bool, std::pair<std::unique_ptr<const char[]>, std::size_t> > uvw::FileReq::readSync |
( |
int64_t |
offset, |
|
|
unsigned int |
len |
|
) |
| |
|
inline |
Sync read.
- Parameters
-
| offset | Offset, as described in the official documentation. |
| len | Length, as described in the official documentation. |
- Returns
- A
std::pair composed as it follows:
- A boolean value that is true in case of success, false otherwise.
- A
std::pair composed as it follows:
- A bunch of data read from the given path.
- The amount of data read from the given path.
Definition at line 591 of file fs.hpp.
◆ sendfile()
| void uvw::FileReq::sendfile |
( |
FileHandle |
out, |
|
|
int64_t |
offset, |
|
|
std::size_t |
length |
|
) |
| |
|
inline |
Async sendfile.
Emit a FsEvent<FileReq::Type::SENDFILE> event when completed.
Emit an ErrorEvent event in case of errors.
- Parameters
-
| out | A valid instance of FileHandle. |
| offset | Offset, as described in the official documentation. |
| length | Length, as described in the official documentation. |
Definition at line 754 of file fs.hpp.
◆ sendfileSync()
| std::pair<bool, std::size_t> uvw::FileReq::sendfileSync |
( |
FileHandle |
out, |
|
|
int64_t |
offset, |
|
|
std::size_t |
length |
|
) |
| |
|
inline |
Sync sendfile.
- Parameters
-
| out | A valid instance of FileHandle. |
| offset | Offset, as described in the official documentation. |
| length | Length, as described in the official documentation. |
- Returns
- A
std::pair composed as it follows:
- A boolean value that is true in case of success, false otherwise.
- The amount of data transferred.
Definition at line 769 of file fs.hpp.
◆ stat()
| void uvw::FileReq::stat |
( |
| ) |
|
|
inline |
◆ statSync()
| std::pair<bool, Stat> uvw::FileReq::statSync |
( |
| ) |
|
|
inline |
Sync fstat.
- Returns
- A
std::pair composed as it follows:
- A boolean value that is true in case of success, false otherwise.
- An initialized instance of Stat.
Definition at line 675 of file fs.hpp.
◆ sync()
| void uvw::FileReq::sync |
( |
| ) |
|
|
inline |
◆ syncSync()
| bool uvw::FileReq::syncSync |
( |
| ) |
|
|
inline |
Sync fsync.
- Returns
- True in case of success, false otherwise.
Definition at line 695 of file fs.hpp.
◆ truncate()
| void uvw::FileReq::truncate |
( |
int64_t |
offset | ) |
|
|
inline |
Async ftruncate.
Emit a FsEvent<FileReq::Type::FTRUNCATE> event when completed.
Emit an ErrorEvent event in case of errors.
- Parameters
-
| offset | Offset, as described in the official documentation. |
Definition at line 729 of file fs.hpp.
◆ truncateSync()
| bool uvw::FileReq::truncateSync |
( |
int64_t |
offset | ) |
|
|
inline |
Sync ftruncate.
- Parameters
-
| offset | Offset, as described in the official documentation. |
- Returns
- True in case of success, false otherwise.
Definition at line 738 of file fs.hpp.
◆ utime()
| void uvw::FileReq::utime |
( |
Time |
atime, |
|
|
Time |
mtime |
|
) |
| |
|
inline |
Async futime.
Emit a FsEvent<FileReq::Type::FUTIME> event when completed.
Emit an ErrorEvent event in case of errors.
- Parameters
-
| 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. |
Definition at line 810 of file fs.hpp.
◆ utimeSync()
| bool uvw::FileReq::utimeSync |
( |
Time |
atime, |
|
|
Time |
mtime |
|
) |
| |
|
inline |
Sync futime.
- Parameters
-
| 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. |
- Returns
- True in case of success, false otherwise.
Definition at line 822 of file fs.hpp.
◆ write() [1/2]
| void uvw::FileReq::write |
( |
std::unique_ptr< char[]> |
buf, |
|
|
unsigned int |
len, |
|
|
int64_t |
offset |
|
) |
| |
|
inline |
Async write.
The request takes the ownership of the data and it is in charge of delete them.
Emit a FsEvent<FileReq::Type::WRITE> event when completed.
Emit an ErrorEvent event in case of errors.
- Parameters
-
| buf | The data to be written. |
| len | The lenght of the submitted data. |
| offset | Offset, as described in the official documentation. |
Definition at line 614 of file fs.hpp.
◆ write() [2/2]
| void uvw::FileReq::write |
( |
char * |
buf, |
|
|
unsigned int |
len, |
|
|
int64_t |
offset |
|
) |
| |
|
inline |
Async write.
The request doesn't take the ownership of the data. Be sure that their lifetime overcome the one of the request.
Emit a FsEvent<FileReq::Type::WRITE> event when completed.
Emit an ErrorEvent event in case of errors.
- Parameters
-
| buf | The data to be written. |
| len | The lenght of the submitted data. |
| offset | Offset, as described in the official documentation. |
Definition at line 633 of file fs.hpp.
◆ writeSync()
| std::pair<bool, std::size_t> uvw::FileReq::writeSync |
( |
std::unique_ptr< char[]> |
buf, |
|
|
unsigned int |
len, |
|
|
int64_t |
offset |
|
) |
| |
|
inline |
Sync write.
- Parameters
-
| buf | The data to be written. |
| len | The lenght of the submitted data. |
| offset | Offset, as described in the official documentation. |
- Returns
- A
std::pair composed as it follows:
- A boolean value that is true in case of success, false otherwise.
- The amount of data written to the given path.
Definition at line 649 of file fs.hpp.
The documentation for this class was generated from the following file: