sfml3-rb 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/CHANGELOG.md +43 -17
- data/README.md +97 -29
- data/ext/audio/audio_enums.c +58 -20
- data/ext/audio/listener.c +89 -6
- data/ext/audio/music.c +206 -5
- data/ext/audio/sound.c +175 -5
- data/ext/audio/sound_buffer.c +189 -47
- data/ext/audio/sound_buffer_recorder.c +83 -16
- data/ext/audio/sound_recorder.c +172 -52
- data/ext/audio/sound_source_cone.c +108 -29
- data/ext/audio/sound_stream.c +178 -5
- data/ext/core/exceptions.c +10 -8
- data/ext/core/unicode.c +12 -2
- data/ext/ext.c +4 -0
- data/ext/graphics/blend_mode.c +203 -53
- data/ext/graphics/circle.c +271 -4
- data/ext/graphics/color.c +240 -90
- data/ext/graphics/drawable.c +15 -4
- data/ext/graphics/font.c +138 -25
- data/ext/graphics/glyph.c +31 -8
- data/ext/graphics/image.c +180 -37
- data/ext/graphics/polygon.c +293 -26
- data/ext/graphics/rect.c +211 -54
- data/ext/graphics/rectangle.c +279 -26
- data/ext/graphics/render_state.c +116 -2
- data/ext/graphics/render_texture.c +163 -2
- data/ext/graphics/shader.c +283 -17
- data/ext/graphics/shape.c +252 -26
- data/ext/graphics/sprite.c +216 -25
- data/ext/graphics/stencil_mode.c +148 -39
- data/ext/graphics/target.c +67 -22
- data/ext/graphics/target.h +15 -15
- data/ext/graphics/text.c +306 -6
- data/ext/graphics/texture.c +257 -3
- data/ext/graphics/transform.c +178 -5
- data/ext/graphics/transformable.c +126 -2
- data/ext/graphics/vertex.c +79 -2
- data/ext/graphics/vertex_array.c +128 -16
- data/ext/graphics/vertex_buffer.c +124 -2
- data/ext/graphics/view.c +130 -2
- data/ext/network/ftp.c +249 -10
- data/ext/network/http.c +156 -38
- data/ext/network/ip_address.c +107 -26
- data/ext/network/network_enums.c +248 -141
- data/ext/network/packet.c +273 -39
- data/ext/network/socket_selector.c +91 -19
- data/ext/network/tcp_listener.c +75 -16
- data/ext/network/tcp_socket.c +128 -25
- data/ext/network/udp_socket.c +122 -26
- data/ext/ports.rb +7 -0
- data/ext/system/buffer.c +41 -12
- data/ext/system/clock.c +68 -9
- data/ext/system/input_stream.c +94 -42
- data/ext/system/sleep.c +10 -2
- data/ext/system/time.c +172 -34
- data/ext/system/vec2.c +156 -35
- data/ext/system/vec3.c +166 -35
- data/ext/window/clipboard.c +47 -17
- data/ext/window/context.c +59 -9
- data/ext/window/context_settings.c +116 -38
- data/ext/window/cursor.c +39 -9
- data/ext/window/event.c +163 -42
- data/ext/window/joystick.c +69 -3
- data/ext/window/keyboard.c +168 -116
- data/ext/window/mouse.c +36 -2
- data/ext/window/sensor.c +28 -2
- data/ext/window/touch.c +20 -2
- data/ext/window/video_mode.c +90 -19
- data/ext/window/vulkan.c +34 -6
- data/ext/window/window.c +340 -16
- data/lib/sfml/version.rb +1 -1
- data/sig/audio/audio_enums.rbs +30 -0
- data/sig/audio/listener.rbs +16 -0
- data/sig/audio/music.rbs +56 -0
- data/sig/audio/sound.rbs +51 -0
- data/sig/audio/sound_buffer.rbs +17 -0
- data/sig/audio/sound_buffer_recorder.rbs +14 -0
- data/sig/audio/sound_recorder.rbs +17 -0
- data/sig/audio/sound_source_cone.rbs +14 -0
- data/sig/audio/sound_stream.rbs +51 -0
- data/sig/graphics/blend_mode.rbs +29 -0
- data/sig/graphics/circle.rbs +44 -0
- data/sig/graphics/color.rbs +39 -0
- data/sig/graphics/drawable.rbs +5 -0
- data/sig/graphics/font.rbs +20 -0
- data/sig/graphics/glyph.rbs +7 -0
- data/sig/graphics/image.rbs +22 -0
- data/sig/graphics/polygon.rbs +42 -0
- data/sig/graphics/rect.rbs +33 -0
- data/sig/graphics/rectangle.rbs +42 -0
- data/sig/graphics/render_state.rbs +21 -0
- data/sig/graphics/render_texture.rbs +37 -0
- data/sig/graphics/shader.rbs +39 -0
- data/sig/graphics/shape.rbs +38 -0
- data/sig/graphics/sprite.rbs +34 -0
- data/sig/graphics/stencil_mode.rbs +18 -0
- data/sig/graphics/target.rbs +10 -0
- data/sig/graphics/text.rbs +48 -0
- data/sig/graphics/texture.rbs +34 -0
- data/sig/graphics/transform.rbs +37 -0
- data/sig/graphics/transformable.rbs +25 -0
- data/sig/graphics/vertex.rbs +17 -0
- data/sig/graphics/vertex_array.rbs +17 -0
- data/sig/graphics/vertex_buffer.rbs +22 -0
- data/sig/graphics/view.rbs +24 -0
- data/sig/network/ftp.rbs +46 -0
- data/sig/network/http.rbs +27 -0
- data/sig/network/ip_address.rbs +22 -0
- data/sig/network/network_enums.rbs +95 -0
- data/sig/network/packet.rbs +40 -0
- data/sig/network/socket_selector.rbs +14 -0
- data/sig/network/tcp_listener.rbs +13 -0
- data/sig/network/tcp_socket.rbs +18 -0
- data/sig/network/udp_socket.rbs +17 -0
- data/sig/system/buffer.rbs +11 -0
- data/sig/system/clock.rbs +13 -0
- data/sig/system/input_stream.rbs +7 -0
- data/sig/system/sleep.rbs +3 -0
- data/sig/system/time.rbs +28 -0
- data/sig/system/vec2.rbs +26 -0
- data/sig/system/vec3.rbs +27 -0
- data/sig/window/clipboard.rbs +8 -0
- data/sig/window/context.rbs +11 -0
- data/sig/window/context_settings.rbs +20 -0
- data/sig/window/cursor.rbs +6 -0
- data/sig/window/event.rbs +20 -0
- data/sig/window/joystick.rbs +15 -0
- data/sig/window/keyboard.rbs +10 -0
- data/sig/window/mouse.rbs +9 -0
- data/sig/window/sensor.rbs +8 -0
- data/sig/window/touch.rbs +6 -0
- data/sig/window/video_mode.rbs +16 -0
- data/sig/window/vulkan.rbs +7 -0
- data/sig/window/window.rbs +57 -0
- metadata +66 -2
data/ext/network/ftp.c
CHANGED
|
@@ -130,10 +130,25 @@ static VALUE FtpListingResponse_wrap(sfFtpListingResponse* handle) {
|
|
|
130
130
|
return TypedData_Wrap_Struct(rb_cFtpListingResponse, &FtpListingResponse_data_type, ptr);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/* call-seq:
|
|
134
|
+
* Ftp.new -> Ftp
|
|
135
|
+
*
|
|
136
|
+
* Creates a new FTP client.
|
|
137
|
+
*
|
|
138
|
+
* @return [Ftp]
|
|
139
|
+
*/
|
|
133
140
|
static VALUE Ftp_new(VALUE klass) {
|
|
134
141
|
return Ftp_wrap(sfFtp_create());
|
|
135
142
|
}
|
|
136
143
|
|
|
144
|
+
/* call-seq:
|
|
145
|
+
* connect(address, port = 21, timeout = Time.zero) -> FtpResponse
|
|
146
|
+
*
|
|
147
|
+
* Connects to the specified FTP server. Blocks until connected or
|
|
148
|
+
* +timeout+ elapses.
|
|
149
|
+
*
|
|
150
|
+
* @return [FtpResponse]
|
|
151
|
+
*/
|
|
137
152
|
static VALUE Ftp_connect(int argc, VALUE* argv, VALUE self) {
|
|
138
153
|
VALUE rb_address, rb_port, rb_timeout;
|
|
139
154
|
sfTime timeout = sfTime_Zero;
|
|
@@ -153,27 +168,70 @@ static VALUE Ftp_connect(int argc, VALUE* argv, VALUE self) {
|
|
|
153
168
|
Get_Ftp_Struct(self), ip_address_from_rb(rb_address, sfIpAddress_None), port, timeout));
|
|
154
169
|
}
|
|
155
170
|
|
|
171
|
+
/* call-seq:
|
|
172
|
+
* login_anonymous -> FtpResponse
|
|
173
|
+
*
|
|
174
|
+
* Logs in using the standard "anonymous" account.
|
|
175
|
+
*
|
|
176
|
+
* @return [FtpResponse]
|
|
177
|
+
*/
|
|
156
178
|
static VALUE Ftp_login_anonymous(VALUE self) {
|
|
157
179
|
return FtpResponse_wrap(sfFtp_loginAnonymous(Get_Ftp_Struct(self)));
|
|
158
180
|
}
|
|
159
181
|
|
|
182
|
+
/* call-seq:
|
|
183
|
+
* login(name, password) -> FtpResponse
|
|
184
|
+
*
|
|
185
|
+
* Logs in with the given +name+ and +password+.
|
|
186
|
+
*
|
|
187
|
+
* @return [FtpResponse]
|
|
188
|
+
*/
|
|
160
189
|
static VALUE Ftp_login(VALUE self, VALUE rb_name, VALUE rb_password) {
|
|
161
190
|
return FtpResponse_wrap(
|
|
162
191
|
sfFtp_login(Get_Ftp_Struct(self), StringValueCStr(rb_name), StringValueCStr(rb_password)));
|
|
163
192
|
}
|
|
164
193
|
|
|
194
|
+
/* call-seq:
|
|
195
|
+
* disconnect -> FtpResponse
|
|
196
|
+
*
|
|
197
|
+
* Closes the connection with the server.
|
|
198
|
+
*
|
|
199
|
+
* @return [FtpResponse]
|
|
200
|
+
*/
|
|
165
201
|
static VALUE Ftp_disconnect(VALUE self) {
|
|
166
202
|
return FtpResponse_wrap(sfFtp_disconnect(Get_Ftp_Struct(self)));
|
|
167
203
|
}
|
|
168
204
|
|
|
205
|
+
/* call-seq:
|
|
206
|
+
* keep_alive -> FtpResponse
|
|
207
|
+
*
|
|
208
|
+
* Sends a null command to keep the connection alive.
|
|
209
|
+
*
|
|
210
|
+
* @return [FtpResponse]
|
|
211
|
+
*/
|
|
169
212
|
static VALUE Ftp_keep_alive(VALUE self) {
|
|
170
213
|
return FtpResponse_wrap(sfFtp_keepAlive(Get_Ftp_Struct(self)));
|
|
171
214
|
}
|
|
172
215
|
|
|
216
|
+
/* call-seq:
|
|
217
|
+
* working_directory -> FtpDirectoryResponse
|
|
218
|
+
*
|
|
219
|
+
* Returns the current working directory on the server.
|
|
220
|
+
*
|
|
221
|
+
* @return [FtpDirectoryResponse] the current working directory on the server
|
|
222
|
+
*/
|
|
173
223
|
static VALUE Ftp_working_directory(VALUE self) {
|
|
174
224
|
return FtpDirectoryResponse_wrap(sfFtp_getWorkingDirectory(Get_Ftp_Struct(self)));
|
|
175
225
|
}
|
|
176
226
|
|
|
227
|
+
/* call-seq:
|
|
228
|
+
* directory_listing(directory = nil) -> FtpListingResponse
|
|
229
|
+
*
|
|
230
|
+
* Lists the contents of +directory+ (or the current working directory if
|
|
231
|
+
* omitted/nil).
|
|
232
|
+
*
|
|
233
|
+
* @return [FtpListingResponse]
|
|
234
|
+
*/
|
|
177
235
|
static VALUE Ftp_directory_listing(int argc, VALUE* argv, VALUE self) {
|
|
178
236
|
VALUE rb_directory;
|
|
179
237
|
|
|
@@ -183,32 +241,82 @@ static VALUE Ftp_directory_listing(int argc, VALUE* argv, VALUE self) {
|
|
|
183
241
|
Get_Ftp_Struct(self), NIL_P(rb_directory) ? NULL : StringValueCStr(rb_directory)));
|
|
184
242
|
}
|
|
185
243
|
|
|
244
|
+
/* call-seq:
|
|
245
|
+
* change_directory(directory) -> FtpResponse
|
|
246
|
+
*
|
|
247
|
+
* Changes the current working directory on the server.
|
|
248
|
+
*
|
|
249
|
+
* @return [FtpResponse]
|
|
250
|
+
*/
|
|
186
251
|
static VALUE Ftp_change_directory(VALUE self, VALUE rb_directory) {
|
|
187
252
|
return FtpResponse_wrap(
|
|
188
253
|
sfFtp_changeDirectory(Get_Ftp_Struct(self), StringValueCStr(rb_directory)));
|
|
189
254
|
}
|
|
190
255
|
|
|
256
|
+
/* call-seq:
|
|
257
|
+
* parent_directory -> FtpResponse
|
|
258
|
+
*
|
|
259
|
+
* Moves to the parent directory of the current working directory.
|
|
260
|
+
*
|
|
261
|
+
* @return [FtpResponse]
|
|
262
|
+
*/
|
|
191
263
|
static VALUE Ftp_parent_directory(VALUE self) {
|
|
192
264
|
return FtpResponse_wrap(sfFtp_parentDirectory(Get_Ftp_Struct(self)));
|
|
193
265
|
}
|
|
194
266
|
|
|
267
|
+
/* call-seq:
|
|
268
|
+
* create_directory(name) -> FtpResponse
|
|
269
|
+
*
|
|
270
|
+
* Creates a directory named +name+ on the server.
|
|
271
|
+
*
|
|
272
|
+
* @return [FtpResponse]
|
|
273
|
+
*/
|
|
195
274
|
static VALUE Ftp_create_directory(VALUE self, VALUE rb_name) {
|
|
196
275
|
return FtpResponse_wrap(sfFtp_createDirectory(Get_Ftp_Struct(self), StringValueCStr(rb_name)));
|
|
197
276
|
}
|
|
198
277
|
|
|
278
|
+
/* call-seq:
|
|
279
|
+
* delete_directory(name) -> FtpResponse
|
|
280
|
+
*
|
|
281
|
+
* Deletes the directory named +name+ on the server.
|
|
282
|
+
*
|
|
283
|
+
* @return [FtpResponse]
|
|
284
|
+
*/
|
|
199
285
|
static VALUE Ftp_delete_directory(VALUE self, VALUE rb_name) {
|
|
200
286
|
return FtpResponse_wrap(sfFtp_deleteDirectory(Get_Ftp_Struct(self), StringValueCStr(rb_name)));
|
|
201
287
|
}
|
|
202
288
|
|
|
289
|
+
/* call-seq:
|
|
290
|
+
* rename_file(file, new_name) -> FtpResponse
|
|
291
|
+
*
|
|
292
|
+
* Renames +file+ to +new_name+ on the server.
|
|
293
|
+
*
|
|
294
|
+
* @return [FtpResponse]
|
|
295
|
+
*/
|
|
203
296
|
static VALUE Ftp_rename_file(VALUE self, VALUE rb_file, VALUE rb_new_name) {
|
|
204
297
|
return FtpResponse_wrap(sfFtp_renameFile(Get_Ftp_Struct(self), StringValueCStr(rb_file),
|
|
205
298
|
StringValueCStr(rb_new_name)));
|
|
206
299
|
}
|
|
207
300
|
|
|
301
|
+
/* call-seq:
|
|
302
|
+
* delete_file(name) -> FtpResponse
|
|
303
|
+
*
|
|
304
|
+
* Deletes the file named +name+ on the server.
|
|
305
|
+
*
|
|
306
|
+
* @return [FtpResponse]
|
|
307
|
+
*/
|
|
208
308
|
static VALUE Ftp_delete_file(VALUE self, VALUE rb_name) {
|
|
209
309
|
return FtpResponse_wrap(sfFtp_deleteFile(Get_Ftp_Struct(self), StringValueCStr(rb_name)));
|
|
210
310
|
}
|
|
211
311
|
|
|
312
|
+
/* call-seq:
|
|
313
|
+
* download(remote_file, local_path, mode = :binary) -> FtpResponse
|
|
314
|
+
*
|
|
315
|
+
* Downloads +remote_file+ from the server into +local_path+ (a local
|
|
316
|
+
* directory). +mode+ is an FtpTransferMode name or value.
|
|
317
|
+
*
|
|
318
|
+
* @return [FtpResponse]
|
|
319
|
+
*/
|
|
212
320
|
static VALUE Ftp_download(int argc, VALUE* argv, VALUE self) {
|
|
213
321
|
VALUE rb_remote, rb_local, rb_mode;
|
|
214
322
|
sfFtpTransferMode mode = sfFtpBinary;
|
|
@@ -223,6 +331,16 @@ static VALUE Ftp_download(int argc, VALUE* argv, VALUE self) {
|
|
|
223
331
|
StringValueCStr(rb_local), mode));
|
|
224
332
|
}
|
|
225
333
|
|
|
334
|
+
/* call-seq:
|
|
335
|
+
* upload(local_file, remote_path, mode = :binary, append = false) -> FtpResponse
|
|
336
|
+
*
|
|
337
|
+
* Uploads +local_file+ to +remote_path+ (a directory on the server).
|
|
338
|
+
* +mode+ is an FtpTransferMode name or value; if +append+ is true, the
|
|
339
|
+
* data is appended to an existing remote file of the same name instead of
|
|
340
|
+
* overwriting it.
|
|
341
|
+
*
|
|
342
|
+
* @return [FtpResponse]
|
|
343
|
+
*/
|
|
226
344
|
static VALUE Ftp_upload(int argc, VALUE* argv, VALUE self) {
|
|
227
345
|
VALUE rb_local, rb_remote, rb_mode, rb_append;
|
|
228
346
|
sfFtpTransferMode mode = sfFtpBinary;
|
|
@@ -242,6 +360,14 @@ static VALUE Ftp_upload(int argc, VALUE* argv, VALUE self) {
|
|
|
242
360
|
StringValueCStr(rb_remote), mode, append));
|
|
243
361
|
}
|
|
244
362
|
|
|
363
|
+
/* call-seq:
|
|
364
|
+
* send_command(command, parameter = nil) -> FtpResponse
|
|
365
|
+
*
|
|
366
|
+
* Sends a raw FTP command, for functionality not exposed by the other
|
|
367
|
+
* methods. +command+ should not include the trailing CRLF.
|
|
368
|
+
*
|
|
369
|
+
* @return [FtpResponse]
|
|
370
|
+
*/
|
|
245
371
|
static VALUE Ftp_send_command(int argc, VALUE* argv, VALUE self) {
|
|
246
372
|
VALUE rb_command, rb_parameter;
|
|
247
373
|
|
|
@@ -252,79 +378,192 @@ static VALUE Ftp_send_command(int argc, VALUE* argv, VALUE self) {
|
|
|
252
378
|
NIL_P(rb_parameter) ? NULL : StringValueCStr(rb_parameter)));
|
|
253
379
|
}
|
|
254
380
|
|
|
381
|
+
/* call-seq: ok? -> true or false
|
|
382
|
+
*
|
|
383
|
+
* Returns +true+ if the server reported success.
|
|
384
|
+
*
|
|
385
|
+
* @return [Boolean] whether the status is a "success" code (< 400)
|
|
386
|
+
*/
|
|
255
387
|
static VALUE FtpResponse_ok(VALUE self) {
|
|
256
388
|
return BOOL2RB(sfFtpResponse_isOk(Get_FtpResponse_Struct(self)));
|
|
257
389
|
}
|
|
258
390
|
|
|
391
|
+
/* call-seq: status -> Integer
|
|
392
|
+
*
|
|
393
|
+
* Returns the raw status code reported by the server.
|
|
394
|
+
*
|
|
395
|
+
* @return [Integer] the raw FTP status code
|
|
396
|
+
*/
|
|
259
397
|
static VALUE FtpResponse_status(VALUE self) {
|
|
260
398
|
return INT2NUM(sfFtpResponse_getStatus(Get_FtpResponse_Struct(self)));
|
|
261
399
|
}
|
|
262
400
|
|
|
401
|
+
/* call-seq: status_name -> Symbol
|
|
402
|
+
*
|
|
403
|
+
* Returns the status as an FtpStatus name.
|
|
404
|
+
*
|
|
405
|
+
* @return [Symbol] an FtpStatus name for #status
|
|
406
|
+
*/
|
|
263
407
|
static VALUE FtpResponse_status_name(VALUE self) {
|
|
264
408
|
return ID2SYM(
|
|
265
409
|
rb_intern(ftp_status_name(sfFtpResponse_getStatus(Get_FtpResponse_Struct(self)))));
|
|
266
410
|
}
|
|
267
411
|
|
|
412
|
+
/* call-seq: message -> String
|
|
413
|
+
*
|
|
414
|
+
* Returns the message sent by the server.
|
|
415
|
+
*
|
|
416
|
+
* @return [String] the full response message sent by the server
|
|
417
|
+
*/
|
|
268
418
|
static VALUE FtpResponse_message(VALUE self) {
|
|
269
419
|
return rb_str_new_cstr(sfFtpResponse_getMessage(Get_FtpResponse_Struct(self)));
|
|
270
420
|
}
|
|
271
421
|
|
|
422
|
+
/* call-seq: ok? -> true or false
|
|
423
|
+
*
|
|
424
|
+
* Returns +true+ if the server reported success.
|
|
425
|
+
*
|
|
426
|
+
* @return [Boolean] whether the status is a "success" code (< 400)
|
|
427
|
+
*/
|
|
272
428
|
static VALUE FtpDirectoryResponse_ok(VALUE self) {
|
|
273
429
|
return BOOL2RB(sfFtpDirectoryResponse_isOk(Get_FtpDirectoryResponse_Struct(self)));
|
|
274
430
|
}
|
|
275
431
|
|
|
432
|
+
/* call-seq: status -> Integer
|
|
433
|
+
*
|
|
434
|
+
* Returns the raw status code reported by the server.
|
|
435
|
+
*
|
|
436
|
+
* @return [Integer] the raw FTP status code
|
|
437
|
+
*/
|
|
276
438
|
static VALUE FtpDirectoryResponse_status(VALUE self) {
|
|
277
439
|
return INT2NUM(sfFtpDirectoryResponse_getStatus(Get_FtpDirectoryResponse_Struct(self)));
|
|
278
440
|
}
|
|
279
441
|
|
|
442
|
+
/* call-seq: status_name -> Symbol
|
|
443
|
+
*
|
|
444
|
+
* Returns the status as an FtpStatus name.
|
|
445
|
+
*
|
|
446
|
+
* @return [Symbol] an FtpStatus name for #status
|
|
447
|
+
*/
|
|
280
448
|
static VALUE FtpDirectoryResponse_status_name(VALUE self) {
|
|
281
449
|
return ID2SYM(rb_intern(
|
|
282
450
|
ftp_status_name(sfFtpDirectoryResponse_getStatus(Get_FtpDirectoryResponse_Struct(self)))));
|
|
283
451
|
}
|
|
284
452
|
|
|
453
|
+
/* call-seq: message -> String
|
|
454
|
+
*
|
|
455
|
+
* Returns the message sent by the server.
|
|
456
|
+
*
|
|
457
|
+
* @return [String] the full response message sent by the server
|
|
458
|
+
*/
|
|
285
459
|
static VALUE FtpDirectoryResponse_message(VALUE self) {
|
|
286
460
|
return rb_str_new_cstr(
|
|
287
461
|
sfFtpDirectoryResponse_getMessage(Get_FtpDirectoryResponse_Struct(self)));
|
|
288
462
|
}
|
|
289
463
|
|
|
290
|
-
/*
|
|
291
|
-
|
|
464
|
+
/* call-seq: directory -> String
|
|
465
|
+
*
|
|
466
|
+
* Through the UTF-32 entry point, so a path with non-ASCII characters survives
|
|
467
|
+
* the trip; the plain getter re-encodes it through the C locale.
|
|
468
|
+
*
|
|
469
|
+
* @return [String] the directory requested/reported by the server
|
|
470
|
+
*/
|
|
292
471
|
static VALUE FtpDirectoryResponse_directory(VALUE self) {
|
|
293
472
|
return utf32_to_rb(
|
|
294
473
|
sfFtpDirectoryResponse_getDirectoryUnicode(Get_FtpDirectoryResponse_Struct(self)));
|
|
295
474
|
}
|
|
296
475
|
|
|
476
|
+
/* call-seq: ok? -> true or false
|
|
477
|
+
*
|
|
478
|
+
* Returns +true+ if the server reported success.
|
|
479
|
+
*
|
|
480
|
+
* @return [Boolean] whether the status is a "success" code (< 400)
|
|
481
|
+
*/
|
|
297
482
|
static VALUE FtpListingResponse_ok(VALUE self) {
|
|
298
483
|
return BOOL2RB(sfFtpListingResponse_isOk(Get_FtpListingResponse_Struct(self)));
|
|
299
484
|
}
|
|
300
485
|
|
|
486
|
+
/* call-seq: status -> Integer
|
|
487
|
+
*
|
|
488
|
+
* Returns the raw status code reported by the server.
|
|
489
|
+
*
|
|
490
|
+
* @return [Integer] the raw FTP status code
|
|
491
|
+
*/
|
|
301
492
|
static VALUE FtpListingResponse_status(VALUE self) {
|
|
302
493
|
return INT2NUM(sfFtpListingResponse_getStatus(Get_FtpListingResponse_Struct(self)));
|
|
303
494
|
}
|
|
304
495
|
|
|
496
|
+
/* call-seq: status_name -> Symbol
|
|
497
|
+
*
|
|
498
|
+
* Returns the status as an FtpStatus name.
|
|
499
|
+
*
|
|
500
|
+
* @return [Symbol] an FtpStatus name for #status
|
|
501
|
+
*/
|
|
305
502
|
static VALUE FtpListingResponse_status_name(VALUE self) {
|
|
306
503
|
return ID2SYM(rb_intern(
|
|
307
504
|
ftp_status_name(sfFtpListingResponse_getStatus(Get_FtpListingResponse_Struct(self)))));
|
|
308
505
|
}
|
|
309
506
|
|
|
507
|
+
/* call-seq: message -> String
|
|
508
|
+
*
|
|
509
|
+
* Returns the message sent by the server.
|
|
510
|
+
*
|
|
511
|
+
* @return [String] the full response message sent by the server
|
|
512
|
+
*/
|
|
310
513
|
static VALUE FtpListingResponse_message(VALUE self) {
|
|
311
514
|
return rb_str_new_cstr(sfFtpListingResponse_getMessage(Get_FtpListingResponse_Struct(self)));
|
|
312
515
|
}
|
|
313
516
|
|
|
517
|
+
/* call-seq: count -> Integer
|
|
518
|
+
*
|
|
519
|
+
* Returns the number of filenames in the listing.
|
|
520
|
+
*
|
|
521
|
+
* @return [Integer] the number of filenames in the listing
|
|
522
|
+
*/
|
|
314
523
|
static VALUE FtpListingResponse_count(VALUE self) {
|
|
315
524
|
return SIZET2NUM(sfFtpListingResponse_getCount(Get_FtpListingResponse_Struct(self)));
|
|
316
525
|
}
|
|
317
526
|
|
|
527
|
+
/* call-seq:
|
|
528
|
+
* name(index) -> String
|
|
529
|
+
*
|
|
530
|
+
* Returns the filename stored at +index+ in the listing.
|
|
531
|
+
*
|
|
532
|
+
* @return [String] the filename at +index+ in the listing
|
|
533
|
+
* @raise [IndexError] if +index+ is out of range
|
|
534
|
+
*/
|
|
318
535
|
static VALUE FtpListingResponse_name(VALUE self, VALUE rb_index) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
536
|
+
void* response = Get_FtpListingResponse_Struct(self);
|
|
537
|
+
size_t index = (size_t)NUM2SIZET(rb_index);
|
|
538
|
+
size_t count = sfFtpListingResponse_getCount(response);
|
|
539
|
+
|
|
540
|
+
if (index >= count) {
|
|
541
|
+
rb_raise(rb_eIndexError, "index %zu outside of listing size %zu", index, count);
|
|
542
|
+
}
|
|
322
543
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
544
|
+
return rb_str_new_cstr(sfFtpListingResponse_getName(response, index));
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/* Document-class: SFML::Ftp
|
|
548
|
+
* A basic FTP client. Every command method blocks until the server replies
|
|
549
|
+
* and returns an FtpResponse (or a more specific subtype).
|
|
550
|
+
*/
|
|
551
|
+
void Init_Ftp(VALUE rb_mSFML) {
|
|
552
|
+
rb_cFtp = rb_define_class_under(rb_mSFML, "Ftp", rb_cObject);
|
|
553
|
+
/* Document-class: SFML::FtpResponse
|
|
554
|
+
* The status and message returned by most Ftp commands.
|
|
555
|
+
*/
|
|
556
|
+
rb_cFtpResponse = rb_define_class_under(rb_mSFML, "FtpResponse", rb_cObject);
|
|
557
|
+
/* Document-class: SFML::FtpDirectoryResponse
|
|
558
|
+
* An FtpResponse specialization returned by Ftp#working_directory,
|
|
559
|
+
* additionally carrying the directory path.
|
|
560
|
+
*/
|
|
561
|
+
rb_cFtpDirectoryResponse = rb_define_class_under(rb_mSFML, "FtpDirectoryResponse", rb_cObject);
|
|
562
|
+
/* Document-class: SFML::FtpListingResponse
|
|
563
|
+
* An FtpResponse specialization returned by Ftp#directory_listing,
|
|
564
|
+
* additionally carrying the list of filenames.
|
|
565
|
+
*/
|
|
566
|
+
rb_cFtpListingResponse = rb_define_class_under(rb_mSFML, "FtpListingResponse", rb_cObject);
|
|
328
567
|
|
|
329
568
|
rb_define_singleton_method(rb_cFtp, "new", Ftp_new, 0);
|
|
330
569
|
|