如何列出所有已安装的光驱乌德夫或者任何其他基于核心的工具(perl 也很好)?
PS:我知道这个wodim --devices
命令,但这是一个不受欢迎的依赖。
答案1
如果你喜欢 Perl,那么这个示例代码成立在 CPAN 中可以解决这个问题。它的依赖性也很低。您需要的库是设备-Cdio。
use strict;
BEGIN {
chdir 'example' if -d 'example';
use lib '../lib';
eval "use blib"; # if we fail keep going - maybe we have installed Cdio
}
use Device::Cdio;
use Device::Cdio::Device;
use Device::Cdio::Track;
use vars qw($0 $program $pause %opts);
sub print_drive_class($$$) {
my ($msg, $bitmask, $any) = @_;
my @cd_drives = Device::Cdio::get_devices_with_cap($bitmask, $any);
print "$msg...\n";
foreach my $drive (@cd_drives) {
print "Drive $drive\n";
}
print "-----\n";
}
my @cd_drives = Device::Cdio::get_devices($perlcdio::DRIVER_DEVICE);
foreach my $drive (@cd_drives) {
print "Drive $drive\n";
}
print "-----\n";
print_drive_class("All CD-ROM drives (again)", $perlcdio::FS_MATCH_ALL, 0);