Class: RbPod::Track

Inherits:
Object
  • Object
show all
Defined in:
ext/rbpod/track.c

Instance Method Summary collapse

Constructor Details

#initialize(source = nil) ⇒ RbPod::Track

Creates a detached track. (Not managed by a database.)



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'ext/rbpod/track.c', line 209

static VALUE rbpod_track_initialize(int argc, VALUE *argv, VALUE self)
{
    Itdb_Track *track = TYPED_DATA_PTR(self, Itdb_Track);
    gchar *buffer = NULL;
    VALUE source = Qnil;

    if (rb_scan_args(argc, argv, "01", &source) == 1) {
        buffer = StringValueCStr(source);

        if (g_file_test(buffer, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_SYMLINK) == FALSE) {
            rb_raise(eRbPodError, "Invalid Argument: Source must be a path to an existing file.");
            return Qnil;
        }

        track->userdata = buffer;
    }

    return self;
}