2017-09-07 20:30:23 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Filename : Main.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-09-07 20:30:23 +01:00
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : DiscImageChef device testing.
|
2017-09-07 20:30:23 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-09-07 20:30:23 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using DiscImageChef.Console;
|
|
|
|
|
|
using DiscImageChef.Devices;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Tests.Devices
|
|
|
|
|
|
{
|
|
|
|
|
|
partial class MainClass
|
|
|
|
|
|
{
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLineEvent += System.Console.WriteLine;
|
|
|
|
|
|
DicConsole.WriteEvent += System.Console.Write;
|
|
|
|
|
|
DicConsole.ErrorWriteLineEvent += System.Console.Error.WriteLine;
|
|
|
|
|
|
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
|
|
|
|
|
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
|
|
|
|
|
|
|
|
|
|
|
DeviceInfo[] devices = DiscImageChef.Devices.Device.ListDevices();
|
|
|
|
|
|
|
|
|
|
|
|
if(devices == null || devices.Length == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("No known devices attached.");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
devices = devices.OrderBy(d => d.Path).ToArray();
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
|
|
|
|
|
int item;
|
|
|
|
|
|
string strDev;
|
|
|
|
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
DicConsole.WriteLine("DiscImageChef device handling tests");
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.WriteLine("{6,-8}|{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", "Path", "Vendor",
|
|
|
|
|
|
"Model", "Serial", "Bus", "Supported?", "Number");
|
|
|
|
|
|
DicConsole.WriteLine("{6,-8}|{0,-22}+{1,-16}+{2,-24}+{3,-24}+{4,-10}+{5,-10}", "----------------------",
|
|
|
|
|
|
"----------------", "------------------------", "------------------------",
|
|
|
|
|
|
"----------", "----------", "--------");
|
2017-09-07 20:30:23 +01:00
|
|
|
|
for(int i = 0; i < devices.Length; i++)
|
2017-12-20 17:15:26 +00:00
|
|
|
|
DicConsole.WriteLine("{6,-8}|{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", devices[i].Path,
|
|
|
|
|
|
devices[i].Vendor, devices[i].Model, devices[i].Serial, devices[i].Bus,
|
|
|
|
|
|
devices[i].Supported, i + 1);
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
|
|
|
|
|
DicConsole.Write("Please choose which drive to test (0 to exit): ");
|
|
|
|
|
|
strDev = System.Console.ReadLine();
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(item == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("Exiting...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(item > devices.Length)
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.WriteLine("No such device. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
Device(devices[item - 1].Path);
|
2017-09-07 20:30:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|