static int CDDAReader_init(cdio_CDDAReader *self, PyObject *args, PyObject *kwds) { char *device = NULL; struct stat buf; self->is_cd_image = 0; self->is_logging = 0; self->dealloc = NULL; self->closed = 0; self->audiotools_pcm = NULL; cddareader_reset_log(&(self->log)); if (!PyArg_ParseTuple(args, "s|i", &device, &(self->is_logging))) return -1; if ((self->audiotools_pcm = open_audiotools_pcm()) == NULL) return -1; /*identify whether drive is physical or a CD image*/ if (stat(device, &buf)) { PyErr_SetFromErrno(PyExc_IOError); return -1; } if (S_ISREG(buf.st_mode)) { if (cdio_is_cuefile(device) || cdio_is_binfile(device) || cdio_is_tocfile(device) || cdio_is_nrg(device)) { /*open CD image and set function pointers*/ self->is_cd_image = 1; self->is_logging = 0; return CDDAReader_init_image(self, device); } else { /*unsupported file*/ PyErr_SetString(PyExc_ValueError, "unsupported CD image type"); return -1; } } else if (S_ISBLK(buf.st_mode)) { if (cdio_is_device(device, DRIVER_LINUX)) { /*open CD device and set function pointers*/ self->is_cd_image = 0; return CDDAReader_init_device(self, device); } else { /*unsupported block device*/ PyErr_SetString(PyExc_ValueError, "unsupported block device"); return -1; } } else { /*unsupported file type*/ PyErr_SetString(PyExc_ValueError, "unsupported file type"); return -1; } }
static PyObject* cdio_identify_cdrom(PyObject *dummy, PyObject *args) { const char* device; struct stat buf; if (!PyArg_ParseTuple(args, "s", &device)) return NULL; if (stat(device, &buf)) { PyErr_SetFromErrno(PyExc_IOError); return NULL; } if (S_ISREG(buf.st_mode)) { if (cdio_is_cuefile(device)) { return Py_BuildValue("i", CD_IMAGE | CUE_FILE); } else if (cdio_is_binfile(device)) { return Py_BuildValue("i", CD_IMAGE | BIN_FILE); } else if (cdio_is_tocfile(device)) { return Py_BuildValue("i", CD_IMAGE | TOC_FILE); } else if (cdio_is_nrg(device)) { return Py_BuildValue("i", CD_IMAGE | NRG_FILE); } else { PyErr_SetString(PyExc_ValueError, "unknown image file"); return NULL; } } else if (S_ISBLK(buf.st_mode)) { if (cdio_is_device(device, DRIVER_LINUX)) { return Py_BuildValue("i", DEVICE_FILE); } else { PyErr_SetString(PyExc_ValueError, "unknown CD device"); return NULL; } } else { PyErr_SetString(PyExc_ValueError, "unknown device"); return NULL; } }
/*! Determine if bin_name is the bin file part of a CDRWIN CD disk image. @param bin_name location of presumed CDRWIN bin image file. @return the corresponding CUE file if bin_name is a BIN file or NULL if not a BIN file. */ char *isBinFile(const char *psz_bin_name) { return cdio_is_binfile(psz_bin_name); }