ext/CdIo_Common.c in rb_cdio-0.1.0 vs ext/CdIo_Common.c in rb_cdio-0.1.1
- old
+ new
@@ -65,20 +65,64 @@
}
#undef CAP
-VALUE get_cdtext(const cdtext_t *cdtext) {
- if(NULL==cdtext) {
- return Qnil;
+VALUE
+get_cdtext(const cdtext_t * cdtext)
+{
+ if (NULL == cdtext) {
+ return Qnil;
} else {
- VALUE ret;
- ret=rb_hash_new();
- int i;
- for (i=0;i < MAX_CDTEXT_FIELDS;i++) {
- if(cdtext->field[i]) {
- rb_hash_aset(ret,rb_str_new2(cdtext_field2str(i)), rb_str_new2(cdtext->field[i]));
- }
- }
- return ret;
+ VALUE ret;
+ ret = rb_hash_new();
+ int i;
+ for (i = 0; i < MAX_CDTEXT_FIELDS; i++) {
+ if (cdtext->field[i]) {
+ rb_hash_aset(ret, rb_str_new2(cdtext_field2str(i)),
+ rb_str_new2(cdtext->field[i]));
+ }
+ }
+ return ret;
}
+}
+
+/**
+* true if track is iso
+*/
+bool
+_cdio_cd_is_iso(CdIo * p_cdio, track_t track)
+{
+ cdio_fs_anal_t fs;
+ cdio_iso_analysis_t iso_analysis;
+ fs = cdio_guess_cd_type(p_cdio, 0, track, &iso_analysis);
+ switch (CDIO_FSTYPE(fs)) {
+ case CDIO_FS_ISO_9660:
+ case CDIO_FS_ISO_9660_INTERACTIVE:
+ case CDIO_FS_ISO_HFS:
+ case CDIO_FS_ISO_UDF:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/**
+ * Returns an object CdIo::Track or a subclass, with an object CdIo::Cd and
+ * a track number
+ * @param CdIo::Cd object
+ * @param track
+ * @return CdIo::Track
+ */
+
+VALUE
+get_track(VALUE obj, track_t i)
+{
+ GET_CDIO(obj, p_cdio);
+ VALUE track;
+ if (_cdio_cd_is_iso(p_cdio, i)) {
+ track = rb_cdio_trackiso9660_new(obj, i);
+ } else {
+ track = rb_cdio_track_new(obj, i);
+ }
+ return track;
}