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 @@
|
||||
/* -*- 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user