Class: Libuv::Filesystem

Inherits:
Object show all
Includes:
Assertions, FsChecks, Listener, Resource
Defined in:
lib/libuv/filesystem.rb

Constant Summary

Constants included from Assertions

Assertions::MSG_NO_PROC

Instance Method Summary collapse

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

included, #stat

Constructor Details

#initialize(reactor) ⇒ Filesystem

Returns a new instance of Filesystem.



26
27
28
# File 'lib/libuv/filesystem.rb', line 26

def initialize(reactor)
    @reactor = reactor
end

Instance Method Details

#chmod(path, mode, wait: true) ⇒ Object



77
78
79
80
81
82
83
84
85
# File 'lib/libuv/filesystem.rb', line 77

def chmod(path, mode, wait: true)
    assert_type(String, path, "path must be a String")
    assert_type(Integer, mode, "mode must be an Integer")
    @chmod_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @chmod_deferred, request, ::Libuv::Ext.fs_chmod(@reactor, request, path, mode, callback(:on_chmod, request.address))
    respond wait, @chmod_deferred.promise
end

#chown(path, uid, gid, wait: true) ⇒ Object



136
137
138
139
140
141
142
143
144
145
# File 'lib/libuv/filesystem.rb', line 136

def chown(path, uid, gid, wait: true)
    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 = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @chown_deferred, request, ::Libuv::Ext.fs_chown(@reactor, request, path, uid, gid, callback(:on_chown, request.address))
    respond wait, @chown_deferred.promise
end


107
108
109
110
111
112
113
114
115
# File 'lib/libuv/filesystem.rb', line 107

def link(old_path, new_path, wait: true)
    assert_type(String, old_path, "old_path must be a String")
    assert_type(String, new_path, "new_path must be a String")
    @link_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @link_deferred, request, ::Libuv::Ext.fs_link(@reactor, request, old_path, new_path, callback(:on_link, request.address))
    respond wait, @link_deferred.promise
end

#lstat(path, wait: true) ⇒ Object



98
99
100
101
102
103
104
105
# File 'lib/libuv/filesystem.rb', line 98

def lstat(path, wait: true)
    assert_type(String, path, "path must be a String")
    @stat_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @stat_deferred, request, ::Libuv::Ext.fs_lstat(@reactor, request, path, callback(:on_stat, request.address))
    respond wait, @stat_deferred.promise
end

#mkdir(path, mode = 0777, wait: true) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/libuv/filesystem.rb', line 39

def mkdir(path, mode = 0777, wait: true)
    assert_type(String, path, "path must be a String")
    assert_type(Integer, mode, "mode must be an Integer")
    @mkdir_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @mkdir_deferred, request, ::Libuv::Ext.fs_mkdir(@reactor, request, path, mode, callback(:on_mkdir, request.address))
    respond wait, @mkdir_deferred.promise
end

#readdir(path, wait: true) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/libuv/filesystem.rb', line 58

def readdir(path, wait: true)
    assert_type(String, path, "path must be a String")
    @readdir_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @readdir_deferred, request, ::Libuv::Ext.fs_readdir(@reactor, request, path, 0, callback(:on_readdir, request.address))
    respond wait, @readdir_deferred.promise
end


127
128
129
130
131
132
133
134
# File 'lib/libuv/filesystem.rb', line 127

def readlink(path, wait: true)
    assert_type(String, path, "path must be a String")
    @readlink_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @readlink_deferred, request, ::Libuv::Ext.fs_readlink(@reactor, request, path, callback(:on_readlink, request.address))
    respond wait, @readlink_deferred.promise
end

#rename(old_path, new_path, wait: true) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/libuv/filesystem.rb', line 67

def rename(old_path, new_path, wait: true)
    assert_type(String, old_path, "old_path must be a String")
    assert_type(String, new_path, "new_path must be a String")
    @rename_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @rename_deferred, request, ::Libuv::Ext.fs_rename(@reactor, request, old_path, new_path, callback(:on_rename, request.address))
    respond wait, @rename_deferred.promise
end

#rmdir(path, wait: true) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/libuv/filesystem.rb', line 49

def rmdir(path, wait: true)
    assert_type(String, path, "path must be a String")
    @rmdir_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @rmdir_deferred, request, ::Libuv::Ext.fs_rmdir(@reactor, request, path, callback(:on_rmdir, request.address))
    respond wait, @rmdir_deferred.promise
end


117
118
119
120
121
122
123
124
125
# File 'lib/libuv/filesystem.rb', line 117

def symlink(old_path, new_path, wait: true)
    assert_type(String, old_path, "old_path must be a String")
    assert_type(String, new_path, "new_path must be a String")
    @symlink_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @symlink_deferred, request, ::Libuv::Ext.fs_symlink(@reactor, request, old_path, new_path, 0, callback(:on_symlink, request.address))
    respond wait, @symlink_deferred.promise
end


30
31
32
33
34
35
36
37
# File 'lib/libuv/filesystem.rb', line 30

def unlink(path, wait: true)
    assert_type(String, path, "path must be a String")
    @unlink_deferred = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @unlink_deferred, request, ::Libuv::Ext.fs_unlink(@reactor, request, path, callback(:on_unlink, request.address))
    respond wait, @unlink_deferred.promise
end

#utime(path, atime, mtime, wait: true) ⇒ Object



87
88
89
90
91
92
93
94
95
96
# File 'lib/libuv/filesystem.rb', line 87

def utime(path, atime, mtime, wait: true)
    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 = @reactor.defer

    request = ::Libuv::Ext.allocate_request_fs
    pre_check @utime_deferred, request, ::Libuv::Ext.fs_utime(@reactor, request, path, atime, mtime, callback(:on_utime, request.address))
    respond wait, @utime_deferred.promise
end