Implemented "list-devices" command for Linux.

This commit is contained in:
2017-08-21 21:04:44 +01:00
parent cdc105c72f
commit 6e441ddda1
14 changed files with 345 additions and 67 deletions

View File

@@ -291,16 +291,16 @@ namespace DiscImageChef.Core
CurrentStats.Commands.Entropy++;
break;
case "extract-files":
AllStats.Commands.Entropy++;
CurrentStats.Commands.Entropy++;
AllStats.Commands.ExtractFiles++;
CurrentStats.Commands.ExtractFiles++;
break;
case "formats":
AllStats.Commands.Formats++;
CurrentStats.Commands.Formats++;
break;
case "ls":
AllStats.Commands.Formats++;
CurrentStats.Commands.Formats++;
AllStats.Commands.Ls++;
CurrentStats.Commands.Ls++;
break;
case "media-info":
AllStats.Commands.MediaInfo++;
@@ -318,6 +318,10 @@ namespace DiscImageChef.Core
AllStats.Commands.Verify++;
CurrentStats.Commands.Verify++;
break;
case "list-devices":
AllStats.Commands.ListDevices++;
CurrentStats.Commands.ListDevices++;
break;
}
}
}

View File

@@ -0,0 +1,62 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : List.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Component
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2017 Natalia Portillo
// ****************************************************************************/
using System;
namespace DiscImageChef.Devices
{
public struct DeviceInfo
{
public string path;
public string vendor;
public string model;
public string serial;
public string bus;
public bool supported;
}
public partial class Device
{
public static DeviceInfo[] ListDevices()
{
switch(Interop.DetectOS.GetRealPlatformID())
{
case Interop.PlatformID.Win32NT:
throw new NotImplementedException();
case Interop.PlatformID.Linux:
return Linux.ListDevices.GetList();
default:
throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", Interop.DetectOS.GetRealPlatformID()));
}
}
}
}

View File

@@ -80,6 +80,8 @@
<Compile Include="Device\MmcCommands\MMC.cs" />
<Compile Include="Device\MmcCommands\SecureDigital.cs" />
<Compile Include="Device\ScsiCommands\Kreon.cs" />
<Compile Include="Device\List.cs" />
<Compile Include="Linux\ListDevices.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@@ -95,22 +97,10 @@
<MonoDevelop>
<Properties>
<Policies>
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild">
<inheritsSet />
<inheritsScope />
</DotNetNamingPolicy>
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************&#xA;The Disc Image Chef&#xA;----------------------------------------------------------------------------&#xA; &#xA;Filename : ${FileName}&#xA;Author(s) : ${AuthorName} &lt;${AuthorEmail}&gt;&#xA;&#xA;Component : Component&#xA; &#xA;--[ Description ] ----------------------------------------------------------&#xA; &#xA; Description&#xA; &#xA;--[ License ] --------------------------------------------------------------&#xA; &#xA; This library is free software; you can redistribute it and/or modify&#xA; it under the terms of the GNU Lesser General Public License as&#xA; published by the Free Software Foundation; either version 2.1 of the&#xA; License, or (at your option) any later version.&#xA;&#xA; This library is distributed in the hope that it will be useful, but&#xA; WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&#xA; Lesser General Public License for more details.&#xA;&#xA; You should have received a copy of the GNU Lesser General Public&#xA; License along with this library; if not, see &lt;http://www.gnu.org/licenses/&gt;.&#xA;&#xA;----------------------------------------------------------------------------&#xA;Copyright © 2011-${Year} ${CopyrightHolder}&#xA;****************************************************************************/">
<inheritsSet />
<inheritsScope />
</StandardHeader>
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp">
<inheritsSet />
<inheritsScope />
</TextStylePolicy>
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp">
<inheritsSet />
<inheritsScope />
</CSharpFormattingPolicy>
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************&#xA;The Disc Image Chef&#xA;----------------------------------------------------------------------------&#xA; &#xA;Filename : ${FileName}&#xA;Author(s) : ${AuthorName} &lt;${AuthorEmail}&gt;&#xA;&#xA;Component : Component&#xA; &#xA;--[ Description ] ----------------------------------------------------------&#xA; &#xA; Description&#xA; &#xA;--[ License ] --------------------------------------------------------------&#xA; &#xA; This library is free software; you can redistribute it and/or modify&#xA; it under the terms of the GNU Lesser General Public License as&#xA; published by the Free Software Foundation; either version 2.1 of the&#xA; License, or (at your option) any later version.&#xA;&#xA; This library is distributed in the hope that it will be useful, but&#xA; WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&#xA; Lesser General Public License for more details.&#xA;&#xA; You should have received a copy of the GNU Lesser General Public&#xA; License along with this library; if not, see &lt;http://www.gnu.org/licenses/&gt;.&#xA;&#xA;----------------------------------------------------------------------------&#xA;Copyright © 2011-${Year} ${CopyrightHolder}&#xA;****************************************************************************/" />
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceAfterControlFlowStatementKeyword="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" scope="text/x-csharp" />
</Policies>
</Properties>
</MonoDevelop>

View File

@@ -31,6 +31,7 @@
// Copyright © 2011-2017 Natalia Portillo
// ****************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace DiscImageChef.Devices.Linux
@@ -60,6 +61,15 @@ namespace DiscImageChef.Devices.Linux
[DllImport("libc", CharSet = CharSet.Ansi, EntryPoint = "readlink", SetLastError = true)]
internal static extern long readlink64(string path, System.IntPtr buf, long bufsize);
[DllImport("libudev", CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern IntPtr udev_new();
[DllImport("libudev", CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern IntPtr udev_device_new_from_subsystem_sysname(IntPtr udev, string subsystem, string sysname);
[DllImport("libudev", CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern string udev_device_get_property_value(IntPtr udev_device, string key);
}
}

View File

@@ -0,0 +1,142 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : ListDevices.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Component
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2017 Natalia Portillo
// ****************************************************************************/
using System;
using System.IO;
using System.Text;
namespace DiscImageChef.Devices.Linux
{
public static class ListDevices
{
const string PATH_SYS_DEVBLOCK = "/sys/block/";
public static DeviceInfo[] GetList()
{
string[] sysdevs = Directory.GetFileSystemEntries(PATH_SYS_DEVBLOCK, "*", SearchOption.TopDirectoryOnly);
DeviceInfo[] devices = new DeviceInfo[sysdevs.Length];
bool hasUdev;
StreamReader sr;
IntPtr udev = IntPtr.Zero;
IntPtr udevDev = IntPtr.Zero;
try
{
udev = Extern.udev_new();
hasUdev = udev != IntPtr.Zero;
}
catch
{
hasUdev = false;
}
for(int i = 0; i < sysdevs.Length; i++)
{
devices[i] = new DeviceInfo();
devices[i].path = "/dev/" + Path.GetFileName(sysdevs[i]);
if(hasUdev)
{
udevDev = Extern.udev_device_new_from_subsystem_sysname(udev, "block", Path.GetFileName(sysdevs[i]));
devices[i].vendor = Extern.udev_device_get_property_value(udevDev, "ID_VENDOR");
devices[i].model = Extern.udev_device_get_property_value(udevDev, "ID_MODEL");
if(!string.IsNullOrEmpty(devices[i].model))
devices[i].model = devices[i].model.Replace('_', ' ');
devices[i].serial = Extern.udev_device_get_property_value(udevDev, "ID_SCSI_SERIAL");
if(string.IsNullOrEmpty(devices[i].serial))
devices[i].serial = Extern.udev_device_get_property_value(udevDev, "ID_SERIAL_SHORT");
devices[i].bus = Extern.udev_device_get_property_value(udevDev, "ID_BUS");
}
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) && string.IsNullOrEmpty(devices[i].vendor))
{
sr = new StreamReader(Path.Combine(sysdevs[i], "device/vendor"), Encoding.ASCII);
devices[i].vendor = sr.ReadLine().Trim();
}
else if(devices[i].path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].vendor = "Linux";
if(File.Exists(Path.Combine(sysdevs[i], "device/model")) && (string.IsNullOrEmpty(devices[i].model) || devices[i].bus == "ata"))
{
sr = new StreamReader(Path.Combine(sysdevs[i], "device/model"), Encoding.ASCII);
devices[i].model = sr.ReadLine().Trim();
}
else if(devices[i].path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].model = "Linux";
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) && string.IsNullOrEmpty(devices[i].serial))
{
sr = new StreamReader(Path.Combine(sysdevs[i], "device/serial"), Encoding.ASCII);
devices[i].serial = sr.ReadLine().Trim();
}
if(string.IsNullOrEmpty(devices[i].vendor) || devices[i].vendor == "ATA")
{
string[] pieces = devices[i].model.Split(' ');
if(pieces.Length > 1)
{
devices[i].vendor = pieces[0];
devices[i].model = devices[i].model.Substring(pieces[0].Length + 1);
}
}
// TODO: Get better device type from sysfs paths
if(string.IsNullOrEmpty(devices[i].bus))
{
if(devices[i].path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].bus = "loop";
else if(devices[i].path.StartsWith("/dev/nvme", StringComparison.CurrentCulture))
devices[i].bus = "NVMe";
else if(devices[i].path.StartsWith("/dev/mmc", StringComparison.CurrentCulture))
devices[i].bus = "MMC/SD";
}
else
devices[i].bus = devices[i].bus.ToUpper();
switch(devices[i].bus)
{
case "ATA":
case "ATAPI":
case "SCSI":
case "USB":
case "PCMCIA":
case "FireWire":
devices[i].supported = true;
break;
}
}
return devices;
}
}
}

View File

@@ -79,6 +79,7 @@ namespace DiscImageChef.Metadata
public long MediaScan;
public long PrintHex;
public long Verify;
public long ListDevices;
}
public class VerifiedItems

View File

@@ -110,6 +110,7 @@ namespace DiscImageChef.Server.Controllers
oldStats.Commands.Verify += newStats.Commands.Verify;
oldStats.Commands.Ls += newStats.Commands.Ls;
oldStats.Commands.ExtractFiles += newStats.Commands.ExtractFiles;
oldStats.Commands.ListDevices += newStats.Commands.ListDevices;
}
}

View File

@@ -49,6 +49,7 @@
<i>entropy</i> command has been run <asp:Label id="lblEntropy" runat="server"/> times<br/>
<i>extract-files</i> command has been run <asp:Label id="lblExtractFiles" runat="server"/> times<br/>
<i>formats</i> command has been run <asp:Label id="lblFormats" runat="server"/> times<br/>
<i>list-devices</i> command has been run <asp:Label id="lblListDevices" runat="server"/> times<br/>
<i>ls</i> command has been run <asp:Label id="lblLs" runat="server"/> times<br/>
<i>media-info</i> command has been run <asp:Label id="lblMediaInfo" runat="server"/> times<br/>
<i>media-scan</i> command has been run <asp:Label id="lblMediaScan" runat="server"/> times<br/>

View File

@@ -105,6 +105,7 @@ namespace DiscImageChef.Server
lblDeviceReport.Text = statistics.Commands.DeviceReport.ToString();
lblLs.Text = statistics.Commands.Ls.ToString();
lblExtractFiles.Text = statistics.Commands.ExtractFiles.ToString();
lblListDevices.Text = statistics.Commands.ListDevices.ToString();
}
else
divCommands.Visible = false;

View File

@@ -1,11 +1,11 @@
//------------------------------------------------------------------------------
// <autogenerated>
// <auto-generated>
// This code was generated by a tool.
// Mono Runtime Version: 4.0.30319.42000
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// </auto-generated>
//------------------------------------------------------------------------------
namespace DiscImageChef.Server {
@@ -53,6 +53,8 @@ namespace DiscImageChef.Server {
protected System.Web.UI.WebControls.Label lblFormats;
protected System.Web.UI.WebControls.Label lblListDevices;
protected System.Web.UI.WebControls.Label lblLs;
protected System.Web.UI.WebControls.Label lblMediaInfo;

View File

@@ -0,0 +1,67 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : ListDevices.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Verbs.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements the 'media-info' verb.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2017 Natalia Portillo
// ****************************************************************************/
using System.Linq;
using DiscImageChef.Console;
using DiscImageChef.Devices;
namespace DiscImageChef.Commands
{
public static class ListDevices
{
public static void doListDevices(ListDevicesOptions options)
{
DicConsole.DebugWriteLine("Media-Info command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Media-Info command", "--verbose={0}", options.Verbose);
Devices.DeviceInfo[] devices = Device.ListDevices();
if(devices == null || devices.Length == 0)
DicConsole.WriteLine("No known devices attached.");
else
{
devices = devices.OrderBy(d => d.path).ToArray();
DicConsole.WriteLine("{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}",
"Path", "Vendor", "Model", "Serial", "Bus", "Supported?");
DicConsole.WriteLine("{0,-22}+{1,-16}+{2,-24}+{3,-24}+{4,-10}+{5,-10}",
"----------------------", "----------------", "------------------------",
"------------------------", "----------", "----------");
foreach(Devices.DeviceInfo dev in devices)
DicConsole.WriteLine("{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", dev.path, dev.vendor, dev.model, dev.serial, dev.bus, dev.supported);
}
Core.Statistics.AddCommand("list-devices");
}
}
}

View File

@@ -68,6 +68,7 @@
<Compile Include="Commands\Ls.cs" />
<Compile Include="Commands\ExtractFiles.cs" />
<Compile Include="Progress.cs" />
<Compile Include="Commands\ListDevices.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@@ -79,22 +80,14 @@
<Policies>
<VersionControlPolicy>
<CommitMessageStyle Indent="&#x9;" LastFilePostfix=":&#xA; " LineAlign="0" IncludeDirectoryPaths="True" />
<inheritsSet />
<inheritsScope />
</VersionControlPolicy>
<ChangeLogPolicy UpdateMode="ProjectRoot" VcsIntegration="RequireEntry">
<MessageStyle Header="" Indent="" LastFilePostfix=":&#xA; " LineAlign="2" IncludeDirectoryPaths="True" />
<inheritsSet />
<inheritsScope />
</ChangeLogPolicy>
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild">
<inheritsSet />
<inheritsScope />
</DotNetNamingPolicy>
<TextStylePolicy TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" FileWidth="80" TabsToSpaces="True" scope="text/plain">
<inheritsSet />
<inheritsScope />
</TextStylePolicy>
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
<TextStylePolicy TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" FileWidth="80" TabsToSpaces="True" scope="text/plain" />
<NameConventionPolicy>
<Rules>
<NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
@@ -148,18 +141,9 @@
</NamingRule>
</Rules>
</NameConventionPolicy>
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************&#xA;The Disc Image Chef&#xA;----------------------------------------------------------------------------&#xA; &#xA;Filename : ${FileName}&#xA;Author(s) : ${AuthorName} &lt;${AuthorEmail}&gt;&#xA;&#xA;Component : Component&#xA; &#xA;--[ Description ] ----------------------------------------------------------&#xA; &#xA; Description&#xA; &#xA;--[ License ] --------------------------------------------------------------&#xA; &#xA; This program is free software: you can redistribute it and/or modify&#xA; it under the terms of the GNU General Public License as&#xA; published by the Free Software Foundation, either version 3 of the&#xA; License, or (at your option) any later version.&#xA;&#xA; This program is distributed in the hope that it will be useful,&#xA; but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#xA; GNU General Public License for more details.&#xA;&#xA; You should have received a copy of the GNU General Public License&#xA; along with this program. If not, see &lt;http://www.gnu.org/licenses/&gt;.&#xA;&#xA;----------------------------------------------------------------------------&#xA;Copyright © 2011-${Year} ${CopyrightHolder}&#xA;****************************************************************************/">
<inheritsSet />
<inheritsScope />
</StandardHeader>
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp">
<inheritsSet />
<inheritsScope />
</TextStylePolicy>
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp">
<inheritsSet />
<inheritsScope />
</CSharpFormattingPolicy>
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************&#xA;The Disc Image Chef&#xA;----------------------------------------------------------------------------&#xA; &#xA;Filename : ${FileName}&#xA;Author(s) : ${AuthorName} &lt;${AuthorEmail}&gt;&#xA;&#xA;Component : Component&#xA; &#xA;--[ Description ] ----------------------------------------------------------&#xA; &#xA; Description&#xA; &#xA;--[ License ] --------------------------------------------------------------&#xA; &#xA; This program is free software: you can redistribute it and/or modify&#xA; it under the terms of the GNU General Public License as&#xA; published by the Free Software Foundation, either version 3 of the&#xA; License, or (at your option) any later version.&#xA;&#xA; This program is distributed in the hope that it will be useful,&#xA; but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#xA; GNU General Public License for more details.&#xA;&#xA; You should have received a copy of the GNU General Public License&#xA; along with this program. If not, see &lt;http://www.gnu.org/licenses/&gt;.&#xA;&#xA;----------------------------------------------------------------------------&#xA;Copyright © 2011-${Year} ${CopyrightHolder}&#xA;****************************************************************************/" />
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceAfterControlFlowStatementKeyword="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" scope="text/x-csharp" />
</Policies>
</Properties>
</MonoDevelop>

View File

@@ -57,7 +57,7 @@ namespace DiscImageChef
typeof(CreateSidecarOptions),
typeof(DumpMediaOptions), typeof(DeviceReportOptions),
typeof(ConfigureOptions), typeof(StatsOptions), typeof(LsOptions),
typeof(ExtractFilesOptions)})
typeof(ExtractFilesOptions), typeof(ListDevicesOptions)})
.WithParsed<AnalyzeOptions>(opts =>
{
if(opts.Debug)
@@ -226,6 +226,15 @@ namespace DiscImageChef
Commands.ExtractFiles.doExtractFiles(opts);
})
.WithParsed<ListDevicesOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.ListDevices.doListDevices(opts);
})
.WithParsed<ConfigureOptions>(opts => { PrintCopyright(); Commands.Configure.doConfigure(); })
.WithParsed<StatsOptions>(opts => { PrintCopyright(); Commands.Statistics.showStats(); })

View File

@@ -352,5 +352,9 @@ namespace DiscImageChef
public bool Xattrs { get; set; }
}
[Verb("list-devices", HelpText = "Lists all connected devices.")]
public class ListDevicesOptions : CommonOptions
{
}
}