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