uvw  1.3.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, int flags, int mode)
 Async open. More...
 
bool openSync (std::string path, int 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...
 
OSFileDescriptor handle () const noexcept
 Gets the OS dependent handle. 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 334 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 643 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 652 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 696 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 706 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 378 of file fs.hpp.

◆ closeSync()

bool uvw::FileReq::closeSync ( )
inline

Sync close.

Returns
True in case of success, false otherwise.

Definition at line 386 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 566 of file fs.hpp.

◆ datasyncSync()

bool uvw::FileReq::datasyncSync ( )
inline

Sync fdatasync.

Returns
True in case of success, false otherwise.

Definition at line 574 of file fs.hpp.

◆ handle()

OSFileDescriptor uvw::FileReq::handle ( ) const
inlinenoexcept

Gets the OS dependent handle.

For a file descriptor in the C runtime, get the OS-dependent handle. On UNIX, returns the file descriptor as-is. On Windows, this calls a system function.
Note that the return value is still owned by the C runtime, any attempts to close it or to use it after closing the file descriptor may lead to malfunction.

Definition at line 722 of file fs.hpp.

◆ open()

void uvw::FileReq::open ( std::string  path,
int  flags,
int  mode 
)
inline

Async open.

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

Parameters
pathA valid path name for a file.
flagsFlags, as described in the official documentation.
modeMode, as described in the official documentation.

Definition at line 403 of file fs.hpp.

◆ openSync()

bool uvw::FileReq::openSync ( std::string  path,
int  flags,
int  mode 
)
inline

Sync open.

Parameters
pathA valid path name for a file.
flagsFlags, as described in the official documentation.
modeMode, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 414 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 734 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 430 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 450 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 613 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 628 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 523 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 534 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 546 of file fs.hpp.

◆ syncSync()

bool uvw::FileReq::syncSync ( )
inline

Sync fsync.

Returns
True in case of success, false otherwise.

Definition at line 554 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 588 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 597 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 669 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 681 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 473 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 492 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 508 of file fs.hpp.


The documentation for this class was generated from the following file: