uvw  1.10.0
Public Member Functions | List of all members
uvw::FsReq Class Referencefinal

The FsReq request. More...

#include <fs.hpp>

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

Public Member Functions

void unlink (std::string path)
 Async unlink. More...
 
bool unlinkSync (std::string path)
 Sync unlink. More...
 
void mkdir (std::string path, int mode)
 Async mkdir. More...
 
bool mkdirSync (std::string path, int mode)
 Sync mkdir. More...
 
void mkdtemp (std::string tpl)
 Async mktemp. More...
 
std::pair< bool, const char * > mkdtempSync (std::string tpl)
 Sync mktemp. More...
 
void rmdir (std::string path)
 Async rmdir. More...
 
bool rmdirSync (std::string path)
 Sync rmdir. More...
 
void scandir (std::string path, int flags)
 Async scandir. More...
 
std::pair< bool, std::size_t > scandirSync (std::string path, int flags)
 Sync scandir. More...
 
std::pair< bool, Entry > scandirNext ()
 Gets entries populated with the next directory entry data. More...
 
void stat (std::string path)
 Async stat. More...
 
std::pair< bool, StatstatSync (std::string path)
 Sync stat. More...
 
void lstat (std::string path)
 Async lstat. More...
 
std::pair< bool, StatlstatSync (std::string path)
 Sync lstat. More...
 
void rename (std::string old, std::string path)
 Async rename. More...
 
bool renameSync (std::string old, std::string path)
 Sync rename. More...
 
void copyfile (std::string old, std::string path, Flags< CopyFile > flags=Flags< CopyFile >{})
 Copies a file asynchronously from a path to a new one. More...
 
bool copyfileSync (std::string old, std::string path, Flags< CopyFile > flags=Flags< CopyFile >{})
 Copies a file synchronously from a path to a new one. More...
 
void access (std::string path, int mode)
 Async access. More...
 
bool accessSync (std::string path, int mode)
 Sync access. More...
 
void chmod (std::string path, int mode)
 Async chmod. More...
 
bool chmodSync (std::string path, int mode)
 Sync chmod. More...
 
void utime (std::string path, Time atime, Time mtime)
 Async utime. More...
 
bool utimeSync (std::string path, Time atime, Time mtime)
 Sync utime. More...
 
void link (std::string old, std::string path)
 Async link. More...
 
bool linkSync (std::string old, std::string path)
 Sync link. More...
 
void symlink (std::string old, std::string path, Flags< SymLink > flags=Flags< SymLink >{})
 Async symlink. More...
 
bool symlinkSync (std::string old, std::string path, Flags< SymLink > flags=Flags< SymLink >{})
 Sync symlink. More...
 
void readlink (std::string path)
 Async readlink. More...
 
std::pair< bool, std::pair< const char *, std::size_t > > readlinkSync (std::string path)
 Sync readlink. More...
 
void realpath (std::string path)
 Async realpath. More...
 
std::pair< bool, const char * > realpathSync (std::string path)
 Sync realpath. More...
 
void chown (std::string path, Uid uid, Gid gid)
 Async chown. More...
 
bool chownSync (std::string path, Uid uid, Gid gid)
 Sync chown. More...
 
void lchown (std::string path, Uid uid, Gid gid)
 Async lchown. More...
 
bool lchownSync (std::string path, Uid uid, Gid gid)
 Sync lchown. More...
 

Detailed Description

The FsReq request.

Cross-platform sync and async filesystem operations.
All file operations are run on the threadpool.

To create a FsReq through a Loop, no arguments are required.

See the official documentation for further details.

Definition at line 843 of file fs.hpp.

Member Function Documentation

◆ access()

void uvw::FsReq::access ( std::string  path,
int  mode 
)
inline

Async access.

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

Parameters
pathPath, as described in the official documentation.
modeMode, as described in the official documentation.

Definition at line 1177 of file fs.hpp.

◆ accessSync()

bool uvw::FsReq::accessSync ( std::string  path,
int  mode 
)
inline

Sync access.

Parameters
pathPath, as described in the official documentation.
modeMode, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 1187 of file fs.hpp.

◆ chmod()

void uvw::FsReq::chmod ( std::string  path,
int  mode 
)
inline

Async chmod.

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

Parameters
pathPath, as described in the official documentation.
modeMode, as described in the official documentation.

Definition at line 1202 of file fs.hpp.

◆ chmodSync()

bool uvw::FsReq::chmodSync ( std::string  path,
int  mode 
)
inline

Sync chmod.

Parameters
pathPath, as described in the official documentation.
modeMode, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 1212 of file fs.hpp.

◆ chown()

void uvw::FsReq::chown ( std::string  path,
Uid  uid,
Gid  gid 
)
inline

Async chown.

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

Parameters
pathPath, as described in the official documentation.
uidUID, as described in the official documentation.
gidGID, as described in the official documentation.

Definition at line 1384 of file fs.hpp.

◆ chownSync()

bool uvw::FsReq::chownSync ( std::string  path,
Uid  uid,
Gid  gid 
)
inline

Sync chown.

Parameters
pathPath, as described in the official documentation.
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 1395 of file fs.hpp.

◆ copyfile()

void uvw::FsReq::copyfile ( std::string  old,
std::string  path,
Flags< CopyFile >  flags = Flags<CopyFile>{} 
)
inline

Copies a file asynchronously from a path to a new one.

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

Available flags are:

  • FsReq::CopyFile::EXCL: it fails if the destination path already exists (the default behavior is to overwrite the destination if it exists).
  • FsReq::CopyFile::FICLONE: If present, it will attempt to create a copy-on-write reflink. If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
  • FsReq::CopyFile::FICLONE_FORCE: If present, it will attempt to create a copy-on-write reflink. If the underlying platform does not support copy-on-write, then an error is returned.
Warning
If the destination path is created, but an error occurs while copying the data, then the destination path is removed. There is a brief window of time between closing and removing the file where another process could access the file.
Parameters
oldOld path, as described in the official documentation.
pathNew path, as described in the official documentation.
flagsOptional additional flags.

Definition at line 1139 of file fs.hpp.

◆ copyfileSync()

bool uvw::FsReq::copyfileSync ( std::string  old,
std::string  path,
Flags< CopyFile >  flags = Flags<CopyFile>{} 
)
inline

Copies a file synchronously from a path to a new one.

Available flags are:

  • FsReq::CopyFile::EXCL: it fails if the destination path already exists (the default behavior is to overwrite the destination if it exists).

If the destination path is created, but an error occurs while copying the data, then the destination path is removed. There is a brief window of time between closing and removing the file where another process could access the file.

Parameters
oldOld path, as described in the official documentation.
pathNew path, as described in the official documentation.
flagsOptional additional flags.
Returns
True in case of success, false otherwise.

Definition at line 1162 of file fs.hpp.

◆ lchown()

void uvw::FsReq::lchown ( std::string  path,
Uid  uid,
Gid  gid 
)
inline

Async lchown.

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

Parameters
pathPath, as described in the official documentation.
uidUID, as described in the official documentation.
gidGID, as described in the official documentation.

Definition at line 1411 of file fs.hpp.

◆ lchownSync()

bool uvw::FsReq::lchownSync ( std::string  path,
Uid  uid,
Gid  gid 
)
inline

Sync lchown.

Parameters
pathPath, as described in the official documentation.
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 1422 of file fs.hpp.

◆ link()

void uvw::FsReq::link ( std::string  old,
std::string  path 
)
inline

Async link.

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

Parameters
oldOld path, as described in the official documentation.
pathNew path, as described in the official documentation.

Definition at line 1258 of file fs.hpp.

◆ linkSync()

bool uvw::FsReq::linkSync ( std::string  old,
std::string  path 
)
inline

Sync link.

Parameters
oldOld path, as described in the official documentation.
pathNew path, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 1268 of file fs.hpp.

◆ lstat()

void uvw::FsReq::lstat ( std::string  path)
inline

Async lstat.

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

Parameters
pathPath, as described in the official documentation.

Definition at line 1066 of file fs.hpp.

◆ lstatSync()

std::pair<bool, Stat> uvw::FsReq::lstatSync ( std::string  path)
inline

Sync lstat.

Parameters
pathPath, 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.
  • An initialized instance of Stat.

Definition at line 1079 of file fs.hpp.

◆ mkdir()

void uvw::FsReq::mkdir ( std::string  path,
int  mode 
)
inline

Async mkdir.

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

Parameters
pathPath, as described in the official documentation.
modeMode, as described in the official documentation.

Definition at line 892 of file fs.hpp.

◆ mkdirSync()

bool uvw::FsReq::mkdirSync ( std::string  path,
int  mode 
)
inline

Sync mkdir.

Parameters
pathPath, as described in the official documentation.
modeMode, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 902 of file fs.hpp.

◆ mkdtemp()

void uvw::FsReq::mkdtemp ( std::string  tpl)
inline

Async mktemp.

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

Parameters
tplTemplate, as described in the official documentation.

Definition at line 916 of file fs.hpp.

◆ mkdtempSync()

std::pair<bool, const char *> uvw::FsReq::mkdtempSync ( std::string  tpl)
inline

Sync mktemp.

Parameters
tplTemplate, 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 actual path of the newly created directoy.

Definition at line 929 of file fs.hpp.

◆ readlink()

void uvw::FsReq::readlink ( std::string  path)
inline

Async readlink.

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

Parameters
pathPath, as described in the official documentation.

Definition at line 1324 of file fs.hpp.

◆ readlinkSync()

std::pair<bool, std::pair<const char *, std::size_t> > uvw::FsReq::readlinkSync ( std::string  path)
inline

Sync readlink.

Parameters
pathPath, 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 1340 of file fs.hpp.

◆ realpath()

void uvw::FsReq::realpath ( std::string  path)
inline

Async realpath.

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

Parameters
pathPath, as described in the official documentation.

Definition at line 1355 of file fs.hpp.

◆ realpathSync()

std::pair<bool, const char *> uvw::FsReq::realpathSync ( std::string  path)
inline

Sync realpath.

Parameters
pathPath, 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 canonicalized absolute pathname.

Definition at line 1368 of file fs.hpp.

◆ rename()

void uvw::FsReq::rename ( std::string  old,
std::string  path 
)
inline

Async rename.

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

Parameters
oldOld path, as described in the official documentation.
pathNew path, as described in the official documentation.

Definition at line 1094 of file fs.hpp.

◆ renameSync()

bool uvw::FsReq::renameSync ( std::string  old,
std::string  path 
)
inline

Sync rename.

Parameters
oldOld path, as described in the official documentation.
pathNew path, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 1104 of file fs.hpp.

◆ rmdir()

void uvw::FsReq::rmdir ( std::string  path)
inline

Async rmdir.

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

Parameters
pathPath, as described in the official documentation.

Definition at line 943 of file fs.hpp.

◆ rmdirSync()

bool uvw::FsReq::rmdirSync ( std::string  path)
inline

Sync rmdir.

Parameters
pathPath, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 952 of file fs.hpp.

◆ scandir()

void uvw::FsReq::scandir ( std::string  path,
int  flags 
)
inline

Async scandir.

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

Parameters
pathPath, as described in the official documentation.
flagsFlags, as described in the official documentation.

Definition at line 967 of file fs.hpp.

◆ scandirNext()

std::pair<bool, Entry> uvw::FsReq::scandirNext ( )
inline

Gets entries populated with the next directory entry data.

Returns instances of Entry, that is an alias for a pair where:

  • The first parameter indicates the entry type (see below).
  • The second parameter is a std::string that contains the actual value.

Available entry types are:

  • FsReq::EntryType::UNKNOWN
  • FsReq::EntryType::FILE
  • FsReq::EntryType::DIR
  • FsReq::EntryType::LINK
  • FsReq::EntryType::FIFO
  • FsReq::EntryType::SOCKET
  • FsReq::EntryType::CHAR
  • FsReq::EntryType::BLOCK

See the official documentation for further details.

Returns
A pair where:
  • The first parameter is a boolean value that indicates if the current entry is still valid.
  • The second parameter is an instance of Entry (see above).

Definition at line 1017 of file fs.hpp.

◆ scandirSync()

std::pair<bool, std::size_t> uvw::FsReq::scandirSync ( std::string  path,
int  flags 
)
inline

Sync scandir.

Parameters
pathPath, as described in the official documentation.
flagsFlags, 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 number of directory entries selected.

Definition at line 981 of file fs.hpp.

◆ stat()

void uvw::FsReq::stat ( std::string  path)
inline

Async stat.

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

Parameters
pathPath, as described in the official documentation.

Definition at line 1039 of file fs.hpp.

◆ statSync()

std::pair<bool, Stat> uvw::FsReq::statSync ( std::string  path)
inline

Sync stat.

Parameters
pathPath, 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.
  • An initialized instance of Stat.

Definition at line 1052 of file fs.hpp.

◆ symlink()

void uvw::FsReq::symlink ( std::string  old,
std::string  path,
Flags< SymLink >  flags = Flags<SymLink>{} 
)
inline

Async symlink.

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

Available flags are:

  • FsReq::SymLink::DIR: it indicates that the old path points to a directory.
  • FsReq::SymLink::JUNCTION: it requests that the symlink is created using junction points.
Parameters
oldOld path, as described in the official documentation.
pathNew path, as described in the official documentation.
flagsOptional additional flags.

Definition at line 1291 of file fs.hpp.

◆ symlinkSync()

bool uvw::FsReq::symlinkSync ( std::string  old,
std::string  path,
Flags< SymLink >  flags = Flags<SymLink>{} 
)
inline

Sync symlink.

Available flags are:

  • FsReq::SymLink::DIR: it indicates that the old path points to a directory.
  • FsReq::SymLink::JUNCTION: it requests that the symlink is created using junction points.
Parameters
oldOld path, as described in the official documentation.
pathNew path, as described in the official documentation.
flagsFlags, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 1310 of file fs.hpp.

◆ unlink()

void uvw::FsReq::unlink ( std::string  path)
inline

Async unlink.

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

Parameters
pathPath, as described in the official documentation.

Definition at line 868 of file fs.hpp.

◆ unlinkSync()

bool uvw::FsReq::unlinkSync ( std::string  path)
inline

Sync unlink.

Parameters
pathPath, as described in the official documentation.
Returns
True in case of success, false otherwise.

Definition at line 877 of file fs.hpp.

◆ utime()

void uvw::FsReq::utime ( std::string  path,
Time  atime,
Time  mtime 
)
inline

Async utime.

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

Parameters
pathPath, as described in the official documentation.
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 1230 of file fs.hpp.

◆ utimeSync()

bool uvw::FsReq::utimeSync ( std::string  path,
Time  atime,
Time  mtime 
)
inline

Sync utime.

Parameters
pathPath, as described in the official documentation.
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 1243 of file fs.hpp.


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