hscdio-0.1.0.0: Haskell bindings to the libcdio disc-reading library.
Copyright(c) 2018-2021 Sam May
LicenseGPL-3.0-or-later
Maintainerag@eitilt.life
Stabilitystable
Portabilitynon-portable (requires libcdio)
Safe HaskellNone
LanguageHaskell2010

Foreign.Libcdio.Device

Description

The entire library architecture revolves around the concept of a device—not the disc, but the drive containing it. A function to read a segment of data is not just a lookup from memory, but an instruction to the device to move the read arm into position and begin interpreting the pits and ridges. With that understanding, it makes sense that this module provides not just the means to determine what any particular drive is capable of, but also the only means to obtain the Cdio object the everything else revolves around.

device.h

Types

Symbols

Sound.Libcdio.Device

Synopsis

Types

data Cdio #

A particular disc reading/writing device, along with the data contained on the loaded disc. Note well that this is always a mutable object, and is not thread-safe; moreover, any function this is passed to may wind up silently modifying the data.

data HardwareInfo #

Information defining the make and model of a (typically physical) device.

Constructors

HardwareInfo 

Fields

  • vendor :: String

    The company who designed and/or built the drive.

  • model :: String

    The name of the specific drive design.

  • revision :: String

    The version number for hardware/firmware following a series.

vendorLength :: Word #

Length of the drive vendor name in returned in a HardwareInfo query.

modelLength :: Word #

Length of the drive model name in returned in a HardwareInfo query.

revisionLength :: Word #

Length of the drive revision number in returned in a HardwareInfo query.

emptyHardwareInfo :: HardwareInfo #

A HardwareInfo object with values suitable as defaults.

data DriverId #

Devices or file types supported by the library.

data DriverReturnCode #

Descriptions of various error states which may be returned by driver functions.

Instances

Instances details
Bounded DriverReturnCode # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Enum DriverReturnCode # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Eq DriverReturnCode # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ord DriverReturnCode # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Read DriverReturnCode # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Show DriverReturnCode # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

data SessionArg #

Metadata about the session in the form of (often freeform) text, providing a type-safe index to getArg. Note that not every driver type supports every item.

The key "access-mode" is handled separately by getAccessMode, to better reflect its restricted outputs.

Constructors

Source 
Cue 
ScsiTuple 
MmcSupported 

Instances

Instances details
Bounded SessionArg # 
Instance details

Defined in Foreign.Libcdio.Device

Enum SessionArg # 
Instance details

Defined in Foreign.Libcdio.Device

Eq SessionArg # 
Instance details

Defined in Foreign.Libcdio.Device

Ord SessionArg # 
Instance details

Defined in Foreign.Libcdio.Device

Read SessionArg # 
Instance details

Defined in Foreign.Libcdio.Device

Show SessionArg # 
Instance details

Defined in Foreign.Libcdio.Device

Storable SessionArg # 
Instance details

Defined in Foreign.Libcdio.Device

data AccessMode #

Which instruction set should be used to communicate with the driver, providing a type-safe input for session initialization. Note that not every driver type supports every item.

Constructors

Image 
Ioctl

The DriverLinux and DriverBsdi drivers use a different internal representation for Ioctl_.

Ioctl_

The DriverFreeBsd and DriverWin32 drivers use a different internal representation for Ioctl.

Aspi 
Atapi 
Cam 
Scsi 
ReadCd 
Read10 
MmcReadWrite 
MmcReadWriteExclusive 

Instances

Instances details
Bounded AccessMode # 
Instance details

Defined in Foreign.Libcdio.Device

Enum AccessMode # 
Instance details

Defined in Foreign.Libcdio.Device

Eq AccessMode # 
Instance details

Defined in Foreign.Libcdio.Device

Ord AccessMode # 
Instance details

Defined in Foreign.Libcdio.Device

Read AccessMode # 
Instance details

Defined in Foreign.Libcdio.Device

Show AccessMode # 
Instance details

Defined in Foreign.Libcdio.Device

Storable AccessMode # 
Instance details

Defined in Foreign.Libcdio.Device

Capabilities

data DriveCapabilityRead #

Instances

Instances details
Bounded DriveCapabilityRead # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Enum DriveCapabilityRead #

Write-related properties a device can have, mostly describing what formats it can burn, which are collected in DriveWriteCaps.

Instance details

Defined in Foreign.Libcdio.Types.Enums

Eq DriveCapabilityRead # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ord DriveCapabilityRead # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Read DriveCapabilityRead # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Show DriveCapabilityRead # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ix DriveCapabilityRead # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

type DriveReadCaps = BitArray DriveCapabilityRead #

The collection of features for reading discs a device provides.

data DriveCapabilityWrite #

Instances

Instances details
Bounded DriveCapabilityWrite # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Enum DriveCapabilityWrite # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Eq DriveCapabilityWrite # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ord DriveCapabilityWrite # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Read DriveCapabilityWrite # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Show DriveCapabilityWrite # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ix DriveCapabilityWrite # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

type DriveWriteCaps = BitArray DriveCapabilityWrite #

The collection of features for writing discs a device provides.

capsWriteCd :: DriveWriteCaps #

Capabilites indicating a device has some sort of CD-writing ability.

capsWriteDvd :: DriveWriteCaps #

Capabilites indicating a device has some sort of DVD-writing ability.

capsWrite :: DriveWriteCaps #

Capabilites indicating a device has some sort of disc-writing ability.

data DriveCapabilityMisc #

Miscellaneous properties a device can have, typically describing hardware features, which are collected in DriveMiscCaps.

Instances

Instances details
Bounded DriveCapabilityMisc # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Enum DriveCapabilityMisc #

Read-related properties a device can have, mostly describing what formats it understands, which are collected in DriveReadCaps.

The difference between ReadAnalogAudio and ReadDigitalAudio is poorly documented in libcdio; they have been named here according to their assumed meanings (see https://www.cdrfaq.org/faq02.html#S2-4-3), but that pattern may not be completely accurate.

Instance details

Defined in Foreign.Libcdio.Types.Enums

Eq DriveCapabilityMisc # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ord DriveCapabilityMisc # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Read DriveCapabilityMisc # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Show DriveCapabilityMisc # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ix DriveCapabilityMisc # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

type DriveMiscCaps = BitArray DriveCapabilityMisc #

The collection of hardware features a device was built with.

type DriveCaps = (DriveReadCaps, DriveWriteCaps, DriveMiscCaps) #

The three types are usually passed around together, so we can simplify the type signatures using them.

Drivers

drivers :: [DriverId] #

All supported drivers, listed in order of preference.

deviceDrivers :: [DriverId] #

All supported drivers for physical devices, listed in order of preference.

osDriver :: DriverId #

The particular driver for the current operating system, or DriverUnknown if no device driver exists.

driverName :: Cdio -> IO (Maybe String) #

Describe the driver used by the session in a human-readable (English) manner. See also driverId.

driverId :: Cdio -> IO (Maybe DriverId) #

The machine-readable identifier of the driver used by the session. This should be preferred to driverName wherever possible.

Returns Nothing if the Cdio object has already been closed.

driverDescribe :: DriverId -> String #

Describe the IO driver in a human-readable manner, as opposed to the machine representation returned by the Show instance.

driverErrmsg :: DriverReturnCode -> String #

Describe the driver-level error in a human-readable manner, as opposed to the machine representation returned by the Show instance.

haveDriver :: DriverId -> Bool #

Determine whether the system provides a particular driver.

Devices

devices :: DriverId -> IO [FilePath] #

List (static) available devices on the system which can be accessed with a particular driver; some file devices (e.g. with DriverBinCue) might be returned, but an exhaustive list should not be expected in that case.

If passed DriverDevice, the returned value will list any type of hardware device, but no image files. Likewise, if passed DriverUnknown, all hardware devices will be returned along with any already-known images.

devicesRet :: DriverId -> IO ([FilePath], DriverId) #

Like devices, but if DriverDevice or DriverUnknown is passed, the second return value reflects the driver the library would use by default. If any other DriverId is passed, that value is returned unchanged.

devicesWithFilesystem #

Arguments

:: [FilePath]

If empty, then search all possible drives.

-> Maybe Filesystem 
-> FilesystemClasses 
-> Bool

If True, then a device matching any of the capabilities succeeds; if False then it must match every capability given (empty capabilities always match).

-> IO [FilePath] 

Determine which of the devices may read discs fitting the given description.

devicesWithFilesystemRet #

Arguments

:: [FilePath]

If empty, then search all possible drives.

-> Maybe Filesystem 
-> FilesystemClasses 
-> Bool

If True, then a device matching any of the capabilities succeeds; if False then it must match every capability given (empty capabilities always match).

-> IO ([FilePath], DriverId) 

Like devicesWithFilesystem, but returning the type of driver found as with devicesRet. This is only helpful if the device list is empty; otherwise it simply returns DriverDevice.

defaultDevice :: IO (Maybe FilePath) #

Find the default disc device for the system, if one exists.

The C library allows getting the default device from a Cdio object, but since that seems to only be initialized from either the default device itself or with an explicit path, doing so seems rather redundant.

defaultDeviceDriver #

Arguments

:: DriverId 
-> IO (Maybe FilePath, DriverId)

The name of the device, along with the associated driver if passed DriverUnknown or DriverDevice.

Find the default disc device for a given driver, if one exists.

hwinfo :: Cdio -> IO (Maybe HardwareInfo) #

Get a description of the hardware associated with a particular session.

Returns Nothing if the Cdio object has already been closed, or if an error occurred in retrieval.

driveCap :: Cdio -> IO DriveCaps #

Get the drive capabilities for the default device.

driveCapDevice :: FilePath -> IO DriveCaps #

Get the drive capabilities for a specified device.

haveAtapi :: Cdio -> IO (Maybe Bool) #

Determine if the device understands ATAPI commands.

Returns Nothing if the Cdio object has already been closed, or if the capability can't be determined.

ejectMedia :: Cdio -> IO DriverReturnCode #

Eject the media represented by the session identifier, if the device supports doing so.

Warning: Assuming this succeeds, the Cdio object is destroyed and any further operations on it will fail!

ejectDrive #

Arguments

:: Maybe FilePath

The name of the device to eject, or Nothing to use the default drive for the machine.

-> IO DriverReturnCode 

Eject media in a CD drive, if the device supports doing so. If a Cdio session has already been opened on the drive, ejectMedia is strongly recommended instead.

closeTray #

Arguments

:: Maybe FilePath

The name of the drive to use, or Nothing to use defaultDeviceDriver.

-> DriverId 
-> IO (DriverReturnCode, DriverId)

Any errors, along with the actual driver used if passed DriverUnknown or DriverDevice.

Close a CD drive, if the device supports doing so.

Session

getArg :: Cdio -> SessionArg -> IO (Maybe String) #

Retrieve the session value associated with the given key. The particular case of "access-mode" is instead handled by getAccessMode.

getAccessMode :: Cdio -> IO (Maybe AccessMode) #

Check what instruction set is in use for reading the disc. Other session values are handled by getArg.

isMediaChanged :: Cdio -> IO (Either DriverReturnCode Bool) #

Find out if the media has changed since the last call.

setBlocksize #

Arguments

:: Cdio

The CdText object is mutated as a result of the function.

-> Int 
-> IO DriverReturnCode 

Set the blocksize for subsequent reads.

setSpeed #

Arguments

:: Cdio

The CdText object is mutated as a result of the function.

-> Int 
-> IO DriverReturnCode 

Set the drive speed. With many devices, if a value above their maximum speed is given, it will be silently capped.

Note that, unlike setSpeed, this uses a unit unique to disc drives, which depends on the type of disc; to convert to or from Kb/s, use the formula dt * cds = kbs where dt is either 176 for raw data or 150 for filesystem data, and cds is the Int passed to this function.

lastSession :: Cdio -> IO (Either DriverReturnCode Lsn) #

Get the starting address of the last write session of a disc.

Device paths

cdioOpen :: Maybe FilePath -> DriverId -> IO (Maybe Cdio) #

Open a session referencing the given location, or the default device if passed Nothing.

cdioOpenAm :: Maybe FilePath -> DriverId -> AccessMode -> IO (Maybe Cdio) #

Open a session referencing the given location, or the default device if passed Nothing, with the desired access mode.

Hardware

isDevice :: FilePath -> DriverId -> IO Bool #

Determine whether the given path refers to a hardware device, according to the given driver. DriverUnknown or DriverDevice may be passed if the system is unknown.

cdioOpenCd :: Maybe FilePath -> IO (Maybe Cdio) #

Set up the specified CD-ROM device for reading.

cdioOpenAmCd :: Maybe FilePath -> AccessMode -> IO (Maybe Cdio) #

Set up the specified CD-ROM device for reading, with the desired access mode.

Images

cueFromBin :: FilePath -> IO (Maybe FilePath) #

If the given file is a BIN disc image (determined by file extension), return the corresponding CUE file. Note that this simply replaces the extension to obtain the new file name.

binFromCue :: FilePath -> IO (Maybe FilePath) #

If the given file is a valid CUE disc description, return the corresponding BIN file. Note that this simply replaces the file extension to obtain the new file name.

isNrg :: FilePath -> IO Bool #

Check that a Nero disc image file is valid.

isToc :: FilePath -> IO Bool #

Check that a cdrdao-style TOC description file is valid.