uvw  2.2.0
Public Member Functions | List of all members
uvw::FileReq Class Referencefinal

The FileReq request. More...

#include <fs.hpp>

Inheritance diagram for uvw::FileReq:
Inheritance graph
[legend]
Collaboration diagram for uvw::FileReq:
Collaboration graph
[legend]

Public Member Functions

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, StatstatSync ()
 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...
 

Detailed Description

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.

Member Function Documentation

◆ 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
modeMode, 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
modeMode, 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
uidUID, as described in the official documentation.
gidGID, 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
uidUID, as described in the official documentation.
gidGID, 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

Async close.

Emit a FsEvent<FileReq::Type::CLOSE> event when completed.
Emit an ErrorEvent event in case of errors.

Definition at line 460 of file fs.hpp.

◆ 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

Async fdatasync.

Emit a FsEvent<FileReq::Type::FDATASYNC> event when completed.
Emit an ErrorEvent event in case of errors.

Definition at line 707 of file fs.hpp.

◆ 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
pathA valid path name for a file.
flagsFlags made out of underlying constants.
modeMode, 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
pathA valid path name for a file.
flagsFlags made out of underlying constants.
modeMode, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 555 of file fs.hpp.

◆ operator FileHandle()

uvw::FileReq::operator FileHandle ( ) const
inlinenoexcept

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
offsetOffset, as described in the official documentation.
lenLength, 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
offsetOffset, as described in the official documentation.
lenLength, 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
outA valid instance of FileHandle.
offsetOffset, as described in the official documentation.
lengthLength, 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
outA valid instance of FileHandle.
offsetOffset, as described in the official documentation.
lengthLength, 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

Async fstat.

Emit a FsEvent<FileReq::Type::FSTAT> event when completed.
Emit an ErrorEvent event in case of errors.

Definition at line 664 of file fs.hpp.

◆ 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

Async fsync.

Emit a FsEvent<FileReq::Type::FSYNC> event when completed.
Emit an ErrorEvent event in case of errors.

Definition at line 687 of file fs.hpp.

◆ 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
offsetOffset, 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
offsetOffset, 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
atimestd::chrono::duration<double>, having the same meaning as described in the official documentation.
mtimestd::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
atimestd::chrono::duration<double>, having the same meaning as described in the official documentation.
mtimestd::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
bufThe data to be written.
lenThe lenght of the submitted data.
offsetOffset, 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
bufThe data to be written.
lenThe lenght of the submitted data.
offsetOffset, 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
bufThe data to be written.
lenThe lenght of the submitted data.
offsetOffset, 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: