Differenze tra le versioni di "Conoscere con le funzioni del API di libcdio i drive CD disponibili nel sistema"

Da Gambas-it.org - Wikipedia.
 
(Una versione intermedia di uno stesso utente non è mostrata)
Riga 1: Riga 1:
 
La libreria '''''Libcdio''''' consente di gestire i CD ed i relativi driver presenti nel sistema.
 
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.17.0.0''".
+
Per utilizzare le funzioni esterne del API di ''libcdio'' sarà necessario richiamare l'attuale libreria: "''libcdio.so.19.0.0'' ".
  
  
 
Mostriamo un semplice codice che consentirà di sapere i drive CD disponibili nel sistema:
 
Mostriamo un semplice codice che consentirà di sapere i drive CD disponibili nel sistema:
  Library "libcdio:17.0.0"
+
  Library "libcdio:19.0.0"
 
   
 
   
 
  Private Enum CDIO_LOG_DEBUG = 1, CDIO_LOG_INFO, CDIO_LOG_WARN, CDIO_LOG_ERROR, CDIO_LOG_ASSERT  
 
  Private Enum CDIO_LOG_DEBUG = 1, CDIO_LOG_INFO, CDIO_LOG_WARN, CDIO_LOG_ERROR, CDIO_LOG_ASSERT  
Riga 28: Riga 28:
 
   
 
   
 
   
 
   
  '''Public''' Sub Main()
+
  Public Sub Main()
 
   
 
   
 
   Dim cd_drive As Pointer
 
   Dim cd_drive As Pointer
Riga 36: Riga 36:
 
      
 
      
 
  <FONT color=gray>' ''Mostra una lista di driver-CD:''</font>
 
  <FONT color=gray>' ''Mostra una lista di driver-CD:''</font>
  cd_drive = cdio_get_devices(DRIVER_DEVICE)
+
  cd_drive = cdio_get_devices(DRIVER_DEVICE)
 +
  If cd_drive == 0 Then Error.Raise("Errore !")
 
   
 
   
 
  <FONT color=gray>' ''Dereferenzia il Puntatore, per ottenere i dati stringa:''</font>
 
  <FONT color=gray>' ''Dereferenzia il Puntatore, per ottenere i dati stringa:''</font>
  st = Memory cd_drive For Read
+
  st = Memory cd_drive For Read
 
   
 
   
  For j = 1 To 8192
+
  For j = 1 To 8192
    Input #st, s
+
    Input #st, s
    If InStr(s, "/dev") > 0 Then drive &= "Drive: " & s & "\n"
+
    If InStr(s, "/dev") > 0 Then drive &= "Drive: " & s & "\n"
  Next
+
  Next
 
      
 
      
  Print "== Tutti i Drive CD-ROM ==\n"; drive; "\n----\n"
+
  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 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 CD-ROM con un filesystem ISO 9660:", CDIO_FS_ANAL_ISO9660_ANY, True)
  Classe_Drive("-- Drive (S)VCD:", CDIO_FS_ANAL_VCD_ANY, True)
+
  Classe_Drive("-- Drive (S)VCD:", CDIO_FS_ANAL_VCD_ANY, True)
 
   
 
   
  '''End'''
+
  End
 
   
 
   
 
   
 
   
  '''Private''' Procedure Classe_Drive(messaggio As String, mask As Integer, b As Boolean)
+
  Private Procedure Classe_Drive(messaggio As String, mask As Integer, b As Boolean)
 
   
 
   
 
   Dim drive_cd As Pointer
 
   Dim drive_cd As Pointer
 
   
 
   
  Print messaggio
+
  Print messaggio
 
    
 
    
  drive_cd = cdio_get_devices_with_cap(Null, mask, b)
+
  drive_cd = cdio_get_devices_with_cap(Null, mask, b)
  If IsAscii(String@(Pointer@(drive_cd))) Then Print "Drive: "; String@(Pointer@(drive_cd)); "\n"
+
  If IsAscii(String@(Pointer@(drive_cd))) Then Print "Drive: "; String@(Pointer@(drive_cd)); "\n"
 
    
 
    
  '''End'''
+
  End
  
  

Versione attuale delle 08:05, 4 giu 2024

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.19.0.0 ".


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

Library "libcdio:19.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_FREEBSD, DRIVER_NETBSD, DRIVER_LINUX, DRIVER_SOLARIS,
             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)
 If cd_drive == 0 Then Error.Raise("Errore !")

' 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