Class: Libuv::Filesystem
- Includes:
- Assertions, FsChecks, Listener, Resource
- Defined in:
- lib/libuv/filesystem.rb
Constant Summary
Constants included from Assertions
Instance Method Summary collapse
- #chmod(path, mode) ⇒ Object
- #chown(path, uid, gid) ⇒ Object
-
#initialize(thread) ⇒ Filesystem
constructor
A new instance of Filesystem.
- #link(old_path, new_path) ⇒ Object
- #lstat(path) ⇒ Object
- #mkdir(path, mode = 0777) ⇒ Object
- #readdir(path) ⇒ Object
- #readlink(path) ⇒ Object
- #rename(old_path, new_path) ⇒ Object
- #rmdir(path) ⇒ Object
- #symlink(old_path, new_path) ⇒ Object
- #unlink(path) ⇒ Object
- #utime(path, atime, mtime) ⇒ Object
Methods included from Assertions
#assert_block, #assert_boolean, #assert_type
Methods included from Resource
#check_result, #check_result!, #resolve, #to_ptr
Methods included from FsChecks
Constructor Details
#initialize(thread) ⇒ Filesystem
Returns a new instance of Filesystem.
24 25 26 |
# File 'lib/libuv/filesystem.rb', line 24 def initialize(thread) @loop = thread end |
Instance Method Details
#chmod(path, mode) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/libuv/filesystem.rb', line 75 def chmod(path, mode) assert_type(String, path, "path must be a String") assert_type(Integer, mode, "mode must be an Integer") @chmod_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @chmod_deferred, request, ::Libuv::Ext.fs_chmod(@loop, request, path, mode, callback(:on_chmod, request.address)) @chmod_deferred.promise end |
#chown(path, uid, gid) ⇒ Object
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/libuv/filesystem.rb', line 134 def chown(path, uid, gid) assert_type(String, path, "path must be a String") assert_type(Integer, uid, "uid must be an Integer") assert_type(Integer, gid, "gid must be an Integer") @chown_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @chown_deferred, request, ::Libuv::Ext.fs_chown(@loop, request, path, uid, gid, callback(:on_chown, request.address)) @chown_deferred.promise end |
#link(old_path, new_path) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/libuv/filesystem.rb', line 105 def link(old_path, new_path) assert_type(String, old_path, "old_path must be a String") assert_type(String, new_path, "new_path must be a String") @link_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @link_deferred, request, ::Libuv::Ext.fs_link(@loop, request, old_path, new_path, callback(:on_link, request.address)) @link_deferred.promise end |
#lstat(path) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/libuv/filesystem.rb', line 96 def lstat(path) assert_type(String, path, "path must be a String") @stat_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @stat_deferred, request, ::Libuv::Ext.fs_lstat(@loop, request, path, callback(:on_stat, request.address)) @stat_deferred.promise end |
#mkdir(path, mode = 0777) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/libuv/filesystem.rb', line 37 def mkdir(path, mode = 0777) assert_type(String, path, "path must be a String") assert_type(Integer, mode, "mode must be an Integer") @mkdir_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @mkdir_deferred, request, ::Libuv::Ext.fs_mkdir(@loop, request, path, mode, callback(:on_mkdir, request.address)) @mkdir_deferred.promise end |
#readdir(path) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/libuv/filesystem.rb', line 56 def readdir(path) assert_type(String, path, "path must be a String") @readdir_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @readdir_deferred, request, ::Libuv::Ext.fs_readdir(@loop, request, path, 0, callback(:on_readdir, request.address)) @readdir_deferred.promise end |
#readlink(path) ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/libuv/filesystem.rb', line 125 def readlink(path) assert_type(String, path, "path must be a String") @readlink_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @readlink_deferred, request, ::Libuv::Ext.fs_readlink(@loop, request, path, callback(:on_readlink, request.address)) @readlink_deferred.promise end |
#rename(old_path, new_path) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/libuv/filesystem.rb', line 65 def rename(old_path, new_path) assert_type(String, old_path, "old_path must be a String") assert_type(String, new_path, "new_path must be a String") @rename_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @rename_deferred, request, ::Libuv::Ext.fs_rename(@loop, request, old_path, new_path, callback(:on_rename, request.address)) @rename_deferred.promise end |
#rmdir(path) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/libuv/filesystem.rb', line 47 def rmdir(path) assert_type(String, path, "path must be a String") @rmdir_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @rmdir_deferred, request, ::Libuv::Ext.fs_rmdir(@loop, request, path, callback(:on_rmdir, request.address)) @rmdir_deferred.promise end |
#symlink(old_path, new_path) ⇒ Object
115 116 117 118 119 120 121 122 123 |
# File 'lib/libuv/filesystem.rb', line 115 def symlink(old_path, new_path) assert_type(String, old_path, "old_path must be a String") assert_type(String, new_path, "new_path must be a String") @symlink_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @symlink_deferred, request, ::Libuv::Ext.fs_symlink(@loop, request, old_path, new_path, 0, callback(:on_symlink, request.address)) @symlink_deferred.promise end |
#unlink(path) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/libuv/filesystem.rb', line 28 def unlink(path) assert_type(String, path, "path must be a String") @unlink_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @unlink_deferred, request, ::Libuv::Ext.fs_unlink(@loop, request, path, callback(:on_unlink, request.address)) @unlink_deferred.promise end |
#utime(path, atime, mtime) ⇒ Object
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/libuv/filesystem.rb', line 85 def utime(path, atime, mtime) assert_type(String, path, "path must be a String") assert_type(Integer, atime, "atime must be an Integer") assert_type(Integer, mtime, "mtime must be an Integer") @utime_deferred = @loop.defer request = ::Libuv::Ext.allocate_request_fs pre_check @utime_deferred, request, ::Libuv::Ext.fs_utime(@loop, request, path, atime, mtime, callback(:on_utime, request.address)) @utime_deferred.promise end |