mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Detecting available CDROM drives
Detecting CDROM drive device information
This commit is contained in:
@@ -155,6 +155,16 @@ namespace Bwg.Scsi
|
|||||||
m_devices.Add(newdev);
|
m_devices.Add(newdev);
|
||||||
return newdev;
|
return newdev;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// This method returns or creates a unique device info structure based on the
|
||||||
|
/// drive letter for a given drive.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="letter">the drive letter for the drive</param>
|
||||||
|
/// <returns>the single DeviceInfo object that represents this drive</returns>
|
||||||
|
public static DeviceInfo CreateDevice(string letter)
|
||||||
|
{
|
||||||
|
return CreateDevice(DeviceManager.GetNtDeviceNameForDrive(letter),letter);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,12 @@ namespace Bwg.Scsi
|
|||||||
|
|
||||||
#region private methods
|
#region private methods
|
||||||
|
|
||||||
private static string GetNtDeviceNameForDrive(string name)
|
/// <summary>
|
||||||
|
/// Return the NT name for a drive given its drive letter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">the drive letter</param>
|
||||||
|
/// <returns>the NT name</returns>
|
||||||
|
public static string GetNtDeviceNameForDrive(string name)
|
||||||
{
|
{
|
||||||
string result;
|
string result;
|
||||||
const int buflen = 512;
|
const int buflen = 512;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ using System.Text;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using CUETools.Ripper.SCSI;
|
using CUETools.Ripper.SCSI;
|
||||||
using CUETools.Codecs;
|
using CUETools.Codecs;
|
||||||
|
using CUETools.CDImage;
|
||||||
using CUETools.AccurateRip;
|
using CUETools.AccurateRip;
|
||||||
|
|
||||||
namespace CUERipper
|
namespace CUERipper
|
||||||
@@ -50,12 +51,19 @@ namespace CUERipper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string destFile = args[0];
|
string destFile = args[0];
|
||||||
|
char[] drives = CDDriveReader.DrivesAvailable();
|
||||||
|
if (drives.Length < 1)
|
||||||
|
{
|
||||||
|
Console.WriteLine("No CD drives found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
char driveLetter = drives[0];
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
CDDriveReader audioSource = new CDDriveReader();
|
CDDriveReader audioSource = new CDDriveReader();
|
||||||
audioSource.Open('D');
|
audioSource.Open(driveLetter);
|
||||||
audioSource.DriveOffset = 48;
|
audioSource.DriveOffset = 48;
|
||||||
|
|
||||||
bool toStdout = false;
|
bool toStdout = false;
|
||||||
@@ -67,7 +75,8 @@ namespace CUERipper
|
|||||||
|
|
||||||
arVerify.ContactAccurateRip(ArId);
|
arVerify.ContactAccurateRip(ArId);
|
||||||
|
|
||||||
Console.WriteLine("File Info : {0}kHz; {1} channel; {2} bit; {3}", audioSource.SampleRate, audioSource.ChannelCount, audioSource.BitsPerSample, TimeSpan.FromSeconds(audioSource.Length * 1.0 / audioSource.SampleRate));
|
Console.WriteLine("Drive : {0}", audioSource.Path);
|
||||||
|
Console.WriteLine("File Info : {0}kHz; {1} channel; {2} bit; {3}", audioSource.SampleRate, audioSource.ChannelCount, audioSource.BitsPerSample, CDImageLayout.TimeToString((uint)(audioSource.Length / 588)));
|
||||||
Console.WriteLine("Filename : {0}", destFile);
|
Console.WriteLine("Filename : {0}", destFile);
|
||||||
Console.WriteLine("AR status : {0}", arVerify.ARStatus == null ? "ok" : arVerify.ARStatus);
|
Console.WriteLine("AR status : {0}", arVerify.ARStatus == null ? "ok" : arVerify.ARStatus);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
using Bwg.Scsi;
|
using Bwg.Scsi;
|
||||||
using Bwg.Logging;
|
using Bwg.Logging;
|
||||||
using CUETools.CDImage;
|
using CUETools.CDImage;
|
||||||
@@ -46,8 +47,9 @@ namespace CUETools.Ripper.SCSI
|
|||||||
const int CB_AUDIO = 588 * 4 + 16;
|
const int CB_AUDIO = 588 * 4 + 16;
|
||||||
const int NSECTORS = 32;
|
const int NSECTORS = 32;
|
||||||
int _currentTrack = -1, _currentIndex = -1, _currentTrackActualStart = -1;
|
int _currentTrack = -1, _currentIndex = -1, _currentTrackActualStart = -1;
|
||||||
Logger m_logger = null;
|
Logger m_logger;
|
||||||
CDImageLayout _toc;
|
CDImageLayout _toc;
|
||||||
|
DeviceInfo m_info;
|
||||||
|
|
||||||
public CDImageLayout TOC
|
public CDImageLayout TOC
|
||||||
{
|
{
|
||||||
@@ -59,17 +61,23 @@ namespace CUETools.Ripper.SCSI
|
|||||||
|
|
||||||
public CDDriveReader()
|
public CDDriveReader()
|
||||||
{
|
{
|
||||||
|
m_logger = new Logger();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Open(char Drive)
|
public bool Open(char Drive)
|
||||||
{
|
{
|
||||||
Device.CommandStatus st;
|
Device.CommandStatus st;
|
||||||
|
|
||||||
|
m_info = DeviceInfo.CreateDevice(Drive + ":");
|
||||||
|
|
||||||
// Open the base device
|
// Open the base device
|
||||||
m_device = new Device(m_logger);
|
m_device = new Device(m_logger);
|
||||||
if (!m_device.Open(Drive))
|
if (!m_device.Open(Drive))
|
||||||
throw new Exception("SCSI error");
|
throw new Exception("SCSI error");
|
||||||
|
|
||||||
|
if (!m_info.ExtractInfo(m_device))
|
||||||
|
throw new Exception("SCSI error");
|
||||||
|
|
||||||
//// Open/Initialize the driver
|
//// Open/Initialize the driver
|
||||||
//Drive m_drive = new Drive(dev);
|
//Drive m_drive = new Drive(dev);
|
||||||
//DiskOperationError status = m_drive.Initialize();
|
//DiskOperationError status = m_drive.Initialize();
|
||||||
@@ -370,7 +378,7 @@ namespace CUETools.Ripper.SCSI
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return m_device.Name;
|
return m_info.LongDesc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,5 +421,14 @@ namespace CUETools.Ripper.SCSI
|
|||||||
{
|
{
|
||||||
return (hex >> 4) * 10 + (hex & 15);
|
return (hex >> 4) * 10 + (hex & 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static char[] DrivesAvailable()
|
||||||
|
{
|
||||||
|
List<char> result = new List<char>();
|
||||||
|
foreach (DriveInfo info in DriveInfo.GetDrives())
|
||||||
|
if (info.DriveType == DriveType.CDRom)
|
||||||
|
result.Add(info.Name[0]);
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -816,7 +816,6 @@ namespace CUETools.Processor
|
|||||||
if (_accurateRipId == null && _dataTrackLength == null && _eacLog != null)
|
if (_accurateRipId == null && _dataTrackLength == null && _eacLog != null)
|
||||||
{
|
{
|
||||||
sr = new StringReader(_eacLog);
|
sr = new StringReader(_eacLog);
|
||||||
uint lastAudioSector = 0;
|
|
||||||
bool isEACLog = false;
|
bool isEACLog = false;
|
||||||
CDImageLayout tocFromLog = new CDImageLayout();
|
CDImageLayout tocFromLog = new CDImageLayout();
|
||||||
while ((lineStr = sr.ReadLine()) != null)
|
while ((lineStr = sr.ReadLine()) != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user