Move the device routines which don't refer to an object private info
(e.g. closign a tray) out of the Device class.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: device.cpp,v 1.2 2005/11/11 12:26:57 rocky Exp $
|
||||
$Id: device.cpp,v 1.3 2006/01/25 07:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -105,7 +105,7 @@ main(int argc, const char *argv[])
|
||||
CdioDevice device;
|
||||
|
||||
if (device.open(NULL)) {
|
||||
char *default_device = device.getDefaultDevice();
|
||||
char *default_device = device.getDevice();
|
||||
cdio_drive_read_cap_t i_read_cap;
|
||||
cdio_drive_write_cap_t i_write_cap;
|
||||
cdio_drive_misc_cap_t i_misc_cap;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: drives.cpp,v 1.1 2006/01/25 06:30:22 rocky Exp $
|
||||
$Id: drives.cpp,v 1.2 2006/01/25 07:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2006 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -57,7 +57,7 @@ main(int argc, const char *argv[])
|
||||
|
||||
/* Print out a list of CD-drives */
|
||||
printf("All CD-ROM/DVD drives...\n");
|
||||
ppsz_cd_drives = getDevices(DRIVER_DEVICE);
|
||||
ppsz_cd_drives = getDevices();
|
||||
if (NULL != ppsz_cd_drives)
|
||||
for( c = ppsz_cd_drives; *c != NULL; c++ ) {
|
||||
printf("Drive %s\n", *c);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: eject.cpp,v 1.5 2006/01/18 20:58:53 rocky Exp $
|
||||
$Id: eject.cpp,v 1.6 2006/01/25 07:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -51,30 +51,30 @@ main(int argc, const char *argv[])
|
||||
psz_drive = strdup(argv[1]);
|
||||
|
||||
if (!psz_drive) {
|
||||
psz_drive = device.getDefaultDevice(driver_id);
|
||||
psz_drive = getDefaultDevice(driver_id);
|
||||
if (!psz_drive) {
|
||||
printf("Can't find a CD-ROM to perform eject operation\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
try {
|
||||
device.ejectMedia(psz_drive);
|
||||
ejectMedia(psz_drive);
|
||||
printf("CD in CD-ROM drive %s ejected.\n", psz_drive);
|
||||
}
|
||||
catch ( CdioDevice::DriverOpUninit e ) {
|
||||
catch ( DriverOpUninit e ) {
|
||||
printf("Can't Eject CD from CD-ROM drive: driver is not initialized.\n",
|
||||
psz_drive);
|
||||
}
|
||||
catch ( CdioDevice::DriverOpException e ) {
|
||||
catch ( DriverOpException e ) {
|
||||
printf("Ejecting CD from CD-ROM drive %s operation error:\n\t%s.\n",
|
||||
psz_drive, e.get_msg());
|
||||
}
|
||||
|
||||
try {
|
||||
device.closeTray(psz_drive);
|
||||
closeTray(psz_drive);
|
||||
printf("Closed CD-ROM %s tray.\n", psz_drive);
|
||||
}
|
||||
catch ( CdioDevice::DriverOpException e ) {
|
||||
catch ( DriverOpException e ) {
|
||||
printf("Closing CD-ROM %s tray operation error error:\n\t%s.\n",
|
||||
psz_drive, e.get_msg());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- C++ -*-
|
||||
$Id: cdio.hpp,v 1.6 2006/01/25 06:36:07 rocky Exp $
|
||||
$Id: cdio.hpp,v 1.7 2006/01/25 07:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -36,8 +36,88 @@
|
||||
// makes sense.
|
||||
#include <cdio++/enum.hpp>
|
||||
|
||||
/* Things related to devices. No class or object is needed. */
|
||||
#include "devices.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_return_code_to_str(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)
|
||||
{
|
||||
switch (drc) {
|
||||
case DRIVER_OP_SUCCESS:
|
||||
return;
|
||||
case DRIVER_OP_ERROR:
|
||||
throw DriverOpError();
|
||||
case DRIVER_OP_UNSUPPORTED:
|
||||
throw DriverOpUnsupported();
|
||||
case DRIVER_OP_UNINIT:
|
||||
throw DriverOpUninit();
|
||||
case DRIVER_OP_NOT_PERMITTED:
|
||||
throw DriverOpNotPermitted();
|
||||
case DRIVER_OP_BAD_PARAMETER:
|
||||
throw DriverOpBadParameter();
|
||||
case DRIVER_OP_BAD_POINTER:
|
||||
throw DriverOpBadPointer();
|
||||
case DRIVER_OP_NO_DRIVER:
|
||||
throw DriverOpNoDriver();
|
||||
default:
|
||||
throw DriverOpException(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).
|
||||
@@ -105,65 +185,6 @@ public:
|
||||
p_cdio = (CdIo_t *) NULL;
|
||||
};
|
||||
|
||||
/** 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_return_code_to_str(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;}
|
||||
};
|
||||
|
||||
// Other member functions
|
||||
#include "device.hpp"
|
||||
#include "disc.hpp"
|
||||
@@ -172,29 +193,9 @@ public:
|
||||
|
||||
private:
|
||||
CdIo_t *p_cdio;
|
||||
void possible_throw_device_exception(driver_return_code_t drc)
|
||||
{
|
||||
switch (drc) {
|
||||
case DRIVER_OP_SUCCESS:
|
||||
return;
|
||||
case DRIVER_OP_ERROR:
|
||||
throw DriverOpError();
|
||||
case DRIVER_OP_UNSUPPORTED:
|
||||
throw DriverOpUnsupported();
|
||||
case DRIVER_OP_UNINIT:
|
||||
throw DriverOpUninit();
|
||||
case DRIVER_OP_NOT_PERMITTED:
|
||||
throw DriverOpNotPermitted();
|
||||
case DRIVER_OP_BAD_PARAMETER:
|
||||
throw DriverOpBadParameter();
|
||||
case DRIVER_OP_BAD_POINTER:
|
||||
throw DriverOpBadPointer();
|
||||
case DRIVER_OP_NO_DRIVER:
|
||||
throw DriverOpNoDriver();
|
||||
default:
|
||||
throw DriverOpException(drc);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* Things related to devices. No class or object is needed. */
|
||||
#include "devices.hpp"
|
||||
|
||||
#endif /* __CDIO_HPP__ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- C++ -*-
|
||||
$Id: device.hpp,v 1.4 2006/01/18 21:01:59 rocky Exp $
|
||||
$Id: device.hpp,v 1.5 2006/01/25 07:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -36,33 +36,6 @@ close()
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
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)
|
||||
{
|
||||
driver_return_code_t drc = cdio_close_tray (psz_drive, &driver_id);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
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)
|
||||
{
|
||||
driver_id_t driver_id = DRIVER_UNKNOWN;
|
||||
closeTray(psz_drive, driver_id);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Eject media in CD drive if there is a routine to do so.
|
||||
|
||||
@@ -75,30 +48,6 @@ ejectMedia ()
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
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)
|
||||
{
|
||||
driver_return_code_t drc = cdio_eject_media_drive(psz_drive);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
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)
|
||||
{
|
||||
return cdio_driver_describe(driver_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
Free device list returned by GetDevices
|
||||
|
||||
@@ -143,104 +92,21 @@ cdtext_t *getCdtext(track_t i_track)
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the default CD device.
|
||||
Get the CD device name for the object.
|
||||
|
||||
@return a string containing the default CD device or NULL is
|
||||
if we couldn't get a default device.
|
||||
@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 *
|
||||
getDefaultDevice ()
|
||||
getDevice ()
|
||||
{
|
||||
return cdio_get_default_device(p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
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 cdio_get_default_device_driver(&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)
|
||||
{
|
||||
return cdio_get_devices(driver_id);
|
||||
}
|
||||
|
||||
/*! 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)
|
||||
{
|
||||
return cdio_get_devices_ret(&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)
|
||||
{
|
||||
return cdio_get_devices_with_cap(ppsz_search_devices, capabilities, b_any);
|
||||
}
|
||||
|
||||
/*!
|
||||
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, bool b_any,
|
||||
/*out*/ driver_id_t &driver_id)
|
||||
{
|
||||
return cdio_get_devices_with_cap_ret(ppsz_search_devices, capabilities,
|
||||
b_any, &driver_id);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Get the what kind of device we've got.
|
||||
|
||||
@@ -260,24 +126,6 @@ getDriveCap (cdio_drive_read_cap_t &read_cap,
|
||||
cdio_get_drive_cap(p_cdio, &read_cap, &write_cap, &misc_cap);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the drive capabilities for a specified device.
|
||||
|
||||
@return a list of device 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 (const char *device,
|
||||
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.
|
||||
|
||||
@@ -343,13 +191,6 @@ haveATAPI ()
|
||||
return cdio_have_atapi(p_cdio);
|
||||
}
|
||||
|
||||
/*! Like cdio_have_xxx but uses an enumeration instead. */
|
||||
bool
|
||||
haveDriver (driver_id_t driver_id)
|
||||
{
|
||||
return cdio_have_driver(driver_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Sets up to read from the device specified by psz_source. An open
|
||||
@@ -399,73 +240,6 @@ open (const char *psz_source, driver_id_t driver_id,
|
||||
return NULL != p_cdio ;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
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 *bin_name)
|
||||
{
|
||||
return cdio_is_binfile(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 *cue_name)
|
||||
{
|
||||
return cdio_is_cuefile(cue_name);
|
||||
}
|
||||
|
||||
/*!
|
||||
Determine if psg_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)
|
||||
{
|
||||
return cdio_is_nrg(psz_nrg);
|
||||
}
|
||||
|
||||
/*!
|
||||
Determine if psg_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)
|
||||
{
|
||||
return cdio_is_tocfile(psz_toc);
|
||||
}
|
||||
|
||||
/*!
|
||||
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)
|
||||
{
|
||||
return cdio_is_device(psz_source, driver_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the blocksize for subsequent reads.
|
||||
*/
|
||||
@@ -498,4 +272,3 @@ setArg (const char key[], const char value[])
|
||||
driver_return_code_t drc = cdio_set_arg (p_cdio, key, value);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- C++ -*-
|
||||
$Id: devices.hpp,v 1.2 2006/01/25 06:36:07 rocky Exp $
|
||||
$Id: devices.hpp,v 1.3 2006/01/25 07:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -20,9 +20,61 @@
|
||||
|
||||
/** \file devices.hpp
|
||||
*
|
||||
* \brief methods relating to getting lists of devices. This file
|
||||
* should not be #included directly.
|
||||
* \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.
|
||||
v*/
|
||||
void closeTray (const char *psz_drive, /*in/out*/ driver_id_t &driver_id)
|
||||
{
|
||||
driver_return_code_t drc = cdio_close_tray (psz_drive, &driver_id);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
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)
|
||||
{
|
||||
driver_id_t driver_id = DRIVER_UNKNOWN;
|
||||
closeTray(psz_drive, driver_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
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)
|
||||
{
|
||||
return cdio_driver_describe(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)
|
||||
{
|
||||
driver_return_code_t drc = cdio_eject_media_drive(psz_drive);
|
||||
possible_throw_device_exception(drc);
|
||||
}
|
||||
|
||||
/*!
|
||||
Free device list returned by GetDevices
|
||||
|
||||
@@ -37,6 +89,19 @@ freeDeviceList (char * device_list[])
|
||||
cdio_free_device_list(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 cdio_get_default_device_driver(&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,
|
||||
@@ -105,3 +170,77 @@ getDevices(/*in*/ char* ppsz_search_devices[],
|
||||
return cdio_get_devices_with_cap_ret(ppsz_search_devices, capabilities,
|
||||
b_any, &driver_id);
|
||||
}
|
||||
|
||||
/*! Like cdio_have_xxx but uses an enumeration instead. */
|
||||
bool
|
||||
haveDriver (driver_id_t driver_id)
|
||||
{
|
||||
return cdio_have_driver(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 *bin_name)
|
||||
{
|
||||
return cdio_is_binfile(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 *cue_name)
|
||||
{
|
||||
return cdio_is_cuefile(cue_name);
|
||||
}
|
||||
|
||||
/*!
|
||||
Determine if psg_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)
|
||||
{
|
||||
return cdio_is_nrg(psz_nrg);
|
||||
}
|
||||
|
||||
/*!
|
||||
Determine if psg_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)
|
||||
{
|
||||
return cdio_is_tocfile(psz_toc);
|
||||
}
|
||||
|
||||
/*!
|
||||
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)
|
||||
{
|
||||
return cdio_is_device(psz_source, driver_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user