Added complete XZ support

This commit is contained in:
Roman Belkov 2015-02-19 18:28:10 +03:00
parent e6facdd339
commit d2e2a6ab76
18 changed files with 1096 additions and 230 deletions

View file

@ -13,6 +13,18 @@
"SccProvider" = "8:"
"Hierarchy"
{
"Entry"
{
"MsmKey" = "8:_4C9E153BB206498EB3F99948F60DD2E3"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_6E9AF8EC5D4F379F4D34C8099B9F1E44"
"OwnerKey" = "8:_8FDF365DCE9B4F70A60EF2BB1651CCBF"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_8FDF365DCE9B4F70A60EF2BB1651CCBF"
@ -34,6 +46,12 @@
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_6E9AF8EC5D4F379F4D34C8099B9F1E44"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_B1090C5A5662721B31DE535DD9FE3833"
"MsmSig" = "8:_UNDEFINED"
}
@ -142,6 +160,57 @@
}
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4C9E153BB206498EB3F99948F60DD2E3"
{
"SourcePath" = "8:..\\XZ.NET\\liblzma.dll"
"TargetName" = "8:liblzma.dll"
"Tag" = "8:"
"Folder" = "8:_072AE4B10D3C471AA2B16D68E3691837"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_6E9AF8EC5D4F379F4D34C8099B9F1E44"
{
"AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:XZ.NET, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86"
"ScatterAssemblies"
{
"_6E9AF8EC5D4F379F4D34C8099B9F1E44"
{
"Name" = "8:XZ.NET.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:XZ.NET.dll"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_072AE4B10D3C471AA2B16D68E3691837"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_B1090C5A5662721B31DE535DD9FE3833"
{
"AssemblyRegister" = "3:1"

View file

@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiskImager", "DiskImager\DiskImager.csproj", "{4A73C63C-2BF2-4F85-AA55-A5CA581A33B4}"
ProjectSection(ProjectDependencies) = postProject
{2A389B68-70DC-4853-81AE-56484F32E94D} = {2A389B68-70DC-4853-81AE-56484F32E94D}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0FB24EA0-02E1-48C7-852F-CF51898CCF93}"
ProjectSection(SolutionItems) = preProject
@ -15,6 +18,8 @@ Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "DiskImager.Installer", "Dis
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpZLib", "ICSharpCode.SharpZipLib\ICSharpCode.SharpZLib.csproj", "{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XZ.NET", "XZ.NET\XZ.NET.csproj", "{2A389B68-70DC-4853-81AE-56484F32E94D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -55,6 +60,16 @@ Global
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|x86.ActiveCfg = Release|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Debug|x86.ActiveCfg = Debug|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Release|Any CPU.Build.0 = Release|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -62,4 +77,7 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
VisualSVNWorkingCopyRoot = .
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal

View file

@ -18,6 +18,7 @@ using DynamicDevices.DiskWriter.Properties;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.Tar;
using ICSharpCode.SharpZipLib.Zip;
using XZ.NET;
namespace DynamicDevices.DiskWriter
{
@ -112,7 +113,6 @@ namespace DynamicDevices.DiskWriter
LogMsg(Resources.Disk_WriteDrive_Failed_to_lock_drive);
return false;
}
//
// Get drive size
@ -152,67 +152,70 @@ namespace DynamicDevices.DiskWriter
switch (eCompType)
{
case EnumCompressionType.Zip:
{
var zipFile = new ZipFile(basefs);
var zipFile = new ZipFile(basefs);
var ze = (from ZipEntry zipEntry in zipFile
where zipEntry.IsFile
select zipEntry).FirstOrDefault();
var ze = (from ZipEntry zipEntry in zipFile
where zipEntry.IsFile
select zipEntry).FirstOrDefault();
if(ze == null)
{
LogMsg(Resources.Disk_WriteDrive_Error_reading_zip_input_stream);
goto readfail2;
}
var zis = zipFile.GetInputStream(ze);
uncompressedlength = ze.Size;
fs = zis;
if(ze == null)
{
LogMsg(Resources.Disk_WriteDrive_Error_reading_zip_input_stream);
goto readfail2;
}
var zis = zipFile.GetInputStream(ze);
uncompressedlength = ze.Size;
fs = zis;
break;
case EnumCompressionType.Gzip:
{
var gzis = new GZipInputStream(basefs) {IsStreamOwner = true};
var gzis = new GZipInputStream(basefs) {IsStreamOwner = true};
uncompressedlength = gzis.Length;
fs = gzis;
}
uncompressedlength = gzis.Length;
fs = gzis;
break;
case EnumCompressionType.Targzip:
var gzos = new GZipInputStream(basefs) {IsStreamOwner = true};
var tis = new TarInputStream(gzos);
TarEntry tarEntry;
do
{
var gzos = new GZipInputStream(basefs) {IsStreamOwner = true};
tarEntry = tis.GetNextEntry();
} while (tarEntry.IsDirectory);
var tis = new TarInputStream(gzos);
uncompressedlength = tarEntry.Size;
fs = tis;
break;
TarEntry tarEntry;
do
{
tarEntry = tis.GetNextEntry();
} while (tarEntry.IsDirectory);
case EnumCompressionType.XZ:
var xzs = new XZInputStream(basefs);
uncompressedlength = xzs.Length;
fs = xzs;
uncompressedlength = tarEntry.Size;
fs = tis;
}
break;
default:
// No compression - direct to file stream
fs = basefs;
uncompressedlength = fs.Length;
break;
}
var bufferOffset = 0;
using (var br = new BinaryReader(fs))
{
while (offset < uncompressedlength && !IsCancelling)
@ -283,6 +286,25 @@ namespace DynamicDevices.DiskWriter
string.Format("{0:F}", (bytesPerSec / (1024 * 1024))) + @" MB/sec," + Resources.Disk_WriteDrive_Elapsed_time__ + tsElapsed.ToString(@"dd\.hh\:mm\:ss")));
}
}
if (fs is ZipOutputStream)
{
((ZipOutputStream)fs).CloseEntry();
((ZipOutputStream)fs).Close();
}
if (fs is TarOutputStream)
{
((TarOutputStream)fs).CloseEntry();
fs.Close();
}
if (fs is GZipOutputStream)
{
fs.Close();
}
if (fs is XZOutputStream)
{
fs.Close();
}
}
errored = false;
@ -370,7 +392,6 @@ namespace DynamicDevices.DiskWriter
var buffer = new byte[Globals.MaxBufferSize];
var offset = 0L;
using(var basefs = (Stream)new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
Stream fs;
@ -378,57 +399,63 @@ namespace DynamicDevices.DiskWriter
switch (eCompType)
{
case EnumCompressionType.Zip:
{
var zfs = new ZipOutputStream(basefs);
var zfs = new ZipOutputStream(basefs);
// Default to middle of the range compression
zfs.SetLevel(Globals.CompressionLevel);
// Default to middle of the range compression
zfs.SetLevel(Globals.CompressionLevel);
var fi = new FileInfo(fileName);
var entryName = fi.Name;
entryName = entryName.ToLower().Replace(".zip", "");
entryName = ZipEntry.CleanName(entryName);
var zipEntry = new ZipEntry(entryName) {DateTime = fi.LastWriteTime};
zfs.IsStreamOwner = true;
var fi = new FileInfo(fileName);
var entryName = fi.Name;
entryName = entryName.ToLower().Replace(".zip", "");
entryName = ZipEntry.CleanName(entryName);
var zipEntry = new ZipEntry(entryName) {DateTime = fi.LastWriteTime};
zfs.IsStreamOwner = true;
// Todo: Consider whether size needs setting for older utils ?
// Todo: Consider whether size needs setting for older utils ?
zfs.PutNextEntry(zipEntry);
zfs.PutNextEntry(zipEntry);
fs = zfs;
fs = zfs;
}
break;
case EnumCompressionType.Gzip:
{
var gzos = new GZipOutputStream(basefs);
gzos.SetLevel(Globals.CompressionLevel);
gzos.IsStreamOwner = true;
var gzis = new GZipOutputStream(basefs);
gzis.SetLevel(Globals.CompressionLevel);
gzis.IsStreamOwner = true;
fs = gzos;
}
fs = gzis;
break;
case EnumCompressionType.Targzip:
{
var gzos = new GZipOutputStream(basefs);
gzos.SetLevel(Globals.CompressionLevel);
gzos.IsStreamOwner = true;
var gzos = new GZipOutputStream(basefs);
gzos.SetLevel(Globals.CompressionLevel);
gzos.IsStreamOwner = true;
var tos = new TarOutputStream(gzos);
var tos = new TarOutputStream(gzos);
fs = tos;
break;
case EnumCompressionType.XZ:
var xzs = new XZOutputStream(basefs);
fs = xzs;
fs = tos;
}
break;
default:
// No compression - direct to file stream
fs = basefs;
break;
}
while (offset < readSize && !IsCancelling)
{
// NOTE: If we provide a buffer that extends past the end of the physical device ReadFile() doesn't
@ -511,7 +538,6 @@ namespace DynamicDevices.DiskWriter
}
// Todo: Do we need this?
if (fs is ZipOutputStream)
{
((ZipOutputStream)fs).CloseEntry();
@ -520,14 +546,16 @@ namespace DynamicDevices.DiskWriter
if (fs is TarOutputStream)
{
((TarOutputStream) fs).CloseEntry();
((TarOutputStream) fs).Close();
fs.Close();
}
if (fs is GZipOutputStream)
{
// ((GZipOutputStream) fs).Finish();
((GZipOutputStream) fs).Close();
fs.Close();
}
if (fs is XZOutputStream)
{
fs.Close();
}
}
readfail1:

View file

@ -161,6 +161,10 @@
<Project>{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}</Project>
<Name>ICSharpCode.SharpZLib</Name>
</ProjectReference>
<ProjectReference Include="..\XZ.NET\XZ.NET.csproj">
<Project>{2a389b68-70dc-4853-81ae-56484f32e94d}</Project>
<Name>XZ.NET</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -1,6 +1,7 @@
/**
* DiskImager - a tool for writing / reading images on SD cards
*
* Copyright 2015 by Roman Belkov <romanbelkov@gmail.com>
* Copyright 2013, 2014 by Alex J. Lennon <ajlennon@dynamicdevices.co.uk>
*
* Licensed under GNU General Public License 3.0 or later.
@ -16,6 +17,7 @@ namespace DynamicDevices.DiskWriter
None = 0,
Zip = 1,
Gzip = 2,
Targzip = 3
Targzip = 3,
XZ = 4
}
}

View file

@ -40,6 +40,7 @@
this.labelDriveTitle = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxCompression = new System.Windows.Forms.GroupBox();
this.radioButtonCompXZ = new System.Windows.Forms.RadioButton();
this.radioButtonCompNone = new System.Windows.Forms.RadioButton();
this.radioButtonCompTgz = new System.Windows.Forms.RadioButton();
this.radioButtonCompGz = new System.Windows.Forms.RadioButton();
@ -128,6 +129,7 @@
// groupBoxCompression
//
resources.ApplyResources(this.groupBoxCompression, "groupBoxCompression");
this.groupBoxCompression.Controls.Add(this.radioButtonCompXZ);
this.groupBoxCompression.Controls.Add(this.radioButtonCompNone);
this.groupBoxCompression.Controls.Add(this.radioButtonCompTgz);
this.groupBoxCompression.Controls.Add(this.radioButtonCompGz);
@ -135,6 +137,14 @@
this.groupBoxCompression.Name = "groupBoxCompression";
this.groupBoxCompression.TabStop = false;
//
// radioButtonCompXZ
//
resources.ApplyResources(this.radioButtonCompXZ, "radioButtonCompXZ");
this.radioButtonCompXZ.Name = "radioButtonCompXZ";
this.radioButtonCompXZ.TabStop = true;
this.radioButtonCompXZ.UseVisualStyleBackColor = true;
this.radioButtonCompXZ.CheckedChanged += new System.EventHandler(this.radioButtonCompXZ_CheckedChanged);
//
// radioButtonCompNone
//
resources.ApplyResources(this.radioButtonCompNone, "radioButtonCompNone");
@ -319,6 +329,7 @@
private System.Windows.Forms.ToolStripMenuItem russianToolStripMenuItem;
private System.Windows.Forms.CheckBox checkBoxUnmount;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.RadioButton radioButtonCompXZ;
}
}

View file

@ -266,6 +266,11 @@ namespace DynamicDevices.DiskWriter
UpdateFileNameText();
}
private void radioButtonCompXZ_CheckedChanged(object sender, EventArgs e)
{
UpdateFileNameText();
}
private void RadioButtonCompNoneCheckedChanged(object sender, EventArgs e)
{
UpdateFileNameText();
@ -285,6 +290,7 @@ namespace DynamicDevices.DiskWriter
text = text.Replace(".gzip", "");
text = text.Replace(".gz", "");
text = text.Replace(".zip", "");
text = text.Replace(".xz", "");
if (radioButtonCompNone.Checked)
{
@ -297,11 +303,14 @@ namespace DynamicDevices.DiskWriter
{
text += ".tgz";
textBoxFileName.Text = text;
}
else if (radioButtonCompGz.Checked)
} else if (radioButtonCompGz.Checked)
{
text += ".gz";
textBoxFileName.Text = text;
} else if (radioButtonCompXZ.Checked)
{
text += ".xz";
textBoxFileName.Text = text;
}
}
@ -373,6 +382,8 @@ namespace DynamicDevices.DiskWriter
radioButtonCompZip.Checked = true;
else if (textBoxFileName.Text.ToLower().EndsWith(".img") || textBoxFileName.Text.ToLower().EndsWith(".bin") || textBoxFileName.Text.ToLower().EndsWith(".sdcard"))
radioButtonCompNone.Checked = true;
else if (textBoxFileName.Text.ToLower().EndsWith(".xz"))
radioButtonCompXZ.Checked = true;
if (radioButtonCompNone.Checked)
_eCompType = EnumCompressionType.None;
@ -382,6 +393,8 @@ namespace DynamicDevices.DiskWriter
_eCompType = EnumCompressionType.Gzip;
else if (radioButtonCompZip.Checked)
_eCompType = EnumCompressionType.Zip;
else if (radioButtonCompXZ.Checked)
_eCompType = EnumCompressionType.XZ;
}
private void DisplayAllDrivesToolStripMenuItemCheckedChanged(object sender, EventArgs e)

View file

@ -123,8 +123,12 @@
<data name="languageToolStripMenuItem.Text" xml:space="preserve">
<value>Language</value>
</data>
<data name="&gt;&gt;languageToolStripMenuItem.Name" xml:space="preserve">
<value>languageToolStripMenuItem</value>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="flowLayoutPanelProgressLabels.FlowDirection" type="System.Windows.Forms.FlowDirection, System.Windows.Forms">
<value>TopDown</value>
</data>
<data name="&gt;&gt;optionsToolStripMenuItem.Name" xml:space="preserve">
<value>optionsToolStripMenuItem</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="labelFileName.Size" type="System.Drawing.Size, System.Drawing">
@ -139,8 +143,8 @@
<data name="checkBoxUnmount.Text" xml:space="preserve">
<value>Unmount drives after write</value>
</data>
<data name="&gt;&gt;checkedListBoxDrives.ZOrder" xml:space="preserve">
<value>3</value>
<data name="checkBoxUnmount.Size" type="System.Drawing.Size, System.Drawing">
<value>149, 17</value>
</data>
<data name="&gt;&gt;checkBoxUnmount.Name" xml:space="preserve">
<value>checkBoxUnmount</value>
@ -148,21 +152,14 @@
<data name="&gt;&gt;checkBoxUnmount.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="buttonExit.TabIndex" type="System.Int32, mscorlib">
<value>18</value>
</data>
<data name="&gt;&gt;flowLayoutPanelProgressBars.Name" xml:space="preserve">
<value>flowLayoutPanelProgressBars</value>
</data>
<data name="&gt;&gt;labelFileName.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="checkBoxUnmount.Size" type="System.Drawing.Size, System.Drawing">
<value>149, 17</value>
</data>
<data name="checkBoxUseMBR.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
<data name="optionsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 20</value>
</data>
<data name="&gt;&gt;groupBoxTruncation.Name" xml:space="preserve">
<value>groupBoxTruncation</value>
@ -176,14 +173,20 @@
<data name="checkBoxUseMBR.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 17</value>
</data>
<data name="&gt;&gt;checkedListBoxDrives.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="&gt;&gt;russianToolStripMenuItem.Name" xml:space="preserve">
<value>russianToolStripMenuItem</value>
</data>
<data name="flowLayoutPanelProgressLabels.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 219</value>
</data>
<data name="&gt;&gt;radioButtonCompNone.Name" xml:space="preserve">
<value>radioButtonCompNone</value>
<data name="flowLayoutPanelProgressBars.Location" type="System.Drawing.Point, System.Drawing">
<value>155, 89</value>
</data>
<data name="&gt;&gt;buttonChooseFile.Name" xml:space="preserve">
<value>buttonChooseFile</value>
</data>
<data name="checkBoxUnmount.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 45</value>
@ -191,22 +194,22 @@
<data name="menuStripMain.Text" xml:space="preserve">
<value>menuStrip1</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="flowLayoutPanelProgressBars.FlowDirection" type="System.Windows.Forms.FlowDirection, System.Windows.Forms">
<value>TopDown</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="radioButtonCompNone.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="&gt;&gt;flowLayoutPanelProgressBars.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="radioButtonCompTgz.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="radioButtonCompZip.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;buttonChooseFile.Name" xml:space="preserve">
<value>buttonChooseFile</value>
</data>
<data name="buttonCancel.Text" xml:space="preserve">
<value>Cancel</value>
</data>
@ -226,7 +229,7 @@
<value>12</value>
</data>
<data name="radioButtonCompGz.Location" type="System.Drawing.Point, System.Drawing">
<value>71, 19</value>
<value>54, 19</value>
</data>
<data name="&gt;&gt;checkBoxUseMBR.ZOrder" xml:space="preserve">
<value>1</value>
@ -243,14 +246,14 @@
<data name="&gt;&gt;menuStripMain.ZOrder" xml:space="preserve">
<value>10</value>
</data>
<data name="&gt;&gt;buttonExit.ZOrder" xml:space="preserve">
<value>12</value>
<data name="&gt;&gt;toolStripStatusLabel1.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="optionsToolStripMenuItem.Text" xml:space="preserve">
<value>Options</value>
</data>
<data name="labelFileName.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
<data name="textBoxFileName.Size" type="System.Drawing.Size, System.Drawing">
<value>366, 20</value>
</data>
<data name="radioButtonCompTgz.Text" xml:space="preserve">
<value>TGZ</value>
@ -259,7 +262,7 @@
<value>...</value>
</data>
<data name="&gt;&gt;radioButtonCompNone.ZOrder" xml:space="preserve">
<value>0</value>
<value>1</value>
</data>
<data name="&gt;&gt;checkBoxUseMBR.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
@ -279,14 +282,14 @@
<data name="englishToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>114, 22</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
<data name="&gt;&gt;buttonRead.ZOrder" xml:space="preserve">
<value>13</value>
</data>
<data name="buttonChooseFile.Size" type="System.Drawing.Size, System.Drawing">
<value>25, 20</value>
</data>
<data name="groupBoxTruncation.Location" type="System.Drawing.Point, System.Drawing">
<value>429, 34</value>
<data name="buttonRead.Location" type="System.Drawing.Point, System.Drawing">
<value>429, 180</value>
</data>
<data name="groupBoxCompression.Location" type="System.Drawing.Point, System.Drawing">
<value>429, 124</value>
@ -297,9 +300,18 @@
<data name="&gt;&gt;labelDriveTitle.Name" xml:space="preserve">
<value>labelDriveTitle</value>
</data>
<data name="&gt;&gt;radioButtonCompNone.Name" xml:space="preserve">
<value>radioButtonCompNone</value>
</data>
<data name="groupBoxTruncation.Location" type="System.Drawing.Point, System.Drawing">
<value>429, 34</value>
</data>
<data name="&gt;&gt;flowLayoutPanelProgressBars.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="&gt;&gt;radioButtonCompGz.Parent" xml:space="preserve">
<value>groupBoxCompression</value>
</data>
<data name="&gt;&gt;buttonRead.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
@ -312,20 +324,23 @@
<data name="&gt;&gt;toolStripStatusLabel1.Name" xml:space="preserve">
<value>toolStripStatusLabel1</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
</data>
<data name="buttonChooseFile.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="&gt;&gt;radioButtonCompZip.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="statusStrip1.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
</data>
<data name="flowLayoutPanelProgressLabels.FlowDirection" type="System.Windows.Forms.FlowDirection, System.Windows.Forms">
<value>TopDown</value>
<data name="&gt;&gt;buttonCancel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="labelDriveTitle.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
<data name="radioButtonCompXZ.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="&gt;&gt;optionsToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
@ -336,8 +351,8 @@
<data name="&gt;&gt;buttonChooseFile.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;displayAllDrivesToolStripMenuItem.Name" xml:space="preserve">
<value>displayAllDrivesToolStripMenuItem</value>
<data name="&gt;&gt;flowLayoutPanelProgressLabels.Type" xml:space="preserve">
<value>System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonCancel.Name" xml:space="preserve">
<value>buttonCancel</value>
@ -348,8 +363,8 @@
<data name="&gt;&gt;labelDriveTitle.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="&gt;&gt;buttonWrite.Parent" xml:space="preserve">
<value>$this</value>
<data name="&gt;&gt;displayAllDrivesToolStripMenuItem.Name" xml:space="preserve">
<value>displayAllDrivesToolStripMenuItem</value>
</data>
<data name="&gt;&gt;radioButtonCompTgz.Parent" xml:space="preserve">
<value>groupBoxCompression</value>
@ -357,8 +372,8 @@
<data name="statusStrip1.Text" xml:space="preserve">
<value>statusStrip1</value>
</data>
<data name="labelFileName.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 34</value>
<data name="radioButtonCompZip.Text" xml:space="preserve">
<value>ZIP</value>
</data>
<data name="&gt;&gt;buttonWrite.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
@ -367,7 +382,7 @@
<value>40, 17</value>
</data>
<data name="radioButtonCompTgz.Location" type="System.Drawing.Point, System.Drawing">
<value>117, 19</value>
<value>100, 19</value>
</data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<value>152, 73</value>
@ -387,20 +402,20 @@
<data name="displayAllDrivesToolStripMenuItem.Text" xml:space="preserve">
<value>Display All Drives *** DANGEROUS ***</value>
</data>
<data name="buttonRead.Location" type="System.Drawing.Point, System.Drawing">
<value>429, 180</value>
</data>
<data name="&gt;&gt;groupBoxCompression.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="englishToolStripMenuItem.Text" xml:space="preserve">
<value>English</value>
</data>
<data name="radioButtonCompXZ.Text" xml:space="preserve">
<value>XZ</value>
</data>
<data name="radioButtonCompNone.Text" xml:space="preserve">
<value>NONE</value>
</data>
<data name="&gt;&gt;buttonExit.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="&gt;&gt;buttonWrite.ZOrder" xml:space="preserve">
<value>12</value>
</data>
<data name="textBoxFileName.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -408,14 +423,20 @@
<data name="&gt;&gt;russianToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;statusStrip1.Parent" xml:space="preserve">
<value>$this</value>
<data name="&gt;&gt;groupBoxCompression.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="labelFileName.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 34</value>
</data>
<data name="&gt;&gt;languageToolStripMenuItem.Name" xml:space="preserve">
<value>languageToolStripMenuItem</value>
</data>
<data name="textBoxFileName.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 50</value>
</data>
<data name="buttonExit.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
<data name="radioButtonCompXZ.Location" type="System.Drawing.Point, System.Drawing">
<value>153, 19</value>
</data>
<data name="buttonWrite.Text" xml:space="preserve">
<value>Write</value>
@ -426,17 +447,23 @@
<data name="statusStrip1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 356</value>
</data>
<data name="radioButtonCompXZ.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>48, 13</value>
</data>
<data name="&gt;&gt;radioButtonCompNone.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="checkBoxUseMBR.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="buttonCancel.Location" type="System.Drawing.Point, System.Drawing">
<value>621, 180</value>
</data>
<data name="&gt;&gt;optionsToolStripMenuItem.Name" xml:space="preserve">
<value>optionsToolStripMenuItem</value>
<data name="&gt;&gt;radioButtonCompZip.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="checkBoxUnmount.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -454,40 +481,46 @@
<value>buttonWrite</value>
</data>
<data name="groupBoxCompression.Size" type="System.Drawing.Size, System.Drawing">
<value>267, 50</value>
<value>267, 45</value>
</data>
<data name="&gt;&gt;flowLayoutPanelProgressBars.Type" xml:space="preserve">
<value>System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonCancel.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="groupBoxCompression.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="&gt;&gt;flowLayoutPanelProgressLabels.ZOrder" xml:space="preserve">
<value>1</value>
<data name="&gt;&gt;radioButtonCompXZ.Name" xml:space="preserve">
<value>radioButtonCompXZ</value>
</data>
<data name="checkBoxUseMBR.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 20</value>
</data>
<data name="&gt;&gt;buttonCancel.Parent" xml:space="preserve">
<value>$this</value>
<data name="&gt;&gt;englishToolStripMenuItem.Name" xml:space="preserve">
<value>englishToolStripMenuItem</value>
</data>
<data name="&gt;&gt;buttonRead.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;buttonExit.Name" xml:space="preserve">
<value>buttonExit</value>
<data name="radioButtonCompXZ.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 17</value>
</data>
<data name="checkedListBoxDrives.Size" type="System.Drawing.Size, System.Drawing">
<value>137, 124</value>
</data>
<data name="&gt;&gt;groupBoxCompression.Name" xml:space="preserve">
<value>groupBoxCompression</value>
</data>
<data name="&gt;&gt;radioButtonCompXZ.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelDriveTitle.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="groupBoxCompression.Text" xml:space="preserve">
<value>Compression</value>
</data>
<data name="&gt;&gt;groupBoxCompression.Name" xml:space="preserve">
<value>groupBoxCompression</value>
<data name="&gt;&gt;buttonWrite.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;textBoxFileName.Parent" xml:space="preserve">
<value>$this</value>
@ -499,7 +532,7 @@
<value>19</value>
</data>
<data name="&gt;&gt;textBoxFileName.ZOrder" xml:space="preserve">
<value>15</value>
<value>14</value>
</data>
<data name="&gt;&gt;groupBoxTruncation.ZOrder" xml:space="preserve">
<value>4</value>
@ -519,8 +552,11 @@
<data name="&gt;&gt;flowLayoutPanelProgressLabels.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;groupBoxCompression.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="&gt;&gt;flowLayoutPanelProgressLabels.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="labelFileName.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="checkedListBoxDrives.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 89</value>
@ -528,11 +564,8 @@
<data name="&gt;&gt;labelFileName.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="buttonExit.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="&gt;&gt;radioButtonCompZip.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="labelDriveTitle.Text" xml:space="preserve">
<value>Removable Drives</value>
</data>
<data name="&gt;&gt;labelDriveTitle.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
@ -549,8 +582,11 @@
<data name="buttonRead.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="displayAllDrivesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>275, 22</value>
<data name="&gt;&gt;buttonCancel.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<value>$this</value>
@ -558,11 +594,11 @@
<data name="&gt;&gt;checkBoxUnmount.Parent" xml:space="preserve">
<value>groupBoxTruncation</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="labelDriveTitle.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="&gt;&gt;buttonWrite.ZOrder" xml:space="preserve">
<value>13</value>
<data name="radioButtonCompZip.Size" type="System.Drawing.Size, System.Drawing">
<value>42, 17</value>
</data>
<data name="&gt;&gt;groupBoxTruncation.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
@ -570,9 +606,6 @@
<data name="&gt;&gt;radioButtonCompGz.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="optionsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 20</value>
</data>
<data name="checkBoxUnmount.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@ -580,19 +613,19 @@
<value>False</value>
</data>
<data name="&gt;&gt;radioButtonCompTgz.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="&gt;&gt;radioButtonCompTgz.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="labelDriveTitle.Text" xml:space="preserve">
<value>Removable Drives</value>
<data name="&gt;&gt;menuStripMain.Name" xml:space="preserve">
<value>menuStripMain</value>
</data>
<data name="buttonCancel.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="textBoxFileName.Size" type="System.Drawing.Size, System.Drawing">
<value>366, 20</value>
<data name="labelDriveTitle.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 73</value>
</data>
<data name="menuStripMain.Size" type="System.Drawing.Size, System.Drawing">
<value>708, 24</value>
@ -607,7 +640,7 @@
<value>1</value>
</data>
<data name="radioButtonCompNone.Location" type="System.Drawing.Point, System.Drawing">
<value>170, 19</value>
<value>198, 19</value>
</data>
<data name="&gt;&gt;checkBoxUnmount.ZOrder" xml:space="preserve">
<value>0</value>
@ -621,23 +654,17 @@
<data name="&gt;&gt;statusStrip1.ZOrder" xml:space="preserve">
<value>9</value>
</data>
<data name="&gt;&gt;menuStripMain.Name" xml:space="preserve">
<value>menuStripMain</value>
</data>
<data name="&gt;&gt;flowLayoutPanelProgressLabels.Type" xml:space="preserve">
<value>System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="statusStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>708, 22</value>
</data>
<data name="buttonWrite.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="&gt;&gt;menuStripMain.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;englishToolStripMenuItem.Name" xml:space="preserve">
<value>englishToolStripMenuItem</value>
<data name="label1.Text" xml:space="preserve">
<value>Progress</value>
</data>
<data name="radioButtonCompTgz.Size" type="System.Drawing.Size, System.Drawing">
<value>47, 17</value>
@ -648,17 +675,14 @@
<data name="buttonRead.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="flowLayoutPanelProgressBars.Location" type="System.Drawing.Point, System.Drawing">
<value>155, 89</value>
<data name="&gt;&gt;radioButtonCompNone.Parent" xml:space="preserve">
<value>groupBoxCompression</value>
</data>
<data name="groupBoxCompression.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
<data name="buttonWrite.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="groupBoxTruncation.Size" type="System.Drawing.Size, System.Drawing">
<value>207, 84</value>
</data>
<data name="&gt;&gt;buttonExit.Parent" xml:space="preserve">
<value>$this</value>
<value>207, 75</value>
</data>
<data name="russianToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>114, 22</value>
@ -672,11 +696,14 @@
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="&gt;&gt;radioButtonCompNone.Parent" xml:space="preserve">
<value>groupBoxCompression</value>
<data name="&gt;&gt;radioButtonCompXZ.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="radioButtonCompTgz.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
<data name="toolStripStatusLabel1.Text" xml:space="preserve">
<value>toolStripStatusLabel1</value>
</data>
<data name="&gt;&gt;statusStrip1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="labelDriveTitle.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -684,15 +711,12 @@
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>708, 378</value>
</data>
<data name="&gt;&gt;radioButtonCompGz.Parent" xml:space="preserve">
<data name="&gt;&gt;radioButtonCompXZ.Parent" xml:space="preserve">
<value>groupBoxCompression</value>
</data>
<data name="&gt;&gt;textBoxFileName.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;toolStripStatusLabel1.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkBoxUseMBR.Name" xml:space="preserve">
<value>checkBoxUseMBR</value>
</data>
@ -714,32 +738,17 @@
<data name="radioButtonCompGz.Text" xml:space="preserve">
<value>GZ</value>
</data>
<data name="label1.Text" xml:space="preserve">
<value>Progress</value>
</data>
<data name="radioButtonCompZip.Text" xml:space="preserve">
<value>ZIP</value>
</data>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="&gt;&gt;buttonRead.ZOrder" xml:space="preserve">
<value>14</value>
</data>
<data name="&gt;&gt;radioButtonCompGz.Name" xml:space="preserve">
<value>radioButtonCompGz</value>
</data>
<data name="&gt;&gt;checkedListBoxDrives.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="radioButtonCompZip.Size" type="System.Drawing.Size, System.Drawing">
<value>42, 17</value>
</data>
<data name="&gt;&gt;radioButtonCompGz.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="radioButtonCompZip.Location" type="System.Drawing.Point, System.Drawing">
<value>23, 19</value>
<value>6, 19</value>
</data>
<data name="&gt;&gt;checkBoxUseMBR.Parent" xml:space="preserve">
<value>groupBoxTruncation</value>
@ -747,14 +756,11 @@
<data name="&gt;&gt;languageToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="toolStripStatusLabel1.Text" xml:space="preserve">
<value>toolStripStatusLabel1</value>
</data>
<data name="&gt;&gt;checkedListBoxDrives.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="labelDriveTitle.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 73</value>
<data name="displayAllDrivesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>275, 22</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -772,7 +778,7 @@
<value>273, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>64</value>
<value>56</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>

View file

@ -130,9 +130,6 @@
<data name="buttonWrite.Text" xml:space="preserve">
<value>Запись</value>
</data>
<data name="buttonExit.Text" xml:space="preserve">
<value>Выход</value>
</data>
<data name="saveFileDialog1.Filter" xml:space="preserve">
<value>Образы файлов (*.img,*.bin,*.sdcard)|*.img;*.bin;*.sdcard|Сжатые файлы (*.zip,*.gz,*tgz)|*.zip;*.gz;*.tgz|Все файлы (*.*)|*.*</value>
</data>
@ -160,24 +157,12 @@
<data name="groupBoxCompression.Text" xml:space="preserve">
<value>Сжатие</value>
</data>
<data name="optionsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>56, 20</value>
</data>
<data name="optionsToolStripMenuItem.Text" xml:space="preserve">
<value>Опции</value>
</data>
<data name="displayAllDrivesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>265, 22</value>
</data>
<data name="displayAllDrivesToolStripMenuItem.Text" xml:space="preserve">
<value>Показать все диски ***ОПАСНО***</value>
</data>
<data name="languageToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>265, 22</value>
</data>
<data name="languageToolStripMenuItem.Text" xml:space="preserve">
<value>Язык</value>
</data>
<data name="englishToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>141, 22</value>
</data>
@ -190,11 +175,17 @@
<data name="russianToolStripMenuItem.Text" xml:space="preserve">
<value>Русский</value>
</data>
<data name="groupBoxTruncation.Size" type="System.Drawing.Size, System.Drawing">
<value>267, 78</value>
<data name="languageToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>265, 22</value>
</data>
<data name="groupBoxTruncation.Text" xml:space="preserve">
<value>Образ логических разделов</value>
<data name="languageToolStripMenuItem.Text" xml:space="preserve">
<value>Язык</value>
</data>
<data name="optionsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>56, 20</value>
</data>
<data name="optionsToolStripMenuItem.Text" xml:space="preserve">
<value>Опции</value>
</data>
<data name="checkBoxUnmount.Size" type="System.Drawing.Size, System.Drawing">
<value>216, 17</value>
@ -208,6 +199,12 @@
<data name="checkBoxUseMBR.Text" xml:space="preserve">
<value>Использовать MBR образа (чтение)</value>
</data>
<data name="groupBoxTruncation.Size" type="System.Drawing.Size, System.Drawing">
<value>267, 78</value>
</data>
<data name="groupBoxTruncation.Text" xml:space="preserve">
<value>Образ логических разделов</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>56, 13</value>
</data>

View file

@ -47,5 +47,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.2.*")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyVersion("1.3.0.*")]
[assembly: AssemblyFileVersion("1.3.0.0")]

View file

@ -9,6 +9,8 @@ Some rights reserved. See LICENSE, AUTHORS.
The current release can be downloaded [here](https://github.com/RomanBelkov/DiskImager/releases)
or [here (old link)](http://www.dynamicdevices.co.uk/downloads/DiskImager.Installer.msi)
Utility was tested on Windows 7 and Windows 8.1 Pro.
(Please feed back any platform testing you do, or any issues you encounter. Thanks.)
## Description ##
@ -16,10 +18,12 @@ This utility is a C#.NET implementation of Win32DiskImager with a couple of feat
- writing images to a number of SD cards at once
- reads/writes images to/from compressed file formats: ZIP, TGZ, GZ
- reads/writes images to/from compressed file formats: ZIP, TGZ, GZ, XZ
- remembers the last file you read/wrote
- unmounts drives after write
- provides more file filters within file dialog for typical image files (.img, .bin, .sdcard)
- it also *might* be slightly faster when dealing with uncompressed read/write
@ -30,6 +34,10 @@ Credits: Inspired by the excellent Win32DiskImager.
## ChangeLog ##
1.3.0 19/02/2015 RB Added XZ support
1.2.2 21/01/2015 RB Added 'Remove drives after write' and drew new GUI
1.2.1 14/01/15 RB Added Russian localization and tweaked GUI a bit.
1.2.0 06/01/15 RB Added ability to write the same image to many SD simultaneously. Changed the look of GUI.

130
XZ.NET/NativeMethods.cs Normal file
View file

@ -0,0 +1,130 @@
/**
* XZ.NET - a .NET wrapper for liblzma.dll
*
* Copyright 2015 by Roman Belkov <romanbelkov@gmail.com>
* Copyright 2015 by Melentyev Kirill <melentyev.k@gmail.com>
*
* Licensed under GNU General Public License 3.0 or later.
* Some rights reserved. See LICENSE, AUTHORS, LICENSE-Notices.
*
* @license GPL-3.0+ <http://www.gnu.org/licenses/gpl-3.0.en.html>
*/
using System;
using System.Runtime.InteropServices;
namespace XZ.NET
{
internal enum LzmaReturn : uint
{
LzmaOK = 0,
LzmaStreamEnd = 1,
LzmaNoCheck = 2,
LzmaUnsupportedCheck = 3,
LzmaGetCheck = 4,
LzmaMemError = 5,
LzmaMemlimitError = 6,
LzmaFormatError = 7,
LzmaOptionsError = 8,
LzmaDataError = 9,
LzmaBufError = 10,
LzmaProgError = 11
}
internal enum LzmaAction
{
LzmaRun = 0,
LzmaSyncFlush = 1,
LzmaFullFlush = 2,
LzmaFinish = 3,
LzmaFullBarrier = 4
}
internal enum LzmaCheck
{
LzmaCheckNone = 0,
LzmaCheckCrc32 = 1,
LzmaCheckCrc64 = 4,
LzmaCheckSha256 = 10
}
[StructLayout(LayoutKind.Sequential)]
internal struct LzmaStreamFlags
{
private readonly UInt32 version;
public UInt64 backwardSize;
public LzmaCheck check;
readonly int reserved_enum1;
readonly int reserved_enum2;
readonly int reserved_enum3;
readonly int reserved_enum4;
readonly char reserved_bool1;
readonly char reserved_bool2;
readonly char reserved_bool3;
readonly char reserved_bool4;
readonly char reserved_bool5;
readonly char reserved_bool6;
readonly char reserved_bool7;
readonly char reserved_bool8;
readonly UInt32 reserved_int1;
readonly UInt32 reserved_int2;
}
[StructLayout(LayoutKind.Sequential)]
internal struct LzmaStream
{
public IntPtr next_in;
public UInt32 avail_in;
public UInt64 total_in;
public IntPtr next_out;
public UInt32 avail_out;
public UInt64 total_out;
public IntPtr allocator;
private readonly IntPtr internalState;
private readonly IntPtr reserved_ptr1;
private readonly IntPtr reserved_ptr2;
private readonly IntPtr reserved_ptr3;
private readonly IntPtr reserved_ptr4;
private readonly UInt64 reserved_int1;
private readonly UInt64 reserved_int2;
private readonly UInt32 reserved_int3;
private readonly UInt32 reserved_int4;
private readonly UInt32 reserved_enum1;
private readonly UInt32 reserved_enum2;
}
public static class Native
{
[DllImport("liblzma.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
internal static extern LzmaReturn lzma_stream_decoder(ref LzmaStream stream, UInt64 memLimit, UInt32 flags);
[DllImport("liblzma.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
internal static extern LzmaReturn lzma_code(ref LzmaStream stream, LzmaAction action);
[DllImport("liblzma.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
internal static extern LzmaReturn lzma_stream_footer_decode(ref LzmaStreamFlags options, byte[] inp);
[DllImport("liblzma.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
internal static extern UInt64 lzma_index_uncompressed_size(IntPtr i);
[DllImport("liblzma.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
internal static extern UInt32 lzma_index_buffer_decode(ref IntPtr i, ref UInt64 memLimit, IntPtr allocator, byte[] indexBuffer,
ref UInt32 inPosition, UInt64 inSize);
[DllImport("liblzma.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
internal static extern void lzma_index_end(IntPtr i, IntPtr allocator);
[DllImport("liblzma.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
internal static extern void lzma_end(ref LzmaStream stream);
[DllImport("liblzma.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
internal static extern LzmaReturn lzma_easy_encoder(ref LzmaStream stream, int preset, LzmaCheck check);
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("XZ.NET")]
[assembly: AssemblyDescription(".NET wrapper for liblzma.dll")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("XZ.NET")]
[assembly: AssemblyCopyright("Copyright © Roman Belkov & Kirill Melentyev 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("12343423-cc1d-47ef-a2b6-16043a43150f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

63
XZ.NET/XZ.NET.csproj Normal file
View file

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2A389B68-70DC-4853-81AE-56484F32E94D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>XZ.NET</RootNamespace>
<AssemblyName>XZ.NET</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="NativeMethods.cs" />
<Compile Include="XZInputStream.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XZOutputStream.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="liblzma.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

28
XZ.NET/XZ.NET.sln Normal file
View file

@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XZ.NET", "XZ.NET.csproj", "{2A389B68-70DC-4853-81AE-56484F32E94D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "..\Examples\Examples.csproj", "{EBEC5795-82AB-455E-806B-64099BA50A0A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A389B68-70DC-4853-81AE-56484F32E94D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A389B68-70DC-4853-81AE-56484F32E94D}.Release|Any CPU.Build.0 = Release|Any CPU
{EBEC5795-82AB-455E-806B-64099BA50A0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBEC5795-82AB-455E-806B-64099BA50A0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBEC5795-82AB-455E-806B-64099BA50A0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBEC5795-82AB-455E-806B-64099BA50A0A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

256
XZ.NET/XZInputStream.cs Normal file
View file

@ -0,0 +1,256 @@
/**
* XZ.NET - a .NET wrapper for liblzma.dll
*
* Copyright 2015 by Roman Belkov <romanbelkov@gmail.com>
* Copyright 2015 by Melentyev Kirill <melentyev.k@gmail.com>
*
* Licensed under GNU General Public License 3.0 or later.
* Some rights reserved. See LICENSE, AUTHORS, LICENSE-Notices.
*
* @license GPL-3.0+ <http://www.gnu.org/licenses/gpl-3.0.en.html>
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
namespace XZ.NET
{
public class XZInputStream : Stream
{
private readonly List<byte> _mInternalBuffer = new List<byte>();
private LzmaStream _lzmaStream;
private readonly Stream _mInnerStream;
private readonly IntPtr _inbuf;
private readonly IntPtr _outbuf;
private long _length;
// You can tweak BufSize value to get optimal results
// of speed and chunk size
private const int BufSize = 512;
private const int LzmaConcatenatedFlag = 0x08;
public XZInputStream(Stream s)
{
_mInnerStream = s;
var ret = Native.lzma_stream_decoder(ref _lzmaStream, UInt64.MaxValue, LzmaConcatenatedFlag);
_inbuf = Marshal.AllocHGlobal(BufSize);
_outbuf = Marshal.AllocHGlobal(BufSize);
_lzmaStream.avail_in = 0;
_lzmaStream.next_out = _outbuf;
_lzmaStream.avail_out = BufSize;
if (ret == LzmaReturn.LzmaOK)
return;
switch (ret)
{
case LzmaReturn.LzmaMemError:
throw new Exception("Memory allocation failed");
case LzmaReturn.LzmaOptionsError:
throw new Exception("Unsupported decompressor flags");
default:
throw new Exception("Unknown error, possibly a bug");
}
}
#region Overrides
public override void Flush()
{
throw new NotSupportedException("XZ Stream does not support flush");
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException("XZ Stream does not support seek");
}
public override void SetLength(long value)
{
throw new NotSupportedException("XZ Stream does not support setting length");
}
/// <summary>
/// Reads bytes from stream
/// </summary>
/// <returns>byte read or -1 on end of stream</returns>
public override int Read(byte[] buffer, int offset, int count)
{
var action = LzmaAction.LzmaRun;
var readBuf = new byte[BufSize];
var outManagedBuf = new byte[BufSize];
while (_mInternalBuffer.Count < count)
{
if (_lzmaStream.avail_in == 0)
{
_lzmaStream.avail_in = (uint)_mInnerStream.Read(readBuf, 0, readBuf.Length);
Marshal.Copy(readBuf, 0, _inbuf, (int)_lzmaStream.avail_in);
_lzmaStream.next_in = _inbuf;
if (_lzmaStream.avail_in == 0)
action = LzmaAction.LzmaFinish;
}
var ret = Native.lzma_code(ref _lzmaStream, action);
if (_lzmaStream.avail_out == 0 || ret == LzmaReturn.LzmaStreamEnd)
{
var writeSize = BufSize - (int)_lzmaStream.avail_out;
Marshal.Copy(_outbuf, outManagedBuf, 0, writeSize);
_mInternalBuffer.AddRange(outManagedBuf);
var tail = outManagedBuf.Length - writeSize;
_mInternalBuffer.RemoveRange(_mInternalBuffer.Count - tail, tail);
_lzmaStream.next_out = _outbuf;
_lzmaStream.avail_out = BufSize;
}
if (ret != LzmaReturn.LzmaOK)
{
if (ret == LzmaReturn.LzmaStreamEnd)
break;
Native.lzma_end(ref _lzmaStream);
switch (ret)
{
case LzmaReturn.LzmaMemError:
throw new Exception("Memory allocation failed");
case LzmaReturn.LzmaFormatError:
throw new Exception("The input is not in the .xz format");
case LzmaReturn.LzmaOptionsError:
throw new Exception("Unsupported compression options");
case LzmaReturn.LzmaDataError:
throw new Exception("Compressed file is corrupt");
case LzmaReturn.LzmaBufError:
throw new Exception("Compressed file is truncated or otherwise corrupt");
default:
throw new Exception("Uknown error.Possibly a bug");
}
}
}
if (_mInternalBuffer.Count >= count)
{
_mInternalBuffer.CopyTo(0, buffer, offset, count);
_mInternalBuffer.RemoveRange(0, count);
return count;
}
else
{
var intBufLength = _mInternalBuffer.Count;
_mInternalBuffer.CopyTo(0, buffer, offset, count);
_mInternalBuffer.Clear();
return intBufLength;
}
}
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotSupportedException("XZ Input stream does not support writing");
}
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanWrite
{
get { return false; }
}
/// <summary>
/// Gives a size of uncompressed data in bytes
/// </summary>
/// <returns>Size of uncompressed data or 0 if error occured</returns>
public override long Length
{
get
{
const int streamFooterSize = 12;
if (_length == 0)
{
var lzmaStreamFlags = new LzmaStreamFlags();
var streamFooter = new byte[streamFooterSize];
_mInnerStream.Seek(-streamFooterSize, SeekOrigin.End);
_mInnerStream.Read(streamFooter, 0, streamFooterSize);
Native.lzma_stream_footer_decode(ref lzmaStreamFlags, streamFooter);
var indexPointer = new byte[lzmaStreamFlags.backwardSize];
_mInnerStream.Seek(-(Int64)streamFooterSize - (Int64)lzmaStreamFlags.backwardSize, SeekOrigin.End);
_mInnerStream.Read(indexPointer, 0, (int)lzmaStreamFlags.backwardSize);
_mInnerStream.Seek(0, SeekOrigin.Begin);
var index = IntPtr.Zero;
var memLimit = UInt64.MaxValue;
UInt32 inPos = 0;
Native.lzma_index_buffer_decode(ref index, ref memLimit, IntPtr.Zero, indexPointer, ref inPos,
lzmaStreamFlags.backwardSize);
if (inPos != lzmaStreamFlags.backwardSize)
{
Native.lzma_index_end(index, IntPtr.Zero);
throw new Exception("Index decoding failed!");
}
var uSize = Native.lzma_index_uncompressed_size(index);
Native.lzma_index_end(index, IntPtr.Zero);
_length = (Int64)uSize;
return _length;
}
else
{
return _length;
}
}
}
public override long Position
{
get { throw new NotSupportedException("XZ Stream does not support getting position"); }
set { throw new NotSupportedException("XZ Stream does not support setting position"); }
}
public override void Close()
{
Dispose(true);
}
protected override void Dispose(bool disposing)
{
Native.lzma_end(ref _lzmaStream);
Marshal.FreeHGlobal(_inbuf);
Marshal.FreeHGlobal(_outbuf);
base.Dispose(disposing);
}
#endregion
}
}

197
XZ.NET/XZOutputStream.cs Normal file
View file

@ -0,0 +1,197 @@
/**
* XZ.NET - a .NET wrapper for liblzma.dll
*
* Copyright 2015 by Roman Belkov <romanbelkov@gmail.com>
* Copyright 2015 by Melentyev Kirill <melentyev.k@gmail.com>
*
* Licensed under GNU General Public License 3.0 or later.
* Some rights reserved. See LICENSE, AUTHORS, LICENSE-Notices.
*
* @license GPL-3.0+ <http://www.gnu.org/licenses/gpl-3.0.en.html>
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
namespace XZ.NET
{
public class XZOutputStream : Stream
{
private readonly List<byte> _mInternalBuffer = new List<byte>();
private LzmaStream _lzmaStream;
private readonly Stream _mInnerStream;
private readonly IntPtr _inbuf;
private readonly IntPtr _outbuf;
// This is a default compression preset & since
// the output does not benefit a lot from changing
// this value it is hard coded
private const int Preset = 6;
// You can tweak BufSize value to get optimal results
// of speed and chunk size
private const int BufSize = 1 * 1024 * 1024;
public XZOutputStream(Stream s)
{
_mInnerStream = s;
var ret = Native.lzma_easy_encoder(ref _lzmaStream, Preset, LzmaCheck.LzmaCheckCrc64);
_inbuf = Marshal.AllocHGlobal(BufSize);
_outbuf = Marshal.AllocHGlobal(BufSize);
_lzmaStream.avail_in = 0;
_lzmaStream.next_out = _outbuf;
_lzmaStream.avail_out = BufSize;
if (ret == LzmaReturn.LzmaOK)
return;
switch (ret)
{
case LzmaReturn.LzmaMemError:
throw new Exception("Memory allocation failed");
case LzmaReturn.LzmaOptionsError:
throw new Exception("Specified preset is not supported");
case LzmaReturn.LzmaUnsupportedCheck:
throw new Exception("Specified integrity check is not supported");
default:
throw new Exception("Unknown error, possibly a bug");
}
}
public override void Flush()
{
throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotSupportedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
var action = LzmaAction.LzmaRun;
var writeBuf = new byte[BufSize];
var outManagedBuf = new byte[BufSize];
if (_lzmaStream.avail_in == 0)
{
_lzmaStream.avail_in = (uint)count;
Marshal.Copy(buffer, 0, _inbuf, (int)_lzmaStream.avail_in);
_lzmaStream.next_in = _inbuf;
}
LzmaReturn ret = LzmaReturn.LzmaOK;
while (_lzmaStream.avail_in > 0)
{
ret = Native.lzma_code(ref _lzmaStream, action);
if (_lzmaStream.avail_out == 0 || ret == LzmaReturn.LzmaStreamEnd)
{
var writeSize = BufSize - (int) _lzmaStream.avail_out;
Marshal.Copy(_outbuf, outManagedBuf, 0, writeSize);
_mInnerStream.Write(outManagedBuf, 0, writeSize);
_lzmaStream.next_out = _outbuf;
_lzmaStream.avail_out = BufSize;
}
}
if (ret != LzmaReturn.LzmaOK)
{
if (ret == LzmaReturn.LzmaStreamEnd)
return;
Native.lzma_end(ref _lzmaStream);
switch (ret)
{
case LzmaReturn.LzmaMemError:
throw new Exception("Memory allocation failed");
case LzmaReturn.LzmaDataError:
throw new Exception("File size limits exceeded");
default:
throw new Exception("Unknown error, possibly a bug");
}
}
}
public override bool CanRead
{
get { throw new NotImplementedException(); }
}
public override bool CanSeek
{
get { throw new NotImplementedException(); }
}
public override bool CanWrite
{
get { throw new NotImplementedException(); }
}
public override long Length
{
get { throw new NotImplementedException(); }
}
public override long Position
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public override void Close()
{
Dispose(true);
}
protected override void Dispose(bool disposing)
{
_lzmaStream.avail_in = 0; //todo check if needed
var ret = Native.lzma_code(ref _lzmaStream, LzmaAction.LzmaFinish);
var outManagedBuf = new byte[BufSize];
if (_lzmaStream.avail_out == 0 || ret == LzmaReturn.LzmaStreamEnd)
{
var writeSize = BufSize - (int) _lzmaStream.avail_out;
Marshal.Copy(_outbuf, outManagedBuf, 0, writeSize);
_mInnerStream.Write(outManagedBuf, 0, writeSize);
}
Native.lzma_end(ref _lzmaStream);
Marshal.FreeHGlobal(_inbuf);
Marshal.FreeHGlobal(_outbuf);
base.Dispose(disposing);
}
}
}

BIN
XZ.NET/liblzma.dll Normal file

Binary file not shown.