First commit after CVS conversion. Should be just administrative changes.
This commit is contained in:
2
include/cdio++/.cvsignore
Normal file
2
include/cdio++/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
2
include/cdio++/.gitignore
vendored
Normal file
2
include/cdio++/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
34
include/cdio++/Makefile.am
Normal file
34
include/cdio++/Makefile.am
Normal file
@@ -0,0 +1,34 @@
|
||||
# $Id: Makefile.am,v 1.5 2008/03/20 19:02:38 karl Exp $
|
||||
#
|
||||
# Copyright (C) 2005, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
########################################################
|
||||
# Things to make the install (public) libcdio++ headers
|
||||
########################################################
|
||||
#
|
||||
|
||||
libcdioincludedir=$(includedir)/cdio++
|
||||
libcdioinclude_HEADERS = \
|
||||
cdio.hpp \
|
||||
cdtext.hpp \
|
||||
device.hpp \
|
||||
devices.hpp \
|
||||
disc.hpp \
|
||||
enum.hpp \
|
||||
iso9660.hpp \
|
||||
mmc.hpp \
|
||||
read.hpp \
|
||||
track.hpp
|
||||
181
include/cdio++/cdio.hpp
Normal file
181
include/cdio++/cdio.hpp
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
$Id: cdio.hpp,v 1.13 2008/03/25 15:59:10 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file cdio.hpp
|
||||
*
|
||||
* \brief C++ class for libcdio: the CD Input and Control
|
||||
* library. Applications use this for anything regarding libcdio.
|
||||
*/
|
||||
|
||||
#ifndef __CDIO_HPP__
|
||||
#define __CDIO_HPP__
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/audio.h>
|
||||
#include <cdio/dvd.h>
|
||||
#include <cdio/mmc.h>
|
||||
|
||||
// Make pre- and post-increment operators for enums in libcdio where it
|
||||
// makes sense.
|
||||
#include <cdio++/enum.hpp>
|
||||
|
||||
/** Class for driver exceptions. **/
|
||||
class DriverOpException
|
||||
{
|
||||
public:
|
||||
driver_return_code_t driver_return_code;
|
||||
DriverOpException( void ) { };
|
||||
DriverOpException( driver_return_code_t drc ) {
|
||||
driver_return_code = drc;
|
||||
};
|
||||
driver_return_code_t get_code(void) {
|
||||
return driver_return_code;
|
||||
};
|
||||
const char *get_msg(void) {
|
||||
return cdio_driver_errmsg(driver_return_code);
|
||||
};
|
||||
};
|
||||
|
||||
class DriverOpError: public DriverOpException
|
||||
{
|
||||
public:
|
||||
DriverOpError(void) { driver_return_code = DRIVER_OP_ERROR; }
|
||||
};
|
||||
|
||||
class DriverOpUnsupported: public DriverOpException
|
||||
{
|
||||
public:
|
||||
DriverOpUnsupported(void) { driver_return_code = DRIVER_OP_UNSUPPORTED; }
|
||||
};
|
||||
|
||||
class DriverOpUninit: public DriverOpException
|
||||
{
|
||||
public:
|
||||
DriverOpUninit(void) { driver_return_code = DRIVER_OP_UNINIT; }
|
||||
};
|
||||
|
||||
class DriverOpNotPermitted: public DriverOpException
|
||||
{
|
||||
public:
|
||||
DriverOpNotPermitted(void) {driver_return_code = DRIVER_OP_NOT_PERMITTED;}
|
||||
};
|
||||
|
||||
class DriverOpBadParameter: public DriverOpException
|
||||
{
|
||||
public:
|
||||
DriverOpBadParameter(void) {driver_return_code = DRIVER_OP_BAD_PARAMETER;}
|
||||
};
|
||||
|
||||
class DriverOpBadPointer: public DriverOpException
|
||||
{
|
||||
public:
|
||||
DriverOpBadPointer(void) {driver_return_code = DRIVER_OP_BAD_POINTER;}
|
||||
};
|
||||
|
||||
class DriverOpNoDriver: public DriverOpException
|
||||
{
|
||||
public:
|
||||
DriverOpNoDriver(void) {driver_return_code = DRIVER_OP_NO_DRIVER;}
|
||||
};
|
||||
|
||||
void possible_throw_device_exception(driver_return_code_t drc);
|
||||
|
||||
/** A class relating to CD-Text. Use invalid track number 0 to specify
|
||||
CD-Text for the CD (as opposed to a specific track).
|
||||
*/
|
||||
class CdioCDText
|
||||
{
|
||||
public:
|
||||
CdioCDText(cdtext_t *p)
|
||||
{
|
||||
p_cdtext = p;
|
||||
cdtext_init(p); // make sure we're initialized on the C side
|
||||
}
|
||||
|
||||
~CdioCDText()
|
||||
{
|
||||
cdtext_destroy(p_cdtext);
|
||||
p_cdtext = (cdtext_t *) NULL;
|
||||
}
|
||||
|
||||
// Other member functions
|
||||
#include "cdtext.hpp"
|
||||
|
||||
private:
|
||||
cdtext_t *p_cdtext;
|
||||
};
|
||||
|
||||
/** A class relating to tracks. A track object basically saves device
|
||||
and track number information so that in track operations these
|
||||
don't have be specified.
|
||||
*/
|
||||
class CdioTrack
|
||||
{
|
||||
|
||||
public:
|
||||
CdioTrack(CdIo_t *p, track_t t)
|
||||
{
|
||||
i_track = t;
|
||||
p_cdio = p;
|
||||
}
|
||||
|
||||
// Other member functions
|
||||
#include "track.hpp"
|
||||
|
||||
private:
|
||||
track_t i_track;
|
||||
CdIo_t *p_cdio;
|
||||
};
|
||||
|
||||
/** A class relating to a CD-ROM device or pseudo CD-ROM device with
|
||||
has a particular CD image. A device basically saves the libcdio
|
||||
"object" (of type CdIo *).
|
||||
*/
|
||||
class CdioDevice
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
CdIo_t *p_cdio;
|
||||
|
||||
public:
|
||||
|
||||
CdioDevice()
|
||||
{
|
||||
p_cdio = (CdIo_t *) NULL;
|
||||
};
|
||||
|
||||
~CdioDevice()
|
||||
{
|
||||
cdio_destroy(p_cdio);
|
||||
p_cdio = (CdIo_t *) NULL;
|
||||
};
|
||||
|
||||
// Other member functions
|
||||
#include "device.hpp"
|
||||
#include "disc.hpp"
|
||||
#include "mmc.hpp"
|
||||
#include "read.hpp"
|
||||
|
||||
};
|
||||
|
||||
/* Things related to devices. No class or object is needed. */
|
||||
#include "devices.hpp"
|
||||
|
||||
#endif /* __CDIO_HPP__ */
|
||||
90
include/cdio++/cdtext.hpp
Normal file
90
include/cdio++/cdtext.hpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
$Id: cdtext.hpp,v 1.2 2008/03/25 15:59:10 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file cdtext.hpp
|
||||
* \brief methods relating to CD-Text information. This file
|
||||
* should not be #included directly.
|
||||
*/
|
||||
|
||||
/*! Return string representation of the enum values above */
|
||||
const char *field2str (cdtext_field_t i)
|
||||
{
|
||||
return cdtext_field2str (i);
|
||||
}
|
||||
|
||||
/*! returns an allocated string associated with the given field. NULL is
|
||||
returned if key is CDTEXT_INVALID or the field is not set.
|
||||
|
||||
The user needs to free the string when done with it.
|
||||
|
||||
@see getConst to retrieve a constant string that doesn't
|
||||
have to be freed.
|
||||
|
||||
*/
|
||||
char *get (cdtext_field_t key)
|
||||
{
|
||||
return cdtext_get (key, p_cdtext);
|
||||
}
|
||||
|
||||
/*! returns the C cdtext_t pointer associated with this object. */
|
||||
cdtext_t *get ()
|
||||
{
|
||||
return p_cdtext;
|
||||
}
|
||||
|
||||
/*! returns a const string associated with the given field. NULL is
|
||||
returned if key is CDTEXT_INVALID or the field is not set.
|
||||
|
||||
Don't use the string when the cdtext object (i.e. the CdIo_t object
|
||||
you got it from) is no longer valid.
|
||||
|
||||
@see cdio_get to retrieve an allocated string that persists past the
|
||||
cdtext object.
|
||||
|
||||
*/
|
||||
const char *getConst (cdtext_field_t key)
|
||||
{
|
||||
return cdtext_get_const (key, p_cdtext);
|
||||
}
|
||||
|
||||
/*!
|
||||
returns enum of keyword if key is a CD-Text keyword,
|
||||
returns MAX_CDTEXT_FIELDS non-zero otherwise.
|
||||
*/
|
||||
cdtext_field_t isKeyword (const char *key)
|
||||
{
|
||||
return cdtext_is_keyword (key);
|
||||
}
|
||||
|
||||
/*!
|
||||
sets cdtext's keyword entry to field
|
||||
*/
|
||||
void set (cdtext_field_t key, const char *value)
|
||||
{
|
||||
cdtext_set (key, value, p_cdtext);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-file-style: "gnu"
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
261
include/cdio++/device.hpp
Normal file
261
include/cdio++/device.hpp
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
$Id: device.hpp,v 1.7 2008/03/25 15:59:10 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file device.hpp
|
||||
*
|
||||
* \brief C++ header for driver- or device-related libcdio calls.
|
||||
* ("device" includes CD-image reading devices.)
|
||||
*/
|
||||
|
||||
/*!
|
||||
Free resources associated with CD-ROM Device/Image. After this we
|
||||
must do another open before any more reading.
|
||||
*/
|
||||
bool
|
||||
close()
|
||||
{
|
||||
cdio_destroy(p_cdio);
|
||||
p_cdio = (CdIo_t *) NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Eject media in CD drive if there is a routine to do so.
|
||||
|
||||
If the CD is ejected, object is destroyed.
|
||||
*/
|
||||
void
|
||||
ejectMedia ()
|
||||
{
|
||||
driver_return_code_t drc = cdio_eject_media(&p_cdio);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Free device list returned by GetDevices
|
||||
|
||||
@param device_list list returned by GetDevices
|
||||
|
||||
@see GetDevices
|
||||
|
||||
*/
|
||||
void
|
||||
freeDeviceList (char * device_list[])
|
||||
{
|
||||
cdio_free_device_list(device_list);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the value associatied with key.
|
||||
|
||||
@param key the key to retrieve
|
||||
@return the value associatd with "key" or NULL if p_cdio is NULL
|
||||
or "key" does not exist.
|
||||
*/
|
||||
const char *
|
||||
getArg (const char key[])
|
||||
{
|
||||
return cdio_get_arg (p_cdio, key);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return an opaque CdIo_t pointer for the given track object.
|
||||
*/
|
||||
CdIo_t *getCdIo()
|
||||
{
|
||||
return p_cdio;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return an opaque CdIo_t pointer for the given track object.
|
||||
*/
|
||||
cdtext_t *getCdtext(track_t i_track)
|
||||
{
|
||||
return cdio_get_cdtext (p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the CD device name for the object.
|
||||
|
||||
@return a string containing the CD device for this object or NULL is
|
||||
if we couldn't get a device anme.
|
||||
|
||||
In some situations of drivers or OS's we can't find a CD device if
|
||||
there is no media in it and it is possible for this routine to return
|
||||
NULL even though there may be a hardware CD-ROM.
|
||||
*/
|
||||
char *
|
||||
getDevice ()
|
||||
{
|
||||
return cdio_get_default_device(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the what kind of device we've got.
|
||||
|
||||
@param p_read_cap pointer to return read capabilities
|
||||
@param p_write_cap pointer to return write capabilities
|
||||
@param p_misc_cap pointer to return miscellaneous other capabilities
|
||||
|
||||
In some situations of drivers or OS's we can't find a CD device if
|
||||
there is no media in it and it is possible for this routine to return
|
||||
NULL even though there may be a hardware CD-ROM.
|
||||
*/
|
||||
void
|
||||
getDriveCap (cdio_drive_read_cap_t &read_cap,
|
||||
cdio_drive_write_cap_t &write_cap,
|
||||
cdio_drive_misc_cap_t &misc_cap)
|
||||
{
|
||||
cdio_get_drive_cap(p_cdio, &read_cap, &write_cap, &misc_cap);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get a string containing the name of the driver in use.
|
||||
|
||||
@return a string with driver name or NULL if CdIo_t is NULL (we
|
||||
haven't initialized a specific device.
|
||||
*/
|
||||
const char *
|
||||
getDriverName ()
|
||||
{
|
||||
return cdio_get_driver_name(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the driver id.
|
||||
if CdIo_t is NULL (we haven't initialized a specific device driver),
|
||||
then return DRIVER_UNKNOWN.
|
||||
|
||||
@return the driver id..
|
||||
*/
|
||||
driver_id_t
|
||||
getDriverId ()
|
||||
{
|
||||
return cdio_get_driver_id(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
|
||||
False is returned if we had an error getting the information.
|
||||
*/
|
||||
bool
|
||||
getHWinfo ( /*out*/ cdio_hwinfo_t &hw_info )
|
||||
{
|
||||
return cdio_get_hwinfo(p_cdio, &hw_info);
|
||||
}
|
||||
|
||||
/*! Get the LSN of the first track of the last session of
|
||||
on the CD.
|
||||
|
||||
@param i_last_session pointer to the session number to be returned.
|
||||
*/
|
||||
void
|
||||
getLastSession (/*out*/ lsn_t &i_last_session)
|
||||
{
|
||||
driver_return_code_t drc = cdio_get_last_session(p_cdio, &i_last_session);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Find out if media has changed since the last call.
|
||||
@return 1 if media has changed since last call, 0 if not. Error
|
||||
return codes are the same as driver_return_code_t
|
||||
*/
|
||||
int
|
||||
getMediaChanged()
|
||||
{
|
||||
return cdio_get_media_changed(p_cdio);
|
||||
}
|
||||
|
||||
/*! True if CD-ROM understand ATAPI commands. */
|
||||
bool_3way_t
|
||||
haveATAPI ()
|
||||
{
|
||||
return cdio_have_atapi(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Sets up to read from the device specified by psz_source. An open
|
||||
routine should be called before using any read routine. If device
|
||||
object was previously opened it is closed first.
|
||||
|
||||
@return true if open succeeded or false if error.
|
||||
|
||||
*/
|
||||
bool
|
||||
open(const char *psz_source)
|
||||
{
|
||||
if (p_cdio) cdio_destroy(p_cdio);
|
||||
p_cdio = cdio_open_cd(psz_source);
|
||||
return NULL != p_cdio ;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Sets up to read from the device specified by psz_source and access
|
||||
mode. An open routine should be called before using any read
|
||||
routine. If device object was previously opened it is "closed".
|
||||
|
||||
@return true if open succeeded or false if error.
|
||||
*/
|
||||
bool
|
||||
open (const char *psz_source, driver_id_t driver_id,
|
||||
const char *psz_access_mode = (const char *) NULL)
|
||||
{
|
||||
if (p_cdio) cdio_destroy(p_cdio);
|
||||
if (psz_access_mode)
|
||||
p_cdio = cdio_open_am(psz_source, driver_id, psz_access_mode);
|
||||
else
|
||||
p_cdio = cdio_open(psz_source, driver_id);
|
||||
return NULL != p_cdio ;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the blocksize for subsequent reads.
|
||||
*/
|
||||
void
|
||||
setBlocksize ( int i_blocksize )
|
||||
{
|
||||
driver_return_code_t drc = cdio_set_blocksize ( p_cdio, i_blocksize );
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the drive speed.
|
||||
*/
|
||||
void
|
||||
setSpeed ( int i_speed )
|
||||
{
|
||||
driver_return_code_t drc = cdio_set_speed ( p_cdio, i_speed );
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the arg "key" with "value" in "p_cdio".
|
||||
|
||||
@param key the key to set
|
||||
@param value the value to assocaiate with key
|
||||
*/
|
||||
void
|
||||
setArg (const char key[], const char value[])
|
||||
{
|
||||
driver_return_code_t drc = cdio_set_arg (p_cdio, key, value);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
181
include/cdio++/devices.hpp
Normal file
181
include/cdio++/devices.hpp
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
$Id: devices.hpp,v 1.5 2008/03/25 15:59:10 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file devices.hpp
|
||||
*
|
||||
* \brief methods relating to devices. It is *not* part of a class.
|
||||
* This file should not be #included directly.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
Close media tray in CD drive if there is a routine to do so.
|
||||
|
||||
@param psz_drive the name of CD-ROM to be closed.
|
||||
@param driver_id is the driver to be used or that got used if
|
||||
it was DRIVER_UNKNOWN or DRIVER_DEVICE; If this is NULL, we won't
|
||||
report back the driver used.
|
||||
*/
|
||||
void closeTray (const char *psz_drive, /*in/out*/ driver_id_t &driver_id);
|
||||
|
||||
/*!
|
||||
Close media tray in CD drive if there is a routine to do so.
|
||||
|
||||
@param psz_drive the name of CD-ROM to be closed. If omitted or
|
||||
NULL, we'll scan for a suitable CD-ROM.
|
||||
*/
|
||||
void closeTray (const char *psz_drive=(const char *)NULL);
|
||||
|
||||
/*!
|
||||
Get a string decribing driver_id.
|
||||
|
||||
@param driver_id the driver you want the description for
|
||||
@return a sring of driver description
|
||||
*/
|
||||
const char *driverDescribe (driver_id_t driver_id);
|
||||
|
||||
/*!
|
||||
Eject media in CD drive if there is a routine to do so.
|
||||
|
||||
If the CD is ejected, object is destroyed.
|
||||
*/
|
||||
void ejectMedia (const char *psz_drive);
|
||||
|
||||
/*!
|
||||
Free device list returned by GetDevices
|
||||
|
||||
@param device_list list returned by GetDevices
|
||||
|
||||
@see GetDevices
|
||||
|
||||
*/
|
||||
void freeDeviceList (char * device_list[]);
|
||||
|
||||
/*!
|
||||
Return a string containing the default CD device if none is specified.
|
||||
if p_driver_id is DRIVER_UNKNOWN or DRIVER_DEVICE
|
||||
then find a suitable one set the default device for that.
|
||||
|
||||
NULL is returned if we couldn't get a default device.
|
||||
*/
|
||||
char * getDefaultDevice(/*in/out*/ driver_id_t &driver_id);
|
||||
|
||||
/*! Return an array of device names. If you want a specific
|
||||
devices for a driver, give that device. If you want hardware
|
||||
devices, give DRIVER_DEVICE and if you want all possible devices,
|
||||
image drivers and hardware drivers give DRIVER_UNKNOWN.
|
||||
|
||||
NULL is returned if we couldn't return a list of devices.
|
||||
|
||||
In some situations of drivers or OS's we can't find a CD device if
|
||||
there is no media in it and it is possible for this routine to return
|
||||
NULL even though there may be a hardware CD-ROM.
|
||||
*/
|
||||
char ** getDevices(driver_id_t driver_id=DRIVER_DEVICE);
|
||||
|
||||
/*! Like GetDevices above, but we may change the p_driver_id if we
|
||||
were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because
|
||||
often one wants to get a drive name and then *open* it
|
||||
afterwards. Giving the driver back facilitates this, and speeds
|
||||
things up for libcdio as well.
|
||||
*/
|
||||
|
||||
char **getDevices (driver_id_t &driver_id);
|
||||
|
||||
/*!
|
||||
Get an array of device names in search_devices that have at least
|
||||
the capabilities listed by the capabities parameter. If
|
||||
search_devices is NULL, then we'll search all possible CD drives.
|
||||
|
||||
If "b_any" is set false then every capability listed in the
|
||||
extended portion of capabilities (i.e. not the basic filesystem)
|
||||
must be satisified. If "any" is set true, then if any of the
|
||||
capabilities matches, we call that a success.
|
||||
|
||||
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
|
||||
|
||||
@return the array of device names or NULL if we couldn't get a
|
||||
default device. It is also possible to return a non NULL but
|
||||
after dereferencing the the value is NULL. This also means nothing
|
||||
was found.
|
||||
*/
|
||||
char ** getDevices(/*in*/ char *ppsz_search_devices[],
|
||||
cdio_fs_anal_t capabilities, bool b_any=false);
|
||||
|
||||
/*!
|
||||
Like GetDevices above but we return the driver we found
|
||||
as well. This is because often one wants to search for kind of drive
|
||||
and then *open* it afterwards. Giving the driver back facilitates this,
|
||||
and speeds things up for libcdio as well.
|
||||
*/
|
||||
char ** getDevices(/*in*/ char* ppsz_search_devices[],
|
||||
cdio_fs_anal_t capabilities, /*out*/ driver_id_t &driver_id,
|
||||
bool b_any=false);
|
||||
|
||||
/*! Return true if we Have driver for driver_id */
|
||||
bool haveDriver (driver_id_t driver_id);
|
||||
|
||||
/*!
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/*!
|
||||
Determine if cue_name is the cue sheet for a CDRWIN CD disk image.
|
||||
|
||||
@return corresponding BIN file if cue_name is a CDRWIN cue file or
|
||||
NULL if not a CUE file.
|
||||
*/
|
||||
char *isCueFile(const char *psz_cue_name);
|
||||
|
||||
/*!
|
||||
Determine if psz_source refers to a real hardware CD-ROM.
|
||||
|
||||
@param psz_source location name of object
|
||||
@param driver_id driver for reading object. Use DRIVER_UNKNOWN if you
|
||||
don't know what driver to use.
|
||||
@return true if psz_source is a device; If false is returned we
|
||||
could have a CD disk image.
|
||||
*/
|
||||
bool isDevice(const char *psz_source, driver_id_t driver_id);
|
||||
|
||||
/*!
|
||||
Determine if psz_nrg is a Nero CD disk image.
|
||||
|
||||
@param psz_nrg location of presumed NRG image file.
|
||||
@return true if psz_nrg is a Nero NRG image or false
|
||||
if not a NRG image.
|
||||
*/
|
||||
bool isNero(const char *psz_nrg);
|
||||
|
||||
/*!
|
||||
Determine if psz_toc is a TOC file for a cdrdao CD disk image.
|
||||
|
||||
@param psz_toc location of presumed TOC image file.
|
||||
@return true if toc_name is a cdrdao TOC file or false
|
||||
if not a TOC file.
|
||||
*/
|
||||
bool isTocFile(const char *psz_toc);
|
||||
|
||||
174
include/cdio++/disc.hpp
Normal file
174
include/cdio++/disc.hpp
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
$Id: disc.hpp,v 1.2 2008/03/25 15:59:10 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file disc.hpp
|
||||
* \brief methods relating to getting Compact Disc information. This file
|
||||
* should not be #included directly.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
|
||||
that we've got. The notion of "CD" is extended a little to include
|
||||
DVD's.
|
||||
*/
|
||||
discmode_t getDiscmode ()
|
||||
{
|
||||
return cdio_get_discmode(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the lsn of the end of the CD
|
||||
|
||||
@return the lsn. On error 0 or CDIO_INVALD_LSN.
|
||||
*/
|
||||
lsn_t getDiscLastLsn()
|
||||
{
|
||||
return cdio_get_disc_last_lsn(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the number of the first track.
|
||||
|
||||
@return a track object or NULL;
|
||||
on error.
|
||||
*/
|
||||
CdioTrack *getFirstTrack()
|
||||
{
|
||||
track_t i_track = cdio_get_first_track_num(p_cdio);
|
||||
return (CDIO_INVALID_TRACK != i_track)
|
||||
? new CdioTrack(p_cdio, i_track)
|
||||
: (CdioTrack *) NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the number of the first track.
|
||||
|
||||
@return the track number or CDIO_INVALID_TRACK
|
||||
on error.
|
||||
*/
|
||||
track_t getFirstTrackNum()
|
||||
{
|
||||
return cdio_get_first_track_num(p_cdio);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Get the number of the first track.
|
||||
|
||||
@return a track object or NULL;
|
||||
on error.
|
||||
*/
|
||||
CdioTrack *getLastTrack()
|
||||
{
|
||||
track_t i_track = cdio_get_last_track_num(p_cdio);
|
||||
return (CDIO_INVALID_TRACK != i_track)
|
||||
? new CdioTrack(p_cdio, i_track)
|
||||
: (CdioTrack *) NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the number of the first track.
|
||||
|
||||
@return the track number or CDIO_INVALID_TRACK
|
||||
on error.
|
||||
*/
|
||||
track_t getLastTrackNum()
|
||||
{
|
||||
return cdio_get_last_track_num(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the Joliet level recognized for p_cdio.
|
||||
*/
|
||||
uint8_t getJolietLevel()
|
||||
{
|
||||
return cdio_get_joliet_level(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the media catalog number (MCN) from the CD.
|
||||
|
||||
@return the media catalog number r NULL if there is none or we
|
||||
don't have the ability to get it.
|
||||
|
||||
Note: string is malloc'd so caller has to free() the returned
|
||||
string when done with it.
|
||||
|
||||
*/
|
||||
char * getMcn ()
|
||||
{
|
||||
return cdio_get_mcn (p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the number of tracks on the CD.
|
||||
|
||||
@return the number of tracks, or CDIO_INVALID_TRACK if there is
|
||||
an error.
|
||||
*/
|
||||
track_t getNumTracks ()
|
||||
{
|
||||
return cdio_get_num_tracks(p_cdio);
|
||||
}
|
||||
|
||||
/*! Find the track which contans lsn.
|
||||
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
|
||||
if there was some error.
|
||||
|
||||
If the lsn is before the pregap of the first track 0 is returned.
|
||||
Otherwise we return the track that spans the lsn.
|
||||
*/
|
||||
CdioTrack *getTrackFromNum(track_t i_track)
|
||||
{
|
||||
return new CdioTrack(p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*! Find the track which contans lsn.
|
||||
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
|
||||
if there was some error.
|
||||
|
||||
If the lsn is before the pregap of the first track 0 is returned.
|
||||
Otherwise we return the track that spans the lsn.
|
||||
*/
|
||||
CdioTrack *getTrackFromLsn(lsn_t lsn)
|
||||
{
|
||||
track_t i_track = cdio_get_track(p_cdio, lsn);
|
||||
return (CDIO_INVALID_TRACK != i_track)
|
||||
? new CdioTrack(p_cdio, i_track)
|
||||
: (CdioTrack *) NULL;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Return true if discmode is some sort of CD.
|
||||
*/
|
||||
bool isDiscmodeCdrom (discmode_t discmode) {
|
||||
return cdio_is_discmode_cdrom(discmode);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Return true if discmode is some sort of DVD.
|
||||
*/
|
||||
bool isDiscmodeDvd (discmode_t discmode)
|
||||
{
|
||||
return cdio_is_discmode_dvd (discmode) ;
|
||||
}
|
||||
|
||||
|
||||
49
include/cdio++/enum.hpp
Normal file
49
include/cdio++/enum.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
$Id: enum.hpp,v 1.2 2008/03/25 15:59:10 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file enum.hpp
|
||||
*
|
||||
* \brief C++ header for pre- and post-increment operators for
|
||||
* enumerations defined in libcdio that it makes sense to iterate over.
|
||||
*/
|
||||
|
||||
#define ENUM_ITERATE_FNS(type) \
|
||||
inline \
|
||||
type &operator++(type &t) \
|
||||
{ \
|
||||
return t = type(t + 1); \
|
||||
} \
|
||||
inline \
|
||||
type &operator++(type &t, int) \
|
||||
{ \
|
||||
return t = type(t + 1); \
|
||||
} \
|
||||
inline \
|
||||
type &operator--(type &t) \
|
||||
{ \
|
||||
return t = type(t - 1); \
|
||||
} \
|
||||
inline \
|
||||
type &operator--(type &t, int) \
|
||||
{ \
|
||||
return t = type(t - 1); \
|
||||
}
|
||||
|
||||
ENUM_ITERATE_FNS(cdtext_field_t)
|
||||
ENUM_ITERATE_FNS(driver_id_t)
|
||||
428
include/cdio++/iso9660.hpp
Normal file
428
include/cdio++/iso9660.hpp
Normal file
@@ -0,0 +1,428 @@
|
||||
/*
|
||||
$Id: iso9660.hpp,v 1.13 2008/06/13 15:58:50 flameeyes Exp $
|
||||
|
||||
Copyright (C) 2006, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file iso9660.hpp
|
||||
*
|
||||
* \brief C++ class for libcdio: the CD Input and Control
|
||||
* library. Applications use this for anything regarding libcdio.
|
||||
*/
|
||||
|
||||
#ifndef __ISO9660_HPP__
|
||||
#define __ISO9660_HPP__
|
||||
|
||||
#include <cdio/iso9660.h>
|
||||
#include <cdio++/cdio.hpp>
|
||||
#include <vector> // vector class library
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
/** ISO 9660 class.
|
||||
*/
|
||||
class ISO9660
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
class PVD // Primary Volume ID
|
||||
{
|
||||
public:
|
||||
|
||||
iso9660_pvd_t pvd; // Make private?
|
||||
|
||||
PVD()
|
||||
{
|
||||
memset(&pvd, 0, sizeof(pvd));
|
||||
}
|
||||
|
||||
PVD(iso9660_pvd_t *p_new_pvd)
|
||||
{
|
||||
memcpy(&pvd, p_new_pvd, sizeof(pvd));
|
||||
};
|
||||
|
||||
/*!
|
||||
Return the PVD's application ID.
|
||||
NULL is returned if there is some problem in getting this.
|
||||
*/
|
||||
char * get_application_id();
|
||||
|
||||
int get_pvd_block_size();
|
||||
|
||||
/*!
|
||||
Return the PVD's preparer ID.
|
||||
NULL is returned if there is some problem in getting this.
|
||||
*/
|
||||
char * get_preparer_id();
|
||||
|
||||
/*!
|
||||
Return the PVD's publisher ID.
|
||||
NULL is returned if there is some problem in getting this.
|
||||
*/
|
||||
char * get_publisher_id();
|
||||
|
||||
const char *get_pvd_id();
|
||||
|
||||
int get_pvd_space_size();
|
||||
|
||||
uint8_t get_pvd_type();
|
||||
|
||||
/*! Return the primary volume id version number (of pvd).
|
||||
If there is an error 0 is returned.
|
||||
*/
|
||||
int get_pvd_version();
|
||||
|
||||
/*! Return the LSN of the root directory for pvd.
|
||||
If there is an error CDIO_INVALID_LSN is returned.
|
||||
*/
|
||||
lsn_t get_root_lsn();
|
||||
|
||||
/*!
|
||||
Return the PVD's system ID.
|
||||
NULL is returned if there is some problem in getting this.
|
||||
*/
|
||||
char * get_system_id();
|
||||
|
||||
/*!
|
||||
Return the PVD's volume ID.
|
||||
NULL is returned if there is some problem in getting this.
|
||||
*/
|
||||
char * get_volume_id();
|
||||
|
||||
/*!
|
||||
Return the PVD's volumeset ID.
|
||||
NULL is returned if there is some problem in getting this.
|
||||
*/
|
||||
char * get_volumeset_id();
|
||||
|
||||
};
|
||||
|
||||
class Stat // ISO 9660 file information
|
||||
{
|
||||
public:
|
||||
|
||||
iso9660_stat_t *p_stat;
|
||||
typedef vector< ISO9660::Stat *> stat_vector_t;
|
||||
|
||||
Stat(iso9660_stat_t *p_new_stat)
|
||||
{
|
||||
p_stat = p_new_stat;
|
||||
};
|
||||
|
||||
Stat(const Stat& copy_in)
|
||||
{
|
||||
free(p_stat);
|
||||
p_stat = (iso9660_stat_t *)
|
||||
calloc( 1, sizeof(iso9660_stat_t)
|
||||
+ strlen(copy_in.p_stat->filename)+1 );
|
||||
p_stat = copy_in.p_stat;
|
||||
}
|
||||
|
||||
const Stat& operator= (const Stat& right)
|
||||
{
|
||||
free(p_stat);
|
||||
this->p_stat = right.p_stat;
|
||||
return right;
|
||||
}
|
||||
|
||||
~Stat()
|
||||
{
|
||||
free(p_stat);
|
||||
p_stat = NULL;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class FS : public CdioDevice // ISO 9660 Filesystem on a CD or CD-image
|
||||
{
|
||||
public:
|
||||
|
||||
typedef vector< ISO9660::Stat *> stat_vector_t;
|
||||
|
||||
/*!
|
||||
Given a directory pointer, find the filesystem entry that contains
|
||||
lsn and return information about it.
|
||||
|
||||
@return Stat * of entry if we found lsn, or NULL otherwise.
|
||||
Caller must free return value.
|
||||
*/
|
||||
Stat *find_lsn(lsn_t i_lsn);
|
||||
|
||||
/*! Read the Primary Volume Descriptor for a CD. A
|
||||
PVD object is returned if read, and NULL if there was an error.
|
||||
*/
|
||||
PVD *read_pvd ();
|
||||
|
||||
/*!
|
||||
Read the Super block of an ISO 9660 image. This is the
|
||||
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
|
||||
Descriptor if (Joliet) extensions are acceptable.
|
||||
*/
|
||||
bool read_superblock (iso_extension_mask_t iso_extension_mask);
|
||||
|
||||
/*! Read psz_path (a directory) and return a vector of iso9660_stat_t
|
||||
pointers for the files inside that directory. The caller must free the
|
||||
returned result.
|
||||
*/
|
||||
bool readdir (const char psz_path[], stat_vector_t& stat_vector,
|
||||
bool b_mode2=false);
|
||||
|
||||
/*!
|
||||
Return file status for path name psz_path. NULL is returned on
|
||||
error.
|
||||
|
||||
If translate is true, version numbers in the ISO 9660 name are
|
||||
dropped, i.e. ;1 is removed and if level 1 ISO-9660 names are
|
||||
lowercased.
|
||||
|
||||
Mode2 is used only if translate is true and is a hack that
|
||||
really should go away in libcdio sometime. If set use mode 2
|
||||
reading, otherwise use mode 1 reading.
|
||||
|
||||
@return file status object for psz_path. NULL is returned on
|
||||
error.
|
||||
*/
|
||||
Stat *
|
||||
stat (const char psz_path[], bool b_translate=false, bool b_mode2=false)
|
||||
{
|
||||
if (b_translate)
|
||||
return new Stat(iso9660_fs_stat_translate (p_cdio, psz_path,
|
||||
b_mode2));
|
||||
else
|
||||
return new Stat(iso9660_fs_stat (p_cdio, psz_path));
|
||||
}
|
||||
};
|
||||
|
||||
class IFS // ISO 9660 filesystem image
|
||||
{
|
||||
public:
|
||||
|
||||
typedef vector< ISO9660::Stat *> stat_vector_t;
|
||||
|
||||
IFS()
|
||||
{
|
||||
p_iso9660=NULL;
|
||||
};
|
||||
|
||||
~IFS()
|
||||
{
|
||||
iso9660_close(p_iso9660);
|
||||
p_iso9660 = (iso9660_t *) NULL;
|
||||
};
|
||||
|
||||
/*! Close previously opened ISO 9660 image and free resources
|
||||
associated with the image. Call this when done using using an ISO
|
||||
9660 image.
|
||||
|
||||
@return true is unconditionally returned. If there was an error
|
||||
false would be returned.
|
||||
*/
|
||||
bool close();
|
||||
|
||||
/*!
|
||||
Given a directory pointer, find the filesystem entry that contains
|
||||
lsn and return information about it.
|
||||
|
||||
Returns Stat* of entry if we found lsn, or NULL otherwise.
|
||||
*/
|
||||
Stat *find_lsn(lsn_t i_lsn);
|
||||
|
||||
/*!
|
||||
Get the application ID. psz_app_id is set to NULL if there
|
||||
is some problem in getting this and false is returned.
|
||||
*/
|
||||
bool get_application_id(/*out*/ char * &psz_app_id)
|
||||
{
|
||||
return iso9660_ifs_get_application_id(p_iso9660, &psz_app_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the Joliet level recognized.
|
||||
*/
|
||||
uint8_t get_joliet_level();
|
||||
|
||||
/*!
|
||||
Get the preparer ID. psz_preparer_id is set to NULL if there
|
||||
is some problem in getting this and false is returned.
|
||||
*/
|
||||
bool get_preparer_id(/*out*/ char * &psz_preparer_id)
|
||||
{
|
||||
return iso9660_ifs_get_preparer_id(p_iso9660, &psz_preparer_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the publisher ID. psz_publisher_id is set to NULL if there
|
||||
is some problem in getting this and false is returned.
|
||||
*/
|
||||
bool get_publisher_id(/*out*/ char * &psz_publisher_id)
|
||||
{
|
||||
return iso9660_ifs_get_publisher_id(p_iso9660, &psz_publisher_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the system ID. psz_system_id is set to NULL if there
|
||||
is some problem in getting this and false is returned.
|
||||
*/
|
||||
bool get_system_id(/*out*/ char * &psz_system_id)
|
||||
{
|
||||
return iso9660_ifs_get_system_id(p_iso9660, &psz_system_id);
|
||||
}
|
||||
|
||||
/*! Return the volume ID in the PVD. psz_volume_id is set to
|
||||
NULL if there is some problem in getting this and false is
|
||||
returned.
|
||||
*/
|
||||
bool get_volume_id(/*out*/ char * &psz_volume_id)
|
||||
{
|
||||
return iso9660_ifs_get_volume_id(p_iso9660, &psz_volume_id);
|
||||
}
|
||||
|
||||
/*! Return the volumeset ID in the PVD. psz_volumeset_id is set to
|
||||
NULL if there is some problem in getting this and false is
|
||||
returned.
|
||||
*/
|
||||
bool get_volumeset_id(/*out*/ char * &psz_volumeset_id)
|
||||
{
|
||||
return iso9660_ifs_get_volumeset_id(p_iso9660, &psz_volumeset_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return true if ISO 9660 image has extended attrributes (XA).
|
||||
*/
|
||||
bool is_xa ();
|
||||
|
||||
/*! Open an ISO 9660 image for reading. Maybe in the future we will
|
||||
have a mode. NULL is returned on error. An open routine should be
|
||||
called before using any read routine. If device object was
|
||||
previously opened it is closed first.
|
||||
|
||||
@param psz_path location of ISO 9660 image
|
||||
@param iso_extension_mask the kinds of ISO 9660 extensions will be
|
||||
considered on access.
|
||||
|
||||
@return true if open succeeded or false if error.
|
||||
|
||||
@see open_fuzzy
|
||||
*/
|
||||
bool open(const char *psz_path,
|
||||
iso_extension_mask_t iso_extension_mask=ISO_EXTENSION_NONE)
|
||||
{
|
||||
if (p_iso9660) iso9660_close(p_iso9660);
|
||||
p_iso9660 = iso9660_open_ext(psz_path, iso_extension_mask);
|
||||
return NULL != (iso9660_t *) p_iso9660 ;
|
||||
}
|
||||
|
||||
/*! Open an ISO 9660 image for "fuzzy" reading. This means that we
|
||||
will try to guess various internal offset based on internal
|
||||
checks. This may be useful when trying to read an ISO 9660 image
|
||||
contained in a file format that libiso9660 doesn't know natively
|
||||
(or knows imperfectly.)
|
||||
|
||||
Maybe in the future we will have a mode. NULL is returned on
|
||||
error.
|
||||
|
||||
@see open
|
||||
*/
|
||||
bool open_fuzzy (const char *psz_path,
|
||||
iso_extension_mask_t iso_extension_mask
|
||||
=ISO_EXTENSION_NONE,
|
||||
uint16_t i_fuzz=20);
|
||||
|
||||
/*! Read the Primary Volume Descriptor for an ISO 9660 image. A
|
||||
PVD object is returned if read, and NULL if there was an error.
|
||||
*/
|
||||
PVD *read_pvd ();
|
||||
|
||||
/*!
|
||||
Read the Super block of an ISO 9660 image but determine framesize
|
||||
and datastart and a possible additional offset. Generally here we are
|
||||
not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
|
||||
filesystem.
|
||||
|
||||
@see read_superblock
|
||||
*/
|
||||
bool read_superblock (iso_extension_mask_t iso_extension_mask
|
||||
=ISO_EXTENSION_NONE,
|
||||
uint16_t i_fuzz=20);
|
||||
|
||||
/*!
|
||||
Read the Super block of an ISO 9660 image but determine framesize
|
||||
and datastart and a possible additional offset. Generally here we are
|
||||
not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
|
||||
filesystem.
|
||||
|
||||
@see read_superblock
|
||||
*/
|
||||
bool
|
||||
read_superblock_fuzzy (iso_extension_mask_t iso_extension_mask
|
||||
=ISO_EXTENSION_NONE,
|
||||
uint16_t i_fuzz=20);
|
||||
|
||||
/*! Read psz_path (a directory) and return a list of iso9660_stat_t
|
||||
pointers for the files inside that directory. The caller must free
|
||||
the returned result.
|
||||
*/
|
||||
bool readdir (const char psz_path[], stat_vector_t& stat_vector)
|
||||
{
|
||||
CdioList_t *p_stat_list = iso9660_ifs_readdir (p_iso9660, psz_path);
|
||||
|
||||
if (p_stat_list) {
|
||||
CdioListNode_t *p_entnode;
|
||||
_CDIO_LIST_FOREACH (p_entnode, p_stat_list) {
|
||||
iso9660_stat_t *p_statbuf =
|
||||
(iso9660_stat_t *) _cdio_list_node_data (p_entnode);
|
||||
stat_vector.push_back(new ISO9660::Stat(p_statbuf));
|
||||
}
|
||||
_cdio_list_free (p_stat_list, false);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Seek to a position and then read n bytes. Size read is returned.
|
||||
*/
|
||||
long int
|
||||
seek_read (void *ptr, lsn_t start, long int i_size=1)
|
||||
{
|
||||
return iso9660_iso_seek_read (p_iso9660, ptr, start, i_size);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return file status for pathname. NULL is returned on error.
|
||||
*/
|
||||
Stat *
|
||||
stat (const char psz_path[], bool b_translate=false)
|
||||
{
|
||||
if (b_translate)
|
||||
return new Stat(iso9660_ifs_stat_translate (p_iso9660, psz_path));
|
||||
else
|
||||
return new Stat(iso9660_ifs_stat (p_iso9660, psz_path));
|
||||
}
|
||||
|
||||
private:
|
||||
iso9660_t *p_iso9660;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
typedef vector< ISO9660::Stat *> stat_vector_t;
|
||||
typedef vector <ISO9660::Stat *>::iterator stat_vector_iterator_t;
|
||||
|
||||
#endif /* __ISO9660_HPP__ */
|
||||
425
include/cdio++/mmc.hpp
Normal file
425
include/cdio++/mmc.hpp
Normal file
@@ -0,0 +1,425 @@
|
||||
/*
|
||||
$Id: mmc.hpp,v 1.3 2008/03/25 15:59:10 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file mmc.hpp
|
||||
* \brief methods relating to MMC (Multimedia Commands). This file
|
||||
* should not be #included directly.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Read Audio Subchannel information
|
||||
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
@param p_subchannel place for returned subchannel information
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
*/
|
||||
void
|
||||
mmcAudioReadSubchannel (/*out*/ cdio_subchannel_t *p_subchannel)
|
||||
{
|
||||
driver_return_code_t drc = mmc_audio_read_subchannel (p_cdio, p_subchannel);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Eject using MMC commands. If CD-ROM is "locked" we'll unlock it.
|
||||
Command is not "immediate" -- we'll wait for the command to complete.
|
||||
For a more general (and lower-level) routine, @see mmc_start_stop_media.
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
*/
|
||||
void mmcEjectMedia()
|
||||
{
|
||||
driver_return_code_t drc = mmc_eject_media( p_cdio );
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the lsn of the end of the CD
|
||||
|
||||
@return the lsn. On error return CDIO_INVALID_LSN.
|
||||
*/
|
||||
lsn_t mmcGetDiscLastLsn()
|
||||
{
|
||||
return mmc_get_disc_last_lsn( p_cdio );
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the discmode as reported by the MMC Read (FULL) TOC
|
||||
command.
|
||||
|
||||
Information was obtained from Section 5.1.13 (Read TOC/PMA/ATIP)
|
||||
pages 56-62 from the MMC draft specification, revision 10a
|
||||
at http://www.t10.org/ftp/t10/drafts/mmc/mmc-r10a.pdf See
|
||||
especially tables 72, 73 and 75.
|
||||
*/
|
||||
discmode_t mmcGetDiscmode()
|
||||
{
|
||||
return mmc_get_discmode( p_cdio );
|
||||
}
|
||||
|
||||
/*!
|
||||
Get drive capabilities for a device.
|
||||
@return the drive capabilities.
|
||||
*/
|
||||
void mmcGetDriveCap ( /*out*/ cdio_drive_read_cap_t *p_read_cap,
|
||||
/*out*/ cdio_drive_write_cap_t *p_write_cap,
|
||||
/*out*/ cdio_drive_misc_cap_t *p_misc_cap)
|
||||
{
|
||||
mmc_get_drive_cap ( p_cdio, p_read_cap, p_write_cap, p_misc_cap);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the MMC level supported by the device.
|
||||
*/
|
||||
cdio_mmc_level_t mmcGetDriveMmcCap()
|
||||
{
|
||||
return mmc_get_drive_mmc_cap(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the DVD type associated with cd object.
|
||||
|
||||
@return the DVD discmode.
|
||||
*/
|
||||
discmode_t mmcGetDvdStructPhysical (cdio_dvd_struct_t *s)
|
||||
{
|
||||
return mmc_get_dvd_struct_physical (p_cdio, s);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the CD-ROM hardware info via an MMC INQUIRY command.
|
||||
|
||||
@return true if we were able to get hardware info, false if we had
|
||||
an error.
|
||||
*/
|
||||
bool mmcGetHwinfo ( /* out*/ cdio_hwinfo_t *p_hw_info )
|
||||
{
|
||||
return mmc_get_hwinfo ( p_cdio, p_hw_info );
|
||||
}
|
||||
|
||||
/*!
|
||||
Find out if media has changed since the last call.
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
@return 1 if media has changed since last call, 0 if not. Error
|
||||
return codes are the same as driver_return_code_t
|
||||
*/
|
||||
int mmcGetMediaChanged()
|
||||
{
|
||||
return mmc_get_media_changed(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the media catalog number (MCN) from the CD via MMC.
|
||||
|
||||
@return the media catalog number r NULL if there is none or we
|
||||
don't have the ability to get it.
|
||||
|
||||
Note: string is malloc'd so caller has to free() the returned
|
||||
string when done with it.
|
||||
|
||||
*/
|
||||
char * mmcGetMcn ()
|
||||
{
|
||||
return mmc_get_mcn ( p_cdio );
|
||||
}
|
||||
|
||||
/** Get the output port volumes and port selections used on AUDIO PLAY
|
||||
commands via a MMC MODE SENSE command using the CD Audio Control
|
||||
Page.
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
*/
|
||||
void mmcAudioGetVolume (mmc_audio_volume_t *p_volume)
|
||||
{
|
||||
driver_return_code_t drc = mmc_audio_get_volume (p_cdio, p_volume);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Report if CD-ROM has a praticular kind of interface (ATAPI, SCSCI, ...)
|
||||
Is it possible for an interface to have serveral? If not this
|
||||
routine could probably return the single mmc_feature_interface_t.
|
||||
@return true if we have the interface and false if not.
|
||||
*/
|
||||
bool_3way_t mmcHaveInterface( cdio_mmc_feature_interface_t e_interface )
|
||||
{
|
||||
return mmc_have_interface( p_cdio, e_interface );
|
||||
}
|
||||
|
||||
/*! Run a MODE_SENSE command (6- or 10-byte version)
|
||||
and put the results in p_buf
|
||||
@return DRIVER_OP_SUCCESS if we ran the command ok.
|
||||
*/
|
||||
int mmcModeSense( /*out*/ void *p_buf, int i_size, int page)
|
||||
{
|
||||
return mmc_mode_sense( p_cdio, /*out*/ p_buf, i_size, page);
|
||||
}
|
||||
|
||||
/*! Run a MODE_SENSE command (10-byte version)
|
||||
and put the results in p_buf
|
||||
@return DRIVER_OP_SUCCESS if we ran the command ok.
|
||||
*/
|
||||
int mmcModeSense10( /*out*/ void *p_buf, int i_size, int page)
|
||||
{
|
||||
return mmc_mode_sense_10( p_cdio, /*out*/ p_buf, i_size, page);
|
||||
}
|
||||
|
||||
/*! Run a MODE_SENSE command (6-byte version)
|
||||
and put the results in p_buf
|
||||
@return DRIVER_OP_SUCCESS if we ran the command ok.
|
||||
*/
|
||||
int mmcModeSense6( /*out*/ void *p_buf, int i_size, int page)
|
||||
{
|
||||
return mmc_mode_sense_6( p_cdio, /*out*/ p_buf, i_size, page);
|
||||
}
|
||||
|
||||
/*! Issue a MMC READ_CD command.
|
||||
|
||||
@param p_cdio object to read from
|
||||
|
||||
@param p_buf Place to store data. The caller should ensure that
|
||||
p_buf can hold at least i_blocksize * i_blocks bytes.
|
||||
|
||||
@param i_lsn sector to read
|
||||
|
||||
@param expected_sector_type restricts reading to a specific CD
|
||||
sector type. Only 3 bits with values 1-5 are used:
|
||||
0 all sector types
|
||||
1 CD-DA sectors only
|
||||
2 Mode 1 sectors only
|
||||
3 Mode 2 formless sectors only. Note in contrast to all other
|
||||
values an MMC CD-ROM is not required to support this mode.
|
||||
4 Mode 2 Form 1 sectors only
|
||||
5 Mode 2 Form 2 sectors only
|
||||
|
||||
@param b_digital_audio_play Control error concealment when the
|
||||
data being read is CD-DA. If the data being read is not CD-DA,
|
||||
this parameter is ignored. If the data being read is CD-DA and
|
||||
DAP is false zero, then the user data returned should not be
|
||||
modified by flaw obscuring mechanisms such as audio data mute and
|
||||
interpolate. If the data being read is CD-DA and DAP is true,
|
||||
then the user data returned should be modified by flaw obscuring
|
||||
mechanisms such as audio data mute and interpolate.
|
||||
|
||||
b_sync_header return the sync header (which will probably have
|
||||
the same value as CDIO_SECTOR_SYNC_HEADER of size
|
||||
CDIO_CD_SYNC_SIZE).
|
||||
|
||||
@param header_codes Header Codes refer to the sector header and
|
||||
the sub-header that is present in mode 2 formed sectors:
|
||||
|
||||
0 No header information is returned.
|
||||
1 The 4-byte sector header of data sectors is be returned,
|
||||
2 The 8-byte sector sub-header of mode 2 formed sectors is
|
||||
returned.
|
||||
3 Both sector header and sub-header (12 bytes) is returned.
|
||||
The Header preceeds the rest of the bytes (e.g. user-data bytes)
|
||||
that might get returned.
|
||||
|
||||
@param b_user_data Return user data if true.
|
||||
|
||||
For CD-DA, the User Data is CDIO_CD_FRAMESIZE_RAW bytes.
|
||||
|
||||
For Mode 1, The User Data is ISO_BLOCKSIZE bytes beginning at
|
||||
offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
|
||||
|
||||
For Mode 2 formless, The User Data is M2RAW_SECTOR_SIZE bytes
|
||||
beginning at offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
|
||||
|
||||
For data Mode 2, form 1, User Data is ISO_BLOCKSIZE bytes beginning at
|
||||
offset CDIO_CD_XA_SYNC_HEADER.
|
||||
|
||||
For data Mode 2, form 2, User Data is 2 324 bytes beginning at
|
||||
offset CDIO_CD_XA_SYNC_HEADER.
|
||||
|
||||
@param b_sync
|
||||
|
||||
@param b_edc_ecc true if we return EDC/ECC error detection/correction bits.
|
||||
|
||||
The presence and size of EDC redundancy or ECC parity is defined
|
||||
according to sector type:
|
||||
|
||||
CD-DA sectors have neither EDC redundancy nor ECC parity.
|
||||
|
||||
Data Mode 1 sectors have 288 bytes of EDC redundancy, Pad, and
|
||||
ECC parity beginning at offset 2064.
|
||||
|
||||
Data Mode 2 formless sectors have neither EDC redundancy nor ECC
|
||||
parity
|
||||
|
||||
Data Mode 2 form 1 sectors have 280 bytes of EDC redundancy and
|
||||
ECC parity beginning at offset 2072
|
||||
|
||||
Data Mode 2 form 2 sectors optionally have 4 bytes of EDC
|
||||
redundancy beginning at offset 2348.
|
||||
|
||||
|
||||
@param c2_error_information If true associate a bit with each
|
||||
sector for C2 error The resulting bit field is ordered exactly as
|
||||
the main channel bytes. Each 8-bit boundary defines a byte of
|
||||
flag bits.
|
||||
|
||||
@param subchannel_selection subchannel-selection bits
|
||||
|
||||
0 No Sub-channel data shall be returned. (0 bytes)
|
||||
1 RAW P-W Sub-channel data shall be returned. (96 byte)
|
||||
2 Formatted Q sub-channel data shall be transferred (16 bytes)
|
||||
3 Reserved
|
||||
4 Corrected and de-interleaved R-W sub-channel (96 bytes)
|
||||
5-7 Reserved
|
||||
|
||||
@param i_blocksize size of the a block expected to be returned
|
||||
|
||||
@param i_blocks number of blocks expected to be returned.
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
*/
|
||||
void
|
||||
mmcReadCd ( void *p_buf, lsn_t i_lsn, int expected_sector_type,
|
||||
bool b_digital_audio_play, bool b_sync, uint8_t header_codes,
|
||||
bool b_user_data, bool b_edc_ecc, uint8_t c2_error_information,
|
||||
uint8_t subchannel_selection, uint16_t i_blocksize,
|
||||
uint32_t i_blocks )
|
||||
{
|
||||
driver_return_code_t drc =
|
||||
mmc_read_cd ( p_cdio, p_buf, i_lsn, expected_sector_type,
|
||||
b_digital_audio_play, b_sync, header_codes,
|
||||
b_user_data, b_edc_ecc, c2_error_information,
|
||||
subchannel_selection, i_blocksize, i_blocks );
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*! Read just the user data part of some sort of data sector (via
|
||||
mmc_read_cd).
|
||||
|
||||
@param p_cdio object to read from
|
||||
|
||||
@param p_buf place to read data into. The caller should make sure
|
||||
this location can store at least CDIO_CD_FRAMESIZE,
|
||||
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending on
|
||||
the kind of sector getting read. If you don't know
|
||||
whether you have a Mode 1/2, Form 1/ Form 2/Formless
|
||||
sector best to reserve space for the maximum,
|
||||
M2RAW_SECTOR_SIZE.
|
||||
|
||||
@param i_lsn sector to read
|
||||
@param i_blocksize size of each block
|
||||
@param i_blocks number of blocks to read
|
||||
|
||||
*/
|
||||
void mmcReadDataSectors ( void *p_buf, lsn_t i_lsn, uint16_t i_blocksize,
|
||||
uint32_t i_blocks=1)
|
||||
{
|
||||
driver_return_code_t drc = mmc_read_data_sectors ( p_cdio, p_buf, i_lsn,
|
||||
i_blocksize, i_blocks );
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
|
||||
/*! Read MMC read mode2 sectors
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
*/
|
||||
void mmcReadSectors ( void *p_buf, lsn_t i_lsn, int read_sector_type,
|
||||
uint32_t i_blocks=1)
|
||||
{
|
||||
driver_return_code_t drc = mmc_read_sectors ( p_cdio, p_buf, i_lsn,
|
||||
read_sector_type, i_blocks);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Run an MMC command.
|
||||
|
||||
@param p_cdio CD structure set by cdio_open().
|
||||
@param i_timeout_ms time in milliseconds we will wait for the command
|
||||
to complete.
|
||||
@param p_cdb CDB bytes. All values that are needed should be set
|
||||
on input. We'll figure out what the right CDB length
|
||||
should be.
|
||||
@param e_direction direction the transfer is to go.
|
||||
@param i_buf Size of buffer
|
||||
@param p_buf Buffer for data, both sending and receiving.
|
||||
|
||||
@return 0 if command completed successfully.
|
||||
*/
|
||||
int mmcRunCmd( unsigned int i_timeout_ms, const mmc_cdb_t *p_cdb,
|
||||
cdio_mmc_direction_t e_direction, unsigned int i_buf,
|
||||
/*in/out*/ void *p_buf )
|
||||
{
|
||||
return mmc_run_cmd( p_cdio, i_timeout_ms, p_cdb, e_direction, i_buf, p_buf );
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the block size for subsequent read requests, via MMC.
|
||||
|
||||
@param i_blocksize size to set for subsequent requests
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
*/
|
||||
void mmcSetBlocksize ( uint16_t i_blocksize)
|
||||
{
|
||||
driver_return_code_t drc = mmc_set_blocksize ( p_cdio, i_blocksize);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Set the drive speed via MMC.
|
||||
|
||||
@param i_speed speed to set drive to.
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
*/
|
||||
void mmcSetSpeed( int i_speed )
|
||||
{
|
||||
driver_return_code_t drc = mmc_set_speed( p_cdio, i_speed );
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Load or Unload media using a MMC START STOP command.
|
||||
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
@param b_eject eject if true and close tray if false
|
||||
@param b_immediate wait or don't wait for operation to complete
|
||||
@param power_condition Set CD-ROM to idle/standby/sleep. If nonzero
|
||||
eject/load is ignored, so set to 0 if you want to eject or load.
|
||||
|
||||
@see mmc_eject_media or mmc_close_tray
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
*/
|
||||
void mmcStartStopMedia(bool b_eject, bool b_immediate,
|
||||
uint8_t power_condition)
|
||||
{
|
||||
driver_return_code_t drc =
|
||||
mmc_start_stop_media(p_cdio, b_eject, b_immediate, power_condition);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-file-style: "gnu"
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
121
include/cdio++/read.hpp
Normal file
121
include/cdio++/read.hpp
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
$Id: read.hpp,v 1.3 2008/03/25 15:59:10 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file read.hpp
|
||||
*
|
||||
* \brief methods relating to reading blocks of Compact Discs. This file
|
||||
* should not be #included directly.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Reposition read offset
|
||||
Similar to (if not the same as) libc's lseek()
|
||||
|
||||
@param offset amount to seek
|
||||
@param whence like corresponding parameter in libc's lseek, e.g.
|
||||
SEEK_SET or SEEK_END.
|
||||
@return (off_t) -1 on error.
|
||||
*/
|
||||
|
||||
off_t lseek(off_t offset, int whence)
|
||||
{
|
||||
return cdio_lseek(p_cdio, offset, whence);
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads into buf the next size bytes.
|
||||
Similar to (if not the same as) libc's read()
|
||||
|
||||
@param p_buf place to read data into. The caller should make sure
|
||||
this location can store at least i_size bytes.
|
||||
@param i_size number of bytes to read
|
||||
|
||||
@return (ssize_t) -1 on error.
|
||||
*/
|
||||
ssize_t read(void *p_buf, size_t i_size)
|
||||
{
|
||||
return cdio_read(p_cdio, p_buf, i_size);
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a number of sectors (AKA blocks).
|
||||
|
||||
@param p_buf place to read data into. The caller should make sure
|
||||
this location is large enough. See below for size information.
|
||||
@param read_mode the kind of "mode" to use in reading.
|
||||
@param i_lsn sector to read
|
||||
@param i_blocks number of sectors to read
|
||||
|
||||
If read_mode is CDIO_MODE_AUDIO,
|
||||
*p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.
|
||||
|
||||
If read_mode is CDIO_MODE_DATA,
|
||||
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
|
||||
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
|
||||
sector getting read. If you don't know whether you have a Mode 1/2,
|
||||
Form 1/ Form 2/Formless sector best to reserve space for the maximum
|
||||
which is M2RAW_SECTOR_SIZE.
|
||||
|
||||
If read_mode is CDIO_MODE_M2F1,
|
||||
*p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.
|
||||
|
||||
If read_mode is CDIO_MODE_M2F2,
|
||||
*p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
*/
|
||||
|
||||
void readSectors(void *p_buf, lsn_t i_lsn, cdio_read_mode_t read_mode,
|
||||
uint32_t i_blocks=1)
|
||||
{
|
||||
driver_return_code_t drc = cdio_read_sectors(p_cdio, p_buf, i_lsn, read_mode,
|
||||
i_blocks);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a number of data sectors (AKA blocks).
|
||||
|
||||
@param p_buf place to read data into. The caller should make sure
|
||||
this location is large enough. See below for size information.
|
||||
|
||||
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
|
||||
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
|
||||
sector getting read. If you don't know whether you have a Mode 1/2,
|
||||
Form 1/ Form 2/Formless sector best to reserve space for the maximum
|
||||
which is M2RAW_SECTOR_SIZE.
|
||||
|
||||
@param i_lsn sector to read
|
||||
|
||||
@param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE,
|
||||
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf.
|
||||
|
||||
@param i_blocks number of sectors to read
|
||||
|
||||
A DriverOpException is raised on error.
|
||||
|
||||
*/
|
||||
|
||||
void readDataBlocks(void *p_buf, lsn_t i_lsn, uint16_t i_blocksize,
|
||||
uint32_t i_blocks=1)
|
||||
{
|
||||
driver_return_code_t drc = cdio_read_data_sectors (p_cdio, p_buf, i_lsn,
|
||||
i_blocksize, i_blocks);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
147
include/cdio++/track.hpp
Normal file
147
include/cdio++/track.hpp
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
$Id: track.hpp,v 1.2 2008/03/25 15:59:10 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file track.hpp
|
||||
* \brief methods relating to getting Compact Discs. This file
|
||||
* should not be #included directly.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Return an opaque CdIo_t pointer for the given track object.
|
||||
*/
|
||||
CdIo_t *getCdIo()
|
||||
{
|
||||
return p_cdio;
|
||||
}
|
||||
|
||||
/*!
|
||||
Get CD-Text information for a CdIo_t object.
|
||||
|
||||
@return the CD-Text object or NULL if obj is NULL
|
||||
or CD-Text information does not exist.
|
||||
*/
|
||||
cdtext_t *getCdtext ()
|
||||
{
|
||||
return cdio_get_cdtext (p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*! Return number of channels in track: 2 or 4; -2 if not
|
||||
implemented or -1 for error.
|
||||
Not meaningful if track is not an audio track.
|
||||
*/
|
||||
int getChannels()
|
||||
{
|
||||
return cdio_get_track_channels(p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*! Return copy protection status on a track. Is this meaningful
|
||||
if not an audio track?
|
||||
*/
|
||||
track_flag_t getCopyPermit()
|
||||
{
|
||||
return cdio_get_track_copy_permit(p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the format (audio, mode2, mode1) of track.
|
||||
*/
|
||||
track_format_t getFormat()
|
||||
{
|
||||
return cdio_get_track_format(p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return true if we have XA data (green, mode2 form1) or
|
||||
XA data (green, mode2 form2). That is track begins:
|
||||
sync - header - subheader
|
||||
12 4 - 8
|
||||
|
||||
FIXME: there's gotta be a better design for this and get_track_format?
|
||||
*/
|
||||
bool getGreen()
|
||||
{
|
||||
return cdio_get_track_green(p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the ending LSN. CDIO_INVALID_LSN is returned on error.
|
||||
*/
|
||||
lsn_t getLastLsn()
|
||||
{
|
||||
return cdio_get_track_last_lsn(p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the starting LBA.
|
||||
|
||||
@return the starting LBA or CDIO_INVALID_LBA on error.
|
||||
*/
|
||||
lba_t getLba()
|
||||
{
|
||||
return cdio_get_track_lba(p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*!
|
||||
@return the starting LSN or CDIO_INVALID_LSN on error.
|
||||
*/
|
||||
lsn_t getLsn()
|
||||
{
|
||||
return cdio_get_track_lsn(p_cdio, i_track);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Return the starting MSF (minutes/secs/frames) for track number
|
||||
i_track in p_cdio.
|
||||
|
||||
@return true if things worked or false if there is no track entry.
|
||||
*/
|
||||
bool getMsf(/*out*/ msf_t &msf)
|
||||
{
|
||||
return cdio_get_track_msf(p_cdio, i_track,/*out*/ &msf);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the track number of the track object.
|
||||
*/
|
||||
track_t getTrackNum()
|
||||
{
|
||||
return i_track;
|
||||
}
|
||||
|
||||
/*! Get linear preemphasis status on an audio track
|
||||
This is not meaningful if not an audio track?
|
||||
*/
|
||||
track_flag_t getPreemphasis()
|
||||
{
|
||||
return cdio_get_track_preemphasis(p_cdio, i_track);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the number of sectors between this track an the next. This
|
||||
includes any pregap sectors before the start of the next track.
|
||||
|
||||
@return the number of sectors or 0 if there is an error.
|
||||
*/
|
||||
unsigned int getSecCount()
|
||||
{
|
||||
return cdio_get_track_sec_count(p_cdio, i_track);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user