예제 #1
0
/*!
   Reads a single mode1 form1 or form2  sector from cd device 
   into data starting from lsn. Returns 0 if no error. 
 */
int
cdio_read_mode1_sector (const CdIo *cdio, void *data, lsn_t lsn, bool is_form2)
{
  uint32_t size = is_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ;
  char buf[M2RAW_SECTOR_SIZE] = { 0, };
  int ret;
  
  cdio_assert (cdio != NULL);
  cdio_assert (data != NULL);

  if (cdio->op.lseek && cdio->op.read) {
    if (0 > cdio_lseek(cdio, CDIO_CD_FRAMESIZE*lsn, SEEK_SET))
      return -1;
    if (0 > cdio_read(cdio, buf, CDIO_CD_FRAMESIZE))
      return -1;
    memcpy (data, buf, size);
    return 0;
  } else {
    ret = cdio_read_mode2_sector(cdio, data, lsn, is_form2);
    if (ret == 0) 
      memcpy (data, buf+CDIO_CD_SUBHEADER_SIZE, size);
  }
  return ret;

}
예제 #2
0
파일: read.c 프로젝트: ngocphu811/rufus
/*!
   Reads a single mode1 form1 or form2  sector from cd device
   into data starting from lsn. Returns DRIVER_OP_SUCCESS if no error.
 */
driver_return_code_t
cdio_read_mode1_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,
                        bool b_form2)
{
    uint32_t size = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ;

    check_lsn(i_lsn);
    if (p_cdio->op.read_mode1_sector) {
        return p_cdio->op.read_mode1_sector(p_cdio->env, p_buf, i_lsn, b_form2);
    } else if (p_cdio->op.lseek && p_cdio->op.read) {
        char buf[M2RAW_SECTOR_SIZE] = { 0, };
        if (0 > cdio_lseek(p_cdio, CDIO_CD_FRAMESIZE*i_lsn, SEEK_SET))
            return -1;
        if (0 > cdio_read(p_cdio, buf, CDIO_CD_FRAMESIZE))
            return -1;
        memcpy (p_buf, buf, size);
        return DRIVER_OP_SUCCESS;
    }

    return DRIVER_OP_UNSUPPORTED;
}
예제 #3
0
파일: read.hpp 프로젝트: 3aychonok/libcdio
off_t lseek(off_t offset, int whence) 
{
  return cdio_lseek(p_cdio, offset, whence);
}