---
name: "Device::Cdio"
section: "3pm"
platform: "linux"
package: "libdevice-cdio-perl"
version: "2.0.0-2+b5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Device::Cdio"
---

# Device::Cdio(3pm)

Module for CD Input and Control library.

## NAME

Device::Cdio - Module for CD Input and Control library.

## SYNOPSIS

This encapsulates CD-ROM reading and control. Applications wishing to be oblivious of the OS- and device-dependent properties of a CD-ROM can use this library.

```
    use Device::Cdio;
    use Device::Cdio::Device;
    $cd_drives = Device::Cdio::get_devices($perlcdio::DRIVER_DEVICE);
    $cd_drives = Device::Cdio::get_devices_with_cap($perlcdio::FS_AUDIO, 0);
    foreach my $drive (@$cd_drives) {
       print "Drive $drive\n";
    }
    foreach my $driver_name (sort keys(%Device::Cdio::drivers)) {
       print "Driver $driver_name is installed.\n"
          if Device::Cdio::have_driver($driver_name) and
          $driver_name !~ m{device|Unknown};
    }
```

## DESCRIPTION

This is an Perl Object-Oriented interface to the GNU CD Input and Control library, `"libcdio"`, written in C. The library encapsulates CD-ROM reading and control. Perl programs wishing to be oblivious of the OS- and device-dependent properties of a CD-ROM can use this library.

The encapsulation is done in two parts. The lower-level Perl interface is called perlcdio and is generated by SWIG.

This module uses `"perlcdio"`. Actually, there are no objects in module, but there are in its sub modules Device::Cdio::Device and Device::Cdio::Track.

Although `"perlcdio"` is perfectly usable on its own, it is expected that Cdio is what most people will use. As `"perlcdio"` more closely models the C interface `"libcdio"`, it is conceivable (if unlikely) that die-hard libcdio C users who are very familiar with that interface could prefer that.

### CALLING ROUTINES

Routines accept named parameters as well as positional parameters. For named parameters, each argument name is preceded by a dash. For example:

```
    Device::Cdio::have_driver(-driver_id=>'GNU/Linux')
```

Each argument name is preceded by a dash.  Neither case nor order matters in the argument list.  `"-driver_id"`, `"-Driver_ID"`, and `"-DRIVER_ID"` are all acceptable.  In fact, only the first argument needs to begin with a dash.  If a dash is present in the first argument, we assume dashes for the subsequent parameters.

In the documentation below and elsewhere in this package the parameter name that can be used in this style of call is given in the parameter list. For example, for `"close_tray"` the documentation below reads:

```
   close_tray(drive=undef, driver_id=$perlcdio::DRIVER_UNKNOWN)
    -> ($drc, $driver_id)
```

So the parameter names are "drive", and "driver\_id". Neither parameter is required. If "drive" is not specified, a value of "undef" will be used. And if "driver\_id" is not specified, a value of `$perlcdio::DRIVER_UNKNOWN` is used.

The older, more traditional style of positional parameters is also supported. So the `"have_driver"` example from above can also be written:

```
    Device::Cdio::have_driver('GNU/Linux')
```

Finally, since no parameter name can be confused with a an integer, negative values will not get confused as a named parameter.

## SUBROUTINES

### close\_tray

close\_tray(drive=undef, driver\_id=$perlcdio::DRIVER\_UNKNOWN)\
  \-\> ($drc, `$driver_id`)

close media tray in CD drive if there is a routine to do so.

In an array context, the driver return-code status and the name of the driver used are returned. In a scalar context, just the return code status is returned.

### driver\_strerror

driver\_strerror(rc)-\>$errmsg

Convert a driver return code into a string text message.

### get\_default\_device\_driver

get\_default\_device\_driver(driver\_id=DRIVER\_DEVICE)-\> ($device, `$driver`)

Return a string containing the default CD device if none is specified. if driver\_id is DRIVER\_UNKNOWN or DRIVER\_DEVICE then find a suitable one set the default device for that.

undef is returned as the driver if we couldn't get a default device.

### get\_devices

`$revices` = get\_devices(driver\_id=$Cdio::DRIVER\_UNKNOWN);

Return an array of device names. If you want a specific devices for a driver, give that device. If you want hardware devices, give `$perlcdio::DRIVER_DEVICE` and if you want all possible devices, image drivers and hardware drivers give `$perlcdio::DRIVER_UNKNOWN`.  undef 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 undef even though there may be a hardware CD-ROM.

### get\_devices\_ret

get\_devices\_ret($driver\_id)-\>(@devices, `$driver_id`)

Like get\_devices, but we may change the p\_driver\_id if we were given `$perlcdio::DRIVER_DEVICE` or `$perlcdio::DRIVER_UNKNOWN`.  This is because often one wants to get a drive name and then *open* it afterwords. Giving the driver back facilitates this, and speeds things up for libcdio as well.

### get\_devices\_with\_cap

`$devices` = get\_devices\_with\_cap($capabilities, `$any`);

Get an array of device names in search\_devices that have at least the capabilities listed by the capabilities parameter.

If "any" is set false then ALL capabilities listed in the extended portion of capabilities (i.e. not the basic filesystem) must be satisfied. 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 `$perlcdio::FS_MATCH_ALL`.

The array of device names is returned or undef if we couldn't get a default device.  It is also possible to return a () but after This means nothing was found.

### get\_devices\_with\_cap\_ret

Like get\_devices\_with\_cap 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 afterward. Giving the driver back facilitates this, and speeds things up for libcdio as well.

### have\_driver

have\_driver(driver\_id) -\> bool

Return 1 if we have driver driver\_id. undef is returned if driver\_id is invalid. driver\_id can either be an integer driver name defined in perlcdio or a string as defined in the hash `%drivers`.

### is\_binfile

is\_binfile(binfile)-\>cue\_name

Determine if binfile is the BIN file part of a CDRWIN Compact Disc image.

Return the corresponding CUE file if bin\_name is a BIN file or undef if not a BIN file.

### is\_cuefile

is\_cuefile(cuefile)-\>bin\_name

Determine if cuefile is the CUE file part of a CDRWIN Compact Disc image.

Return the corresponding BIN file if cue\_name is a CUE file or undef if not a CUE file.

### is\_device

is\_device(source, driver\_id=$perlcdio::DRIVER\_UNKNOWN)-\>bool

Return True if source refers to a real hardware CD-ROM.

### is\_nrg

is\_nrg(nrgfile)-\>bool

Determine if nrgfile is a Nero NRG file disc image.

### is\_tocfile

is\_tocfile(tocfile\_name)-\>bool

Determine if tocfile\_name is a cdrdao CD disc image.

### convert\_drive\_cap\_misc

convert\_drive\_cap\_misc(bitmask)-\>hash\_ref

Convert bit mask for miscellaneous drive properties into a hash reference of drive capabilities

### convert\_drive\_cap\_read

convert\_drive\_cap\_read($bitmask)-\>hash\_ref

Convert bit mask for read drive properties into a hash reference of drive capabilities

### convert\_drive\_cap\_write

convert\_drive\_cap\_write($bitmask)-\>hash\_ref

## SEE ALSO

Device::Cdio::Device for device objects and Device::Cdio::Track for track objects and Device::Cdio::ISO9660 for working with ISO 9660 filesystems.

perlcdio is the lower-level interface to libcdio.

\<http://www.gnu.org/software/libcdio/doxygen/files.html\> is documentation via doxygen for `"libcdio"`.

## AUTHORS

Rocky Bernstein

## COPYRIGHT

Copyright (C) 2006, 2011 Rocky Bernstein \<rocky@cpan.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 The GNU General Public License \<http://www.gnu.org/licenses/#GPL\>.
