utility cleanup
zipfiledebugger converted
This commit is contained in:
@@ -2,29 +2,27 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Duplicati.Library.Interface;
|
||||
|
||||
namespace ZipFileDebugger
|
||||
{
|
||||
class MainClass
|
||||
class Program
|
||||
{
|
||||
public static void Main(string[] _args)
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var args = new List<string>(_args);
|
||||
var opts = Duplicati.Library.Utility.CommandLineParser.ExtractOptions(args, null);
|
||||
var argslist = new List<string>(args);
|
||||
var opts = Duplicati.Library.Utility.CommandLineParser.ExtractOptions(argslist, null);
|
||||
|
||||
if (args == null || args.Count == 0)
|
||||
if (argslist == null || argslist.Count == 0)
|
||||
{
|
||||
Console.WriteLine("Usage:");
|
||||
Console.WriteLine("{0} <filename.zip>", System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||
return;
|
||||
}
|
||||
|
||||
Duplicati.Library.Logging.Log.LogLevel = Duplicati.Library.Logging.LogMessageType.Profiling;
|
||||
Duplicati.Library.Logging.Log.CurrentLog = new Duplicati.Library.Logging.StreamLog(Console.OpenStandardOutput());
|
||||
|
||||
var filecount = 0;
|
||||
var errorcount = 0;
|
||||
foreach (var file in args)
|
||||
foreach (var file in argslist)
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
@@ -45,33 +43,38 @@ namespace ZipFileDebugger
|
||||
try
|
||||
{
|
||||
filecount++;
|
||||
using (var zr = new Duplicati.Library.Compression.FileArchiveZip(file, opts))
|
||||
using (var filestream = System.IO.File.Open(file, FileMode.Open, FileAccess.Read,
|
||||
FileShare.None))
|
||||
{
|
||||
var files = zr.ListFilesWithSize(null).ToArray();
|
||||
Console.WriteLine("Found {0} files in archive, testing read-ability for each", files.Length);
|
||||
|
||||
for (var i = 0; i < files.Length; i++)
|
||||
using (var zr = new Duplicati.Library.Compression.FileArchiveZip(filestream, ArchiveMode.Read, opts))
|
||||
{
|
||||
Console.Write("Opening file #{0} - {1}", i + 1, files[i].Key);
|
||||
try
|
||||
var files = zr.ListFilesWithSize(null).ToArray();
|
||||
Console.WriteLine("Found {0} files in archive, testing read-ability for each",
|
||||
files.Length);
|
||||
|
||||
for (var i = 0; i < files.Length; i++)
|
||||
{
|
||||
using (var ms = new MemoryStream())
|
||||
using (var sr = zr.OpenRead(files[i].Key))
|
||||
Console.Write("Opening file #{0} - {1}", i + 1, files[i].Key);
|
||||
try
|
||||
{
|
||||
sr.CopyTo(ms);
|
||||
using (var ms = new MemoryStream())
|
||||
using (var sr = zr.OpenRead(files[i].Key))
|
||||
{
|
||||
sr.CopyTo(ms);
|
||||
|
||||
if (ms.Length == files[i].Value)
|
||||
Console.WriteLine(" -- success");
|
||||
else
|
||||
Console.WriteLine(" -- bad length: {0} vs {1}", ms.Length, files[i].Value);
|
||||
if (ms.Length == files[i].Value)
|
||||
Console.WriteLine(" -- success");
|
||||
else
|
||||
Console.WriteLine(" -- bad length: {0} vs {1}", ms.Length, files[i].Value);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errors = true;
|
||||
Console.WriteLine(" -- failed: {0}", ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errors = true;
|
||||
Console.WriteLine(" -- failed: {0}", ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("ZipFileDebugger")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("2.0.0.7")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
@@ -1,51 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{669E137C-1DD4-4134-81E8-D94C467392A9}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>ZipFileDebugger</RootNamespace>
|
||||
<AssemblyName>ZipFileDebugger</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
|
||||
<Version>2.0.0.7</Version>
|
||||
<Copyright>LGPL, Copyright © Duplicati Team 2015</Copyright>
|
||||
<Product>Duplicati.Tools.ZipFileDebugger</Product>
|
||||
<Company>Duplicati Team</Company>
|
||||
<Authors>Duplicati Team</Authors>
|
||||
<Description>ZipFileDebugger</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<ProjectReference Include="..\..\Duplicati\Library\Interface\Duplicati.Library.Interface.csproj" />
|
||||
<ProjectReference Include="..\..\Duplicati\Library\Compression\Duplicati.Library.Compression.csproj" />
|
||||
<ProjectReference Include="..\..\Duplicati\Library\Utility\Duplicati.Library.Utility.csproj" />
|
||||
<ProjectReference Include="..\..\Duplicati\Library\Logging\Duplicati.Library.Logging.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Duplicati\Library\Compression\Duplicati.Library.Compression.csproj">
|
||||
<Project>{19ECCE09-B5EB-406C-8C57-BAC66997D469}</Project>
|
||||
<Name>Duplicati.Library.Compression</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Duplicati\Library\Interface\Duplicati.Library.Interface.csproj">
|
||||
<Project>{C5899F45-B0FF-483C-9D38-24A9FCAAB237}</Project>
|
||||
<Name>Duplicati.Library.Interface</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Duplicati\Library\Utility\Duplicati.Library.Utility.csproj">
|
||||
<Project>{DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65}</Project>
|
||||
<Name>Duplicati.Library.Utility</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Duplicati\Library\Logging\Duplicati.Library.Logging.csproj">
|
||||
<Project>{D10A5FC0-11B4-4E70-86AA-8AEA52BD9798}</Project>
|
||||
<Name>Duplicati.Library.Logging</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user