gio2 0.90.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/ChangeLog +60 -0
  2. data/README +34 -0
  3. data/Rakefile +76 -0
  4. data/ext/gio2/depend +5 -0
  5. data/ext/gio2/extconf.rb +91 -0
  6. data/ext/gio2/gappinfo.c +318 -0
  7. data/ext/gio2/gapplaunchcontext.c +79 -0
  8. data/ext/gio2/gasyncinitable.c +244 -0
  9. data/ext/gio2/gasyncresult.c +39 -0
  10. data/ext/gio2/gbufferedinputstream.c +184 -0
  11. data/ext/gio2/gbufferedoutputstream.c +82 -0
  12. data/ext/gio2/gcancellable.c +177 -0
  13. data/ext/gio2/gcharsetconverter.c +72 -0
  14. data/ext/gio2/gcontenttype.c +135 -0
  15. data/ext/gio2/gconverter.c +117 -0
  16. data/ext/gio2/gconverterinputstream.c +48 -0
  17. data/ext/gio2/gconverteroutputstream.c +48 -0
  18. data/ext/gio2/gdatainputstream.c +341 -0
  19. data/ext/gio2/gdataoutputstream.c +202 -0
  20. data/ext/gio2/gdesktopappinfo.c +90 -0
  21. data/ext/gio2/gdrive.c +267 -0
  22. data/ext/gio2/gemblem.c +71 -0
  23. data/ext/gio2/gemblemedicon.c +63 -0
  24. data/ext/gio2/gfile.c +2058 -0
  25. data/ext/gio2/gfileattribute.c +263 -0
  26. data/ext/gio2/gfileattributematcher.c +90 -0
  27. data/ext/gio2/gfiledescriptorbased.c +42 -0
  28. data/ext/gio2/gfileenumerator.c +167 -0
  29. data/ext/gio2/gfileicon.c +46 -0
  30. data/ext/gio2/gfileinfo.c +641 -0
  31. data/ext/gio2/gfileinputstream.c +92 -0
  32. data/ext/gio2/gfileiostream.c +98 -0
  33. data/ext/gio2/gfilemonitor.c +63 -0
  34. data/ext/gio2/gfilenamecompleter.c +72 -0
  35. data/ext/gio2/gfileoutputstream.c +100 -0
  36. data/ext/gio2/gfilterinputstream.c +56 -0
  37. data/ext/gio2/gfilteroutputstream.c +56 -0
  38. data/ext/gio2/gicon.c +69 -0
  39. data/ext/gio2/ginetaddress.c +188 -0
  40. data/ext/gio2/ginetsocketaddress.c +54 -0
  41. data/ext/gio2/ginitable.c +195 -0
  42. data/ext/gio2/ginputstream.c +341 -0
  43. data/ext/gio2/gio2.c +120 -0
  44. data/ext/gio2/gio2.def +2 -0
  45. data/ext/gio2/gio2.h +343 -0
  46. data/ext/gio2/gioerror.c +67 -0
  47. data/ext/gio2/giomodule.c +63 -0
  48. data/ext/gio2/gioscheduler.c +195 -0
  49. data/ext/gio2/giostream.c +129 -0
  50. data/ext/gio2/gloadableicon.c +91 -0
  51. data/ext/gio2/gmemoryinputstream.c +65 -0
  52. data/ext/gio2/gmemoryoutputstream.c +65 -0
  53. data/ext/gio2/gmount.c +283 -0
  54. data/ext/gio2/gmountoperation.c +168 -0
  55. data/ext/gio2/gnetworkaddress.c +71 -0
  56. data/ext/gio2/gnetworkservice.c +64 -0
  57. data/ext/gio2/goutputstream.c +343 -0
  58. data/ext/gio2/gresolver.c +230 -0
  59. data/ext/gio2/gseekable.c +89 -0
  60. data/ext/gio2/gsimpleasyncresult.c +153 -0
  61. data/ext/gio2/gsocket.c +451 -0
  62. data/ext/gio2/gsocketaddress.c +45 -0
  63. data/ext/gio2/gsocketclient.c +273 -0
  64. data/ext/gio2/gsocketconnectable.c +97 -0
  65. data/ext/gio2/gsocketconnection.c +82 -0
  66. data/ext/gio2/gsocketcontrolmessage.c +82 -0
  67. data/ext/gio2/gsocketlistener.c +239 -0
  68. data/ext/gio2/gsocketservice.c +64 -0
  69. data/ext/gio2/gsrvtarget.c +77 -0
  70. data/ext/gio2/gtcpconnection.c +48 -0
  71. data/ext/gio2/gthemedicon.c +86 -0
  72. data/ext/gio2/gthreadedsocketservice.c +39 -0
  73. data/ext/gio2/gunixconnection.c +69 -0
  74. data/ext/gio2/gunixfdlist.c +112 -0
  75. data/ext/gio2/gunixfdmessage.c +81 -0
  76. data/ext/gio2/gunixinputstream.c +73 -0
  77. data/ext/gio2/gunixmounts.c +346 -0
  78. data/ext/gio2/gunixoutputstream.c +73 -0
  79. data/ext/gio2/gunixsocketaddress.c +79 -0
  80. data/ext/gio2/gvfs.c +84 -0
  81. data/ext/gio2/gvolume.c +191 -0
  82. data/ext/gio2/gvolumemonitor.c +77 -0
  83. data/ext/gio2/gzlibcompressor.c +47 -0
  84. data/ext/gio2/gzlibdecompressor.c +43 -0
  85. data/ext/gio2/util.c +323 -0
  86. data/extconf.rb +49 -0
  87. data/lib/gio2.rb +141 -0
  88. metadata +184 -0
@@ -0,0 +1,71 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
4
+ * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #define _SELF(value) RVAL2GEMBLEM(value)
24
+
25
+ #define GEMBLEMORIGIN2RVAL(value) \
26
+ GENUM2RVAL((value), G_TYPE_EMBLEM_ORIGIN)
27
+
28
+ #define RVAL2GEMBLEMORIGIN(value) \
29
+ RVAL2GENUM((value), G_TYPE_EMBLEM_ORIGIN)
30
+
31
+ static VALUE
32
+ emblem_initialize(int argc, VALUE *argv, VALUE self)
33
+ {
34
+ VALUE rbicon, origin;
35
+ GIcon *icon;
36
+ GEmblem *emblem;
37
+
38
+ rb_scan_args(argc, argv, "11", &rbicon, &origin);
39
+ icon = RVAL2GICON(rbicon);
40
+ emblem = NIL_P(origin) ?
41
+ g_emblem_new(icon) :
42
+ g_emblem_new_with_origin(icon, RVAL2GEMBLEMORIGIN(origin));
43
+ G_INITIALIZE(self, emblem);
44
+
45
+ return Qnil;
46
+ }
47
+
48
+ static VALUE
49
+ emblem_get_icon(VALUE self)
50
+ {
51
+ return GOBJ2RVAL(g_emblem_get_icon(_SELF(self)));
52
+ }
53
+
54
+ static VALUE
55
+ emblem_get_origin(VALUE self)
56
+ {
57
+ return GEMBLEMORIGIN2RVAL(g_emblem_get_origin(_SELF(self)));
58
+ }
59
+
60
+ void
61
+ Init_gemblem(VALUE glib)
62
+ {
63
+ VALUE emblem = G_DEF_CLASS(G_TYPE_EMBLEM, "Emblem", glib);
64
+
65
+ G_DEF_CLASS(G_TYPE_EMBLEM_ORIGIN, "Origin", emblem);
66
+ G_DEF_CONSTANTS(emblem, G_TYPE_EMBLEM_ORIGIN, "G_EMBLEM_");
67
+
68
+ rb_define_method(emblem, "initialize", emblem_initialize, -1);
69
+ rb_define_method(emblem, "icon", emblem_get_icon, 0);
70
+ rb_define_method(emblem, "origin", emblem_get_origin, 0);
71
+ }
@@ -0,0 +1,63 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
4
+ * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #define _SELF(value) G_EMBLEMED_ICON(RVAL2GOBJ(value))
24
+
25
+ static VALUE
26
+ emblemedicon_initialize(VALUE self, VALUE icon, VALUE emblem)
27
+ {
28
+ G_INITIALIZE(self, g_emblemed_icon_new(RVAL2GICON(icon), RVAL2GEMBLEM(emblem)));
29
+
30
+ return Qnil;
31
+ }
32
+
33
+ static VALUE
34
+ emblemedicon_get_icon(VALUE self)
35
+ {
36
+ return GOBJ2RVAL(g_emblemed_icon_get_icon(_SELF(self)));
37
+ }
38
+
39
+ static VALUE
40
+ emblemedicon_get_emblems(VALUE self)
41
+ {
42
+ return GLIST2ARY_FREE(g_emblemed_icon_get_emblems(_SELF(self)));
43
+ }
44
+
45
+ static VALUE
46
+ emblemedicon_add_emblem(VALUE self, VALUE emblem)
47
+ {
48
+ g_emblemed_icon_add_emblem(_SELF(self), RVAL2GEMBLEM(emblem));
49
+
50
+ return self;
51
+ }
52
+
53
+ void
54
+ Init_gemblemedicon(VALUE glib)
55
+ {
56
+ VALUE emblemedicon = G_DEF_CLASS(G_TYPE_EMBLEMED_ICON, "EmblemedIcon", glib);
57
+
58
+ rb_define_method(emblemedicon, "initialize", emblemedicon_initialize, 2);
59
+ rb_define_method(emblemedicon, "icon", emblemedicon_get_icon, 0);
60
+ rb_define_method(emblemedicon, "emblems", emblemedicon_get_emblems, 0);
61
+ rb_define_method(emblemedicon, "add_emblem", emblemedicon_add_emblem, 1);
62
+ rb_define_alias(emblemedicon, "<<", "add_emblem");
63
+ }
@@ -0,0 +1,2058 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
4
+ * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #define _SELF(value) RVAL2GFILE(value)
24
+
25
+ #define RVAL2GFILECOPYFLAGS(value) \
26
+ RVAL2GFLAGS((value), G_TYPE_FILE_COPY_FLAGS)
27
+
28
+ #define RVAL2GFILECOPYFLAGSDEFAULT(value) \
29
+ RVAL2TYPE_WITH_DEFAULT((value), RVAL2GFILECOPYFLAGS, G_FILE_COPY_NONE)
30
+
31
+ #define RVAL2GFILECREATEFLAGS(value) \
32
+ RVAL2GFLAGS((value), G_TYPE_FILE_CREATE_FLAGS)
33
+
34
+ #define RVAL2GFILECREATEFLAGSDEFAULT(value) \
35
+ RVAL2TYPE_WITH_DEFAULT((value), \
36
+ RVAL2GFILECREATEFLAGS, \
37
+ G_FILE_CREATE_NONE)
38
+
39
+ #define RVAL2GFILEMONITORFLAGS(value) \
40
+ RVAL2GFLAGS((value), G_TYPE_FILE_MONITOR_FLAGS)
41
+
42
+ #define RVAL2GFILEMONITORFLAGSDEFAULT(value) \
43
+ RVAL2TYPE_WITH_DEFAULT((value), \
44
+ RVAL2GFILEMONITORFLAGS, \
45
+ G_FILE_MONITOR_NONE)
46
+
47
+ #define RVAL2GFILEQUERYINFOFLAGS(value) \
48
+ RVAL2GFLAGS((value), G_TYPE_FILE_QUERY_INFO_FLAGS)
49
+
50
+ #define RVAL2GFILEQUERYINFOFLAGSDEFAULT(value) \
51
+ RVAL2TYPE_WITH_DEFAULT((value), \
52
+ RVAL2GFILEQUERYINFOFLAGS, \
53
+ G_FILE_QUERY_INFO_NONE)
54
+
55
+ #define RVAL2FSATTRIBUTESDEFAULT(value) \
56
+ RVAL2TYPE_WITH_DEFAULT((value), RVAL2CSTR, "fs::*")
57
+
58
+ static VALUE
59
+ file_new_for_path(G_GNUC_UNUSED VALUE self, VALUE value)
60
+ {
61
+ return GOBJ2RVAL_UNREF(g_file_new_for_path(RVAL2CSTR(value)));
62
+ }
63
+
64
+ static VALUE
65
+ file_new_for_uri(G_GNUC_UNUSED VALUE self, VALUE value)
66
+ {
67
+ return GOBJ2RVAL_UNREF(g_file_new_for_uri(RVAL2CSTR(value)));
68
+ }
69
+
70
+ static VALUE
71
+ file_new_for_commandline_arg(G_GNUC_UNUSED VALUE self, VALUE value)
72
+ {
73
+ return GOBJ2RVAL_UNREF(g_file_new_for_commandline_arg(RVAL2CSTR(value)));
74
+ }
75
+
76
+ static VALUE
77
+ file_parse_name(G_GNUC_UNUSED VALUE self, VALUE value)
78
+ {
79
+ return GOBJ2RVAL_UNREF(g_file_parse_name(RVAL2CSTR(value)));
80
+ }
81
+
82
+ static VALUE
83
+ file_dup(VALUE self)
84
+ {
85
+ return GOBJ2RVAL_UNREF(g_file_dup(_SELF(self)));
86
+ }
87
+
88
+ static VALUE
89
+ file_hash(VALUE self)
90
+ {
91
+ return GUINT2RVAL(g_file_hash(_SELF(self)));
92
+ }
93
+
94
+ static VALUE
95
+ file_equal(VALUE self, VALUE other)
96
+ {
97
+ return CBOOL2RVAL(g_file_equal(_SELF(self), _SELF(other)));
98
+ }
99
+
100
+ static VALUE
101
+ file_get_basename(VALUE self)
102
+ {
103
+ return CSTR2RVAL_FREE(g_file_get_basename(_SELF(self)));
104
+ }
105
+
106
+ static VALUE
107
+ file_get_path(VALUE self)
108
+ {
109
+ return CSTR2RVAL_FREE(g_file_get_path(_SELF(self)));
110
+ }
111
+
112
+ static VALUE
113
+ file_get_uri(VALUE self)
114
+ {
115
+ return CSTR2RVAL_FREE(g_file_get_uri(_SELF(self)));
116
+ }
117
+
118
+ static VALUE
119
+ file_get_parse_name(VALUE self)
120
+ {
121
+ return CSTR2RVAL_FREE(g_file_get_parse_name(_SELF(self)));
122
+ }
123
+
124
+ static VALUE
125
+ file_get_parent(VALUE self)
126
+ {
127
+ return GOBJ2RVAL_UNREF(g_file_get_parent(_SELF(self)));
128
+ }
129
+
130
+ static VALUE
131
+ file_has_parent(int argc, VALUE *argv, VALUE self)
132
+ {
133
+ VALUE parent;
134
+
135
+ rb_scan_args(argc, argv, "01", &parent);
136
+ return CBOOL2RVAL(g_file_has_parent(_SELF(self), RVAL2GFILE(parent)));
137
+ }
138
+
139
+ static VALUE
140
+ file_get_child(VALUE self, VALUE name)
141
+ {
142
+ return GOBJ2RVAL_UNREF(g_file_get_child(_SELF(self), RVAL2CSTR(name)));
143
+ }
144
+
145
+ static VALUE
146
+ file_get_child_for_display_name(VALUE self, VALUE name)
147
+ {
148
+ GError *error = NULL;
149
+ GFile *file = g_file_get_child_for_display_name(_SELF(self),
150
+ RVAL2CSTR(name),
151
+ &error);
152
+ if (file == NULL)
153
+ rbgio_raise_error(error);
154
+
155
+ return GOBJ2RVAL_UNREF(file);
156
+ }
157
+
158
+ static VALUE
159
+ file_has_prefix(VALUE self, VALUE prefix)
160
+ {
161
+ return CBOOL2RVAL(g_file_has_prefix(_SELF(self), _SELF(prefix)));
162
+ }
163
+
164
+ static VALUE
165
+ file_get_relative_path(VALUE self, VALUE other)
166
+ {
167
+ return CSTR2RVAL_FREE(g_file_get_relative_path(_SELF(self), _SELF(other)));
168
+ }
169
+
170
+ static VALUE
171
+ file_resolve_relative_path(VALUE self, VALUE path)
172
+ {
173
+ return GOBJ2RVAL_UNREF(g_file_resolve_relative_path(_SELF(self), RVAL2CSTR(path)));
174
+ }
175
+
176
+ static VALUE
177
+ file_is_native(VALUE self)
178
+ {
179
+ return CBOOL2RVAL(g_file_is_native(_SELF(self)));
180
+ }
181
+
182
+ static VALUE
183
+ file_has_uri_scheme(VALUE self, VALUE scheme)
184
+ {
185
+ return CBOOL2RVAL(g_file_has_uri_scheme(_SELF(self), RVAL2CSTR(scheme)));
186
+ }
187
+
188
+ static VALUE
189
+ file_get_uri_scheme(VALUE self)
190
+ {
191
+ return CSTR2RVAL_FREE(g_file_get_uri_scheme(_SELF(self)));
192
+ }
193
+
194
+ struct file_input_stream_close_data
195
+ {
196
+ GCancellable *cancellable;
197
+ GFileInputStream *stream;
198
+ };
199
+
200
+ static VALUE
201
+ file_input_stream_close(VALUE data)
202
+ {
203
+ struct file_input_stream_close_data *real;
204
+ GError *error = NULL;
205
+
206
+ real = (struct file_input_stream_close_data *)data;
207
+
208
+ if (!g_input_stream_close(G_INPUT_STREAM(real->stream),
209
+ real->cancellable,
210
+ &error))
211
+ rbgio_raise_error(error);
212
+
213
+ return Qnil;
214
+ }
215
+
216
+ static VALUE
217
+ file_read(int argc, VALUE *argv, VALUE self)
218
+ {
219
+ VALUE cancellable;
220
+ struct file_input_stream_close_data data;
221
+ GError *error = NULL;
222
+
223
+ rb_scan_args(argc, argv, "01", &cancellable);
224
+ data.cancellable = RVAL2GCANCELLABLE(cancellable);
225
+ data.stream = g_file_read(_SELF(self), data.cancellable, &error);
226
+ if (data.stream == NULL)
227
+ rbgio_raise_error(error);
228
+
229
+ if (!rb_block_given_p())
230
+ return GOBJ2RVAL_UNREF(data.stream);
231
+
232
+ return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream),
233
+ file_input_stream_close, (VALUE)&data);
234
+ }
235
+
236
+ static VALUE
237
+ file_read_async(int argc, VALUE *argv, VALUE self)
238
+ {
239
+ VALUE rbio_priority, rbcancellable, block;
240
+ int io_priority;
241
+ GCancellable *cancellable;
242
+
243
+ rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
244
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
245
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
246
+ SAVE_BLOCK(block);
247
+ g_file_read_async(_SELF(self),
248
+ io_priority,
249
+ cancellable,
250
+ rbgio_async_ready_callback,
251
+ (gpointer)block);
252
+
253
+ return self;
254
+ }
255
+
256
+ static VALUE
257
+ file_read_finish(VALUE self, VALUE result)
258
+ {
259
+ GError *error = NULL;
260
+ GFileInputStream *stream;
261
+
262
+ stream = g_file_read_finish(_SELF(self), RVAL2GASYNCRESULT(result), &error);
263
+ if (stream == NULL)
264
+ rbgio_raise_error(error);
265
+
266
+ return GOBJ2RVAL_UNREF(stream);
267
+ }
268
+
269
+ typedef GFileOutputStream *(*CreateMethod)(GFile *,
270
+ GFileCreateFlags,
271
+ GCancellable *,
272
+ GError **);
273
+
274
+ struct file_output_stream_close_data
275
+ {
276
+ GCancellable *cancellable;
277
+ GFileOutputStream *stream;
278
+ };
279
+
280
+ static VALUE
281
+ file_output_stream_close(VALUE data)
282
+ {
283
+ struct file_output_stream_close_data *real;
284
+ GError *error = NULL;
285
+
286
+ real = (struct file_output_stream_close_data *)data;
287
+
288
+ if (!g_output_stream_close(G_OUTPUT_STREAM(real->stream),
289
+ real->cancellable,
290
+ &error))
291
+ rbgio_raise_error(error);
292
+
293
+ return Qnil;
294
+ }
295
+
296
+ static VALUE
297
+ create_method(CreateMethod method, int argc, VALUE *argv, VALUE self)
298
+ {
299
+ VALUE flags, cancellable;
300
+ struct file_output_stream_close_data data;
301
+ GError *error = NULL;
302
+
303
+ rb_scan_args(argc, argv, "02", &flags, &cancellable);
304
+ data.cancellable = RVAL2GCANCELLABLE(cancellable);
305
+ data.stream = method(_SELF(self),
306
+ RVAL2GFILECREATEFLAGSDEFAULT(flags),
307
+ data.cancellable,
308
+ &error);
309
+ if (data.stream == NULL)
310
+ rbgio_raise_error(error);
311
+
312
+ if (!rb_block_given_p())
313
+ return GOBJ2RVAL_UNREF(data.stream);
314
+
315
+ return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream),
316
+ file_output_stream_close, (VALUE)&data);
317
+ }
318
+
319
+ static VALUE
320
+ file_append_to(int argc, VALUE *argv, VALUE self)
321
+ {
322
+ return create_method(g_file_append_to, argc, argv, self);
323
+ }
324
+
325
+ static VALUE
326
+ file_create(int argc, VALUE *argv, VALUE self)
327
+ {
328
+ return create_method(g_file_create, argc, argv, self);
329
+ }
330
+
331
+ static VALUE
332
+ file_replace(int argc, VALUE *argv, VALUE self)
333
+ {
334
+ VALUE etag, make_backup, flags, cancellable;
335
+ struct file_output_stream_close_data data;
336
+ GError *error = NULL;
337
+
338
+ rb_scan_args(argc, argv, "04", &etag, &make_backup, &flags, &cancellable);
339
+ data.cancellable = RVAL2GCANCELLABLE(cancellable);
340
+ data.stream = g_file_replace(_SELF(self),
341
+ RVAL2CSTR_ACCEPT_NIL(etag),
342
+ RVAL2CBOOL(make_backup),
343
+ RVAL2GFILECREATEFLAGSDEFAULT(flags),
344
+ data.cancellable,
345
+ &error);
346
+ if (data.stream == NULL)
347
+ rbgio_raise_error(error);
348
+
349
+ if (!rb_block_given_p())
350
+ return GOBJ2RVAL_UNREF(data.stream);
351
+
352
+ return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream),
353
+ file_output_stream_close, (VALUE)&data);
354
+ }
355
+
356
+ typedef void (*CreateAsyncMethod)(GFile *, GFileCreateFlags, int,
357
+ GCancellable *, GAsyncReadyCallback,
358
+ gpointer);
359
+
360
+ static VALUE
361
+ create_async_method(CreateAsyncMethod method, int argc, VALUE *argv, VALUE self)
362
+ {
363
+ VALUE rbflags, rbio_priority, rbcancellable, block;
364
+ GFileCreateFlags flags;
365
+ int io_priority;
366
+ GCancellable *cancellable;
367
+
368
+ rb_scan_args(argc, argv, "03&", &rbflags, &rbio_priority, &rbcancellable, &block);
369
+ flags = RVAL2GFILECREATEFLAGSDEFAULT(rbflags);
370
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
371
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
372
+ SAVE_BLOCK(block);
373
+ method(_SELF(self),
374
+ flags,
375
+ io_priority,
376
+ cancellable,
377
+ rbgio_async_ready_callback,
378
+ (gpointer)block);
379
+
380
+ return self;
381
+ }
382
+
383
+ static VALUE
384
+ file_append_to_async(int argc, VALUE *argv, VALUE self)
385
+ {
386
+ return create_async_method(g_file_append_to_async, argc, argv, self);
387
+ }
388
+
389
+ typedef GFileOutputStream *(*WriteFinishMethod)(GFile *, GAsyncResult *, GError **);
390
+
391
+ static VALUE
392
+ write_finish_method(WriteFinishMethod method, VALUE self, VALUE result)
393
+ {
394
+ GError *error = NULL;
395
+ GFileOutputStream *stream;
396
+
397
+ stream = method(_SELF(self), RVAL2GASYNCRESULT(result), &error);
398
+ if (stream == NULL)
399
+ rbgio_raise_error(error);
400
+
401
+ return GOBJ2RVAL_UNREF(stream);
402
+ }
403
+
404
+ static VALUE
405
+ file_append_to_finish(VALUE self, VALUE result)
406
+ {
407
+ return write_finish_method(g_file_append_to_finish, self, result);
408
+ }
409
+
410
+ static VALUE
411
+ file_create_async(int argc, VALUE *argv, VALUE self)
412
+ {
413
+ return create_async_method(g_file_create_async, argc, argv, self);
414
+ }
415
+
416
+ static VALUE
417
+ file_create_finish(VALUE self, VALUE result)
418
+ {
419
+ return write_finish_method(g_file_create_finish, self, result);
420
+ }
421
+
422
+ typedef void (*ReplaceAsyncMethod)(GFile *,
423
+ const char *,
424
+ gboolean,
425
+ GFileCreateFlags,
426
+ int,
427
+ GCancellable *,
428
+ GAsyncReadyCallback,
429
+ gpointer);
430
+
431
+ static VALUE
432
+ replace_async_method(ReplaceAsyncMethod method, int argc, VALUE *argv, VALUE self)
433
+ {
434
+ VALUE rbetag, rbmake_backup, rbflags, rbio_priority, rbcancellable, block;
435
+ const char *etag;
436
+ gboolean make_backup;
437
+ GFileCreateFlags flags;
438
+ int io_priority;
439
+ GCancellable *cancellable;
440
+
441
+ rb_scan_args(argc, argv, "05&", &rbetag, &rbmake_backup, &rbflags, &rbio_priority, &rbcancellable, &block);
442
+ etag = RVAL2CSTR_ACCEPT_NIL(rbetag);
443
+ make_backup = RVAL2CBOOL(rbmake_backup);
444
+ flags = RVAL2GFILECREATEFLAGSDEFAULT(rbflags);
445
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
446
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
447
+ SAVE_BLOCK(block);
448
+ method(_SELF(self),
449
+ etag,
450
+ make_backup,
451
+ flags,
452
+ io_priority,
453
+ cancellable,
454
+ rbgio_async_ready_callback,
455
+ (gpointer)block);
456
+
457
+ return self;
458
+ }
459
+
460
+ static VALUE
461
+ file_replace_async(int argc, VALUE *argv, VALUE self)
462
+ {
463
+ return replace_async_method(g_file_replace_async, argc, argv, self);
464
+ }
465
+
466
+ static VALUE
467
+ file_replace_finish(VALUE self, VALUE result)
468
+ {
469
+ return write_finish_method(g_file_replace_finish, self, result);
470
+ }
471
+
472
+ static VALUE
473
+ file_query_info(int argc, VALUE *argv, VALUE self)
474
+ {
475
+ VALUE attributes, flags, cancellable;
476
+ GError *error = NULL;
477
+ GFileInfo *info;
478
+
479
+ rb_scan_args(argc, argv, "03", &attributes, &flags, &cancellable);
480
+ info = g_file_query_info(_SELF(self),
481
+ RVAL2ATTRIBUTESDEFAULT(attributes),
482
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
483
+ RVAL2GCANCELLABLE(cancellable),
484
+ &error);
485
+ if (info == NULL)
486
+ rbgio_raise_error(error);
487
+
488
+ return GOBJ2RVAL_UNREF(info);
489
+ }
490
+
491
+ static VALUE
492
+ file_query_info_async(int argc, VALUE *argv, VALUE self)
493
+ {
494
+ VALUE rbattributes, rbflags, rbio_priority, rbcancellable, block;
495
+ const char *attributes;
496
+ GFileQueryInfoFlags flags;
497
+ int io_priority;
498
+ GCancellable *cancellable;
499
+
500
+ rb_scan_args(argc, argv, "04&", &rbattributes, &rbflags, &rbio_priority, &rbcancellable, &block);
501
+ attributes = RVAL2ATTRIBUTESDEFAULT(rbattributes);
502
+ flags = RVAL2GFILEQUERYINFOFLAGSDEFAULT(rbflags);
503
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
504
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
505
+ SAVE_BLOCK(block);
506
+ g_file_query_info_async(_SELF(self),
507
+ attributes,
508
+ flags,
509
+ io_priority,
510
+ cancellable,
511
+ rbgio_async_ready_callback,
512
+ (gpointer)block);
513
+
514
+ return self;
515
+ }
516
+
517
+ static VALUE
518
+ file_query_info_finish(VALUE self, VALUE result)
519
+ {
520
+ GError *error = NULL;
521
+
522
+ GFileInfo *info = g_file_query_info_finish(_SELF(self), RVAL2GASYNCRESULT(result), &error);
523
+ if (info == NULL)
524
+ rbgio_raise_error(error);
525
+
526
+ return GOBJ2RVAL_UNREF(info);
527
+ }
528
+
529
+ static VALUE
530
+ file_query_exists(int argc, VALUE *argv, VALUE self)
531
+ {
532
+ VALUE cancellable;
533
+
534
+ rb_scan_args(argc, argv, "01", &cancellable);
535
+
536
+ return CBOOL2RVAL(g_file_query_exists(_SELF(self), RVAL2GCANCELLABLE(cancellable)));
537
+ }
538
+
539
+ static VALUE
540
+ file_query_file_type(int argc, VALUE *argv, VALUE self)
541
+ {
542
+ VALUE flags, cancellable;
543
+
544
+ rb_scan_args(argc, argv, "02", &flags, &cancellable);
545
+
546
+ return GFILETYPE2RVAL(g_file_query_file_type(_SELF(self),
547
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
548
+ RVAL2GCANCELLABLE(cancellable)));
549
+ }
550
+
551
+ static VALUE
552
+ file_query_filesystem_info(int argc, VALUE *argv, VALUE self)
553
+ {
554
+ VALUE attributes, cancellable;
555
+ GError *error = NULL;
556
+ GFileInfo *info;
557
+
558
+ rb_scan_args(argc, argv, "02", &attributes, &cancellable);
559
+ info = g_file_query_filesystem_info(_SELF(self),
560
+ RVAL2FSATTRIBUTESDEFAULT(attributes),
561
+ RVAL2GCANCELLABLE(cancellable),
562
+ &error);
563
+ if (info == NULL)
564
+ rbgio_raise_error(error);
565
+
566
+ return GOBJ2RVAL_UNREF(info);
567
+ }
568
+
569
+ static VALUE
570
+ file_query_filesystem_info_async(int argc, VALUE *argv, VALUE self)
571
+ {
572
+ VALUE rbattributes, rbio_priority, rbcancellable, block;
573
+ const char *attributes;
574
+ int io_priority;
575
+ GCancellable *cancellable;
576
+
577
+ rb_scan_args(argc, argv, "03&", &rbattributes, &rbio_priority, &rbcancellable, &block);
578
+ attributes = RVAL2FSATTRIBUTESDEFAULT(rbattributes);
579
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
580
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
581
+ SAVE_BLOCK(block);
582
+ g_file_query_filesystem_info_async(_SELF(self),
583
+ attributes,
584
+ io_priority,
585
+ cancellable,
586
+ rbgio_async_ready_callback,
587
+ (gpointer)block);
588
+
589
+ return self;
590
+ }
591
+
592
+ static VALUE
593
+ file_query_filesystem_info_finish(VALUE self, VALUE result)
594
+ {
595
+ GError *error = NULL;
596
+ GFileInfo *info;
597
+
598
+ info = g_file_query_filesystem_info_finish(_SELF(self),
599
+ RVAL2GASYNCRESULT(result),
600
+ &error);
601
+ if (info == NULL)
602
+ rbgio_raise_error(error);
603
+
604
+ return GOBJ2RVAL_UNREF(info);
605
+ }
606
+
607
+ static VALUE
608
+ file_query_default_handler(int argc, VALUE *argv, VALUE self)
609
+ {
610
+ VALUE cancellable;
611
+ GError *error = NULL;
612
+ GAppInfo *info;
613
+
614
+ rb_scan_args(argc, argv, "01", &cancellable);
615
+ info = g_file_query_default_handler(_SELF(self),
616
+ RVAL2GCANCELLABLE(cancellable),
617
+ &error);
618
+ if (info == NULL)
619
+ rbgio_raise_error(error);
620
+
621
+ return GOBJ2RVAL_UNREF(info);
622
+ }
623
+
624
+ static VALUE
625
+ file_find_enclosing_mount(int argc, VALUE *argv, VALUE self)
626
+ {
627
+ VALUE cancellable;
628
+ GError *error = NULL;
629
+ GMount *mount;
630
+
631
+ rb_scan_args(argc, argv, "01", &cancellable);
632
+ mount = g_file_find_enclosing_mount(_SELF(self),
633
+ RVAL2GCANCELLABLE(cancellable),
634
+ &error);
635
+ if (mount == NULL)
636
+ rbgio_raise_error(error);
637
+
638
+ return GOBJ2RVAL_UNREF(mount);
639
+ }
640
+
641
+ static VALUE
642
+ file_find_enclosing_mount_async(int argc, VALUE *argv, VALUE self)
643
+ {
644
+ VALUE rbio_priority, rbcancellable, block;
645
+ int io_priority;
646
+ GCancellable *cancellable;
647
+
648
+ rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
649
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
650
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
651
+ SAVE_BLOCK(block);
652
+ g_file_find_enclosing_mount_async(_SELF(self),
653
+ io_priority,
654
+ cancellable,
655
+ rbgio_async_ready_callback,
656
+ (gpointer)block);
657
+
658
+ return self;
659
+ }
660
+
661
+ static VALUE
662
+ file_find_enclosing_mount_finish(VALUE self, VALUE result)
663
+ {
664
+ GError *error = NULL;
665
+
666
+ GMount *mount = g_file_find_enclosing_mount_finish(_SELF(self), RVAL2GASYNCRESULT(result), &error);
667
+ if (mount == NULL)
668
+ rbgio_raise_error(error);
669
+
670
+ return GOBJ2RVAL_UNREF(mount);
671
+ }
672
+
673
+ struct file_enumerator_each_data
674
+ {
675
+ GCancellable *cancellable;
676
+ GFileEnumerator *enumerator;
677
+ };
678
+
679
+ static VALUE
680
+ file_enumerator_each(VALUE data)
681
+ {
682
+ struct file_enumerator_each_data *real;
683
+ GError *error = NULL;
684
+
685
+ real = (struct file_enumerator_each_data *)data;
686
+
687
+ while (TRUE) {
688
+ GFileInfo *info = g_file_enumerator_next_file(real->enumerator,
689
+ real->cancellable,
690
+ &error);
691
+ if (error != NULL)
692
+ rbgio_raise_error(error);
693
+
694
+ if (info == NULL)
695
+ break;
696
+
697
+ rb_yield(GOBJ2RVAL_UNREF(info));
698
+ }
699
+
700
+ return Qnil;
701
+ }
702
+
703
+ static VALUE
704
+ file_enumerator_each_ensure(VALUE data)
705
+ {
706
+ struct file_enumerator_each_data *real;
707
+ GError *error = NULL;
708
+
709
+ real = (struct file_enumerator_each_data *)data;
710
+
711
+ if (!g_file_enumerator_close(real->enumerator,
712
+ real->cancellable,
713
+ &error)) {
714
+ g_object_unref(real->enumerator);
715
+ rbgio_raise_error(error);
716
+ }
717
+
718
+ g_object_unref(real->enumerator);
719
+
720
+ return Qnil;
721
+ }
722
+
723
+ static VALUE
724
+ file_enumerate_children(int argc, VALUE *argv, VALUE self)
725
+ {
726
+ VALUE attributes, flags, cancellable;
727
+ struct file_enumerator_each_data data;
728
+ GError *error = NULL;
729
+
730
+ rb_scan_args(argc, argv, "03", &attributes, &flags, &cancellable);
731
+ data.cancellable = RVAL2GCANCELLABLE(cancellable);
732
+ data.enumerator = g_file_enumerate_children(_SELF(self),
733
+ RVAL2ATTRIBUTESDEFAULT(attributes),
734
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
735
+ data.cancellable,
736
+ &error);
737
+ if (data.enumerator == NULL)
738
+ rbgio_raise_error(error);
739
+
740
+ if (!rb_block_given_p())
741
+ return GOBJ2RVAL_UNREF(data.enumerator);
742
+
743
+ rb_ensure(file_enumerator_each, (VALUE)&data,
744
+ file_enumerator_each_ensure, (VALUE)&data);
745
+
746
+ return self;
747
+ }
748
+
749
+ static VALUE
750
+ file_enumerate_children_async(int argc, VALUE *argv, VALUE self)
751
+ {
752
+ VALUE rbattributes, rbflags, rbio_priority, rbcancellable, block;
753
+ const char *attributes;
754
+ GFileQueryInfoFlags flags;
755
+ int io_priority;
756
+ GCancellable *cancellable;
757
+
758
+ rb_scan_args(argc, argv, "04&", &rbattributes, &rbflags, &rbio_priority, &rbcancellable, &block);
759
+ attributes = RVAL2ATTRIBUTESDEFAULT(rbattributes);
760
+ flags = RVAL2GFILEQUERYINFOFLAGSDEFAULT(rbflags);
761
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
762
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
763
+ SAVE_BLOCK(block);
764
+ g_file_enumerate_children_async(_SELF(self),
765
+ attributes,
766
+ flags,
767
+ io_priority,
768
+ cancellable,
769
+ rbgio_async_ready_callback,
770
+ (gpointer)block);
771
+
772
+ return self;
773
+ }
774
+
775
+ static VALUE
776
+ file_enumerate_children_finish(VALUE self, VALUE result)
777
+ {
778
+ GError *error = NULL;
779
+ GFileEnumerator *enumerator;
780
+
781
+ enumerator = g_file_enumerate_children_finish(_SELF(self),
782
+ RVAL2GASYNCRESULT(result),
783
+ &error);
784
+ if (enumerator == NULL)
785
+ rbgio_raise_error(error);
786
+
787
+ return GOBJ2RVAL_UNREF(enumerator);
788
+ }
789
+
790
+ static VALUE
791
+ file_set_display_name(int argc, VALUE *argv, VALUE self)
792
+ {
793
+ VALUE display_name, cancellable;
794
+ GError *error = NULL;
795
+ GFile *file;
796
+
797
+ rb_scan_args(argc, argv, "11", &display_name, &cancellable);
798
+
799
+ file = g_file_set_display_name(_SELF(self),
800
+ RVAL2CSTR(display_name),
801
+ RVAL2GCANCELLABLE(cancellable),
802
+ &error);
803
+ if (file == NULL)
804
+ rbgio_raise_error(error);
805
+
806
+ return GOBJ2RVAL_UNREF(file);
807
+ }
808
+
809
+ static VALUE
810
+ file_set_display_name_async(int argc, VALUE *argv, VALUE self)
811
+ {
812
+ VALUE rbdisplay_name, rbio_priority, rbcancellable, block;
813
+ const char *display_name;
814
+ int io_priority;
815
+ GCancellable *cancellable;
816
+
817
+ rb_scan_args(argc, argv, "03&", &rbdisplay_name, &rbio_priority, &rbcancellable, &block);
818
+ display_name = RVAL2CSTR(rbdisplay_name);
819
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
820
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
821
+ SAVE_BLOCK(block);
822
+ g_file_set_display_name_async(_SELF(self),
823
+ display_name,
824
+ io_priority,
825
+ cancellable,
826
+ rbgio_async_ready_callback,
827
+ (gpointer)block);
828
+
829
+ return self;
830
+ }
831
+
832
+ static VALUE
833
+ file_set_display_name_finish(VALUE self, VALUE result)
834
+ {
835
+ GError *error = NULL;
836
+ GFileInfo *info;
837
+
838
+ info = g_file_query_filesystem_info_finish(_SELF(self),
839
+ RVAL2GASYNCRESULT(result),
840
+ &error);
841
+ if (info == NULL)
842
+ rbgio_raise_error(error);
843
+
844
+ return GOBJ2RVAL_UNREF(info);
845
+ }
846
+
847
+ typedef gboolean (*CancellableMethod)(GFile *, GCancellable *, GError **);
848
+
849
+ static VALUE
850
+ cancellable_method(CancellableMethod method, int argc, VALUE *argv, VALUE self)
851
+ {
852
+ VALUE cancellable;
853
+ GError *error = NULL;
854
+
855
+ rb_scan_args(argc, argv, "01", &cancellable);
856
+ if (!method(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error))
857
+ rbgio_raise_error(error);
858
+
859
+ return self;
860
+ }
861
+
862
+ static VALUE
863
+ file_delete(int argc, VALUE *argv, VALUE self)
864
+ {
865
+ return cancellable_method(g_file_delete, argc, argv, self);
866
+ }
867
+
868
+ static VALUE
869
+ file_trash(int argc, VALUE *argv, VALUE self)
870
+ {
871
+ return cancellable_method(g_file_trash, argc, argv, self);
872
+ }
873
+
874
+ struct progress_callback_data
875
+ {
876
+ goffset current_num_bytes;
877
+ goffset total_num_bytes;
878
+ gpointer data;
879
+ };
880
+
881
+ static VALUE
882
+ progress_callback_call(VALUE data)
883
+ {
884
+ static ID s_id_call;
885
+ struct progress_callback_data *real;
886
+ VALUE block;
887
+
888
+ if (s_id_call == 0)
889
+ s_id_call = rb_intern("call");
890
+
891
+ real = (struct progress_callback_data *)data;
892
+ block = USE_BLOCK_AND_SAVE(real->data);
893
+ if (!NIL_P(block))
894
+ rb_funcall(block, s_id_call, 2,
895
+ GOFFSET2RVAL(real->current_num_bytes),
896
+ GOFFSET2RVAL(real->total_num_bytes));
897
+
898
+ return Qnil;
899
+ }
900
+
901
+ static void
902
+ progress_callback(goffset current_num_bytes, goffset total_num_bytes, gpointer data)
903
+ {
904
+ struct progress_callback_data real;
905
+
906
+ real.current_num_bytes = current_num_bytes;
907
+ real.total_num_bytes = total_num_bytes;
908
+ real.data = data;
909
+
910
+ G_PROTECT_CALLBACK(progress_callback_call, &real);
911
+ }
912
+
913
+ typedef gboolean (*CopyMoveMethod)(GFile *,
914
+ GFile *,
915
+ GFileCopyFlags,
916
+ GCancellable *,
917
+ GFileProgressCallback,
918
+ gpointer,
919
+ GError **);
920
+
921
+ static VALUE
922
+ copy_move_method(CopyMoveMethod method, int argc, VALUE *argv, VALUE self)
923
+ {
924
+ VALUE rbdestination, rbflags, rbcancellable, block;
925
+ GFile *destination;
926
+ GFileCopyFlags flags;
927
+ GCancellable *cancellable;
928
+ GError *error = NULL;
929
+
930
+ rb_scan_args(argc, argv, "12&", &rbdestination, &rbflags, &rbcancellable, &block);
931
+ destination = _SELF(rbdestination);
932
+ flags = RVAL2GFILECOPYFLAGSDEFAULT(rbflags);
933
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
934
+ SAVE_BLOCK(block);
935
+ if (!method(_SELF(self),
936
+ destination,
937
+ flags,
938
+ cancellable,
939
+ NIL_P(block) ? NULL : progress_callback,
940
+ (gpointer)block,
941
+ &error))
942
+ rbgio_raise_error(error);
943
+
944
+ return self;
945
+ }
946
+
947
+ static VALUE
948
+ file_copy(int argc, VALUE *argv, VALUE self)
949
+ {
950
+ return copy_move_method(g_file_copy, argc, argv, self);
951
+ }
952
+
953
+ static VALUE
954
+ file_copy_async(int argc, VALUE *argv, VALUE self)
955
+ {
956
+ VALUE rbdestination, rbflags, rbio_priority, rbcancellable, block;
957
+ GFile *destination;
958
+ GFileCopyFlags flags;
959
+ int io_priority;
960
+ GCancellable *cancellable;
961
+
962
+ rb_scan_args(argc, argv, "13&", &rbdestination, &rbflags, &rbio_priority, &rbcancellable, &block);
963
+ destination = _SELF(rbdestination);
964
+ flags = RVAL2GFILECOPYFLAGSDEFAULT(rbflags);
965
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
966
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
967
+ SAVE_BLOCK(block);
968
+ /* NOTE: This requires the block to take a variable number of
969
+ * arguments. It will be two integer values for the progress part and
970
+ * a GLib::AsyncResult when done. */
971
+ g_file_copy_async(_SELF(self),
972
+ destination,
973
+ flags,
974
+ io_priority,
975
+ cancellable,
976
+ NIL_P(block) ? NULL : progress_callback,
977
+ (gpointer)block,
978
+ rbgio_async_ready_callback,
979
+ (gpointer)block);
980
+
981
+ return self;
982
+ }
983
+
984
+ typedef gboolean (*BooleanFinishMethod)(GFile *, GAsyncResult *, GError **);
985
+
986
+ static VALUE
987
+ boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result)
988
+ {
989
+ GError *error = NULL;
990
+
991
+ if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error))
992
+ rbgio_raise_error(error);
993
+
994
+ return self;
995
+ }
996
+
997
+ static VALUE
998
+ file_copy_finish(VALUE self, VALUE result)
999
+ {
1000
+ return boolean_finish_method(g_file_copy_finish, self, result);
1001
+ }
1002
+
1003
+ static VALUE
1004
+ file_move(int argc, VALUE *argv, VALUE self)
1005
+ {
1006
+ return copy_move_method(g_file_move, argc, argv, self);
1007
+ }
1008
+
1009
+ static VALUE
1010
+ file_make_directory(int argc, VALUE *argv, VALUE self)
1011
+ {
1012
+ return cancellable_method(g_file_make_directory, argc, argv, self);
1013
+ }
1014
+
1015
+ static VALUE
1016
+ file_make_directory_with_parents(int argc, VALUE *argv, VALUE self)
1017
+ {
1018
+ return cancellable_method(g_file_make_directory_with_parents, argc, argv, self);
1019
+ }
1020
+
1021
+ static VALUE
1022
+ file_make_symbolic_link(int argc, VALUE *argv, VALUE self)
1023
+ {
1024
+ VALUE symlink_value, cancellable;
1025
+ GError *error = NULL;
1026
+
1027
+ rb_scan_args(argc, argv, "11", &symlink_value, &cancellable);
1028
+ if (!g_file_make_symbolic_link(_SELF(self),
1029
+ RVAL2CSTR(symlink_value),
1030
+ RVAL2GCANCELLABLE(cancellable),
1031
+ &error))
1032
+ rbgio_raise_error(error);
1033
+
1034
+ return self;
1035
+ }
1036
+
1037
+ typedef GFileAttributeInfoList *(*QueryAttributesMethod)(GFile *,
1038
+ GCancellable *,
1039
+ GError **);
1040
+
1041
+ static VALUE
1042
+ query_attributes_method(QueryAttributesMethod method,
1043
+ int argc, VALUE *argv, VALUE self)
1044
+ {
1045
+ VALUE cancellable;
1046
+ GError *error = NULL;
1047
+ GFileAttributeInfoList *list;
1048
+
1049
+ rb_scan_args(argc, argv, "01", &cancellable);
1050
+ list = method(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error);
1051
+ if (list == NULL)
1052
+ rbgio_raise_error(error);
1053
+
1054
+ return GFILEATTRIBUTEINFOLIST2RVAL(list);
1055
+ }
1056
+
1057
+ static VALUE
1058
+ file_query_settable_attributes(int argc, VALUE *argv, VALUE self)
1059
+ {
1060
+ return query_attributes_method(g_file_query_settable_attributes,
1061
+ argc, argv, self);
1062
+ }
1063
+
1064
+ static VALUE
1065
+ file_query_writable_namespaces(int argc, VALUE *argv, VALUE self)
1066
+ {
1067
+ return query_attributes_method(g_file_query_writable_namespaces,
1068
+ argc, argv, self);
1069
+ }
1070
+
1071
+ static VALUE
1072
+ file_set_attribute(int argc, VALUE *argv, VALUE self)
1073
+ {
1074
+ VALUE rbattribute, rbtype, rbvalue, rbflags, rbcancellable;
1075
+ const char *attribute;
1076
+ GFileAttributeType type;
1077
+ gpointer value;
1078
+ gboolean gboolean_value;
1079
+ guint32 guint32_value;
1080
+ gint32 gint32_value;
1081
+ guint64 guint64_value;
1082
+ gint64 gint64_value;
1083
+ char **stringv_value = NULL;
1084
+ GFileQueryInfoFlags flags;
1085
+ GCancellable *cancellable;
1086
+ GError *error = NULL;
1087
+
1088
+ rb_scan_args(argc, argv, "32", &rbattribute, &rbtype, &rbvalue, &rbflags, &rbcancellable);
1089
+ attribute = RVAL2CSTR(rbattribute);
1090
+ type = RVAL2GFILEATTRIBUTETYPE(rbtype);
1091
+ flags = RVAL2GFILEQUERYINFOFLAGSDEFAULT(rbflags);
1092
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
1093
+
1094
+ switch (type) {
1095
+ case G_FILE_ATTRIBUTE_TYPE_STRING:
1096
+ case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING:
1097
+ value = RVAL2CSTR(rbvalue);
1098
+ break;
1099
+ case G_FILE_ATTRIBUTE_TYPE_BOOLEAN:
1100
+ gboolean_value = RVAL2CBOOL(rbvalue);
1101
+ value = &gboolean_value;
1102
+ break;
1103
+ case G_FILE_ATTRIBUTE_TYPE_UINT32:
1104
+ guint32_value = RVAL2GUINT32(rbvalue);
1105
+ value = &guint32_value;
1106
+ break;
1107
+ case G_FILE_ATTRIBUTE_TYPE_INT32:
1108
+ gint32_value = RVAL2GINT32(rbvalue);
1109
+ value = &gint32_value;
1110
+ break;
1111
+ case G_FILE_ATTRIBUTE_TYPE_UINT64:
1112
+ guint64_value = RVAL2GUINT64(rbvalue);
1113
+ value = &guint64_value;
1114
+ break;
1115
+ case G_FILE_ATTRIBUTE_TYPE_INT64:
1116
+ gint64_value = RVAL2GINT64(rbvalue);
1117
+ value = &gint64_value;
1118
+ break;
1119
+ case G_FILE_ATTRIBUTE_TYPE_OBJECT:
1120
+ value = RVAL2GOBJ(rbvalue);
1121
+ break;
1122
+ case G_FILE_ATTRIBUTE_TYPE_STRINGV:
1123
+ value = stringv_value = ARY2STRVECTOR(rbvalue);
1124
+ break;
1125
+ case G_FILE_ATTRIBUTE_TYPE_INVALID:
1126
+ default:
1127
+ rb_raise(rb_eArgError, "Unknown file attribute type: %d", type);
1128
+ }
1129
+
1130
+ g_file_set_attribute(_SELF(self),
1131
+ attribute,
1132
+ type,
1133
+ value,
1134
+ flags,
1135
+ cancellable,
1136
+ &error);
1137
+ g_free(stringv_value);
1138
+ if (error != NULL)
1139
+ rbgio_raise_error(error);
1140
+
1141
+ return self;
1142
+ }
1143
+
1144
+ static VALUE
1145
+ file_set_attributes_from_info(int argc, VALUE *argv, VALUE self)
1146
+ {
1147
+ VALUE info, flags, cancellable;
1148
+ GError *error = NULL;
1149
+
1150
+ rb_scan_args(argc, argv, "12", &info, &flags, &cancellable);
1151
+ if (!g_file_set_attributes_from_info(_SELF(self),
1152
+ RVAL2GFILEINFO(info),
1153
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
1154
+ RVAL2GCANCELLABLE(cancellable),
1155
+ &error))
1156
+ rbgio_raise_error(error);
1157
+
1158
+ return self;
1159
+ }
1160
+
1161
+ static VALUE
1162
+ file_set_attributes_async(int argc, VALUE *argv, VALUE self)
1163
+ {
1164
+ VALUE rbinfo, rbflags, rbio_priority, rbcancellable, block;
1165
+ GFileInfo *info;
1166
+ GFileQueryInfoFlags flags;
1167
+ int io_priority;
1168
+ GCancellable *cancellable;
1169
+
1170
+ rb_scan_args(argc, argv, "13&", &rbinfo, &rbflags, &rbio_priority, &rbcancellable, &block);
1171
+ info = RVAL2GFILEINFO(rbinfo);
1172
+ flags = RVAL2GFILEQUERYINFOFLAGSDEFAULT(rbflags);
1173
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
1174
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
1175
+ SAVE_BLOCK(block);
1176
+ g_file_set_attributes_async(_SELF(self),
1177
+ info,
1178
+ flags,
1179
+ io_priority,
1180
+ cancellable,
1181
+ rbgio_async_ready_callback,
1182
+ (gpointer)block);
1183
+
1184
+ return self;
1185
+ }
1186
+
1187
+ static VALUE
1188
+ file_set_attributes_finish(VALUE self, VALUE result)
1189
+ {
1190
+ GFileInfo *info;
1191
+ GError *error = NULL;
1192
+
1193
+ if (!g_file_set_attributes_finish(_SELF(self),
1194
+ RVAL2GASYNCRESULT(result),
1195
+ &info,
1196
+ &error))
1197
+ rbgio_raise_error(error);
1198
+
1199
+ return GOBJ2RVAL_UNREF(info);
1200
+ }
1201
+
1202
+ static VALUE
1203
+ file_set_attribute_string(int argc, VALUE *argv, VALUE self)
1204
+ {
1205
+ VALUE attribute, value, flags, cancellable;
1206
+ GError *error = NULL;
1207
+
1208
+ rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable);
1209
+ if (!g_file_set_attribute_string(_SELF(self),
1210
+ RVAL2CSTR(attribute),
1211
+ RVAL2CSTR(value),
1212
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
1213
+ RVAL2GCANCELLABLE(cancellable),
1214
+ &error))
1215
+ rbgio_raise_error(error);
1216
+
1217
+ return self;
1218
+ }
1219
+
1220
+ static VALUE
1221
+ file_set_attribute_byte_string(int argc, VALUE *argv, VALUE self)
1222
+ {
1223
+ VALUE attribute, value, flags, cancellable;
1224
+ GError *error = NULL;
1225
+
1226
+ rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable);
1227
+ if (!g_file_set_attribute_byte_string(_SELF(self),
1228
+ RVAL2CSTR(attribute),
1229
+ RVAL2CSTR(value),
1230
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
1231
+ RVAL2GCANCELLABLE(cancellable),
1232
+ &error))
1233
+ rbgio_raise_error(error);
1234
+
1235
+ return self;
1236
+ }
1237
+
1238
+ static VALUE
1239
+ file_set_attribute_uint32(int argc, VALUE *argv, VALUE self)
1240
+ {
1241
+ VALUE attribute, value, flags, cancellable;
1242
+ GError *error = NULL;
1243
+
1244
+ rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable);
1245
+ if (!g_file_set_attribute_uint32(_SELF(self),
1246
+ RVAL2CSTR(attribute),
1247
+ RVAL2GUINT32(value),
1248
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
1249
+ RVAL2GCANCELLABLE(cancellable),
1250
+ &error))
1251
+ rbgio_raise_error(error);
1252
+
1253
+ return self;
1254
+ }
1255
+
1256
+ static VALUE
1257
+ file_set_attribute_int32(int argc, VALUE *argv, VALUE self)
1258
+ {
1259
+ VALUE attribute, value, flags, cancellable;
1260
+ GError *error = NULL;
1261
+
1262
+ rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable);
1263
+ if (!g_file_set_attribute_int32(_SELF(self),
1264
+ RVAL2CSTR(attribute),
1265
+ RVAL2GINT32(value),
1266
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
1267
+ RVAL2GCANCELLABLE(cancellable),
1268
+ &error))
1269
+ rbgio_raise_error(error);
1270
+
1271
+ return self;
1272
+ }
1273
+
1274
+ static VALUE
1275
+ file_set_attribute_uint64(int argc, VALUE *argv, VALUE self)
1276
+ {
1277
+ VALUE attribute, value, flags, cancellable;
1278
+ GError *error = NULL;
1279
+
1280
+ rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable);
1281
+ if (!g_file_set_attribute_uint64(_SELF(self),
1282
+ RVAL2CSTR(attribute),
1283
+ RVAL2GUINT64(value),
1284
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
1285
+ RVAL2GCANCELLABLE(cancellable),
1286
+ &error))
1287
+ rbgio_raise_error(error);
1288
+
1289
+ return self;
1290
+ }
1291
+
1292
+ static VALUE
1293
+ file_set_attribute_int64(int argc, VALUE *argv, VALUE self)
1294
+ {
1295
+ VALUE attribute, value, flags, cancellable;
1296
+ GError *error = NULL;
1297
+
1298
+ rb_scan_args(argc, argv, "22", &attribute, &value, &flags, &cancellable);
1299
+ if (!g_file_set_attribute_int64(_SELF(self),
1300
+ RVAL2CSTR(attribute),
1301
+ RVAL2GINT64(value),
1302
+ RVAL2GFILEQUERYINFOFLAGSDEFAULT(flags),
1303
+ RVAL2GCANCELLABLE(cancellable),
1304
+ &error))
1305
+ rbgio_raise_error(error);
1306
+
1307
+ return self;
1308
+ }
1309
+
1310
+ typedef void (*MountMethod)(GFile *,
1311
+ GMountMountFlags,
1312
+ GMountOperation *,
1313
+ GCancellable *,
1314
+ GAsyncReadyCallback,
1315
+ gpointer);
1316
+
1317
+ static VALUE
1318
+ mount_method(MountMethod method, int argc, VALUE *argv, VALUE self)
1319
+ {
1320
+ VALUE rbflags, rbmount_operation, rbcancellable, block;
1321
+ GMountMountFlags flags;
1322
+ GMountOperation *mount_operation;
1323
+ GCancellable *cancellable;
1324
+
1325
+ rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block);
1326
+ flags = RVAL2GMOUNTMOUNTFLAGSDEFAULT(rbflags);
1327
+ mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation);
1328
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
1329
+ SAVE_BLOCK(block);
1330
+ method(_SELF(self),
1331
+ flags,
1332
+ mount_operation,
1333
+ cancellable,
1334
+ rbgio_async_ready_callback,
1335
+ (gpointer)block);
1336
+
1337
+ return self;
1338
+ }
1339
+
1340
+ static VALUE
1341
+ file_mount_mountable(int argc, VALUE *argv, VALUE self)
1342
+ {
1343
+ return mount_method(g_file_mount_mountable, argc, argv, self);
1344
+ }
1345
+
1346
+ static VALUE
1347
+ file_mount_mountable_finish(VALUE self, VALUE result)
1348
+ {
1349
+ GError *error = NULL;
1350
+ GFile *file;
1351
+
1352
+ file = g_file_mount_mountable_finish(_SELF(self),
1353
+ RVAL2GASYNCRESULT(result),
1354
+ &error);
1355
+ if (file == NULL)
1356
+ rbgio_raise_error(error);
1357
+
1358
+ return GOBJ2RVAL_UNREF(file);
1359
+ }
1360
+
1361
+ typedef void (*UnmountEjectStopMountableMethod)(GFile *,
1362
+ GMountUnmountFlags,
1363
+ GMountOperation *,
1364
+ GCancellable *,
1365
+ GAsyncReadyCallback,
1366
+ gpointer);
1367
+
1368
+ static VALUE
1369
+ unmount_eject_stop_mountable_method(UnmountEjectStopMountableMethod method,
1370
+ int argc, VALUE *argv, VALUE self)
1371
+ {
1372
+ VALUE rbflags, rbmount_operation, rbcancellable, block;
1373
+ GMountUnmountFlags flags;
1374
+ GMountOperation *mount_operation;
1375
+ GCancellable *cancellable;
1376
+
1377
+ rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block);
1378
+ flags = RVAL2GMOUNTUNMOUNTFLAGSDEFAULT(rbflags);
1379
+ mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation);
1380
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
1381
+ SAVE_BLOCK(block);
1382
+ method(_SELF(self),
1383
+ flags,
1384
+ mount_operation,
1385
+ cancellable,
1386
+ rbgio_async_ready_callback,
1387
+ (gpointer)block);
1388
+
1389
+ return self;
1390
+ }
1391
+
1392
+ static VALUE
1393
+ file_unmount_mountable_with_operation(int argc, VALUE *argv, VALUE self)
1394
+ {
1395
+ return unmount_eject_stop_mountable_method(g_file_unmount_mountable_with_operation,
1396
+ argc, argv, self);
1397
+ }
1398
+
1399
+ static VALUE
1400
+ file_unmount_mountable_with_operation_finish(VALUE self, VALUE result)
1401
+ {
1402
+ return boolean_finish_method(g_file_unmount_mountable_with_operation_finish, self, result);
1403
+ }
1404
+
1405
+ static VALUE
1406
+ file_eject_mountable_with_operation(int argc, VALUE *argv, VALUE self)
1407
+ {
1408
+ return unmount_eject_stop_mountable_method(g_file_eject_mountable_with_operation,
1409
+ argc, argv, self);
1410
+ }
1411
+
1412
+ static VALUE
1413
+ file_eject_mountable_with_operation_finish(VALUE self, VALUE result)
1414
+ {
1415
+ return boolean_finish_method(g_file_eject_mountable_with_operation_finish, self, result);
1416
+ }
1417
+
1418
+ static VALUE
1419
+ file_start_mountable(int argc, VALUE *argv, VALUE self)
1420
+ {
1421
+ VALUE rbflags, rbstart_operation, rbcancellable, block;
1422
+ GDriveStartFlags flags;
1423
+ GMountOperation *start_operation;
1424
+ GCancellable *cancellable;
1425
+
1426
+ rb_scan_args(argc, argv, "02&", &rbflags, &rbstart_operation, &rbcancellable, &block);
1427
+ flags = RVAL2GDRIVESTARTFLAGSDEFAULT(rbflags);
1428
+ start_operation = RVAL2GMOUNTOPERATION(rbstart_operation);
1429
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
1430
+ SAVE_BLOCK(block);
1431
+ g_file_start_mountable(_SELF(self),
1432
+ flags,
1433
+ start_operation,
1434
+ cancellable,
1435
+ rbgio_async_ready_callback,
1436
+ (gpointer)block);
1437
+
1438
+ return self;
1439
+ }
1440
+
1441
+ static VALUE
1442
+ file_start_mountable_finish(VALUE self, VALUE result)
1443
+ {
1444
+ return boolean_finish_method(g_file_start_mountable_finish, self, result);
1445
+ }
1446
+
1447
+ static VALUE
1448
+ file_stop_mountable(int argc, VALUE *argv, VALUE self)
1449
+ {
1450
+ return unmount_eject_stop_mountable_method(g_file_stop_mountable,
1451
+ argc, argv, self);
1452
+ }
1453
+
1454
+ static VALUE
1455
+ file_stop_mountable_finish(VALUE self, VALUE result)
1456
+ {
1457
+ return boolean_finish_method(g_file_stop_mountable_finish, self, result);
1458
+ }
1459
+
1460
+ typedef void (*CancellableAsyncMethod)(GFile *,
1461
+ GCancellable *,
1462
+ GAsyncReadyCallback,
1463
+ gpointer);
1464
+
1465
+ static VALUE
1466
+ cancellable_async_method(CancellableAsyncMethod method, int argc, VALUE *argv, VALUE self)
1467
+ {
1468
+ VALUE rbcancellable, block;
1469
+ GCancellable *cancellable;
1470
+
1471
+ rb_scan_args(argc, argv, "01&", &rbcancellable, &block);
1472
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
1473
+ SAVE_BLOCK(block);
1474
+ method(_SELF(self), cancellable, rbgio_async_ready_callback, (gpointer)block);
1475
+
1476
+ return self;
1477
+ }
1478
+
1479
+ static VALUE
1480
+ file_poll_mountable(int argc, VALUE *argv, VALUE self)
1481
+ {
1482
+ return cancellable_async_method(g_file_poll_mountable, argc, argv, self);
1483
+ }
1484
+
1485
+ static VALUE
1486
+ file_poll_mountable_finish(VALUE self, VALUE result)
1487
+ {
1488
+ return boolean_finish_method(g_file_poll_mountable_finish, self, result);
1489
+ }
1490
+
1491
+ static VALUE
1492
+ file_mount_enclosing_volume(int argc, VALUE *argv, VALUE self)
1493
+ {
1494
+ return mount_method(g_file_mount_enclosing_volume, argc, argv, self);
1495
+ }
1496
+
1497
+ static VALUE
1498
+ file_mount_enclosing_volume_finish(VALUE self, VALUE result)
1499
+ {
1500
+ return boolean_finish_method(g_file_mount_enclosing_volume_finish, self, result);
1501
+ }
1502
+
1503
+ typedef GFileMonitor *(*MonitorMethod)(GFile *,
1504
+ GFileMonitorFlags,
1505
+ GCancellable *,
1506
+ GError **);
1507
+
1508
+ static VALUE
1509
+ monitor_method(MonitorMethod method, int argc, VALUE *argv, VALUE self)
1510
+ {
1511
+ VALUE flags, cancellable;
1512
+ GError *error = NULL;
1513
+ GFileMonitor *monitor;
1514
+
1515
+ rb_scan_args(argc, argv, "02", &flags, &cancellable);
1516
+ monitor = method(_SELF(self),
1517
+ RVAL2GFILEMONITORFLAGSDEFAULT(flags),
1518
+ RVAL2GCANCELLABLE(cancellable),
1519
+ &error);
1520
+ if (monitor == NULL)
1521
+ rbgio_raise_error(error);
1522
+
1523
+ return GOBJ2RVAL_UNREF(monitor);
1524
+ }
1525
+
1526
+ static VALUE
1527
+ file_monitor_directory(int argc, VALUE *argv, VALUE self)
1528
+ {
1529
+ return monitor_method(g_file_monitor_directory, argc, argv, self);
1530
+ }
1531
+
1532
+ static VALUE
1533
+ file_monitor_file(int argc, VALUE *argv, VALUE self)
1534
+ {
1535
+ return monitor_method(g_file_monitor_file, argc, argv, self);
1536
+ }
1537
+
1538
+ static VALUE
1539
+ file_monitor(int argc, VALUE *argv, VALUE self)
1540
+ {
1541
+ return monitor_method(g_file_monitor, argc, argv, self);
1542
+ }
1543
+
1544
+ static VALUE
1545
+ file_load_contents(int argc, VALUE *argv, VALUE self)
1546
+ {
1547
+ VALUE cancellable;
1548
+ char *contents;
1549
+ gsize length;
1550
+ char *etag_out;
1551
+ GError *error = NULL;
1552
+
1553
+ rb_scan_args(argc, argv, "01", &cancellable);
1554
+ if (!g_file_load_contents(_SELF(self),
1555
+ RVAL2GCANCELLABLE(cancellable),
1556
+ &contents,
1557
+ &length,
1558
+ &etag_out,
1559
+ &error))
1560
+ rbgio_raise_error(error);
1561
+
1562
+ return rb_assoc_new(CSTR2RVAL_TAINTED_FREE(contents, length),
1563
+ CSTR2RVAL_FREE(etag_out));
1564
+ }
1565
+
1566
+ static VALUE
1567
+ file_load_contents_async(int argc, VALUE *argv, VALUE self)
1568
+ {
1569
+ return cancellable_async_method(g_file_load_contents_async, argc, argv, self);
1570
+ }
1571
+
1572
+ static VALUE
1573
+ file_load_contents_finish(VALUE self, VALUE result)
1574
+ {
1575
+ char *contents;
1576
+ gsize length;
1577
+ char *etag_out;
1578
+ GError *error = NULL;
1579
+
1580
+ if (!g_file_load_contents_finish(_SELF(self),
1581
+ RVAL2GASYNCRESULT(result),
1582
+ &contents,
1583
+ &length,
1584
+ &etag_out,
1585
+ &error))
1586
+ rbgio_raise_error(error);
1587
+
1588
+ return rb_assoc_new(CSTR2RVAL_TAINTED_FREE(contents, length),
1589
+ CSTR2RVAL_FREE(etag_out));
1590
+ }
1591
+
1592
+ struct load_partial_contents_async_read_more_callback_data
1593
+ {
1594
+ const char *file_contents;
1595
+ goffset file_size;
1596
+ gpointer data;
1597
+ };
1598
+
1599
+ static VALUE
1600
+ load_partial_contents_async_read_more_callback_call(VALUE data)
1601
+ {
1602
+ static ID s_id_call;
1603
+ struct load_partial_contents_async_read_more_callback_data *real;
1604
+ VALUE block;
1605
+
1606
+ if (s_id_call == 0)
1607
+ s_id_call = rb_intern("call");
1608
+
1609
+ real = (struct load_partial_contents_async_read_more_callback_data *)data;
1610
+ block = USE_BLOCK_AND_SAVE(real->data);
1611
+ if (NIL_P(block))
1612
+ return Qtrue;
1613
+
1614
+ return rb_funcall(block, s_id_call, 1,
1615
+ CSTR2RVAL_TAINTED(real->file_contents,
1616
+ real->file_size));
1617
+ }
1618
+
1619
+ static gboolean
1620
+ load_partial_contents_async_read_more_callback(const char *file_contents,
1621
+ goffset file_size,
1622
+ gpointer data)
1623
+ {
1624
+ struct load_partial_contents_async_read_more_callback_data real;
1625
+
1626
+ real.file_contents = file_contents;
1627
+ real.file_size = file_size;
1628
+ real.data = data;
1629
+
1630
+ return RVAL2CBOOL(G_PROTECT_CALLBACK(load_partial_contents_async_read_more_callback_call,
1631
+ &real));
1632
+ }
1633
+
1634
+ static VALUE
1635
+ file_load_partial_contents_async(int argc, VALUE *argv, VALUE self)
1636
+ {
1637
+ VALUE rbcancellable, rbuse_read_more_callback, block;
1638
+ GCancellable *cancellable;
1639
+ gboolean use_read_more_callback;
1640
+
1641
+ rb_scan_args(argc, argv, "02&", &rbcancellable, &rbuse_read_more_callback, &block);
1642
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
1643
+ use_read_more_callback = RVAL2CBOOL(rbuse_read_more_callback);
1644
+ SAVE_BLOCK(block);
1645
+ /* TODO: Should we force a block if use_read_more_callback is true? */
1646
+ g_file_load_partial_contents_async(_SELF(self),
1647
+ cancellable,
1648
+ use_read_more_callback ?
1649
+ load_partial_contents_async_read_more_callback :
1650
+ NULL,
1651
+ rbgio_async_ready_callback,
1652
+ (gpointer)block);
1653
+
1654
+ return self;
1655
+ }
1656
+
1657
+ static VALUE
1658
+ file_load_partial_contents_finish(VALUE self, VALUE result)
1659
+ {
1660
+ char *contents;
1661
+ gsize length;
1662
+ char *etag_out;
1663
+ GError *error = NULL;
1664
+
1665
+ if (!g_file_load_partial_contents_finish(_SELF(self),
1666
+ RVAL2GASYNCRESULT(result),
1667
+ &contents,
1668
+ &length,
1669
+ &etag_out,
1670
+ &error))
1671
+ rbgio_raise_error(error);
1672
+
1673
+ return rb_assoc_new(CSTR2RVAL_TAINTED_FREE(contents, length),
1674
+ CSTR2RVAL_FREE(etag_out));
1675
+ }
1676
+
1677
+ static VALUE
1678
+ file_replace_contents(int argc, VALUE *argv, VALUE self)
1679
+ {
1680
+ VALUE rbcontents, etag, make_backup, flags, cancellable;
1681
+ const char *contents;
1682
+ gsize length;
1683
+ char *new_etag;
1684
+ GError *error = NULL;
1685
+
1686
+ rb_scan_args(argc, argv, "14", &rbcontents, &etag, &make_backup, &flags, &cancellable);
1687
+ contents = RVAL2CSTR(rbcontents);
1688
+ length = RSTRING_LEN(rbcontents);
1689
+ if (!g_file_replace_contents(_SELF(self),
1690
+ contents,
1691
+ length,
1692
+ RVAL2CSTR_ACCEPT_NIL(etag),
1693
+ RVAL2CBOOL(make_backup),
1694
+ RVAL2GFILECREATEFLAGSDEFAULT(flags),
1695
+ &new_etag,
1696
+ RVAL2GCANCELLABLE(cancellable),
1697
+ &error))
1698
+ rbgio_raise_error(error);
1699
+
1700
+ return CSTR2RVAL_FREE(new_etag);
1701
+ }
1702
+
1703
+ static VALUE
1704
+ file_replace_contents_async(int argc, VALUE *argv, VALUE self)
1705
+ {
1706
+ VALUE rbcontents, rbetag, rbmake_backup, rbflags, rbcancellable, block;
1707
+ const char *contents;
1708
+ gsize length;
1709
+ const char *etag;
1710
+ gboolean make_backup;
1711
+ GFileCreateFlags flags;
1712
+ GCancellable *cancellable;
1713
+
1714
+ rb_scan_args(argc, argv, "14&", &rbcontents, &rbetag, &rbmake_backup, &rbflags, &rbcancellable, &block);
1715
+ contents = RVAL2CSTR(rbcontents);
1716
+ length = RSTRING_LEN(rbcontents);
1717
+ etag = RVAL2CSTR_ACCEPT_NIL(rbetag);
1718
+ make_backup = RVAL2CBOOL(rbmake_backup);
1719
+ flags = RVAL2GFILECREATEFLAGSDEFAULT(rbflags);
1720
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
1721
+ SAVE_BLOCK(block);
1722
+ g_file_replace_contents_async(_SELF(self),
1723
+ contents,
1724
+ length,
1725
+ etag,
1726
+ make_backup,
1727
+ flags,
1728
+ cancellable,
1729
+ rbgio_async_ready_callback,
1730
+ (gpointer)block);
1731
+
1732
+ return self;
1733
+ }
1734
+
1735
+ static VALUE
1736
+ file_replace_contents_finish(VALUE self, VALUE result)
1737
+ {
1738
+ char *new_etag;
1739
+ GError *error = NULL;
1740
+
1741
+ if (!g_file_replace_contents_finish(_SELF(self),
1742
+ RVAL2GASYNCRESULT(result),
1743
+ &new_etag,
1744
+ &error))
1745
+ rbgio_raise_error(error);
1746
+
1747
+ return CSTR2RVAL_FREE(new_etag);
1748
+ }
1749
+
1750
+ static VALUE
1751
+ file_copy_attributes(int argc, VALUE *argv, VALUE self)
1752
+ {
1753
+ VALUE destination, flags, cancellable;
1754
+ GError *error = NULL;
1755
+
1756
+ rb_scan_args(argc, argv, "12", &destination, &flags, &cancellable);
1757
+ if (!g_file_copy_attributes(_SELF(self),
1758
+ _SELF(destination),
1759
+ RVAL2GFILECOPYFLAGSDEFAULT(flags),
1760
+ RVAL2GCANCELLABLE(cancellable),
1761
+ &error))
1762
+ rbgio_raise_error(error);
1763
+
1764
+ return self;
1765
+ }
1766
+
1767
+ struct file_io_stream_close_data
1768
+ {
1769
+ GCancellable *cancellable;
1770
+ GFileIOStream *stream;
1771
+ };
1772
+
1773
+ static VALUE
1774
+ file_io_stream_close(VALUE data)
1775
+ {
1776
+ struct file_io_stream_close_data *real;
1777
+ GError *error = NULL;
1778
+
1779
+ real = (struct file_io_stream_close_data *)data;
1780
+
1781
+ if (!g_io_stream_close(G_IO_STREAM(real->stream),
1782
+ real->cancellable,
1783
+ &error))
1784
+ rbgio_raise_error(error);
1785
+
1786
+ return Qnil;
1787
+ }
1788
+
1789
+ static VALUE
1790
+ file_create_readwrite(int argc, VALUE *argv, VALUE self)
1791
+ {
1792
+ VALUE flags, cancellable;
1793
+ struct file_io_stream_close_data data;
1794
+ GError *error = NULL;
1795
+
1796
+ rb_scan_args(argc, argv, "02", &flags, &cancellable);
1797
+ data.cancellable = RVAL2GCANCELLABLE(cancellable);
1798
+ data.stream = g_file_create_readwrite(_SELF(self),
1799
+ RVAL2GFILECREATEFLAGSDEFAULT(flags),
1800
+ data.cancellable,
1801
+ &error);
1802
+ if (data.stream == NULL)
1803
+ rbgio_raise_error(error);
1804
+
1805
+ if (!rb_block_given_p())
1806
+ return GOBJ2RVAL_UNREF(data.stream);
1807
+
1808
+ return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream),
1809
+ file_io_stream_close, (VALUE)&data);
1810
+ }
1811
+
1812
+ static VALUE
1813
+ file_create_readwrite_async(int argc, VALUE *argv, VALUE self)
1814
+ {
1815
+ return create_async_method(g_file_create_readwrite_async, argc, argv, self);
1816
+ }
1817
+
1818
+ typedef GFileIOStream *(*ReadwriteFinishMethod)(GFile *, GAsyncResult *, GError **);
1819
+
1820
+ static VALUE
1821
+ readwrite_finish_method(ReadwriteFinishMethod method, VALUE self, VALUE result)
1822
+ {
1823
+ GError *error = NULL;
1824
+
1825
+ GFileIOStream *stream = method(_SELF(self), RVAL2GASYNCRESULT(result), &error);
1826
+ if (stream == NULL)
1827
+ rbgio_raise_error(error);
1828
+
1829
+ return GOBJ2RVAL_UNREF(stream);
1830
+ }
1831
+
1832
+ static VALUE
1833
+ file_create_readwrite_finish(VALUE self, VALUE result)
1834
+ {
1835
+ return readwrite_finish_method(g_file_create_readwrite_finish, self, result);
1836
+ }
1837
+
1838
+ static VALUE
1839
+ file_open_readwrite(int argc, VALUE *argv, VALUE self)
1840
+ {
1841
+ VALUE cancellable;
1842
+ struct file_io_stream_close_data data;
1843
+ GError *error = NULL;
1844
+
1845
+ rb_scan_args(argc, argv, "01", &cancellable);
1846
+ data.cancellable = RVAL2GCANCELLABLE(cancellable);
1847
+ data.stream = g_file_open_readwrite(_SELF(self),
1848
+ data.cancellable,
1849
+ &error);
1850
+ if (data.stream == NULL)
1851
+ rbgio_raise_error(error);
1852
+
1853
+ if (!rb_block_given_p())
1854
+ return GOBJ2RVAL_UNREF(data.stream);
1855
+
1856
+ return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream),
1857
+ file_io_stream_close, (VALUE)&data);
1858
+ }
1859
+
1860
+ static VALUE
1861
+ file_open_readwrite_async(int argc, VALUE *argv, VALUE self)
1862
+ {
1863
+ VALUE rbio_priority, rbcancellable, block;
1864
+ int io_priority;
1865
+ GCancellable *cancellable;
1866
+
1867
+ rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
1868
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
1869
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
1870
+ SAVE_BLOCK(block);
1871
+ g_file_open_readwrite_async(_SELF(self), io_priority, cancellable,
1872
+ rbgio_async_ready_callback, (gpointer)block);
1873
+
1874
+ return self;
1875
+ }
1876
+
1877
+ static VALUE
1878
+ file_open_readwrite_finish(VALUE self, VALUE result)
1879
+ {
1880
+ return readwrite_finish_method(g_file_open_readwrite_finish, self, result);
1881
+ }
1882
+
1883
+ static VALUE
1884
+ file_replace_readwrite(int argc, VALUE *argv, VALUE self)
1885
+ {
1886
+ VALUE etag, make_backup, flags, cancellable;
1887
+ struct file_io_stream_close_data data;
1888
+ GError *error = NULL;
1889
+
1890
+ rb_scan_args(argc, argv, "04", &etag, &make_backup, &flags, &cancellable);
1891
+ data.cancellable = RVAL2GCANCELLABLE(cancellable);
1892
+ data.stream = g_file_replace_readwrite(_SELF(self),
1893
+ RVAL2CSTR_ACCEPT_NIL(etag),
1894
+ RVAL2CBOOL(make_backup),
1895
+ RVAL2GFILECREATEFLAGSDEFAULT(flags),
1896
+ data.cancellable,
1897
+ &error);
1898
+ if (data.stream == NULL)
1899
+ rbgio_raise_error(error);
1900
+
1901
+ if (!rb_block_given_p())
1902
+ return GOBJ2RVAL_UNREF(data.stream);
1903
+
1904
+ return rb_ensure(rb_yield, GOBJ2RVAL_UNREF(data.stream),
1905
+ file_io_stream_close, (VALUE)&data);
1906
+ }
1907
+
1908
+ static VALUE
1909
+ file_replace_readwrite_async(int argc, VALUE *argv, VALUE self)
1910
+ {
1911
+ return replace_async_method(g_file_replace_readwrite_async, argc, argv, self);
1912
+ }
1913
+
1914
+ static VALUE
1915
+ file_replace_readwrite_finish(VALUE self, VALUE result)
1916
+ {
1917
+ return readwrite_finish_method(g_file_replace_readwrite_finish, self, result);
1918
+ }
1919
+
1920
+ static VALUE
1921
+ file_supports_thread_contexts(VALUE self)
1922
+ {
1923
+ return CBOOL2RVAL(g_file_supports_thread_contexts(_SELF(self)));
1924
+ }
1925
+
1926
+ void
1927
+ Init_gfile(VALUE glib)
1928
+ {
1929
+ VALUE file = G_DEF_INTERFACE(G_TYPE_FILE, "File", glib);
1930
+
1931
+ G_DEF_CLASS(G_TYPE_FILE_QUERY_INFO_FLAGS, "QueryInfoFlags", file);
1932
+ G_DEF_CONSTANTS(file, G_TYPE_FILE_QUERY_INFO_FLAGS, "G_FILE_");
1933
+
1934
+ G_DEF_CLASS(G_TYPE_FILE_CREATE_FLAGS, "CreateFlags", file);
1935
+ G_DEF_CONSTANTS(file, G_TYPE_FILE_CREATE_FLAGS, "G_FILE_");
1936
+
1937
+ G_DEF_CLASS(G_TYPE_FILE_COPY_FLAGS, "CopyFlags", file);
1938
+ G_DEF_CONSTANTS(file, G_TYPE_FILE_COPY_FLAGS, "G_FILE_");
1939
+
1940
+ G_DEF_CLASS(G_TYPE_FILE_MONITOR_FLAGS, "MonitorFlags", file);
1941
+ G_DEF_CONSTANTS(file, G_TYPE_FILE_MONITOR_FLAGS, "G_FILE_");
1942
+
1943
+ G_DEF_CLASS(G_TYPE_FILESYSTEM_PREVIEW_TYPE, "FilesystemPreviewType", glib);
1944
+ G_DEF_CONSTANTS(glib, G_TYPE_FILESYSTEM_PREVIEW_TYPE, "G_");
1945
+
1946
+ rb_define_singleton_method(file, "new_for_path", file_new_for_path, 1);
1947
+ rb_define_singleton_method(file, "new_for_uri", file_new_for_uri, 1);
1948
+ rb_define_singleton_method(file, "new_for_commandline_arg", file_new_for_commandline_arg, 1);
1949
+ rb_define_singleton_method(file, "parse_name", file_parse_name, 1);
1950
+
1951
+ rb_define_method(file, "dup", file_dup, 0);
1952
+ rb_define_method(file, "hash", file_hash, 0);
1953
+ rb_define_method(file, "==", file_equal, 1);
1954
+ rb_define_method(file, "basename", file_get_basename, 0);
1955
+ rb_define_method(file, "path", file_get_path, 0);
1956
+ rb_define_method(file, "uri", file_get_uri, 0);
1957
+ rb_define_method(file, "parse_name", file_get_parse_name, 0);
1958
+ rb_define_method(file, "parent", file_get_parent, 0);
1959
+ rb_define_method(file, "has_parent?", file_has_parent, -1);
1960
+ rb_define_method(file, "get_child", file_get_child, 1);
1961
+ rb_define_method(file, "get_child_for_display_name", file_get_child_for_display_name, 1);
1962
+ rb_define_method(file, "has_prefix?", file_has_prefix, 1);
1963
+ rb_define_method(file, "get_relative_path", file_get_relative_path, 1);
1964
+ rb_define_method(file, "resolve_relative_path", file_resolve_relative_path, 1);
1965
+ rb_define_method(file, "native?", file_is_native, 0);
1966
+ rb_define_method(file, "has_uri_scheme?", file_has_uri_scheme, 1);
1967
+ rb_define_method(file, "uri_scheme", file_get_uri_scheme, 0);
1968
+ rb_define_method(file, "read", file_read, -1);
1969
+ rb_define_method(file, "read_async", file_read_async, -1);
1970
+ rb_define_method(file, "read_finish", file_read_finish, 1);
1971
+ rb_define_method(file, "append_to", file_append_to, -1);
1972
+ rb_define_method(file, "create", file_create, -1);
1973
+ rb_define_method(file, "replace", file_replace, -1);
1974
+ rb_define_method(file, "append_to_async", file_append_to_async, -1);
1975
+ rb_define_method(file, "append_to_finish", file_append_to_finish, 1);
1976
+ rb_define_method(file, "create_async", file_create_async, -1);
1977
+ rb_define_method(file, "create_finish", file_create_finish, 1);
1978
+ rb_define_method(file, "replace_async", file_replace_async, -1);
1979
+ rb_define_method(file, "replace_finish", file_replace_finish, 1);
1980
+ rb_define_method(file, "query_info", file_query_info, -1);
1981
+ rb_define_method(file, "query_info_async", file_query_info_async, -1);
1982
+ rb_define_method(file, "query_info_finish", file_query_info_finish, 1);
1983
+ rb_define_method(file, "query_exists?", file_query_exists, -1);
1984
+ rb_define_alias(file, "exists?", "query_exists?");
1985
+ rb_define_method(file, "query_file_type", file_query_file_type, -1);
1986
+ rb_define_method(file, "query_filesystem_info", file_query_filesystem_info, -1);
1987
+ rb_define_method(file, "query_filesystem_info_async", file_query_filesystem_info_async, -1);
1988
+ rb_define_method(file, "query_filesystem_info_finish", file_query_filesystem_info_finish, 1);
1989
+ rb_define_method(file, "query_default_handler", file_query_default_handler, -1);
1990
+ rb_define_method(file, "find_enclosing_mount", file_find_enclosing_mount, -1);
1991
+ rb_define_method(file, "find_enclosing_mount_async", file_find_enclosing_mount_async, -1);
1992
+ rb_define_method(file, "find_enclosing_mount_finish", file_find_enclosing_mount_finish, 1);
1993
+ rb_define_method(file, "enumerate_children", file_enumerate_children, -1);
1994
+ rb_define_method(file, "enumerate_children_async", file_enumerate_children_async, -1);
1995
+ rb_define_method(file, "enumerate_children_finish", file_enumerate_children_finish, 1);
1996
+ rb_define_method(file, "set_display_name", file_set_display_name, -1);
1997
+ G_DEF_SETTER(file, "display_name");
1998
+ rb_define_method(file, "set_display_name_async", file_set_display_name_async, -1);
1999
+ rb_define_method(file, "set_display_name_finish", file_set_display_name_finish, 1);
2000
+ rb_define_method(file, "delete", file_delete, -1);
2001
+ rb_define_method(file, "trash", file_trash, -1);
2002
+ rb_define_method(file, "copy", file_copy, -1);
2003
+ rb_define_method(file, "copy_async", file_copy_async, -1);
2004
+ rb_define_method(file, "copy_finish", file_copy_finish, 1);
2005
+ rb_define_method(file, "move", file_move, -1);
2006
+ rb_define_method(file, "make_directory", file_make_directory, -1);
2007
+ rb_define_method(file, "make_directory_with_parents", file_make_directory_with_parents, -1);
2008
+ rb_define_method(file, "make_symbolic_link", file_make_symbolic_link, -1);
2009
+ rb_define_method(file, "query_settable_attributes", file_query_settable_attributes, -1);
2010
+ rb_define_method(file, "query_writable_namespaces", file_query_writable_namespaces, -1);
2011
+ rb_define_method(file, "set_attribute", file_set_attribute, -1);
2012
+ rb_define_method(file, "set_attributes_from_info", file_set_attributes_from_info, -1);
2013
+ G_DEF_SETTER(file, "attributes_from_info");
2014
+ rb_define_method(file, "set_attributes_async", file_set_attributes_async, -1);
2015
+ rb_define_method(file, "set_attributes_finish", file_set_attributes_finish, 1);
2016
+ rb_define_method(file, "set_attribute_string", file_set_attribute_string, -1);
2017
+ rb_define_method(file, "set_attribute_byte_string", file_set_attribute_byte_string, -1);
2018
+ rb_define_method(file, "set_attribute_uint32", file_set_attribute_uint32, -1);
2019
+ rb_define_method(file, "set_attribute_int32", file_set_attribute_int32, -1);
2020
+ rb_define_method(file, "set_attribute_uint64", file_set_attribute_uint64, -1);
2021
+ rb_define_method(file, "set_attribute_int64", file_set_attribute_int64, -1);
2022
+ rb_define_method(file, "mount_mountable", file_mount_mountable, -1);
2023
+ rb_define_method(file, "mount_mountable_finish", file_mount_mountable_finish, 1);
2024
+ rb_define_method(file, "unmount_mountable_with_operation", file_unmount_mountable_with_operation, -1);
2025
+ rb_define_method(file, "unmount_mountable_with_operation_finish", file_unmount_mountable_with_operation_finish, 1);
2026
+ rb_define_method(file, "eject_mountable_with_operation", file_eject_mountable_with_operation, -1);
2027
+ rb_define_method(file, "eject_mountable_with_operation_finish", file_eject_mountable_with_operation_finish, 1);
2028
+ rb_define_method(file, "start_mountable", file_start_mountable, -1);
2029
+ rb_define_method(file, "start_mountable_finish", file_start_mountable_finish, 1);
2030
+ rb_define_method(file, "stop_mountable", file_stop_mountable, -1);
2031
+ rb_define_method(file, "stop_mountable_finish", file_stop_mountable_finish, 1);
2032
+ rb_define_method(file, "poll_mountable", file_poll_mountable, -1);
2033
+ rb_define_method(file, "poll_mountable_finish", file_poll_mountable_finish, 1);
2034
+ rb_define_method(file, "mount_enclosing_volume", file_mount_enclosing_volume, -1);
2035
+ rb_define_method(file, "mount_enclosing_volume_finish", file_mount_enclosing_volume_finish, 1);
2036
+ rb_define_method(file, "monitor_directory", file_monitor_directory, -1);
2037
+ rb_define_method(file, "monitor_file", file_monitor_file, -1);
2038
+ rb_define_method(file, "monitor", file_monitor, -1);
2039
+ rb_define_method(file, "load_contents", file_load_contents, -1);
2040
+ rb_define_method(file, "load_contents_async", file_load_contents_async, -1);
2041
+ rb_define_method(file, "load_contents_finish", file_load_contents_finish, 1);
2042
+ rb_define_method(file, "load_partial_contents_async", file_load_partial_contents_async, -1);
2043
+ rb_define_method(file, "load_partial_contents_finish", file_load_partial_contents_finish, 1);
2044
+ rb_define_method(file, "replace_contents", file_replace_contents, -1);
2045
+ rb_define_method(file, "replace_contents_async", file_replace_contents_async, -1);
2046
+ rb_define_method(file, "replace_contents_finish", file_replace_contents_finish, 1);
2047
+ rb_define_method(file, "copy_attributes", file_copy_attributes, -1);
2048
+ rb_define_method(file, "create_readwrite", file_create_readwrite, -1);
2049
+ rb_define_method(file, "create_readwrite_async", file_create_readwrite_async, -1);
2050
+ rb_define_method(file, "create_readwrite_finish", file_create_readwrite_finish, 1);
2051
+ rb_define_method(file, "open_readwrite", file_open_readwrite, -1);
2052
+ rb_define_method(file, "open_readwrite_async", file_open_readwrite_async, -1);
2053
+ rb_define_method(file, "open_readwrite_finish", file_open_readwrite_finish, 1);
2054
+ rb_define_method(file, "replace_readwrite", file_replace_readwrite, -1);
2055
+ rb_define_method(file, "replace_readwrite_async", file_replace_readwrite_async, -1);
2056
+ rb_define_method(file, "replace_readwrite_finish", file_replace_readwrite_finish, 1);
2057
+ rb_define_method(file, "supports_thread_contexts?", file_supports_thread_contexts, 0);
2058
+ }