UniEvent
view release on metacpan or search on metacpan
clib/src/panda/unievent/Fs.cc view on Meta::CPAN
}
ex<void> Fs::lutime (string_view path, double atime, double mtime) {
UE_NULL_TERMINATE(path, path_str);
UEFS_SYNC({
uv_fs_lutime(nullptr, &uvr, path_str, atime, mtime, nullptr);
}, {});
return {};
}
ex<void> Fs::chown (string_view path, uid_t uid, gid_t gid) {
UE_NULL_TERMINATE(path, path_str);
UEFS_SYNC({
uv_fs_chown(nullptr, &uvr, path_str, uid, gid, nullptr);
}, {});
return {};
}
ex<void> Fs::lchown (string_view path, uid_t uid, gid_t gid) {
UE_NULL_TERMINATE(path, path_str);
UEFS_SYNC({
uv_fs_lchown(nullptr, &uvr, path_str, uid, gid, nullptr);
}, {});
return {};
}
ex<void> Fs::chown (fd_t fd, uid_t uid, gid_t gid) {
UEFS_SYNC({
uv_fs_fchown(nullptr, &uvr, fd, uid, gid, nullptr);
}, {});
return {};
}
ex<string> Fs::read (fd_t fd, size_t length, int64_t offset) {
string ret;
char* ptr = ret.reserve(length);
uv_buf_t uvbuf;
uvbuf.base = ptr;
uvbuf.len = length;
clib/src/panda/unievent/Fs.cc view on Meta::CPAN
Fs::RequestSP Fs::sync (fd_t f, const fn& cb, const LoopSP& l) { UEFS_ASYNC_SFD(ret->sync(cb)); }
Fs::RequestSP Fs::datasync (fd_t f, const fn& cb, const LoopSP& l) { UEFS_ASYNC_SFD(ret->datasync(cb)); }
Fs::RequestSP Fs::truncate (string_view path, int64_t off, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->truncate(path, off, cb)); }
Fs::RequestSP Fs::truncate (fd_t f, int64_t off, const fn& cb, const LoopSP& l) { UEFS_ASYNC_SFD(ret->truncate(off, cb)); }
Fs::RequestSP Fs::chmod (string_view path, int mode, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->chmod(path, mode, cb)); }
Fs::RequestSP Fs::chmod (fd_t f, int mode, const fn& cb, const LoopSP& l) { UEFS_ASYNC_SFD(ret->chmod(mode, cb)); }
Fs::RequestSP Fs::touch (string_view path, int mode, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->touch(path, mode, cb)); }
Fs::RequestSP Fs::utime (string_view path, double atime, double mtime, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->utime(path, atime, mtime, cb)); }
Fs::RequestSP Fs::utime (fd_t f, double atime, double mtime, const fn& cb, const LoopSP& l) { UEFS_ASYNC_SFD(ret->utime(atime, mtime, cb)); }
Fs::RequestSP Fs::lutime (string_view path, double atime, double mtime, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->lutime(path, atime, mtime, cb)); }
Fs::RequestSP Fs::chown (string_view path, uid_t uid, gid_t gid, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->chown(path, uid, gid, cb)); }
Fs::RequestSP Fs::lchown (string_view path, uid_t uid, gid_t gid, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->lchown(path, uid, gid, cb)); }
Fs::RequestSP Fs::chown (fd_t f, uid_t uid, gid_t gid, const fn& cb, const LoopSP& l) { UEFS_ASYNC_SFD(ret->chown(uid, gid, cb)); }
Fs::RequestSP Fs::rename (string_view src, string_view dst, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->rename(src, dst, cb)); }
Fs::RequestSP Fs::sendfile (fd_t out, fd_t in, int64_t off, size_t len, const sendfile_fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->sendfile(out, in, off, len, cb)); }
Fs::RequestSP Fs::link (string_view src, string_view dst, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->link(src, dst, cb)); }
Fs::RequestSP Fs::symlink (string_view src, string_view dst, int flags, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->symlink(src, dst, flags, cb)); }
Fs::RequestSP Fs::readlink (string_view path, const string_fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->readlink(path, cb)); }
Fs::RequestSP Fs::realpath (string_view path, const string_fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->realpath(path, cb)); }
Fs::RequestSP Fs::copyfile (string_view src, string_view dst, int flags, const fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->copyfile(src, dst, flags, cb)); }
Fs::RequestSP Fs::mkdtemp (string_view path, const string_fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->mkdtemp(path, cb)); }
Fs::RequestSP Fs::mkstemp (string_view path, const path_fd_fn& cb, const LoopSP& l) { UEFS_ASYNC_S(ret->mkstemp(path, cb)); }
Fs::RequestSP Fs::read (fd_t f, size_t size, int64_t off, const string_fn& cb, const LoopSP& l) { UEFS_ASYNC_SFD(ret->read(size, off, cb)); }
clib/src/panda/unievent/Fs.cc view on Meta::CPAN
void Fs::Request::sync (const fn& cb) { UEFS_ASYNC_VOID(Fs::sync(_fd)); }
void Fs::Request::datasync (const fn& cb) { UEFS_ASYNC_VOID(Fs::datasync(_fd)); }
void Fs::Request::truncate (string_view _path, int64_t off, const fn& cb) { auto path = string(_path); UEFS_ASYNC_VOID(Fs::truncate(path, off)); }
void Fs::Request::truncate (int64_t off, const fn& cb) { UEFS_ASYNC_VOID(Fs::truncate(_fd, off)); }
void Fs::Request::chmod (string_view _path, int mode, const fn& cb) { auto path = string(_path); UEFS_ASYNC_VOID(Fs::chmod(path, mode)); }
void Fs::Request::chmod (int mode, const fn& cb) { UEFS_ASYNC_VOID(Fs::chmod(_fd, mode)); }
void Fs::Request::touch (string_view _path, int mode, const fn& cb) { auto path = string(_path); UEFS_ASYNC_VOID(Fs::touch(path, mode)); }
void Fs::Request::utime (string_view _path, double atime, double mtime, const fn& cb) { auto path = string(_path); UEFS_ASYNC_VOID(Fs::utime(path, atime, mtime)); }
void Fs::Request::utime (double atime, double mtime, const fn& cb) { UEFS_ASYNC_VOID(Fs::utime(_fd, atime, mtime)); }
void Fs::Request::lutime (string_view _path, double atime, double mtime, const fn& cb) { auto path = string(_path); UEFS_ASYNC_VOID(Fs::lutime(path, atime, mtime)); }
void Fs::Request::chown (string_view _path, uid_t uid, gid_t gid, const fn& cb) { auto path = string(_path); UEFS_ASYNC_VOID(Fs::chown(path, uid, gid)); }
void Fs::Request::lchown (string_view _path, uid_t uid, gid_t gid, const fn& cb) { auto path = string(_path); UEFS_ASYNC_VOID(Fs::lchown(path, uid, gid)); }
void Fs::Request::chown (uid_t uid, gid_t gid, const fn& cb) { UEFS_ASYNC_VOID(Fs::chown(_fd, uid, gid)); }
void Fs::Request::rename (string_view _src, string_view _dst, const fn& cb) { auto src = string(_src); auto dst = string(_dst); UEFS_ASYNC_VOID(Fs::rename(src, dst)); }
void Fs::Request::sendfile (fd_t out, fd_t in, int64_t off, size_t len, const sendfile_fn& cb) { UEFS_ASYNC(Fs::sendfile(out, in, off, len), (_size = *ret), cb(_size, _err, this)); }
void Fs::Request::link (string_view _src, string_view _dst, const fn& cb) { auto src = string(_src); auto dst = string(_dst); UEFS_ASYNC_VOID(Fs::link(src, dst)); }
void Fs::Request::symlink (string_view _src, string_view _dst, int flags, const fn& cb) { auto src = string(_src); auto dst = string(_dst); UEFS_ASYNC_VOID(Fs::symlink(src, dst, flags)); }
void Fs::Request::readlink (string_view _path, const string_fn& cb) { auto path = string(_path); UEFS_ASYNC_STR(Fs::readlink(path)); }
void Fs::Request::realpath (string_view _path, const string_fn& cb) { auto path = string(_path); UEFS_ASYNC_STR(Fs::realpath(path)); }
void Fs::Request::copyfile (string_view _src, string_view _dst, int flags, const fn& cb) { auto src = string(_src); auto dst = string(_dst); UEFS_ASYNC_VOID(Fs::copyfile(src, dst, flags)); }
void Fs::Request::mkdtemp (string_view _path, const string_fn& cb) { auto path = string(_path); UEFS_ASYNC_STR(Fs::mkdtemp(path)); }
void Fs::Request::mkstemp (string_view _path, const path_fd_fn& cb) { auto path = string(_path); UEFS_ASYNC_PATH_FD(Fs::mkstemp(path)); }
void Fs::Request::read (size_t size, int64_t off, const string_fn& cb) { UEFS_ASYNC_STR(Fs::read(_fd, size, off)); }
clib/src/panda/unievent/Fs.h view on Meta::CPAN
static ex<void> sync (fd_t);
static ex<void> datasync (fd_t);
static ex<void> truncate (string_view, int64_t length = 0);
static ex<void> truncate (fd_t, int64_t length = 0);
static ex<void> chmod (string_view, int mode);
static ex<void> chmod (fd_t, int mode);
static ex<void> touch (string_view, int mode = DEFAULT_FILE_MODE);
static ex<void> utime (string_view, double atime, double mtime);
static ex<void> utime (fd_t, double atime, double mtime);
static ex<void> lutime (string_view, double atime, double mtime);
static ex<void> chown (string_view, uid_t uid, gid_t gid);
static ex<void> lchown (string_view, uid_t uid, gid_t gid);
static ex<void> chown (fd_t, uid_t uid, gid_t gid);
static ex<void> rename (string_view src, string_view dst);
static ex<size_t> sendfile (fd_t out, fd_t in, int64_t offset, size_t length);
static ex<void> link (string_view src, string_view dst);
static ex<void> symlink (string_view src, string_view dst, int flags = 0);
static ex<string> readlink (string_view);
static ex<string> realpath (string_view);
static ex<void> copyfile (string_view src, string_view dst, int flags = 0);
static ex<string> mkdtemp (string_view);
static ex<path_fd_t> mkstemp (string_view);
static ex<string> read (fd_t, size_t length, int64_t offset = -1);
clib/src/panda/unievent/Fs.h view on Meta::CPAN
static RequestSP sync (fd_t, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP datasync (fd_t, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP truncate (string_view, int64_t offset, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP truncate (fd_t, int64_t offset, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP chmod (string_view, int mode, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP chmod (fd_t, int mode, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP touch (string_view, int mode, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP utime (string_view, double atime, double mtime, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP utime (fd_t, double atime, double mtime, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP lutime (string_view, double atime, double mtime, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP chown (string_view, uid_t uid, gid_t gid, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP lchown (string_view, uid_t uid, gid_t gid, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP chown (fd_t, uid_t uid, gid_t gid, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP rename (string_view src, string_view dst, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP sendfile (fd_t out, fd_t in, int64_t offset, size_t length, const sendfile_fn&, const LoopSP& = Loop::default_loop());
static RequestSP link (string_view src, string_view dst, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP symlink (string_view src, string_view dst, int flags, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP readlink (string_view, const string_fn&, const LoopSP& = Loop::default_loop());
static RequestSP realpath (string_view, const string_fn&, const LoopSP& = Loop::default_loop());
static RequestSP copyfile (string_view src, string_view dst, int flags, const fn&, const LoopSP& = Loop::default_loop());
static RequestSP mkdtemp (string_view, const string_fn&, const LoopSP& = Loop::default_loop());
static RequestSP mkstemp (string_view, const path_fd_fn&, const LoopSP& = Loop::default_loop());
static RequestSP read (fd_t, size_t size, int64_t offset, const string_fn&, const LoopSP& = Loop::default_loop());
clib/src/panda/unievent/Fs.h view on Meta::CPAN
void sync (const fn&);
void datasync (const fn&);
void truncate (string_view, int64_t offset, const fn&);
void truncate (int64_t offset, const fn&);
void chmod (string_view, int mode, const fn&);
void chmod (int mode, const fn&);
void touch (string_view, int mode, const fn&);
void utime (string_view, double atime, double mtime, const fn&);
void utime (double atime, double mtime, const fn&);
void lutime (string_view, double atime, double mtime, const fn&);
void chown (string_view, uid_t uid, gid_t gid, const fn&);
void lchown (string_view, uid_t uid, gid_t gid, const fn&);
void chown (uid_t uid, gid_t gid, const fn&);
void rename (string_view src, string_view dst, const fn&);
void sendfile (fd_t out, fd_t in, int64_t offset, size_t length, const sendfile_fn&);
void link (string_view src, string_view dst, const fn&);
void symlink (string_view src, string_view dst, int flags, const fn&);
void readlink (string_view, const string_fn&);
void realpath (string_view, const string_fn&);
void copyfile (string_view src, string_view dst, int flags, const fn&);
void mkdtemp (string_view, const string_fn&);
void mkstemp (string_view, const path_fd_fn&);
void read (size_t size, int64_t offset, const string_fn&);
clib/tests/fs.cc view on Meta::CPAN
SECTION("fd") {
Fs::touch(t.file);
auto fd = Fs::open(t.file, Fs::OpenFlags::RDONLY).value();
CHECK(Fs::utime(fd, 2000, 2000));
Fs::close(fd);
CHECK(Fs::stat(t.file).value().atime.get() == 2000);
CHECK(Fs::stat(t.file).value().mtime.get() == 2000);
}
}
// no tests for chown
TEST("rename") {
Test t;
SECTION("non-existant") {
Fs::touch(t.file2);
auto ret = Fs::rename(t.file, t.file2);
REQUIRE(!ret);
CHECK(ret.error() == std::errc::no_such_file_or_directory);
}
SECTION("exists file") {
clib/tests/fs.cc view on Meta::CPAN
SECTION("fd") {
auto fd = Fs::open(t.file, Fs::OpenFlags::RDONLY).value();
Fs::utime(fd, 2000, 2000, t.success, t.loop);
t.run();
Fs::close(fd);
CHECK(Fs::stat(t.file).value().atime.get() == 2000);
CHECK(Fs::stat(t.file).value().mtime.get() == 2000);
}
}
// no tests for chown
TEST("rename") {
Test t(10000, 1);
Fs::touch(t.file);
Fs::rename(t.file, t.file2, t.success, t.loop);
t.run();
CHECK(!Fs::exists(t.file));
CHECK(Fs::isfile(t.file2));
}
lib/UniEvent/Fs.pod view on Meta::CPAN
RETURNS: void
=head2 lutime($path, $atime, $mtime, [$callback], [$loop])
Changes file access and modification times. Does not follow symlinks.
RETURNS: void
=head2 chown($path_or_fd, $uid, $gid, [$callback], [$loop])
Changes file user and group ownership.
RETURNS: void
=head2 lchown($path_or_fd, $uid, $gid, [$callback], [$loop])
C<chown> variant for symbolic links (does not follow symlinks).
RETURNS: void
=head2 rename($from, $to, [$callback], [$loop])
Changes name or location of a file.
RETURNS: void
subtest "fd" => sub {
Fs::touch($file);
my $fd = Fs::open($file, OPEN_RDONLY);
ok Fs::utime($fd, 2000, 2000);
Fs::close($fd);
is Fs::stat($file)->[STAT_ATIME], 2000;
is Fs::stat($file)->[STAT_MTIME], 2000;
} unless win32();
};
#no tests for chown
subtest "rename" => sub {
Fs::touch($file);
ok Fs::rename($file, $file2);
ok Fs::isfile($file2);
ok !Fs::exists($file);
};
subtest "mkdtemp" => sub {
my $dir = Fs::mkdtemp(var("tmpXXXXXX"));
Fs::touch($file);
my $fd = Fs::open($file, OPEN_RDONLY);
Fs::utime($fd, 2000, 2100, $success);
$l->run();
Fs::close($fd);
is Fs::stat($file)->[STAT_ATIME], 2000;
is Fs::stat($file)->[STAT_MTIME], 2100;
} unless win32();
};
# no tests for chown
subtest "rename" => sub {
Fs::touch($file);
Fs::rename($file, $file2, $success);
$l->run();
ok !Fs::exists($file);
ok Fs::isfile($file2);
};
subtest "mkdtemp" => sub {
} else {
auto fd = sv2fd(path_or_fd);
FSXS_EXPECTED(Fs::utime(fd, atime, mtime, cb, l), Fs::utime(fd, atime, mtime));
}
}
void lutime (string_view path, double atime, double mtime, Fs::fn cb = nullptr, DLoopSP l = {}) {
FSXS_EXPECTED(Fs::lutime(path, atime, mtime, cb, l), Fs::lutime(path, atime, mtime));
}
void chown (Sv path_or_fd, uid_t uid, gid_t gid, Fs::fn cb = nullptr, DLoopSP l = {}) {
if (path_or_fd.is_string()) {
auto path = xs::in<string_view>(path_or_fd);
FSXS_EXPECTED(Fs::chown(path, uid, gid, cb, l), Fs::chown(path, uid, gid));
} else {
auto fd = sv2fd(path_or_fd);
FSXS_EXPECTED(Fs::chown(fd, uid, gid, cb, l), Fs::chown(fd, uid, gid));
}
}
void lchown (string_view path, uid_t uid, gid_t gid, Fs::fn cb = nullptr, DLoopSP l = {}) {
FSXS_EXPECTED(Fs::lchown(path, uid, gid, cb, l), Fs::lchown(path, uid, gid));
}
void rename (string_view src, string_view dst, Fs::fn cb = nullptr, DLoopSP l = {}) {
FSXS_EXPECTED(Fs::rename(src, dst, cb, l), Fs::rename(src, dst));
}
void sendfile (Sv _out, Sv _in, int64_t offset, size_t length, Fs::sendfile_fn cb = nullptr, DLoopSP l = {}) {
auto out = sv2fd(_out);
auto in = sv2fd(_in);
FSXS_EXPECTED(Fs::sendfile(out, in, offset, length, cb, l), Fs::sendfile(out, in, offset, length));
void Fs::Request::touch (string_view path, int mode, Fs::fn cb)
void Fs::Request::utime (Sv arg1, Sv arg2, Sv arg3, Sv arg4 = Sv()) {
if (arg4) THIS->utime(xs::in<string_view>(arg1), xs::in<double>(arg2), xs::in<double>(arg3), xs::in<Fs::fn>(arg4));
else THIS->utime(xs::in<double>(arg1), xs::in<double>(arg2), xs::in<Fs::fn>(arg3));
}
void Fs::Request::lutime (string_view path, double atime, double mtime, Fs::fn cb)
void Fs::Request::chown (Sv arg1, Sv arg2, Sv arg3, Sv arg4 = Sv()) {
if (arg4) THIS->chown(xs::in<string_view>(arg1), xs::in<uid_t>(arg2), xs::in<gid_t>(arg3), xs::in<Fs::fn>(arg4));
else THIS->chown(xs::in<uid_t>(arg1), xs::in<gid_t>(arg2), xs::in<Fs::fn>(arg3));
}
void Fs::Request::lchown (string_view path, uid_t uid, gid_t gid, Fs::fn cb)
void Fs::Request::rename (string_view src, string_view dst, Fs::fn cb)
void Fs::Request::sendfile (Sv out, Sv in, int64_t offset, size_t length, Fs::sendfile_fn cb) {
THIS->sendfile(sv2fd(out), sv2fd(in), offset, length, cb);
}
void Fs::Request::link (string_view src, string_view dst, Fs::fn cb)
void Fs::Request::symlink (string_view src, string_view dst, int flags, Fs::fn cb)
( run in 2.324 seconds using v1.01-cache-2.11-cpan-5511b514fd6 )