Compare commits

...

1 Commits
async ... WinRT

Author SHA1 Message Date
Adam Hathcock
cbc58c4d8f First WinRT project 2013-05-04 16:58:50 +01:00
11 changed files with 441 additions and 1 deletions

View File

@@ -9,28 +9,82 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.Portable", "S
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.WindowsStore", "SharpCompress\SharpCompress.WindowsStore.csproj", "{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCompress.WinRT", "SharpCompress\SharpCompress.WinRT.csproj", "{90F0D086-689E-470D-A72C-2FA01779FF90}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|ARM.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|x64.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Debug|x86.ActiveCfg = Debug|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|Any CPU.Build.0 = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|ARM.ActiveCfg = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|x64.ActiveCfg = Release|Any CPU
{10A689CF-76A2-4A4F-96E4-553C33398438}.Release|x86.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|ARM.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|x64.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Debug|x86.ActiveCfg = Debug|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|Any CPU.Build.0 = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|ARM.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|x64.ActiveCfg = Release|Any CPU
{15679D7A-F22C-4943-87FF-BF5C76C4A6FD}.Release|x86.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|x64.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Debug|x86.ActiveCfg = Debug|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|Any CPU.Build.0 = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|ARM.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|x64.ActiveCfg = Release|Any CPU
{7FA7D133-1417-4F85-9998-4C618AC8FEDA}.Release|x86.ActiveCfg = Release|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|ARM.ActiveCfg = Debug|ARM
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|ARM.Build.0 = Debug|ARM
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x64.ActiveCfg = Debug|x64
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x64.Build.0 = Debug|x64
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x86.ActiveCfg = Debug|x86
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Debug|x86.Build.0 = Debug|x86
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|Any CPU.Build.0 = Release|Any CPU
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|ARM.ActiveCfg = Release|ARM
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|ARM.Build.0 = Release|ARM
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x64.ActiveCfg = Release|x64
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x64.Build.0 = Release|x64
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x86.ActiveCfg = Release|x86
{1DF6D83C-31FF-47B6-82FE-C4603BE916B5}.Release|x86.Build.0 = Release|x86
{90F0D086-689E-470D-A72C-2FA01779FF90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90F0D086-689E-470D-A72C-2FA01779FF90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90F0D086-689E-470D-A72C-2FA01779FF90}.Debug|ARM.ActiveCfg = Debug|ARM
{90F0D086-689E-470D-A72C-2FA01779FF90}.Debug|ARM.Build.0 = Debug|ARM
{90F0D086-689E-470D-A72C-2FA01779FF90}.Debug|x64.ActiveCfg = Debug|x64
{90F0D086-689E-470D-A72C-2FA01779FF90}.Debug|x64.Build.0 = Debug|x64
{90F0D086-689E-470D-A72C-2FA01779FF90}.Debug|x86.ActiveCfg = Debug|x86
{90F0D086-689E-470D-A72C-2FA01779FF90}.Debug|x86.Build.0 = Debug|x86
{90F0D086-689E-470D-A72C-2FA01779FF90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90F0D086-689E-470D-A72C-2FA01779FF90}.Release|Any CPU.Build.0 = Release|Any CPU
{90F0D086-689E-470D-A72C-2FA01779FF90}.Release|ARM.ActiveCfg = Release|ARM
{90F0D086-689E-470D-A72C-2FA01779FF90}.Release|ARM.Build.0 = Release|ARM
{90F0D086-689E-470D-A72C-2FA01779FF90}.Release|x64.ActiveCfg = Release|x64
{90F0D086-689E-470D-A72C-2FA01779FF90}.Release|x64.Build.0 = Release|x64
{90F0D086-689E-470D-A72C-2FA01779FF90}.Release|x86.ActiveCfg = Release|x86
{90F0D086-689E-470D-A72C-2FA01779FF90}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,11 @@
namespace SharpCompress
{
public enum ArchiveType
{
Rar,
Zip,
Tar,
SevenZip,
GZip,
}
}

View File

@@ -0,0 +1,14 @@
namespace SharpCompress
{
public enum CompressionType
{
None,
GZip,
BZip2,
PPMd,
Deflate,
Rar,
LZMA,
Unknown,
}
}

56
SharpCompress/IEntry.cs Normal file
View File

@@ -0,0 +1,56 @@
using System;
namespace SharpCompress
{
public interface IEntry
{
CompressionType CompressionType
{
get;
}
DateTimeOffset ArchivedTime
{
get;
}
long CompressedSize
{
get;
}
uint Crc
{
get;
}
DateTimeOffset CreatedTime
{
get;
}
string FilePath
{
get;
}
bool IsDirectory
{
get;
}
bool IsEncrypted
{
get;
}
bool IsSplit
{
get;
}
DateTimeOffset LastAccessedTime
{
get;
}
DateTimeOffset LastModifiedTime
{
get;
}
long Size
{
get;
}
}
}

19
SharpCompress/IReader.cs Normal file
View File

@@ -0,0 +1,19 @@
using Windows.Storage.Streams;
namespace SharpCompress
{
public interface IReader
{
ArchiveType ArchiveType
{
get;
}
IEntry Entry
{
get;
}
void WriteEntryTo(IOutputStream writableStream);
bool MoveToNextEntry();
}
}

View File

@@ -0,0 +1,10 @@
using Windows.Foundation;
using Windows.Storage.Streams;
namespace SharpCompress
{
public interface IReaderFactory
{
IAsyncOperation<IReader> Open(IInputStream stream);
}
}

View File

@@ -0,0 +1,28 @@
using System.IO;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Storage.Streams;
namespace SharpCompress
{
public sealed class ReaderFactory : IReaderFactory
{
/// <summary>
/// Opens a Reader for Non-seeking usage
/// </summary>
/// <param name="stream"></param>
/// <param name="listener"></param>
/// <param name="options"></param>
/// <returns></returns>
public IAsyncOperation<IReader> Open(IInputStream stream)
{
return AsyncInfo.Run(x => OpenPrivate(stream));
}
private Task<IReader> OpenPrivate(IInputStream stream)
{
return Task.Run<IReader>(() => new WrappedReader(SharpCompress.Reader.ReaderFactory.Open(stream.AsStreamForRead())));
}
}
}

View File

@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{90F0D086-689E-470D-A72C-2FA01779FF90}</ProjectGuid>
<OutputType>winmdobj</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpCompress</RootNamespace>
<AssemblyName>SharpCompress.WinRT</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<ProjectReference Include="SharpCompress.WindowsStore.csproj">
<Project>{1df6d83c-31ff-47b6-82fe-c4603be916b5}</Project>
<Name>SharpCompress.WindowsStore</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Compile Include="ArchiveType.cs" />
<Compile Include="CompressionType.cs" />
<Compile Include="IEntry.cs" />
<Compile Include="IReader.cs" />
<Compile Include="IReaderFactory.cs" />
<Compile Include="ReaderFactory.cs" />
<Compile Include="WrappedEntry.cs" />
<Compile Include="WrappedReader.cs" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.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>

View File

@@ -57,7 +57,8 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
<DocumentationFile>..\bin\SharpCompress.XML</DocumentationFile>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@@ -0,0 +1,72 @@
namespace SharpCompress
{
internal class WrappedEntry : IEntry
{
private readonly Common.IEntry entry;
internal WrappedEntry(Common.IEntry entry)
{
this.entry = entry;
}
public CompressionType CompressionType
{
get { return (CompressionType)entry.CompressionType; }
}
public System.DateTimeOffset ArchivedTime
{
get { throw new System.NotImplementedException(); }
}
public long CompressedSize
{
get { return entry.CompressedSize; }
}
public uint Crc
{
get { return entry.Crc; }
}
public System.DateTimeOffset CreatedTime
{
get { throw new System.NotImplementedException(); }
}
public string FilePath
{
get { return entry.FilePath; }
}
public bool IsDirectory
{
get { return entry.IsDirectory; }
}
public bool IsEncrypted
{
get { return entry.IsEncrypted; }
}
public bool IsSplit
{
get { return entry.IsSplit; }
}
public System.DateTimeOffset LastAccessedTime
{
get { throw new System.NotImplementedException(); }
}
public System.DateTimeOffset LastModifiedTime
{
get { throw new System.NotImplementedException(); }
}
public long Size
{
get { return entry.Size; }
}
}
}

View File

@@ -0,0 +1,43 @@
using System.IO;
using System.Threading.Tasks;
using Windows.Storage.Streams;
namespace SharpCompress
{
internal class WrappedReader : IReader
{
private readonly Reader.IReader reader;
internal WrappedReader(Reader.IReader reader)
{
this.reader = reader;
}
public ArchiveType ArchiveType
{
get { return (ArchiveType)reader.ArchiveType; }
}
public IEntry Entry
{
get;
private set;
}
public async void WriteEntryTo(IOutputStream writableStream)
{
await Task.Run(() => reader.WriteEntryTo(writableStream.AsStreamForWrite()));
}
public bool MoveToNextEntry()
{
if (reader.MoveToNextEntry())
{
Entry = new WrappedEntry(reader.Entry);
return true;
}
Entry = null;
return false;
}
}
}