Conoscere con le funzioni del API di libcdio i drive CD disponibili nel sistema

Da Gambas-it.org - Wikipedia.
Versione del 21 ago 2014 alle 19:26 di Vuott (Discussione | contributi) (Creata pagina con 'La libreria '''''Libcdio''''' consente di gestire i CD ed i relativi driver presenti nel sistema. Per utilizzare le funzioni esterne del API di ''libcdio'' sarà necessario r...')

(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

La libreria Libcdio consente di gestire i CD ed i relativi driver presenti nel sistema.

Per utilizzare le funzioni esterne del API di libcdio sarà necessario richiamare l'attuale libreria: "libcdio.so.13.0.0".


Mostriamo un semplice codice che consentirà di sapere i drive CD disponibili nel sistema:

Library "libcdio:13.0.0"

Private Enum CDIO_LOG_DEBUG = 1, CDIO_LOG_INFO, CDIO_LOG_WARN, CDIO_LOG_ERROR, CDIO_LOG_ASSERT 

Private Enum DRIVER_UNKNOWN = 0, DRIVER_AIX, DRIVER_BSDI, DRIVER_FREEBSD, DRIVER_NETBSD, DRIVER_LINUX, DRIVER_SOLARIS, DRIVER_OS2, DRIVER_OSX,
             DRIVER_WIN32, drive_cdRDAO, DRIVER_BINCUE, DRIVER_NRG, DRIVER_DEVICE
 
Private Enum CDIO_FS_MASK = &0F, CDIO_FS_ANAL_XA = &10, CDIO_FS_ANAL_MULTISESSION = &20, CDIO_FS_ANAL_PHOTO_CD = &40, CDIO_FS_ANAL_HIDDEN_TRACK = &80, CDIO_FS_ANAL_CDTV = &100,
             CDIO_FS_ANAL_BOOTABLE = &200, CDIO_FS_ANAL_VIDEOCD = &400, CDIO_FS_ANAL_ROCKRIDGE = &800, CDIO_FS_ANAL_JOLIET = &1000, CDIO_FS_ANAL_SVCD = &2000,
             CDIO_FS_ANAL_CVD = &4000, CDIO_FS_ANAL_XISO = &8000, CDIO_FS_ANAL_ISO9660_ANY = &10000, CDIO_FS_ANAL_VCD_ANY = &6400, CDIO_FS_MATCH_ALL = &F0
              
Private Enum CDIO_FS_AUDIO = 1, CDIO_FS_HIGH_SIERRA, CDIO_FS_ISO_9660, CDIO_FS_INTERACTIVE, CDIO_FS_HFS, CDIO_FS_UFS, CDIO_FS_EXT2, CDIO_FS_ISO_HFS,
             CDIO_FS_ISO_9660_INTERACTIVE, CDIO_FS_3DO, CDIO_FS_XISO, CDIO_FS_UDFX, CDIO_FS_UDF, CDIO_FS_ISO_UDF, CDIO_FS_UNKNOWN

' char** cdio_get_devices(driver_id_t driver_id)
' Return an array of device names.
Private Extern cdio_get_devices(driver_id As Integer) As Pointer

' char ** cdio_get_devices_with_cap(char *ppsz_search_devices[], cdio_fs_anal_t capabilities, bool b_any)
' Get an array of device names in search_devices that have at least the capabilities listed by the capabities parameter.
Private Extern cdio_get_devices_with_cap(ppsz_search_devices As String, capabilities As Integer, boo As Boolean) As Pointer


Public Sub Main()

 Dim cd_drive As Pointer
 Dim st As Stream
 Dim s, drive As String
 Dim j As Short
   
' Mostra una lista di driver-CD:
  cd_drive = cdio_get_devices(DRIVER_DEVICE)

' Dereferenzia il Puntatore, per ottenere i dati stringa:
  st = Memory cd_drive For Read

  For j = 1 To 8192
    Input #st, s
    If InStr(s, "/dev") > 0 Then drive &= "Drive: " & s & "\n"
  Next
   
  Print "== Tutti i Drive CD-ROM ==\n"; drive; "\n----\n"

  Classe_Drive("-- Drive CD-ROM con CD-DA:", CDIO_FS_AUDIO, False)
  Classe_Drive("-- Drive CD-ROM con un filesystem ISO 9660:", CDIO_FS_ANAL_ISO9660_ANY, True)
  Classe_Drive("-- Drive (S)VCD:", CDIO_FS_ANAL_VCD_ANY, True)

End


Private Procedure Classe_Drive(messaggio As String, mask As Integer, b As Boolean)

 Dim drive_cd As Pointer

  Print messaggio
 
  drive_cd = cdio_get_devices_with_cap(Null, mask, b)
  If IsAscii(String@(Pointer@(drive_cd))) Then Print "Drive: "; String@(Pointer@(drive_cd)); "\n"
 
End


Riferimenti