Class: UV::Filesystem

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

Instance Method Summary collapse

Methods included from Assertions

#assert_arity, #assert_block, #assert_boolean, #assert_signal, #assert_type

Methods included from Resource

#check_result, #check_result!, #to_ptr

Methods included from Listener

define_callback, undefine_callbacks

Constructor Details

#initialize(loop) ⇒ Filesystem

Returns a new instance of Filesystem.



5
6
7
# File 'lib/uv/filesystem.rb', line 5

def initialize(loop)
  @loop = loop
end

Instance Method Details

#chmod(path, mode, &block) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/uv/filesystem.rb', line 97

def chmod(path, mode, &block)
  assert_block(block)
  assert_arity(1, block)
  assert_type(String, path, "path must be a String")
  assert_type(Integer, mode, "mode must be an Integer")

  @chmod_block = block

  check_result! UV.fs_chmod(loop.to_ptr, UV.create_request(:uv_fs), path, mode, callback(:on_chmod))

  self
end

#chown(path, uid, gid, &block) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/uv/filesystem.rb', line 174

def chown(path, uid, gid, &block)
  assert_block(block)
  assert_arity(1, block)
  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_block = block

  check_result! UV.fs_chown(loop.to_ptr, UV.create_request(:uv_fs), path, uid, gid, callback(:on_chown))

  self
end


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

def link(old_path, new_path, &block)
  assert_block(block)
  assert_arity(1, block)
  assert_type(String, old_path, "old_path must be a String")
  assert_type(String, new_path, "new_path must be a String")

  @link_block = block

  check_result! UV.fs_link(loop.to_ptr, UV.create_request(:uv_fs), old_path, new_path, callback(:on_link))

  self
end

#lstat(path, &block) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/uv/filesystem.rb', line 124

def lstat(path, &block)
  assert_block(block)
  assert_arity(2, block)
  assert_type(String, path, "path must be a String")

  @lstat_block = block

  check_result! UV.fs_lstat(loop.to_ptr, UV.create_request(:uv_fs), path, callback(:on_lstat))

  self
end

#mkdir(path, mode = 0777, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/uv/filesystem.rb', line 35

def mkdir(path, mode = 0777, &block)
  assert_block(block)
  assert_arity(1, block)
  assert_type(String, path, "path must be a String")
  assert_type(Integer, mode, "mode must be an Integer")

  @mkdir_block = block

  check_result! UV.fs_mkdir(loop.to_ptr, UV.create_request(:uv_fs), path, mode, callback(:on_mkdir))

  self
end

#open(path, flags = 0, mode = 0, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/uv/filesystem.rb', line 9

def open(path, flags = 0, mode = 0, &block)
  assert_block(block)
  assert_arity(2, block)
  assert_type(String, path, "path must be a String")
  assert_type(Integer, flags, "flags must be an Integer")
  assert_type(Integer, mode, "mode must be an Integer")

  @open_block = block

  check_result! UV.fs_open(loop.to_ptr, UV.create_request(:uv_fs), path, flags, mode, callback(:on_open))

  self
end

#readdir(path, &block) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/uv/filesystem.rb', line 60

def readdir(path, &block)
  assert_block(block)
  assert_arity(2, block)
  assert_type(String, path, "path must be a String")

  @readdir_block = block

  check_result! UV.fs_readdir(loop.to_ptr, UV.create_request(:uv_fs), path, 0, callback(:on_readdir))

  self
end


162
163
164
165
166
167
168
169
170
171
172
# File 'lib/uv/filesystem.rb', line 162

def readlink(path, &block)
  assert_block(block)
  assert_arity(2, block)
  assert_type(String, path, "path must be a String")

  @readlink_block = block

  check_result! UV.fs_readlink(loop.to_ptr, UV.create_request(:uv_fs), path, callback(:on_readlink))

  self
end

#rename(old_path, new_path, &block) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/uv/filesystem.rb', line 84

def rename(old_path, new_path, &block)
  assert_block(block)
  assert_arity(1, block)
  assert_type(String, old_path, "old_path must be a String")
  assert_type(String, new_path, "new_path must be a String")

  @rename_block = block

  check_result! UV.fs_rename(loop.to_ptr, UV.create_request(:uv_fs), old_path, new_path, callback(:on_rename))

  self
end

#rmdir(path, &block) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/uv/filesystem.rb', line 48

def rmdir(path, &block)
  assert_block(block)
  assert_arity(1, block)
  assert_type(String, path, "path must be a String")

  @rmdir_block = block

  check_result! UV.fs_rmdir(loop.to_ptr, UV.create_request(:uv_fs), path, callback(:on_rmdir))

  self
end

#stat(path, &block) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/uv/filesystem.rb', line 72

def stat(path, &block)
  assert_block(block)
  assert_arity(2, block)
  assert_type(String, path, "path must be a String")

  @stat_block = block

  check_result! UV.fs_stat(loop.to_ptr, UV.create_request(:uv_fs), path, callback(:on_stat))

  self
end


149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/uv/filesystem.rb', line 149

def symlink(old_path, new_path, &block)
  assert_block(block)
  assert_arity(1, block)
  assert_type(String, old_path, "old_path must be a String")
  assert_type(String, new_path, "new_path must be a String")

  @symlink_block = block

  check_result! UV.fs_symlink(loop.to_ptr, UV.create_request(:uv_fs), old_path, new_path, 0, callback(:on_symlink))

  self
end


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/uv/filesystem.rb', line 23

def unlink(path, &block)
  assert_block(block)
  assert_arity(1, block)
  assert_type(String, path, "path must be a String")

  @unlink_block = block

  check_result! UV.fs_unlink(loop.to_ptr, UV.create_request(:uv_fs), path, callback(:on_unlink))

  self
end

#utime(path, atime, mtime, &block) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/uv/filesystem.rb', line 110

def utime(path, atime, mtime, &block)
  assert_block(block)
  assert_arity(1, block)
  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_block = block

  check_result! UV.fs_utime(loop.to_ptr, UV.create_request(:uv_fs), path, atime, mtime, callback(:on_utime))

  self
end