147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'ext/easy_crc/easy_crc.c', line 147
static VALUE
easy_crc_crc32(VALUE self, VALUE path, VALUE seed)
{
easy_crc32_params params;
VALUE vparams;
if(TYPE(path) != T_STRING)
rb_raise(rb_eTypeError, "invalid type for path name");
if(TYPE(seed) != T_FIXNUM)
rb_raise(rb_eTypeError, "invalid type for seed");
params.path = StringValueCStr(path);
params.fd = NULL;
if(seed == Qnil)
params.crc = 0;
else
params.crc = FIX2LONG(seed);
params.error = 0;
params.stop = false;
vparams = Data_Wrap_Struct(0, 0, 0, ¶ms);
rb_ensure(easy_crc_crc32_start, vparams, easy_crc_crc32_cleanup, vparams);
if(params.error == 1)
rb_raise(rb_eIOError, "failed to open file");
if(params.error == 2)
rb_raise(rb_eThreadError, "thread stopped");
if(params.error == 3)
rb_raise(rb_eIOError, "failed to read from file");
return INT2FIX(params.crc);
}
|