Add support for choosing character encoding in appropiate command.

This commit is contained in:
2017-10-12 23:54:02 +01:00
parent 9cd9285276
commit 90a4a0b37d
72 changed files with 678 additions and 14 deletions

View File

@@ -39,6 +39,7 @@ using DiscImageChef.Filesystems;
using DiscImageChef.Filters;
using DiscImageChef.ImagePlugins;
using DiscImageChef.PartPlugins;
using System.Text;
namespace DiscImageChef.Commands
{
@@ -61,8 +62,26 @@ namespace DiscImageChef.Commands
return;
}
Encoding encoding = null;
if(options.EncodingName != null)
{
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName);
if(options.Verbose)
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
}
catch(ArgumentException)
{
DicConsole.ErrorWriteLine("Specified encoding is not supported.");
encoding = null;
return;
}
}
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins();
plugins.RegisterAllPlugins(encoding);
List<string> id_plugins;
Filesystem _plugin;

View File

@@ -33,6 +33,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using DiscImageChef.Console;
using DiscImageChef.Core;
using DiscImageChef.Filters;
@@ -53,6 +54,25 @@ namespace DiscImageChef.Commands
Sidecar.EndProgressEvent2 += Progress.EndProgress2;
Sidecar.UpdateStatusEvent += Progress.UpdateStatus;
Encoding encoding = null;
if(options.EncodingName != null)
{
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName);
if(options.Verbose)
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
}
catch(ArgumentException)
{
DicConsole.ErrorWriteLine("Specified encoding is not supported.");
encoding = null;
return;
}
}
if(File.Exists(options.InputFile))
{
if(options.Tape)
@@ -110,7 +130,7 @@ namespace DiscImageChef.Commands
Core.Statistics.AddMediaFormat(_imageFormat.GetImageFormat());
Core.Statistics.AddFilter(inputFilter.Name);
CICMMetadataType sidecar = Sidecar.Create(_imageFormat, options.InputFile, inputFilter.UUID);
CICMMetadataType sidecar = Sidecar.Create(_imageFormat, options.InputFile, inputFilter.UUID, encoding);
DicConsole.WriteLine("Writing metadata sidecar");

View File

@@ -40,6 +40,7 @@ using System.IO;
using DiscImageChef.Filters;
using DiscImageChef.Core;
using DiscImageChef.CommonTypes;
using System.Text;
namespace DiscImageChef.Commands
{
@@ -62,8 +63,26 @@ namespace DiscImageChef.Commands
return;
}
Encoding encoding = null;
if(options.EncodingName != null)
{
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName);
if(options.Verbose)
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
}
catch(ArgumentException)
{
DicConsole.ErrorWriteLine("Specified encoding is not supported.");
encoding = null;
return;
}
}
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins();
plugins.RegisterAllPlugins(encoding);
List<string> id_plugins;
Filesystem _plugin;

View File

@@ -32,6 +32,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.Core;
@@ -58,9 +59,27 @@ namespace DiscImageChef.Commands
DicConsole.ErrorWriteLine("Cannot open specified file.");
return;
}
Encoding encoding = null;
if(options.EncodingName != null)
{
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName);
if(options.Verbose)
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
}
catch(ArgumentException)
{
DicConsole.ErrorWriteLine("Specified encoding is not supported.");
encoding = null;
return;
}
}
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins();
plugins.RegisterAllPlugins(encoding);
List<string> id_plugins;
Filesystem _plugin;

View File

@@ -41,7 +41,7 @@
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Claunia.Encoding">
<HintPath>..\packages\Claunia.Encoding.1.1.0\lib\portable40-net40+sl5+win8+wp8\Claunia.Encoding.dll</HintPath>
<HintPath>..\packages\Claunia.Encoding.1.2.0\lib\portable40-net40+sl5+win8+wp8\Claunia.Encoding.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -147,7 +147,7 @@
</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;****************************************************************************/" />
<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" 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" PlaceSystemDirectiveFirst="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="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

@@ -56,6 +56,9 @@ namespace DiscImageChef
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
[Option('e', "encoding", Default = null, HelpText = "Name of character encoding to use.")]
public string EncodingName { get; set; }
}
[Verb("compare", HelpText = "Compares two disc images.")]
@@ -272,8 +275,12 @@ namespace DiscImageChef
public bool Tape { get; set; }
[Option('b', "block-size", Required = false, Default = 512, HelpText = "Only used for tapes, indicates block size. Files in the folder whose size is not a multiple of this value will simply be ignored.")]
public int BlockSize { get; set; }
[Option('e', "encoding", Default = null, HelpText = "Name of character encoding to use.")]
public string EncodingName { get; set; }
}
// TODO: Add encoding
[Verb("dump-media", HelpText = "Dumps the media inserted on a device to a media image.")]
public class DumpMediaOptions : CommonOptions
{
@@ -337,6 +344,9 @@ namespace DiscImageChef
[Option('l', "long", Default = false, HelpText = "Uses long format.")]
public bool Long { get; set; }
[Option('e', "encoding", Default = null, HelpText = "Name of character encoding to use.")]
public string EncodingName { get; set; }
}
[Verb("extract-files", HelpText = "Extracts all files in disc image.")]
@@ -350,6 +360,9 @@ namespace DiscImageChef
[Option('x', "xattrs", Default = false, HelpText = "Extract extended attributes if present.")]
public bool Xattrs { get; set; }
[Option('e', "encoding", Default = null, HelpText = "Name of character encoding to use.")]
public string EncodingName { get; set; }
}
[Verb("list-devices", HelpText = "Lists all connected devices.")]

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Claunia.Encoding" version="1.1.0" targetFramework="net40" />
<package id="Claunia.Encoding" version="1.2.0" targetFramework="net40" />
<package id="CommandLineParser" version="2.1.1-beta" targetFramework="net40" />
</packages>