uvw 2.12.1
|
#include <fs.h>
Public Member Functions | |
void | unlink (const std::string &path) |
Async unlink. | |
bool | unlinkSync (const std::string &path) |
Sync unlink. | |
void | mkdir (const std::string &path, int mode) |
Async mkdir. | |
bool | mkdirSync (const std::string &path, int mode) |
Sync mkdir. | |
void | mkdtemp (const std::string &tpl) |
Async mktemp. | |
std::pair< bool, const char * > | mkdtempSync (const std::string &tpl) |
Sync mktemp. | |
void | mkstemp (const std::string &tpl) |
Async mkstemp. | |
std::pair< bool, std::pair< std::string, std::size_t > > | mkstempSync (const std::string &tpl) |
Sync mkstemp. | |
void | lutime (const std::string &path, Time atime, Time mtime) |
Async lutime. | |
bool | lutimeSync (const std::string &path, Time atime, Time mtime) |
Sync lutime. | |
void | rmdir (const std::string &path) |
Async rmdir. | |
bool | rmdirSync (const std::string &path) |
Sync rmdir. | |
void | scandir (const std::string &path, int flags) |
Async scandir. | |
std::pair< bool, std::size_t > | scandirSync (const std::string &path, int flags) |
Sync scandir. | |
std::pair< bool, std::pair< EntryType, const char * > > | scandirNext () |
Gets entries populated with the next directory entry data. | |
void | stat (const std::string &path) |
Async stat. | |
std::pair< bool, Stat > | statSync (const std::string &path) |
Sync stat. | |
void | lstat (const std::string &path) |
Async lstat. | |
std::pair< bool, Stat > | lstatSync (const std::string &path) |
Sync lstat. | |
void | statfs (const std::string &path) |
Async statfs. | |
std::pair< bool, Statfs > | statfsSync (const std::string &path) |
Sync statfs. | |
void | rename (const std::string &old, const std::string &path) |
Async rename. | |
bool | renameSync (const std::string &old, const std::string &path) |
Sync rename. | |
void | copyfile (const std::string &old, const std::string &path, Flags< CopyFile > flags=Flags< CopyFile >{}) |
Copies a file asynchronously from a path to a new one. | |
bool | copyfileSync (const std::string &old, const std::string &path, Flags< CopyFile > flags=Flags< CopyFile >{}) |
Copies a file synchronously from a path to a new one. | |
void | access (const std::string &path, int mode) |
Async access. | |
bool | accessSync (const std::string &path, int mode) |
Sync access. | |
void | chmod (const std::string &path, int mode) |
Async chmod. | |
bool | chmodSync (const std::string &path, int mode) |
Sync chmod. | |
void | utime (const std::string &path, Time atime, Time mtime) |
Async utime. | |
bool | utimeSync (const std::string &path, Time atime, Time mtime) |
Sync utime. | |
void | link (const std::string &old, const std::string &path) |
Async link. | |
bool | linkSync (const std::string &old, const std::string &path) |
Sync link. | |
void | symlink (const std::string &old, const std::string &path, Flags< SymLink > flags=Flags< SymLink >{}) |
Async symlink. | |
bool | symlinkSync (const std::string &old, const std::string &path, Flags< SymLink > flags=Flags< SymLink >{}) |
Sync symlink. | |
void | readlink (const std::string &path) |
Async readlink. | |
std::pair< bool, std::pair< const char *, std::size_t > > | readlinkSync (const std::string &path) |
Sync readlink. | |
void | realpath (const std::string &path) |
Async realpath. | |
std::pair< bool, const char * > | realpathSync (const std::string &path) |
Sync realpath. | |
void | chown (const std::string &path, Uid uid, Gid gid) |
Async chown. | |
bool | chownSync (const std::string &path, Uid uid, Gid gid) |
Sync chown. | |
void | lchown (const std::string &path, Uid uid, Gid gid) |
Async lchown. | |
bool | lchownSync (const std::string &path, Uid uid, Gid gid) |
Sync lchown. | |
void | opendir (const std::string &path) |
Opens a path asynchronously as a directory stream. | |
bool | opendirSync (const std::string &path) |
Opens a path synchronously as a directory stream. | |
void | closedir () |
Closes asynchronously a directory stream. | |
bool | closedirSync () |
Closes synchronously a directory stream. | |
void | readdir () |
Iterates asynchronously over a directory stream one entry at a time. | |
std::pair< bool, std::pair< EntryType, const char * > > | readdirSync () |
Iterates synchronously over a directory stream one entry at a time. | |
![]() | |
bool | cancel () |
Cancels a pending request. | |
std::size_t | size () const noexcept |
Returns the size of the underlying request type. | |
![]() | |
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. | |
![]() | |
Loop & | loop () const noexcept |
Gets the loop from which the resource was originated. | |
const uv_fs_t * | raw () const noexcept |
Gets the underlying raw data structure. | |
uv_fs_t * | raw () noexcept |
Gets the underlying raw data structure. | |
![]() | |
Connection< E > | on (Listener< E > f) |
Registers a long-lived listener with the event emitter. | |
Connection< E > | once (Listener< E > f) |
Registers a short-lived listener with the event emitter. | |
void | erase (Connection< E > conn) noexcept |
Disconnects a listener from the event emitter. | |
void | clear () noexcept |
Disconnects all the listeners for the given event type. | |
void | clear () noexcept |
Disconnects all the listeners. | |
bool | empty () const noexcept |
Checks if there are listeners registered for the specific event. | |
bool | empty () const noexcept |
Checks if there are listeners registered with the event emitter. | |
Additional Inherited Members | |
![]() | |
![]() | |
![]() | |
static std::shared_ptr< FsReq > | create (Args &&...args) |
Creates a new resource of the given type. | |
![]() | |
![]() | |
![]() | |
![]() | |
![]() | |
![]() | |
![]() | |
![]() |
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.
void uvw::FsReq::access | ( | const std::string & | path, |
int | mode ) |
Async access.
Emit a FsEvent<FsReq::Type::ACCESS>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
mode | Mode, as described in the official documentation. |
bool uvw::FsReq::accessSync | ( | const std::string & | path, |
int | mode ) |
Sync access.
path | Path, as described in the official documentation. |
mode | Mode, as described in the official documentation. |
void uvw::FsReq::chmod | ( | const std::string & | path, |
int | mode ) |
Async chmod.
Emit a FsEvent<FsReq::Type::CHMOD>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
mode | Mode, as described in the official documentation. |
bool uvw::FsReq::chmodSync | ( | const std::string & | path, |
int | mode ) |
Sync chmod.
path | Path, as described in the official documentation. |
mode | Mode, as described in the official documentation. |
Async chown.
Emit a FsEvent<FsReq::Type::CHOWN>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
uid | UID, as described in the official documentation. |
gid | GID, as described in the official documentation. |
Sync chown.
path | Path, as described in the official documentation. |
uid | UID, as described in the official documentation. |
gid | GID, as described in the official documentation. |
void uvw::FsReq::closedir | ( | ) |
Closes asynchronously a directory stream.
Emit a FsEvent<FsReq::Type::CLOSEDIR>
event when completed.
Emit an ErrorEvent event in case of errors.
It frees also the memory allocated internally when a path has been opened as a directory stream.
bool uvw::FsReq::closedirSync | ( | ) |
Closes synchronously a directory stream.
It frees also the memory allocated internally when a path has been opened as a directory stream.
void uvw::FsReq::copyfile | ( | const std::string & | old, |
const std::string & | path, | ||
Flags< CopyFile > | flags = Flags< CopyFile >{} ) |
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.old | Old path, as described in the official documentation. |
path | New path, as described in the official documentation. |
flags | Optional additional flags. |
bool uvw::FsReq::copyfileSync | ( | const std::string & | old, |
const std::string & | path, | ||
Flags< CopyFile > | flags = Flags< CopyFile >{} ) |
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.
old | Old path, as described in the official documentation. |
path | New path, as described in the official documentation. |
flags | Optional additional flags. |
Async lchown.
Emit a FsEvent<FsReq::Type::LCHOWN>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
uid | UID, as described in the official documentation. |
gid | GID, as described in the official documentation. |
Sync lchown.
path | Path, as described in the official documentation. |
uid | UID, as described in the official documentation. |
gid | GID, as described in the official documentation. |
void uvw::FsReq::link | ( | const std::string & | old, |
const std::string & | path ) |
Async link.
Emit a FsEvent<FsReq::Type::LINK>
event when completed.
Emit an ErrorEvent event in case of errors.
old | Old path, as described in the official documentation. |
path | New path, as described in the official documentation. |
bool uvw::FsReq::linkSync | ( | const std::string & | old, |
const std::string & | path ) |
Sync link.
old | Old path, as described in the official documentation. |
path | New path, as described in the official documentation. |
void uvw::FsReq::lstat | ( | const std::string & | path | ) |
Async lstat.
Emit a FsEvent<FsReq::Type::LSTAT>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
std::pair< bool, Stat > uvw::FsReq::lstatSync | ( | const std::string & | path | ) |
Sync lstat.
path | Path, as described in the official documentation. |
std::pair
composed as it follows:void uvw::FsReq::lutime | ( | const std::string & | path, |
Time | atime, | ||
Time | mtime ) |
Async lutime.
Emit a FsEvent<FsReq::Type::UTIME>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
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. |
bool uvw::FsReq::lutimeSync | ( | const std::string & | path, |
Time | atime, | ||
Time | mtime ) |
Sync lutime.
path | Path, as described in the official documentation. |
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::FsReq::mkdir | ( | const std::string & | path, |
int | mode ) |
Async mkdir.
Emit a FsEvent<FsReq::Type::MKDIR>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
mode | Mode, as described in the official documentation. |
bool uvw::FsReq::mkdirSync | ( | const std::string & | path, |
int | mode ) |
Sync mkdir.
path | Path, as described in the official documentation. |
mode | Mode, as described in the official documentation. |
void uvw::FsReq::mkdtemp | ( | const std::string & | tpl | ) |
Async mktemp.
Emit a FsEvent<FsReq::Type::MKDTEMP>
event when completed.
Emit an ErrorEvent event in case of errors.
tpl | Template, as described in the official documentation. |
std::pair< bool, const char * > uvw::FsReq::mkdtempSync | ( | const std::string & | tpl | ) |
Sync mktemp.
tpl | Template, as described in the official documentation. |
std::pair
composed as it follows:void uvw::FsReq::mkstemp | ( | const std::string & | tpl | ) |
Async mkstemp.
Emit a FsEvent<FsReq::Type::MKSTEMP>
event when completed.
Emit an ErrorEvent event in case of errors.
tpl | Template, as described in the official documentation. |
std::pair< bool, std::pair< std::string, std::size_t > > uvw::FsReq::mkstempSync | ( | const std::string & | tpl | ) |
Sync mkstemp.
Returns a composed value where:
See the official documentation for further details.
tpl | Template, as described in the official documentation. |
void uvw::FsReq::opendir | ( | const std::string & | path | ) |
Opens a path asynchronously as a directory stream.
Emit a FsEvent<FsReq::Type::OPENDIR>
event when completed.
Emit an ErrorEvent event in case of errors.
The contents of the directory can be iterated over by means of the readdir
od readdirSync
member functions. The memory allocated by this function must be freed by calling closedir
or closedirSync
.
path | The path to open as a directory stream. |
bool uvw::FsReq::opendirSync | ( | const std::string & | path | ) |
Opens a path synchronously as a directory stream.
The contents of the directory can be iterated over by means of the readdir
od readdirSync
member functions. The memory allocated by this function must be freed by calling closedir
or closedirSync
.
path | The path to open as a directory stream. |
void uvw::FsReq::readdir | ( | ) |
Iterates asynchronously over a directory stream one entry at a time.
Emit a FsEvent<FsReq::Type::READDIR>
event when completed.
Emit an ErrorEvent event in case of errors.
This function isn't thread safe. Moreover, it doesn't return the .
and ..
entries.
std::pair< bool, std::pair< EntryType, const char * > > uvw::FsReq::readdirSync | ( | ) |
Iterates synchronously over a directory stream one entry at a time.
Returns a composed value where:
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.
This function isn't thread safe. Moreover, it doesn't return the .
and ..
entries.
void uvw::FsReq::readlink | ( | const std::string & | path | ) |
Async readlink.
Emit a FsEvent<FsReq::Type::READLINK>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
std::pair< bool, std::pair< const char *, std::size_t > > uvw::FsReq::readlinkSync | ( | const std::string & | path | ) |
Sync readlink.
path | Path, as described in the official documentation. |
std::pair
composed as it follows:std::pair
composed as it follows:void uvw::FsReq::realpath | ( | const std::string & | path | ) |
Async realpath.
Emit a FsEvent<FsReq::Type::REALPATH>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
std::pair< bool, const char * > uvw::FsReq::realpathSync | ( | const std::string & | path | ) |
Sync realpath.
path | Path, as described in the official documentation. |
std::pair
composed as it follows:void uvw::FsReq::rename | ( | const std::string & | old, |
const std::string & | path ) |
Async rename.
Emit a FsEvent<FsReq::Type::RENAME>
event when completed.
Emit an ErrorEvent event in case of errors.
old | Old path, as described in the official documentation. |
path | New path, as described in the official documentation. |
bool uvw::FsReq::renameSync | ( | const std::string & | old, |
const std::string & | path ) |
Sync rename.
old | Old path, as described in the official documentation. |
path | New path, as described in the official documentation. |
void uvw::FsReq::rmdir | ( | const std::string & | path | ) |
Async rmdir.
Emit a FsEvent<FsReq::Type::RMDIR>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
bool uvw::FsReq::rmdirSync | ( | const std::string & | path | ) |
Sync rmdir.
path | Path, as described in the official documentation. |
void uvw::FsReq::scandir | ( | const std::string & | path, |
int | flags ) |
Async scandir.
Emit a FsEvent<FsReq::Type::SCANDIR>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
flags | Flags, as described in the official documentation. |
std::pair< bool, std::pair< EntryType, const char * > > uvw::FsReq::scandirNext | ( | ) |
Gets entries populated with the next directory entry data.
Returns a composed value where:
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.
std::pair< bool, std::size_t > uvw::FsReq::scandirSync | ( | const std::string & | path, |
int | flags ) |
void uvw::FsReq::stat | ( | const std::string & | path | ) |
Async stat.
Emit a FsEvent<FsReq::Type::STAT>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
void uvw::FsReq::statfs | ( | const std::string & | path | ) |
Async statfs.
Emit a FsEvent<FsReq::Type::STATFS>
event when completed.
Emit an ErrorEvent event in case of errors.
Any fields in the resulting object that are not supported by the underlying operating system are set to zero.
path | Path, as described in the official documentation. |
std::pair< bool, Statfs > uvw::FsReq::statfsSync | ( | const std::string & | path | ) |
Sync statfs.
Any fields in the resulting object that are not supported by the underlying operating system are set to zero.
path | Path, as described in the official documentation. |
std::pair
composed as it follows:std::pair< bool, Stat > uvw::FsReq::statSync | ( | const std::string & | path | ) |
Sync stat.
path | Path, as described in the official documentation. |
std::pair
composed as it follows:void uvw::FsReq::symlink | ( | const std::string & | old, |
const std::string & | path, | ||
Flags< SymLink > | flags = Flags< SymLink >{} ) |
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.old | Old path, as described in the official documentation. |
path | New path, as described in the official documentation. |
flags | Optional additional flags. |
bool uvw::FsReq::symlinkSync | ( | const std::string & | old, |
const std::string & | path, | ||
Flags< SymLink > | flags = Flags< SymLink >{} ) |
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.old | Old path, as described in the official documentation. |
path | New path, as described in the official documentation. |
flags | Flags, as described in the official documentation. |
void uvw::FsReq::unlink | ( | const std::string & | path | ) |
Async unlink.
Emit a FsEvent<FsReq::Type::UNLINK>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
bool uvw::FsReq::unlinkSync | ( | const std::string & | path | ) |
Sync unlink.
path | Path, as described in the official documentation. |
void uvw::FsReq::utime | ( | const std::string & | path, |
Time | atime, | ||
Time | mtime ) |
Async utime.
Emit a FsEvent<FsReq::Type::UTIME>
event when completed.
Emit an ErrorEvent event in case of errors.
path | Path, as described in the official documentation. |
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. |
bool uvw::FsReq::utimeSync | ( | const std::string & | path, |
Time | atime, | ||
Time | mtime ) |
Sync utime.
path | Path, as described in the official documentation. |
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. |