2017-09-07 20:30:23 +01:00
|
|
|
|
// /***************************************************************************
|
2020-07-25 02:01:36 +01:00
|
|
|
|
// Aaru Data Preservation Suite
|
2017-09-07 20:30:23 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
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
|
|
|
|
//
|
2020-07-25 02:01:36 +01:00
|
|
|
|
// Component : Aaru 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:10 +00:00
|
|
|
|
// Copyright © 2011-2023 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;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.Console;
|
|
|
|
|
|
using Aaru.Devices;
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Tests.Devices;
|
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
static partial class MainClass
|
2017-09-07 20:30:23 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public static void Main()
|
2017-09-07 20:30:23 +01:00
|
|
|
|
{
|
2022-11-15 15:58:43 +00:00
|
|
|
|
AaruConsole.WriteLineEvent += System.Console.WriteLine;
|
|
|
|
|
|
AaruConsole.WriteEvent += System.Console.Write;
|
|
|
|
|
|
AaruConsole.ErrorWriteLineEvent += System.Console.Error.WriteLine;
|
|
|
|
|
|
AaruConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
|
|
|
|
|
AaruConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
2023-10-08 04:10:19 +01:00
|
|
|
|
AaruConsole.WriteExceptionEvent += System.Console.Error.WriteLine;
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
DeviceInfo[] devices = Aaru.Devices.Device.ListDevices();
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(devices == null || devices.Length == 0)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-11-30 16:31:56 +00:00
|
|
|
|
AaruConsole.WriteLine(Localization.No_known_devices_attached);
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
devices = devices.OrderBy(d => d.Path).ToArray();
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
2022-11-15 15:58:43 +00:00
|
|
|
|
System.Console.Clear();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-11-30 16:31:56 +00:00
|
|
|
|
AaruConsole.WriteLine(Localization.Aaru_device_handling_tests);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-11-30 16:31:56 +00:00
|
|
|
|
AaruConsole.WriteLine("{6,-8}|{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", Localization.Path,
|
|
|
|
|
|
Localization.Vendor, Localization.Model, Localization.Serial, Localization.Bus,
|
|
|
|
|
|
Localization.Supported, Localization.Number);
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
AaruConsole.WriteLine("{6,-8}|{0,-22}+{1,-16}+{2,-24}+{3,-24}+{4,-10}+{5,-10}", "----------------------",
|
|
|
|
|
|
"----------------", "------------------------", "------------------------",
|
|
|
|
|
|
"----------", "----------", "--------");
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2023-10-03 23:49:06 +01:00
|
|
|
|
for(var i = 0; i < devices.Length; i++)
|
|
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
AaruConsole.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);
|
2023-10-03 23:49:06 +01:00
|
|
|
|
}
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-11-30 16:31:56 +00:00
|
|
|
|
AaruConsole.Write(Localization.Please_choose_which_drive_to_test_zero_to_exit);
|
2022-11-15 15:58:43 +00:00
|
|
|
|
string strDev = System.Console.ReadLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!int.TryParse(strDev, out int item))
|
|
|
|
|
|
{
|
2022-11-30 16:31:56 +00:00
|
|
|
|
AaruConsole.WriteLine(Localization.Not_a_number_Press_any_key_to_continue);
|
2022-11-15 15:58:43 +00:00
|
|
|
|
System.Console.ReadKey();
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(item == 0)
|
|
|
|
|
|
{
|
2022-11-30 16:31:56 +00:00
|
|
|
|
AaruConsole.WriteLine(Localization.Exiting);
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(item > devices.Length)
|
|
|
|
|
|
{
|
2022-11-30 16:31:56 +00:00
|
|
|
|
AaruConsole.WriteLine(Localization.No_such_device_Press_any_key_to_continue);
|
2022-11-15 15:58:43 +00:00
|
|
|
|
System.Console.ReadKey();
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
2017-09-07 20:30:23 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
Device(devices[item - 1].Path);
|
2017-09-07 20:30:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|