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 Source #

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 Source #

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 Source #

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

modelLength :: Word Source #

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

revisionLength :: Word Source #

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

emptyHardwareInfo :: HardwareInfo Source #

A HardwareInfo object with values suitable as defaults.

data DriverId Source #

Devices or file types supported by the library.

data DriverReturnCode Source #

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

Instances

Instances details
Bounded DriverReturnCode Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Enum DriverReturnCode Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Eq DriverReturnCode Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ord DriverReturnCode Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Read DriverReturnCode Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Show DriverReturnCode Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

data SessionArg Source #

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 Source # 
Instance details

Defined in Foreign.Libcdio.Device

Enum SessionArg Source # 
Instance details

Defined in Foreign.Libcdio.Device

Eq SessionArg Source # 
Instance details

Defined in Foreign.Libcdio.Device

Ord SessionArg Source # 
Instance details

Defined in Foreign.Libcdio.Device

Read SessionArg Source # 
Instance details

Defined in Foreign.Libcdio.Device

Show SessionArg Source # 
Instance details

Defined in Foreign.Libcdio.Device

Storable SessionArg Source # 
Instance details

Defined in Foreign.Libcdio.Device

data AccessMode Source #

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 Source # 
Instance details

Defined in Foreign.Libcdio.Device

Enum AccessMode Source # 
Instance details

Defined in Foreign.Libcdio.Device

Eq AccessMode Source # 
Instance details

Defined in Foreign.Libcdio.Device

Ord AccessMode Source # 
Instance details

Defined in Foreign.Libcdio.Device

Read AccessMode Source # 
Instance details

Defined in Foreign.Libcdio.Device

Show AccessMode Source # 
Instance details

Defined in Foreign.Libcdio.Device

Storable AccessMode Source # 
Instance details

Defined in Foreign.Libcdio.Device

Capabilities

data DriveCapabilityRead Source #

Instances

Instances details
Bounded DriveCapabilityRead Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Enum DriveCapabilityRead Source #

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 Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ord DriveCapabilityRead Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Read DriveCapabilityRead Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Show DriveCapabilityRead Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ix DriveCapabilityRead Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

type DriveReadCaps = BitArray DriveCapabilityRead Source #

The collection of features for reading discs a device provides.

data DriveCapabilityWrite Source #

Instances

Instances details
Bounded DriveCapabilityWrite Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Enum DriveCapabilityWrite Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Eq DriveCapabilityWrite Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ord DriveCapabilityWrite Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Read DriveCapabilityWrite Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Show DriveCapabilityWrite Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ix DriveCapabilityWrite Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

type DriveWriteCaps = BitArray DriveCapabilityWrite Source #

The collection of features for writing discs a device provides.

capsWriteCd :: DriveWriteCaps Source #

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

capsWriteDvd :: DriveWriteCaps Source #

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

capsWrite :: DriveWriteCaps Source #

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

data DriveCapabilityMisc Source #

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

Instances

Instances details
Bounded DriveCapabilityMisc Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Enum DriveCapabilityMisc Source #

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 Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ord DriveCapabilityMisc Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Read DriveCapabilityMisc Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Show DriveCapabilityMisc Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

Ix DriveCapabilityMisc Source # 
Instance details

Defined in Foreign.Libcdio.Types.Enums

type DriveMiscCaps = BitArray DriveCapabilityMisc Source #

The collection of hardware features a device was built with.

type DriveCaps = (DriveReadCaps, DriveWriteCaps, DriveMiscCaps) Source #

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

Drivers

drivers :: [DriverId] Source #

All supported drivers, listed in order of preference.

deviceDrivers :: [DriverId] Source #

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

osDriver :: DriverId Source #

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

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

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

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

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 Source #

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

driverErrmsg :: DriverReturnCode -> String Source #

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

haveDriver :: DriverId -> Bool Source #

Determine whether the system provides a particular driver.

Devices

devices :: DriverId -> IO [FilePath] Source #

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) Source #

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 Source #

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 Source #

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) Source #

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 Source #

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) Source #

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 Source #

Get the drive capabilities for the default device.

driveCapDevice :: FilePath -> IO DriveCaps Source #

Get the drive capabilities for a specified device.

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

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 Source #

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 Source #

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 Source #

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) Source #

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) Source #

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

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

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

setBlocksize Source #

Arguments

:: Cdio

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

-> Int 
-> IO DriverReturnCode 

Set the blocksize for subsequent reads.

setSpeed Source #

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) Source #

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

Device paths

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

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

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

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 Source #

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) Source #

Set up the specified CD-ROM device for reading.

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

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

Images

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

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) Source #

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 Source #

Check that a Nero disc image file is valid.

isToc :: FilePath -> IO Bool Source #

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