diff --git a/SharpCompress.Test/SharpCompress.Test.Portable.csproj b/SharpCompress.Test/SharpCompress.Test.Portable.csproj
deleted file mode 100644
index 944e5eb4..00000000
--- a/SharpCompress.Test/SharpCompress.Test.Portable.csproj
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 8.0.30703
- 2.0
- {E9C3C94B-FB27-4B4F-B225-57513C254D37}
- Library
- Properties
- SharpCompress.Test
- SharpCompress.Test.Portable
- v4.0
-
-
- 512
- ..\..\sharpcompress\
- true
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
-
-
- AnyCPU
- true
- full
- false
- bin\DebugPortable\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
- false
-
-
- ..\SharpCompress\SharpCompress.pfx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- True
- Resources.resx
- True
-
-
- SharpCompress.pfx
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
- True
- Settings.settings
- True
-
-
-
-
- {efdcaf57-fd4d-4e5d-a3d5-f26b875817ed}
- SharpCompress.PortableTest
-
-
-
-
-
\ No newline at end of file
diff --git a/SharpCompress.Test/SharpCompress.Test.csproj b/SharpCompress.Test/SharpCompress.Test.csproj
deleted file mode 100644
index 98b88909..00000000
--- a/SharpCompress.Test/SharpCompress.Test.csproj
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 8.0.30703
- 2.0
- {15679D7A-F22C-4943-87FF-BF5C76C4A6FD}
- Library
- Properties
- SharpCompress.Test
- SharpCompress.Test
- v4.0
-
-
- 512
- ..\..\sharpcompress\
- true
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
- false
-
-
- ..\SharpCompress\SharpCompress.pfx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- True
- Resources.resx
- True
-
-
- SharpCompress.pfx
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
- True
- Settings.settings
- True
-
-
-
-
- {27d535cb-2fd3-4621-8c9a-46161fc77a5d}
- SharpCompress.Unsigned
-
-
-
-
-
\ No newline at end of file
diff --git a/SharpCompress.Test/global.json b/SharpCompress.Test/global.json
deleted file mode 100644
index b09540bb..00000000
--- a/SharpCompress.Test/global.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "sdk": {
- "version": "1.0.0-rc1-final"
- }
-}
diff --git a/SharpCompress.sln b/SharpCompress.sln
index 898da837..db973c5a 100644
--- a/SharpCompress.sln
+++ b/SharpCompress.sln
@@ -5,13 +5,17 @@ VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F18F1765-4A02-42FD-9BEF-F0E2FCBD9D17}"
ProjectSection(SolutionItems) = preProject
- SharpCompress.Test\global.json = SharpCompress.Test\global.json
+ global.json = global.json
NuGet\sharpcompress.nuspec = NuGet\sharpcompress.nuspec
EndProjectSection
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SharpCompress", "SharpCompress\SharpCompress.xproj", "{FD19DDD8-72B2-4024-8665-0D1F7A2AA998}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SharpCompress", "src\SharpCompress\SharpCompress.xproj", "{FD19DDD8-72B2-4024-8665-0D1F7A2AA998}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SharpCompress.Test", "SharpCompress.Test\SharpCompress.Test.xproj", "{3B80E585-A2F3-4666-8F69-C7FFDA0DD7E5}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C5BE746-03E5-4895-9988-0B57F162F86C}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0F0901FF-E8D9-426A-B5A2-17C7F47C1529}"
+EndProject
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SharpCompress.Test", "test\SharpCompress.Test\SharpCompress.Test.xproj", "{3B80E585-A2F3-4666-8F69-C7FFDA0DD7E5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -31,4 +35,8 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {FD19DDD8-72B2-4024-8665-0D1F7A2AA998} = {3C5BE746-03E5-4895-9988-0B57F162F86C}
+ {3B80E585-A2F3-4666-8F69-C7FFDA0DD7E5} = {0F0901FF-E8D9-426A-B5A2-17C7F47C1529}
+ EndGlobalSection
EndGlobal
diff --git a/SharpCompress/sharpcompress.DotSettings b/SharpCompress/sharpcompress.DotSettings
deleted file mode 100644
index cb391bb6..00000000
--- a/SharpCompress/sharpcompress.DotSettings
+++ /dev/null
@@ -1,134 +0,0 @@
-
- True
- True
- True
- True
- True
- True
- False
- True
- True
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- DoHide
- True
- ERROR
- ERROR
- ERROR
- ERROR
- ERROR
- DO_NOT_SHOW
- DO_NOT_SHOW
- DO_NOT_SHOW
- ERROR
- DO_NOT_SHOW
- <?xml version="1.0" encoding="utf-16"?><Profile name="Adam Clean"><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_IMPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSShortenReferences>True</CSShortenReferences><HtmlReformatCode>True</HtmlReformatCode><JsInsertSemicolon>True</JsInsertSemicolon><JsReformatCode>True</JsReformatCode><CSArrangeThisQualifier>True</CSArrangeThisQualifier></Profile>
- <?xml version="1.0" encoding="utf-16"?><Profile name="NaaS Clean"><CSReformatCode>True</CSReformatCode><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReorderTypeMembers>True</CSReorderTypeMembers><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty></Profile>
- NaaS Clean
- Default: Full Cleanup
- True
- NEXT_LINE
- NEXT_LINE
- SEPARATE
- True
- True
- True
- ALWAYS_ADD
- ALWAYS_ADD
- ALWAYS_ADD
- ALWAYS_ADD
- ALWAYS_ADD
- ALWAYS_ADD
- True
- NEXT_LINE
- False
- False
- False
- False
- False
- False
- False
- True
- LINE_BREAK
- False
- False
- True
- WRAP_IF_LONG
- WRAP_IF_LONG
- WRAP_IF_LONG
- CHOP_ALWAYS
- CHOP_ALWAYS
- WRAP_IF_LONG
- True
- True
- True
- False
- True
- Automatic property
- True
- False
- False
- True
- False
- False
- True
- False
- False
- True
- False
- False
- EC
- IIS
- <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" />
- <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- $object$_On$event$
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
- True
- True
- True
- True
\ No newline at end of file
diff --git a/global.json b/global.json
new file mode 100644
index 00000000..29fdab68
--- /dev/null
+++ b/global.json
@@ -0,0 +1,6 @@
+{
+ "projects": ["src","test"],
+ "sdk": {
+ "version": "1.0.0-rc1-final"
+ }
+}
diff --git a/SharpCompress/Archive/AbstractArchive.cs b/src/SharpCompress/Archive/AbstractArchive.cs
similarity index 97%
rename from SharpCompress/Archive/AbstractArchive.cs
rename to src/SharpCompress/Archive/AbstractArchive.cs
index 27c01366..8f51d31d 100644
--- a/SharpCompress/Archive/AbstractArchive.cs
+++ b/src/SharpCompress/Archive/AbstractArchive.cs
@@ -1,212 +1,212 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using SharpCompress.Common;
-using SharpCompress.Reader;
-
-namespace SharpCompress.Archive
-{
- public abstract class AbstractArchive : IArchive, IArchiveExtractionListener
- where TEntry : IArchiveEntry
- where TVolume : IVolume
- {
- private readonly LazyReadOnlyCollection lazyVolumes;
- private readonly LazyReadOnlyCollection lazyEntries;
-
- public event EventHandler> EntryExtractionBegin;
- public event EventHandler> EntryExtractionEnd;
-
- public event EventHandler CompressedBytesRead;
- public event EventHandler FilePartExtractionBegin;
-
- protected string Password { get; private set; }
-
-#if !DOTNET51
- internal AbstractArchive(ArchiveType type, FileInfo fileInfo, Options options, string password)
- {
- Type = type;
- Password = password;
- if (!fileInfo.Exists)
- {
- throw new ArgumentException("File does not exist: " + fileInfo.FullName);
- }
- options = (Options) FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
- lazyVolumes = new LazyReadOnlyCollection(LoadVolumes(fileInfo, options));
- lazyEntries = new LazyReadOnlyCollection(LoadEntries(Volumes));
- }
-
-
- protected abstract IEnumerable LoadVolumes(FileInfo file, Options options);
-#endif
-
- internal AbstractArchive(ArchiveType type, IEnumerable streams, Options options, string password)
- {
- Type = type;
- Password = password;
- lazyVolumes = new LazyReadOnlyCollection(LoadVolumes(streams.Select(CheckStreams), options));
- lazyEntries = new LazyReadOnlyCollection(LoadEntries(Volumes));
- }
-
- internal AbstractArchive(ArchiveType type)
- {
- Type = type;
- lazyVolumes = new LazyReadOnlyCollection(Enumerable.Empty());
- lazyEntries = new LazyReadOnlyCollection(Enumerable.Empty());
- }
- public ArchiveType Type { get; private set; }
-
- void IArchiveExtractionListener.FireEntryExtractionBegin(IArchiveEntry entry)
- {
- if (EntryExtractionBegin != null)
- {
- EntryExtractionBegin(this, new ArchiveExtractionEventArgs(entry));
- }
- }
-
- void IArchiveExtractionListener.FireEntryExtractionEnd(IArchiveEntry entry)
- {
- if (EntryExtractionEnd != null)
- {
- EntryExtractionEnd(this, new ArchiveExtractionEventArgs(entry));
- }
- }
-
- private static Stream CheckStreams(Stream stream)
- {
- if (!stream.CanSeek || !stream.CanRead)
- {
- throw new ArgumentException("Archive streams must be Readable and Seekable");
- }
- return stream;
- }
-
- ///
- /// Returns an ReadOnlyCollection of all the RarArchiveEntries across the one or many parts of the RarArchive.
- ///
- public virtual ICollection Entries
- {
- get { return lazyEntries; }
- }
-
- ///
- /// Returns an ReadOnlyCollection of all the RarArchiveVolumes across the one or many parts of the RarArchive.
- ///
- public ICollection Volumes
- {
- get { return lazyVolumes; }
- }
-
- ///
- /// The total size of the files compressed in the archive.
- ///
- public virtual long TotalSize
- {
- get { return Entries.Aggregate(0L, (total, cf) => total + cf.CompressedSize); }
- }
-
- ///
- /// The total size of the files as uncompressed in the archive.
- ///
- public virtual long TotalUncompressSize
- {
- get { return Entries.Aggregate(0L, (total, cf) => total + cf.Size); }
- }
-
- protected abstract IEnumerable LoadVolumes(IEnumerable streams, Options options);
- protected abstract IEnumerable LoadEntries(IEnumerable volumes);
-
- IEnumerable IArchive.Entries
- {
- get { return Entries.Cast(); }
- }
-
- IEnumerable IArchive.Volumes
- {
- get { return lazyVolumes.Cast(); }
- }
-
- private bool disposed;
-
- public virtual void Dispose()
- {
- if (!disposed)
- {
- lazyVolumes.ForEach(v => v.Dispose());
- lazyEntries.GetLoaded().Cast().ForEach(x => x.Close());
- disposed = true;
- }
- }
-
- void IArchiveExtractionListener.EnsureEntriesLoaded()
- {
- lazyEntries.EnsureFullyLoaded();
- lazyVolumes.EnsureFullyLoaded();
- }
-
- void IExtractionListener.FireCompressedBytesRead(long currentPartCompressedBytes, long compressedReadBytes)
- {
- if (CompressedBytesRead != null)
- {
- CompressedBytesRead(this, new CompressedBytesReadEventArgs()
- {
- CurrentFilePartCompressedBytesRead = currentPartCompressedBytes,
- CompressedBytesRead = compressedReadBytes
- });
- }
- }
-
- void IExtractionListener.FireFilePartExtractionBegin(string name, long size, long compressedSize)
- {
- if (FilePartExtractionBegin != null)
- {
- FilePartExtractionBegin(this, new FilePartExtractionBeginEventArgs()
- {
- CompressedSize = compressedSize,
- Size = size,
- Name = name,
- });
- }
- }
-
- ///
- /// Use this method to extract all entries in an archive in order.
- /// This is primarily for SOLID Rar Archives or 7Zip Archives as they need to be
- /// extracted sequentially for the best performance.
- ///
- /// This method will load all entry information from the archive.
- ///
- /// WARNING: this will reuse the underlying stream for the archive. Errors may
- /// occur if this is used at the same time as other extraction methods on this instance.
- ///
- ///
- public IReader ExtractAllEntries()
- {
- ((IArchiveExtractionListener)this).EnsureEntriesLoaded();
- return CreateReaderForSolidExtraction();
- }
-
- protected abstract IReader CreateReaderForSolidExtraction();
-
- ///
- /// Archive is SOLID (this means the Archive saved bytes by reusing information which helps for archives containing many small files).
- ///
- public virtual bool IsSolid
- {
- get { return false; }
- }
-
-
- ///
- /// The archive can find all the parts of the archive needed to fully extract the archive. This forces the parsing of the entire archive.
- ///
- public bool IsComplete
- {
- get
- {
- ((IArchiveExtractionListener)this).EnsureEntriesLoaded();
- return Entries.All(x => x.IsComplete);
- }
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using SharpCompress.Common;
+using SharpCompress.Reader;
+
+namespace SharpCompress.Archive
+{
+ public abstract class AbstractArchive : IArchive, IArchiveExtractionListener
+ where TEntry : IArchiveEntry
+ where TVolume : IVolume
+ {
+ private readonly LazyReadOnlyCollection lazyVolumes;
+ private readonly LazyReadOnlyCollection lazyEntries;
+
+ public event EventHandler> EntryExtractionBegin;
+ public event EventHandler> EntryExtractionEnd;
+
+ public event EventHandler CompressedBytesRead;
+ public event EventHandler FilePartExtractionBegin;
+
+ protected string Password { get; private set; }
+
+#if !DOTNET51
+ internal AbstractArchive(ArchiveType type, FileInfo fileInfo, Options options, string password)
+ {
+ Type = type;
+ Password = password;
+ if (!fileInfo.Exists)
+ {
+ throw new ArgumentException("File does not exist: " + fileInfo.FullName);
+ }
+ options = (Options) FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
+ lazyVolumes = new LazyReadOnlyCollection(LoadVolumes(fileInfo, options));
+ lazyEntries = new LazyReadOnlyCollection(LoadEntries(Volumes));
+ }
+
+
+ protected abstract IEnumerable LoadVolumes(FileInfo file, Options options);
+#endif
+
+ internal AbstractArchive(ArchiveType type, IEnumerable streams, Options options, string password)
+ {
+ Type = type;
+ Password = password;
+ lazyVolumes = new LazyReadOnlyCollection(LoadVolumes(streams.Select(CheckStreams), options));
+ lazyEntries = new LazyReadOnlyCollection(LoadEntries(Volumes));
+ }
+
+ internal AbstractArchive(ArchiveType type)
+ {
+ Type = type;
+ lazyVolumes = new LazyReadOnlyCollection(Enumerable.Empty());
+ lazyEntries = new LazyReadOnlyCollection(Enumerable.Empty());
+ }
+ public ArchiveType Type { get; private set; }
+
+ void IArchiveExtractionListener.FireEntryExtractionBegin(IArchiveEntry entry)
+ {
+ if (EntryExtractionBegin != null)
+ {
+ EntryExtractionBegin(this, new ArchiveExtractionEventArgs(entry));
+ }
+ }
+
+ void IArchiveExtractionListener.FireEntryExtractionEnd(IArchiveEntry entry)
+ {
+ if (EntryExtractionEnd != null)
+ {
+ EntryExtractionEnd(this, new ArchiveExtractionEventArgs(entry));
+ }
+ }
+
+ private static Stream CheckStreams(Stream stream)
+ {
+ if (!stream.CanSeek || !stream.CanRead)
+ {
+ throw new ArgumentException("Archive streams must be Readable and Seekable");
+ }
+ return stream;
+ }
+
+ ///
+ /// Returns an ReadOnlyCollection of all the RarArchiveEntries across the one or many parts of the RarArchive.
+ ///
+ public virtual ICollection Entries
+ {
+ get { return lazyEntries; }
+ }
+
+ ///
+ /// Returns an ReadOnlyCollection of all the RarArchiveVolumes across the one or many parts of the RarArchive.
+ ///
+ public ICollection Volumes
+ {
+ get { return lazyVolumes; }
+ }
+
+ ///
+ /// The total size of the files compressed in the archive.
+ ///
+ public virtual long TotalSize
+ {
+ get { return Entries.Aggregate(0L, (total, cf) => total + cf.CompressedSize); }
+ }
+
+ ///
+ /// The total size of the files as uncompressed in the archive.
+ ///
+ public virtual long TotalUncompressSize
+ {
+ get { return Entries.Aggregate(0L, (total, cf) => total + cf.Size); }
+ }
+
+ protected abstract IEnumerable LoadVolumes(IEnumerable streams, Options options);
+ protected abstract IEnumerable LoadEntries(IEnumerable volumes);
+
+ IEnumerable IArchive.Entries
+ {
+ get { return Entries.Cast(); }
+ }
+
+ IEnumerable IArchive.Volumes
+ {
+ get { return lazyVolumes.Cast(); }
+ }
+
+ private bool disposed;
+
+ public virtual void Dispose()
+ {
+ if (!disposed)
+ {
+ lazyVolumes.ForEach(v => v.Dispose());
+ lazyEntries.GetLoaded().Cast().ForEach(x => x.Close());
+ disposed = true;
+ }
+ }
+
+ void IArchiveExtractionListener.EnsureEntriesLoaded()
+ {
+ lazyEntries.EnsureFullyLoaded();
+ lazyVolumes.EnsureFullyLoaded();
+ }
+
+ void IExtractionListener.FireCompressedBytesRead(long currentPartCompressedBytes, long compressedReadBytes)
+ {
+ if (CompressedBytesRead != null)
+ {
+ CompressedBytesRead(this, new CompressedBytesReadEventArgs()
+ {
+ CurrentFilePartCompressedBytesRead = currentPartCompressedBytes,
+ CompressedBytesRead = compressedReadBytes
+ });
+ }
+ }
+
+ void IExtractionListener.FireFilePartExtractionBegin(string name, long size, long compressedSize)
+ {
+ if (FilePartExtractionBegin != null)
+ {
+ FilePartExtractionBegin(this, new FilePartExtractionBeginEventArgs()
+ {
+ CompressedSize = compressedSize,
+ Size = size,
+ Name = name,
+ });
+ }
+ }
+
+ ///
+ /// Use this method to extract all entries in an archive in order.
+ /// This is primarily for SOLID Rar Archives or 7Zip Archives as they need to be
+ /// extracted sequentially for the best performance.
+ ///
+ /// This method will load all entry information from the archive.
+ ///
+ /// WARNING: this will reuse the underlying stream for the archive. Errors may
+ /// occur if this is used at the same time as other extraction methods on this instance.
+ ///
+ ///
+ public IReader ExtractAllEntries()
+ {
+ ((IArchiveExtractionListener)this).EnsureEntriesLoaded();
+ return CreateReaderForSolidExtraction();
+ }
+
+ protected abstract IReader CreateReaderForSolidExtraction();
+
+ ///
+ /// Archive is SOLID (this means the Archive saved bytes by reusing information which helps for archives containing many small files).
+ ///
+ public virtual bool IsSolid
+ {
+ get { return false; }
+ }
+
+
+ ///
+ /// The archive can find all the parts of the archive needed to fully extract the archive. This forces the parsing of the entire archive.
+ ///
+ public bool IsComplete
+ {
+ get
+ {
+ ((IArchiveExtractionListener)this).EnsureEntriesLoaded();
+ return Entries.All(x => x.IsComplete);
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/AbstractWritableArchive.cs b/src/SharpCompress/Archive/AbstractWritableArchive.cs
similarity index 97%
rename from SharpCompress/Archive/AbstractWritableArchive.cs
rename to src/SharpCompress/Archive/AbstractWritableArchive.cs
index 074a95c3..3efa2ba3 100644
--- a/SharpCompress/Archive/AbstractWritableArchive.cs
+++ b/src/SharpCompress/Archive/AbstractWritableArchive.cs
@@ -1,149 +1,149 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using SharpCompress.Common;
-
-namespace SharpCompress.Archive
-{
- public abstract class AbstractWritableArchive : AbstractArchive, IWritableArchive
- where TEntry : IArchiveEntry
- where TVolume : IVolume
- {
- private readonly List newEntries = new List();
- private readonly List removedEntries = new List();
-
- private readonly List modifiedEntries = new List();
- private bool hasModifications;
-
- internal AbstractWritableArchive(ArchiveType type)
- : base(type)
- {
- }
-
- internal AbstractWritableArchive(ArchiveType type, Stream stream, Options options)
- : base(type, stream.AsEnumerable(), options, null)
- {
- }
-
-#if !DOTNET51
- internal AbstractWritableArchive(ArchiveType type, FileInfo fileInfo, Options options)
- : base(type, fileInfo, options, null)
- {
- }
-#endif
-
- public override ICollection Entries
- {
- get
- {
- if (hasModifications)
- {
- return modifiedEntries;
- }
- return base.Entries;
- }
- }
-
- private void RebuildModifiedCollection()
- {
- hasModifications = true;
- newEntries.RemoveAll(v => removedEntries.Contains(v));
- modifiedEntries.Clear();
- modifiedEntries.AddRange(OldEntries.Concat(newEntries));
- }
-
- private IEnumerable OldEntries
- {
- get { return base.Entries.Where(x => !removedEntries.Contains(x)); }
- }
-
- public void RemoveEntry(TEntry entry)
- {
- if (!removedEntries.Contains(entry))
- {
- removedEntries.Add(entry);
- RebuildModifiedCollection();
- }
- }
- void IWritableArchive.RemoveEntry(IArchiveEntry entry)
- {
- RemoveEntry((TEntry)entry);
- }
-
- public TEntry AddEntry(string key, Stream source,
- long size = 0, DateTime? modified = null)
- {
- return AddEntry(key, source, false, size, modified);
- }
-
-
- IArchiveEntry IWritableArchive.AddEntry(string key, Stream source, bool closeStream, long size, DateTime? modified)
- {
- return AddEntry(key, source, closeStream, size, modified);
- }
-
- public TEntry AddEntry(string key, Stream source, bool closeStream,
- long size = 0, DateTime? modified = null)
- {
- if (key.StartsWith("/")
- || key.StartsWith("\\"))
- {
- key = key.Substring(1);
- }
- if (DoesKeyMatchExisting(key))
- {
- throw new ArchiveException("Cannot add entry with duplicate key: " + key);
- }
- var entry = CreateEntry(key, source, size, modified, closeStream);
- newEntries.Add(entry);
- RebuildModifiedCollection();
- return entry;
- }
-
- private bool DoesKeyMatchExisting(string key)
- {
- foreach (var path in Entries.Select(x => x.Key))
- {
- var p = path.Replace('/','\\');
- if (p.StartsWith("\\"))
- {
- p = p.Substring(1);
- }
- return string.Equals(p, key, StringComparison.OrdinalIgnoreCase);
- }
- return false;
- }
-
- public void SaveTo(Stream stream, CompressionInfo compressionType)
- {
- //reset streams of new entries
- newEntries.Cast().ForEach(x => x.Stream.Seek(0, SeekOrigin.Begin));
- SaveTo(stream, compressionType, OldEntries, newEntries);
- }
-
- protected TEntry CreateEntry(string key, Stream source, long size, DateTime? modified,
- bool closeStream)
- {
- if (!source.CanRead || !source.CanSeek)
- {
- throw new ArgumentException("Streams must be readable and seekable to use the Writing Archive API");
- }
- return CreateEntryInternal(key, source, size, modified, closeStream);
- }
-
- protected abstract TEntry CreateEntryInternal(string key, Stream source, long size, DateTime? modified,
- bool closeStream);
-
- protected abstract void SaveTo(Stream stream, CompressionInfo compressionType,
- IEnumerable oldEntries, IEnumerable newEntries);
-
- public override void Dispose()
- {
- base.Dispose();
- newEntries.Cast().ForEach(x => x.Close());
- removedEntries.Cast().ForEach(x => x.Close());
- modifiedEntries.Cast().ForEach(x => x.Close());
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using SharpCompress.Common;
+
+namespace SharpCompress.Archive
+{
+ public abstract class AbstractWritableArchive : AbstractArchive, IWritableArchive
+ where TEntry : IArchiveEntry
+ where TVolume : IVolume
+ {
+ private readonly List newEntries = new List();
+ private readonly List removedEntries = new List();
+
+ private readonly List modifiedEntries = new List();
+ private bool hasModifications;
+
+ internal AbstractWritableArchive(ArchiveType type)
+ : base(type)
+ {
+ }
+
+ internal AbstractWritableArchive(ArchiveType type, Stream stream, Options options)
+ : base(type, stream.AsEnumerable(), options, null)
+ {
+ }
+
+#if !DOTNET51
+ internal AbstractWritableArchive(ArchiveType type, FileInfo fileInfo, Options options)
+ : base(type, fileInfo, options, null)
+ {
+ }
+#endif
+
+ public override ICollection Entries
+ {
+ get
+ {
+ if (hasModifications)
+ {
+ return modifiedEntries;
+ }
+ return base.Entries;
+ }
+ }
+
+ private void RebuildModifiedCollection()
+ {
+ hasModifications = true;
+ newEntries.RemoveAll(v => removedEntries.Contains(v));
+ modifiedEntries.Clear();
+ modifiedEntries.AddRange(OldEntries.Concat(newEntries));
+ }
+
+ private IEnumerable OldEntries
+ {
+ get { return base.Entries.Where(x => !removedEntries.Contains(x)); }
+ }
+
+ public void RemoveEntry(TEntry entry)
+ {
+ if (!removedEntries.Contains(entry))
+ {
+ removedEntries.Add(entry);
+ RebuildModifiedCollection();
+ }
+ }
+ void IWritableArchive.RemoveEntry(IArchiveEntry entry)
+ {
+ RemoveEntry((TEntry)entry);
+ }
+
+ public TEntry AddEntry(string key, Stream source,
+ long size = 0, DateTime? modified = null)
+ {
+ return AddEntry(key, source, false, size, modified);
+ }
+
+
+ IArchiveEntry IWritableArchive.AddEntry(string key, Stream source, bool closeStream, long size, DateTime? modified)
+ {
+ return AddEntry(key, source, closeStream, size, modified);
+ }
+
+ public TEntry AddEntry(string key, Stream source, bool closeStream,
+ long size = 0, DateTime? modified = null)
+ {
+ if (key.StartsWith("/")
+ || key.StartsWith("\\"))
+ {
+ key = key.Substring(1);
+ }
+ if (DoesKeyMatchExisting(key))
+ {
+ throw new ArchiveException("Cannot add entry with duplicate key: " + key);
+ }
+ var entry = CreateEntry(key, source, size, modified, closeStream);
+ newEntries.Add(entry);
+ RebuildModifiedCollection();
+ return entry;
+ }
+
+ private bool DoesKeyMatchExisting(string key)
+ {
+ foreach (var path in Entries.Select(x => x.Key))
+ {
+ var p = path.Replace('/','\\');
+ if (p.StartsWith("\\"))
+ {
+ p = p.Substring(1);
+ }
+ return string.Equals(p, key, StringComparison.OrdinalIgnoreCase);
+ }
+ return false;
+ }
+
+ public void SaveTo(Stream stream, CompressionInfo compressionType)
+ {
+ //reset streams of new entries
+ newEntries.Cast().ForEach(x => x.Stream.Seek(0, SeekOrigin.Begin));
+ SaveTo(stream, compressionType, OldEntries, newEntries);
+ }
+
+ protected TEntry CreateEntry(string key, Stream source, long size, DateTime? modified,
+ bool closeStream)
+ {
+ if (!source.CanRead || !source.CanSeek)
+ {
+ throw new ArgumentException("Streams must be readable and seekable to use the Writing Archive API");
+ }
+ return CreateEntryInternal(key, source, size, modified, closeStream);
+ }
+
+ protected abstract TEntry CreateEntryInternal(string key, Stream source, long size, DateTime? modified,
+ bool closeStream);
+
+ protected abstract void SaveTo(Stream stream, CompressionInfo compressionType,
+ IEnumerable oldEntries, IEnumerable newEntries);
+
+ public override void Dispose()
+ {
+ base.Dispose();
+ newEntries.Cast().ForEach(x => x.Close());
+ removedEntries.Cast().ForEach(x => x.Close());
+ modifiedEntries.Cast().ForEach(x => x.Close());
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/ArchiveFactory.cs b/src/SharpCompress/Archive/ArchiveFactory.cs
similarity index 97%
rename from SharpCompress/Archive/ArchiveFactory.cs
rename to src/SharpCompress/Archive/ArchiveFactory.cs
index a5411b74..bba5c9fe 100644
--- a/SharpCompress/Archive/ArchiveFactory.cs
+++ b/src/SharpCompress/Archive/ArchiveFactory.cs
@@ -1,172 +1,172 @@
-using System;
-using System.IO;
-using SharpCompress.Archive.GZip;
-using SharpCompress.Archive.Rar;
-using SharpCompress.Archive.SevenZip;
-using SharpCompress.Archive.Tar;
-using SharpCompress.Archive.Zip;
-using SharpCompress.Common;
-
-namespace SharpCompress.Archive
-{
- public class ArchiveFactory
- {
- ///
- /// Opens an Archive for random access
- ///
- ///
- ///
- ///
- public static IArchive Open(Stream stream, Options options = Options.KeepStreamsOpen)
- {
- stream.CheckNotNull("stream");
- if (!stream.CanRead || !stream.CanSeek)
- {
- throw new ArgumentException("Stream should be readable and seekable");
- }
-
- if (ZipArchive.IsZipFile(stream, null))
- {
- stream.Seek(0, SeekOrigin.Begin);
- return ZipArchive.Open(stream, options, null);
- }
- stream.Seek(0, SeekOrigin.Begin);
- if (TarArchive.IsTarFile(stream))
- {
- stream.Seek(0, SeekOrigin.Begin);
- return TarArchive.Open(stream, options);
- }
- stream.Seek(0, SeekOrigin.Begin);
- if (SevenZipArchive.IsSevenZipFile(stream))
- {
- stream.Seek(0, SeekOrigin.Begin);
- return SevenZipArchive.Open(stream, options);
- }
- stream.Seek(0, SeekOrigin.Begin);
- if (GZipArchive.IsGZipFile(stream))
- {
- stream.Seek(0, SeekOrigin.Begin);
- return GZipArchive.Open(stream, options);
- }
- stream.Seek(0, SeekOrigin.Begin);
- if(RarArchive.IsRarFile(stream, Options.LookForHeader | Options.KeepStreamsOpen))
- {
- stream.Seek(0, SeekOrigin.Begin);
- return RarArchive.Open(stream, options);
- }
- throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
- }
-
- public static IWritableArchive Create(ArchiveType type)
- {
- switch (type)
- {
- case ArchiveType.Zip:
- {
- return ZipArchive.Create();
- }
- case ArchiveType.Tar:
- {
- return TarArchive.Create();
- }
- case ArchiveType.GZip:
- {
- return GZipArchive.Create();
- }
- default:
- {
- throw new NotSupportedException("Cannot create Archives of type: " + type);
- }
- }
- }
-
-#if !DOTNET51
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- public static IArchive Open(string filePath)
- {
- return Open(filePath, Options.None);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- public static IArchive Open(FileInfo fileInfo)
- {
- return Open(fileInfo, Options.None);
- }
-
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- ///
- public static IArchive Open(string filePath, Options options)
- {
- filePath.CheckNotNullOrEmpty("filePath");
- return Open(new FileInfo(filePath), options);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- public static IArchive Open(FileInfo fileInfo, Options options)
- {
- fileInfo.CheckNotNull("fileInfo");
- using (var stream = fileInfo.OpenRead())
- {
- if (ZipArchive.IsZipFile(stream, null))
- {
- stream.Dispose();
- return ZipArchive.Open(fileInfo, options, null);
- }
- stream.Seek(0, SeekOrigin.Begin);
- if (TarArchive.IsTarFile(stream))
- {
- stream.Dispose();
- return TarArchive.Open(fileInfo, options);
- }
- stream.Seek(0, SeekOrigin.Begin);
- if (SevenZipArchive.IsSevenZipFile(stream))
- {
- stream.Dispose();
- return SevenZipArchive.Open(fileInfo, options);
- }
- stream.Seek(0, SeekOrigin.Begin);
- if (GZipArchive.IsGZipFile(stream))
- {
- stream.Dispose();
- return GZipArchive.Open(fileInfo, options);
- }
- stream.Seek(0, SeekOrigin.Begin);
- if(RarArchive.IsRarFile(stream, Options.LookForHeader | Options.KeepStreamsOpen))
- {
- stream.Dispose();
- return RarArchive.Open(fileInfo, options);
- }
- throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
- }
- }
-
- ///
- /// Extract to specific directory, retaining filename
- ///
- public static void WriteToDirectory(string sourceArchive, string destinationDirectory,
- ExtractOptions options = ExtractOptions.Overwrite)
- {
- using (IArchive archive = Open(sourceArchive))
- {
- foreach (IArchiveEntry entry in archive.Entries)
- {
- entry.WriteToDirectory(destinationDirectory, options);
- }
- }
- }
-#endif
- }
+using System;
+using System.IO;
+using SharpCompress.Archive.GZip;
+using SharpCompress.Archive.Rar;
+using SharpCompress.Archive.SevenZip;
+using SharpCompress.Archive.Tar;
+using SharpCompress.Archive.Zip;
+using SharpCompress.Common;
+
+namespace SharpCompress.Archive
+{
+ public class ArchiveFactory
+ {
+ ///
+ /// Opens an Archive for random access
+ ///
+ ///
+ ///
+ ///
+ public static IArchive Open(Stream stream, Options options = Options.KeepStreamsOpen)
+ {
+ stream.CheckNotNull("stream");
+ if (!stream.CanRead || !stream.CanSeek)
+ {
+ throw new ArgumentException("Stream should be readable and seekable");
+ }
+
+ if (ZipArchive.IsZipFile(stream, null))
+ {
+ stream.Seek(0, SeekOrigin.Begin);
+ return ZipArchive.Open(stream, options, null);
+ }
+ stream.Seek(0, SeekOrigin.Begin);
+ if (TarArchive.IsTarFile(stream))
+ {
+ stream.Seek(0, SeekOrigin.Begin);
+ return TarArchive.Open(stream, options);
+ }
+ stream.Seek(0, SeekOrigin.Begin);
+ if (SevenZipArchive.IsSevenZipFile(stream))
+ {
+ stream.Seek(0, SeekOrigin.Begin);
+ return SevenZipArchive.Open(stream, options);
+ }
+ stream.Seek(0, SeekOrigin.Begin);
+ if (GZipArchive.IsGZipFile(stream))
+ {
+ stream.Seek(0, SeekOrigin.Begin);
+ return GZipArchive.Open(stream, options);
+ }
+ stream.Seek(0, SeekOrigin.Begin);
+ if(RarArchive.IsRarFile(stream, Options.LookForHeader | Options.KeepStreamsOpen))
+ {
+ stream.Seek(0, SeekOrigin.Begin);
+ return RarArchive.Open(stream, options);
+ }
+ throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
+ }
+
+ public static IWritableArchive Create(ArchiveType type)
+ {
+ switch (type)
+ {
+ case ArchiveType.Zip:
+ {
+ return ZipArchive.Create();
+ }
+ case ArchiveType.Tar:
+ {
+ return TarArchive.Create();
+ }
+ case ArchiveType.GZip:
+ {
+ return GZipArchive.Create();
+ }
+ default:
+ {
+ throw new NotSupportedException("Cannot create Archives of type: " + type);
+ }
+ }
+ }
+
+#if !DOTNET51
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ public static IArchive Open(string filePath)
+ {
+ return Open(filePath, Options.None);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ public static IArchive Open(FileInfo fileInfo)
+ {
+ return Open(fileInfo, Options.None);
+ }
+
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ ///
+ public static IArchive Open(string filePath, Options options)
+ {
+ filePath.CheckNotNullOrEmpty("filePath");
+ return Open(new FileInfo(filePath), options);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ public static IArchive Open(FileInfo fileInfo, Options options)
+ {
+ fileInfo.CheckNotNull("fileInfo");
+ using (var stream = fileInfo.OpenRead())
+ {
+ if (ZipArchive.IsZipFile(stream, null))
+ {
+ stream.Dispose();
+ return ZipArchive.Open(fileInfo, options, null);
+ }
+ stream.Seek(0, SeekOrigin.Begin);
+ if (TarArchive.IsTarFile(stream))
+ {
+ stream.Dispose();
+ return TarArchive.Open(fileInfo, options);
+ }
+ stream.Seek(0, SeekOrigin.Begin);
+ if (SevenZipArchive.IsSevenZipFile(stream))
+ {
+ stream.Dispose();
+ return SevenZipArchive.Open(fileInfo, options);
+ }
+ stream.Seek(0, SeekOrigin.Begin);
+ if (GZipArchive.IsGZipFile(stream))
+ {
+ stream.Dispose();
+ return GZipArchive.Open(fileInfo, options);
+ }
+ stream.Seek(0, SeekOrigin.Begin);
+ if(RarArchive.IsRarFile(stream, Options.LookForHeader | Options.KeepStreamsOpen))
+ {
+ stream.Dispose();
+ return RarArchive.Open(fileInfo, options);
+ }
+ throw new InvalidOperationException("Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip");
+ }
+ }
+
+ ///
+ /// Extract to specific directory, retaining filename
+ ///
+ public static void WriteToDirectory(string sourceArchive, string destinationDirectory,
+ ExtractOptions options = ExtractOptions.Overwrite)
+ {
+ using (IArchive archive = Open(sourceArchive))
+ {
+ foreach (IArchiveEntry entry in archive.Entries)
+ {
+ entry.WriteToDirectory(destinationDirectory, options);
+ }
+ }
+ }
+#endif
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/GZip/GZipArchive.cs b/src/SharpCompress/Archive/GZip/GZipArchive.cs
similarity index 96%
rename from SharpCompress/Archive/GZip/GZipArchive.cs
rename to src/SharpCompress/Archive/GZip/GZipArchive.cs
index 17c5845f..ff3c57a8 100644
--- a/SharpCompress/Archive/GZip/GZipArchive.cs
+++ b/src/SharpCompress/Archive/GZip/GZipArchive.cs
@@ -1,218 +1,218 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using SharpCompress.Common;
-using SharpCompress.Common.GZip;
-using SharpCompress.Reader;
-using SharpCompress.Reader.GZip;
-using SharpCompress.Writer.GZip;
-
-namespace SharpCompress.Archive.GZip
-{
- public class GZipArchive : AbstractWritableArchive
- {
-#if !DOTNET51
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- public static GZipArchive Open(string filePath)
- {
- return Open(filePath, Options.None);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- public static GZipArchive Open(FileInfo fileInfo)
- {
- return Open(fileInfo, Options.None);
- }
-
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- ///
- public static GZipArchive Open(string filePath, Options options)
- {
- filePath.CheckNotNullOrEmpty("filePath");
- return Open(new FileInfo(filePath), options);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- public static GZipArchive Open(FileInfo fileInfo, Options options)
- {
- fileInfo.CheckNotNull("fileInfo");
- return new GZipArchive(fileInfo, options);
- }
-#endif
-
- ///
- /// Takes a seekable Stream as a source
- ///
- ///
- public static GZipArchive Open(Stream stream)
- {
- stream.CheckNotNull("stream");
- return Open(stream, Options.None);
- }
-
- ///
- /// Takes a seekable Stream as a source
- ///
- ///
- ///
- public static GZipArchive Open(Stream stream, Options options)
- {
- stream.CheckNotNull("stream");
- return new GZipArchive(stream, options);
- }
-
- public static GZipArchive Create()
- {
- return new GZipArchive();
- }
-
-#if !DOTNET51
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- internal GZipArchive(FileInfo fileInfo, Options options)
- : base(ArchiveType.GZip, fileInfo, options)
- {
- }
-
- protected override IEnumerable LoadVolumes(FileInfo file, Options options)
- {
- return new GZipVolume(file, options).AsEnumerable();
- }
-
- public static bool IsGZipFile(string filePath)
- {
- return IsGZipFile(new FileInfo(filePath));
- }
-
- public static bool IsGZipFile(FileInfo fileInfo)
- {
- if (!fileInfo.Exists)
- {
- return false;
- }
- using (Stream stream = fileInfo.OpenRead())
- {
- return IsGZipFile(stream);
- }
- }
-
- public void SaveTo(string filePath)
- {
- SaveTo(new FileInfo(filePath));
- }
-
- public void SaveTo(FileInfo fileInfo)
- {
- using (var stream = fileInfo.Open(FileMode.Create, FileAccess.Write))
- {
- SaveTo(stream);
- }
- }
-#endif
-
- public static bool IsGZipFile(Stream stream)
- {
- // read the header on the first read
- byte[] header = new byte[10];
- int n = stream.Read(header, 0, header.Length);
-
- // workitem 8501: handle edge case (decompress empty stream)
- if (n == 0)
- return false;
-
- if (n != 10)
- return false;
-
- if (header[0] != 0x1F || header[1] != 0x8B || header[2] != 8)
- return false;
-
- return true;
- }
-
- ///
- /// Takes multiple seekable Streams for a multi-part archive
- ///
- ///
- ///
- internal GZipArchive(Stream stream, Options options)
- : base(ArchiveType.GZip, stream, options)
- {
- }
-
- internal GZipArchive()
- : base(ArchiveType.GZip)
- {
- }
-
- public void SaveTo(Stream stream)
- {
- SaveTo(stream, CompressionType.GZip);
- }
-
- protected override GZipArchiveEntry CreateEntryInternal(string filePath, Stream source, long size, DateTime? modified,
- bool closeStream)
- {
- if (Entries.Any())
- {
- throw new InvalidOperationException("Only one entry is allowed in a GZip Archive");
- }
- return new GZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream);
- }
-
- protected override void SaveTo(Stream stream, CompressionInfo compressionInfo,
- IEnumerable oldEntries,
- IEnumerable newEntries)
- {
- if (Entries.Count > 1)
- {
- throw new InvalidOperationException("Only one entry is allowed in a GZip Archive");
- }
- using (var writer = new GZipWriter(stream))
- {
- foreach (var entry in oldEntries.Concat(newEntries)
- .Where(x => !x.IsDirectory))
- {
- using (var entryStream = entry.OpenEntryStream())
- {
- writer.Write(entry.Key, entryStream, entry.LastModifiedTime);
- }
- }
- }
- }
-
- protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
- {
- return new GZipVolume(streams.First(), options).AsEnumerable();
- }
-
- protected override IEnumerable LoadEntries(IEnumerable volumes)
- {
- Stream stream = volumes.Single().Stream;
- yield return new GZipArchiveEntry(this, new GZipFilePart(stream));
- }
-
- protected override IReader CreateReaderForSolidExtraction()
- {
- var stream = Volumes.Single().Stream;
- stream.Position = 0;
- return GZipReader.Open(stream);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using SharpCompress.Common;
+using SharpCompress.Common.GZip;
+using SharpCompress.Reader;
+using SharpCompress.Reader.GZip;
+using SharpCompress.Writer.GZip;
+
+namespace SharpCompress.Archive.GZip
+{
+ public class GZipArchive : AbstractWritableArchive
+ {
+#if !DOTNET51
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ public static GZipArchive Open(string filePath)
+ {
+ return Open(filePath, Options.None);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ public static GZipArchive Open(FileInfo fileInfo)
+ {
+ return Open(fileInfo, Options.None);
+ }
+
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ ///
+ public static GZipArchive Open(string filePath, Options options)
+ {
+ filePath.CheckNotNullOrEmpty("filePath");
+ return Open(new FileInfo(filePath), options);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ public static GZipArchive Open(FileInfo fileInfo, Options options)
+ {
+ fileInfo.CheckNotNull("fileInfo");
+ return new GZipArchive(fileInfo, options);
+ }
+#endif
+
+ ///
+ /// Takes a seekable Stream as a source
+ ///
+ ///
+ public static GZipArchive Open(Stream stream)
+ {
+ stream.CheckNotNull("stream");
+ return Open(stream, Options.None);
+ }
+
+ ///
+ /// Takes a seekable Stream as a source
+ ///
+ ///
+ ///
+ public static GZipArchive Open(Stream stream, Options options)
+ {
+ stream.CheckNotNull("stream");
+ return new GZipArchive(stream, options);
+ }
+
+ public static GZipArchive Create()
+ {
+ return new GZipArchive();
+ }
+
+#if !DOTNET51
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ internal GZipArchive(FileInfo fileInfo, Options options)
+ : base(ArchiveType.GZip, fileInfo, options)
+ {
+ }
+
+ protected override IEnumerable LoadVolumes(FileInfo file, Options options)
+ {
+ return new GZipVolume(file, options).AsEnumerable();
+ }
+
+ public static bool IsGZipFile(string filePath)
+ {
+ return IsGZipFile(new FileInfo(filePath));
+ }
+
+ public static bool IsGZipFile(FileInfo fileInfo)
+ {
+ if (!fileInfo.Exists)
+ {
+ return false;
+ }
+ using (Stream stream = fileInfo.OpenRead())
+ {
+ return IsGZipFile(stream);
+ }
+ }
+
+ public void SaveTo(string filePath)
+ {
+ SaveTo(new FileInfo(filePath));
+ }
+
+ public void SaveTo(FileInfo fileInfo)
+ {
+ using (var stream = fileInfo.Open(FileMode.Create, FileAccess.Write))
+ {
+ SaveTo(stream);
+ }
+ }
+#endif
+
+ public static bool IsGZipFile(Stream stream)
+ {
+ // read the header on the first read
+ byte[] header = new byte[10];
+ int n = stream.Read(header, 0, header.Length);
+
+ // workitem 8501: handle edge case (decompress empty stream)
+ if (n == 0)
+ return false;
+
+ if (n != 10)
+ return false;
+
+ if (header[0] != 0x1F || header[1] != 0x8B || header[2] != 8)
+ return false;
+
+ return true;
+ }
+
+ ///
+ /// Takes multiple seekable Streams for a multi-part archive
+ ///
+ ///
+ ///
+ internal GZipArchive(Stream stream, Options options)
+ : base(ArchiveType.GZip, stream, options)
+ {
+ }
+
+ internal GZipArchive()
+ : base(ArchiveType.GZip)
+ {
+ }
+
+ public void SaveTo(Stream stream)
+ {
+ SaveTo(stream, CompressionType.GZip);
+ }
+
+ protected override GZipArchiveEntry CreateEntryInternal(string filePath, Stream source, long size, DateTime? modified,
+ bool closeStream)
+ {
+ if (Entries.Any())
+ {
+ throw new InvalidOperationException("Only one entry is allowed in a GZip Archive");
+ }
+ return new GZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream);
+ }
+
+ protected override void SaveTo(Stream stream, CompressionInfo compressionInfo,
+ IEnumerable oldEntries,
+ IEnumerable newEntries)
+ {
+ if (Entries.Count > 1)
+ {
+ throw new InvalidOperationException("Only one entry is allowed in a GZip Archive");
+ }
+ using (var writer = new GZipWriter(stream))
+ {
+ foreach (var entry in oldEntries.Concat(newEntries)
+ .Where(x => !x.IsDirectory))
+ {
+ using (var entryStream = entry.OpenEntryStream())
+ {
+ writer.Write(entry.Key, entryStream, entry.LastModifiedTime);
+ }
+ }
+ }
+ }
+
+ protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
+ {
+ return new GZipVolume(streams.First(), options).AsEnumerable();
+ }
+
+ protected override IEnumerable LoadEntries(IEnumerable volumes)
+ {
+ Stream stream = volumes.Single().Stream;
+ yield return new GZipArchiveEntry(this, new GZipFilePart(stream));
+ }
+
+ protected override IReader CreateReaderForSolidExtraction()
+ {
+ var stream = Volumes.Single().Stream;
+ stream.Position = 0;
+ return GZipReader.Open(stream);
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/GZip/GZipArchiveEntry.cs b/src/SharpCompress/Archive/GZip/GZipArchiveEntry.cs
similarity index 95%
rename from SharpCompress/Archive/GZip/GZipArchiveEntry.cs
rename to src/SharpCompress/Archive/GZip/GZipArchiveEntry.cs
index 4526956d..6c46f7a1 100644
--- a/SharpCompress/Archive/GZip/GZipArchiveEntry.cs
+++ b/src/SharpCompress/Archive/GZip/GZipArchiveEntry.cs
@@ -1,31 +1,31 @@
-using System.IO;
-using System.Linq;
-using SharpCompress.Common.GZip;
-
-namespace SharpCompress.Archive.GZip
-{
- public class GZipArchiveEntry : GZipEntry, IArchiveEntry
- {
-
- internal GZipArchiveEntry(GZipArchive archive, GZipFilePart part)
- : base(part)
- {
- Archive = archive;
- }
-
- public virtual Stream OpenEntryStream()
- {
- return Parts.Single().GetCompressedStream();
- }
-
- #region IArchiveEntry Members
- public IArchive Archive { get; private set; }
-
- public bool IsComplete
- {
- get { return true; }
- }
-
- #endregion
- }
+using System.IO;
+using System.Linq;
+using SharpCompress.Common.GZip;
+
+namespace SharpCompress.Archive.GZip
+{
+ public class GZipArchiveEntry : GZipEntry, IArchiveEntry
+ {
+
+ internal GZipArchiveEntry(GZipArchive archive, GZipFilePart part)
+ : base(part)
+ {
+ Archive = archive;
+ }
+
+ public virtual Stream OpenEntryStream()
+ {
+ return Parts.Single().GetCompressedStream();
+ }
+
+ #region IArchiveEntry Members
+ public IArchive Archive { get; private set; }
+
+ public bool IsComplete
+ {
+ get { return true; }
+ }
+
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/GZip/GZipWritableArchiveEntry.cs b/src/SharpCompress/Archive/GZip/GZipWritableArchiveEntry.cs
similarity index 95%
rename from SharpCompress/Archive/GZip/GZipWritableArchiveEntry.cs
rename to src/SharpCompress/Archive/GZip/GZipWritableArchiveEntry.cs
index 8ef98379..0c5067b5 100644
--- a/SharpCompress/Archive/GZip/GZipWritableArchiveEntry.cs
+++ b/src/SharpCompress/Archive/GZip/GZipWritableArchiveEntry.cs
@@ -1,111 +1,111 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using SharpCompress.Common;
-using SharpCompress.IO;
-
-namespace SharpCompress.Archive.GZip
-{
- internal class GZipWritableArchiveEntry : GZipArchiveEntry, IWritableArchiveEntry
- {
- private readonly string path;
- private readonly long size;
- private readonly DateTime? lastModified;
- private readonly bool closeStream;
- private readonly Stream stream;
-
- internal GZipWritableArchiveEntry(GZipArchive archive, Stream stream,
- string path, long size, DateTime? lastModified, bool closeStream)
- : base(archive, null)
- {
- this.stream = stream;
- this.path = path;
- this.size = size;
- this.lastModified = lastModified;
- this.closeStream = closeStream;
- }
-
- public override long Crc
- {
- get { return 0; }
- }
-
- public override string Key
- {
- get { return path; }
- }
-
- public override long CompressedSize
- {
- get { return 0; }
- }
-
- public override long Size
- {
- get { return size; }
- }
-
- public override DateTime? LastModifiedTime
- {
- get { return lastModified; }
- }
-
- public override DateTime? CreatedTime
- {
- get { return null; }
- }
-
- public override DateTime? LastAccessedTime
- {
- get { return null; }
- }
-
- public override DateTime? ArchivedTime
- {
- get { return null; }
- }
-
- public override bool IsEncrypted
- {
- get { return false; }
- }
-
- public override bool IsDirectory
- {
- get { return false; }
- }
-
- public override bool IsSplit
- {
- get { return false; }
- }
-
- internal override IEnumerable Parts
- {
- get { throw new NotImplementedException(); }
- }
-
- Stream IWritableArchiveEntry.Stream
- {
- get
- {
- return stream;
- }
- }
-
- public override Stream OpenEntryStream()
- {
- //ensure new stream is at the start, this could be reset
- stream.Seek(0, SeekOrigin.Begin);
- return new NonDisposingStream(stream);
- }
-
- internal override void Close()
- {
- if (closeStream)
- {
- stream.Dispose();
- }
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using SharpCompress.Common;
+using SharpCompress.IO;
+
+namespace SharpCompress.Archive.GZip
+{
+ internal class GZipWritableArchiveEntry : GZipArchiveEntry, IWritableArchiveEntry
+ {
+ private readonly string path;
+ private readonly long size;
+ private readonly DateTime? lastModified;
+ private readonly bool closeStream;
+ private readonly Stream stream;
+
+ internal GZipWritableArchiveEntry(GZipArchive archive, Stream stream,
+ string path, long size, DateTime? lastModified, bool closeStream)
+ : base(archive, null)
+ {
+ this.stream = stream;
+ this.path = path;
+ this.size = size;
+ this.lastModified = lastModified;
+ this.closeStream = closeStream;
+ }
+
+ public override long Crc
+ {
+ get { return 0; }
+ }
+
+ public override string Key
+ {
+ get { return path; }
+ }
+
+ public override long CompressedSize
+ {
+ get { return 0; }
+ }
+
+ public override long Size
+ {
+ get { return size; }
+ }
+
+ public override DateTime? LastModifiedTime
+ {
+ get { return lastModified; }
+ }
+
+ public override DateTime? CreatedTime
+ {
+ get { return null; }
+ }
+
+ public override DateTime? LastAccessedTime
+ {
+ get { return null; }
+ }
+
+ public override DateTime? ArchivedTime
+ {
+ get { return null; }
+ }
+
+ public override bool IsEncrypted
+ {
+ get { return false; }
+ }
+
+ public override bool IsDirectory
+ {
+ get { return false; }
+ }
+
+ public override bool IsSplit
+ {
+ get { return false; }
+ }
+
+ internal override IEnumerable Parts
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ Stream IWritableArchiveEntry.Stream
+ {
+ get
+ {
+ return stream;
+ }
+ }
+
+ public override Stream OpenEntryStream()
+ {
+ //ensure new stream is at the start, this could be reset
+ stream.Seek(0, SeekOrigin.Begin);
+ return new NonDisposingStream(stream);
+ }
+
+ internal override void Close()
+ {
+ if (closeStream)
+ {
+ stream.Dispose();
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/IArchive.Extensions.cs b/src/SharpCompress/Archive/IArchive.Extensions.cs
similarity index 96%
rename from SharpCompress/Archive/IArchive.Extensions.cs
rename to src/SharpCompress/Archive/IArchive.Extensions.cs
index 6c961998..bb337551 100644
--- a/SharpCompress/Archive/IArchive.Extensions.cs
+++ b/src/SharpCompress/Archive/IArchive.Extensions.cs
@@ -1,22 +1,22 @@
-using System.Linq;
-using SharpCompress.Common;
-
-namespace SharpCompress.Archive
-{
- public static class IArchiveExtensions
- {
-#if !DOTNET51
- ///
- /// Extract to specific directory, retaining filename
- ///
- public static void WriteToDirectory(this IArchive archive, string destinationDirectory,
- ExtractOptions options = ExtractOptions.Overwrite)
- {
- foreach (IArchiveEntry entry in archive.Entries.Where(x => !x.IsDirectory))
- {
- entry.WriteToDirectory(destinationDirectory, options);
- }
- }
-#endif
- }
+using System.Linq;
+using SharpCompress.Common;
+
+namespace SharpCompress.Archive
+{
+ public static class IArchiveExtensions
+ {
+#if !DOTNET51
+ ///
+ /// Extract to specific directory, retaining filename
+ ///
+ public static void WriteToDirectory(this IArchive archive, string destinationDirectory,
+ ExtractOptions options = ExtractOptions.Overwrite)
+ {
+ foreach (IArchiveEntry entry in archive.Entries.Where(x => !x.IsDirectory))
+ {
+ entry.WriteToDirectory(destinationDirectory, options);
+ }
+ }
+#endif
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/IArchive.cs b/src/SharpCompress/Archive/IArchive.cs
similarity index 97%
rename from SharpCompress/Archive/IArchive.cs
rename to src/SharpCompress/Archive/IArchive.cs
index c70e49d3..a34f7f9d 100644
--- a/SharpCompress/Archive/IArchive.cs
+++ b/src/SharpCompress/Archive/IArchive.cs
@@ -1,49 +1,49 @@
-using System;
-using System.Collections.Generic;
-using SharpCompress.Common;
-using SharpCompress.Reader;
-
-namespace SharpCompress.Archive
-{
- public interface IArchive : IDisposable
- {
- event EventHandler> EntryExtractionBegin;
- event EventHandler> EntryExtractionEnd;
-
- event EventHandler CompressedBytesRead;
- event EventHandler FilePartExtractionBegin;
-
- IEnumerable Entries { get; }
- IEnumerable Volumes { get; }
-
- ArchiveType Type { get; }
-
- ///
- /// Use this method to extract all entries in an archive in order.
- /// This is primarily for SOLID Rar Archives or 7Zip Archives as they need to be
- /// extracted sequentially for the best performance.
- ///
- IReader ExtractAllEntries();
-
- ///
- /// Archive is SOLID (this means the Archive saved bytes by reusing information which helps for archives containing many small files).
- /// Rar Archives can be SOLID while all 7Zip archives are considered SOLID.
- ///
- bool IsSolid { get; }
-
- ///
- /// This checks to see if all the known entries have IsComplete = true
- ///
- bool IsComplete { get; }
-
- ///
- /// The total size of the files compressed in the archive.
- ///
- long TotalSize { get; }
-
- ///
- /// The total size of the files as uncompressed in the archive.
- ///
- long TotalUncompressSize { get; }
- }
+using System;
+using System.Collections.Generic;
+using SharpCompress.Common;
+using SharpCompress.Reader;
+
+namespace SharpCompress.Archive
+{
+ public interface IArchive : IDisposable
+ {
+ event EventHandler> EntryExtractionBegin;
+ event EventHandler> EntryExtractionEnd;
+
+ event EventHandler CompressedBytesRead;
+ event EventHandler FilePartExtractionBegin;
+
+ IEnumerable Entries { get; }
+ IEnumerable Volumes { get; }
+
+ ArchiveType Type { get; }
+
+ ///
+ /// Use this method to extract all entries in an archive in order.
+ /// This is primarily for SOLID Rar Archives or 7Zip Archives as they need to be
+ /// extracted sequentially for the best performance.
+ ///
+ IReader ExtractAllEntries();
+
+ ///
+ /// Archive is SOLID (this means the Archive saved bytes by reusing information which helps for archives containing many small files).
+ /// Rar Archives can be SOLID while all 7Zip archives are considered SOLID.
+ ///
+ bool IsSolid { get; }
+
+ ///
+ /// This checks to see if all the known entries have IsComplete = true
+ ///
+ bool IsComplete { get; }
+
+ ///
+ /// The total size of the files compressed in the archive.
+ ///
+ long TotalSize { get; }
+
+ ///
+ /// The total size of the files as uncompressed in the archive.
+ ///
+ long TotalUncompressSize { get; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/IArchiveEntry.Extensions.cs b/src/SharpCompress/Archive/IArchiveEntry.Extensions.cs
similarity index 97%
rename from SharpCompress/Archive/IArchiveEntry.Extensions.cs
rename to src/SharpCompress/Archive/IArchiveEntry.Extensions.cs
index dc4140de..0d5924a4 100644
--- a/SharpCompress/Archive/IArchiveEntry.Extensions.cs
+++ b/src/SharpCompress/Archive/IArchiveEntry.Extensions.cs
@@ -1,123 +1,123 @@
-using System.IO;
-using SharpCompress.Common;
-using SharpCompress.IO;
-
-namespace SharpCompress.Archive
-{
- public static class IArchiveEntryExtensions
- {
- public static void WriteTo(this IArchiveEntry archiveEntry, Stream streamToWriteTo)
- {
- if (archiveEntry.Archive.Type == ArchiveType.Rar && archiveEntry.Archive.IsSolid)
- {
- throw new InvalidFormatException("Cannot use Archive random access on SOLID Rar files.");
- }
-
- if (archiveEntry.IsDirectory)
- {
- throw new ExtractionException("Entry is a file directory and cannot be extracted.");
- }
-
- var streamListener = archiveEntry.Archive as IArchiveExtractionListener;
- streamListener.EnsureEntriesLoaded();
- streamListener.FireEntryExtractionBegin(archiveEntry);
- streamListener.FireFilePartExtractionBegin(archiveEntry.Key, archiveEntry.Size, archiveEntry.CompressedSize);
- var entryStream = archiveEntry.OpenEntryStream();
- if (entryStream == null)
- {
- return;
- }
- using(entryStream)
- using (Stream s = new ListeningStream(streamListener, entryStream))
- {
- s.TransferTo(streamToWriteTo);
- }
- streamListener.FireEntryExtractionEnd(archiveEntry);
- }
-
-#if !DOTNET51
- ///
- /// Extract to specific directory, retaining filename
- ///
- public static void WriteToDirectory(this IArchiveEntry entry, string destinationDirectory,
- ExtractOptions options = ExtractOptions.Overwrite)
- {
- string destinationFileName;
- string file = Path.GetFileName(entry.Key);
-
-
- if (options.HasFlag(ExtractOptions.ExtractFullPath))
- {
- string folder = Path.GetDirectoryName(entry.Key);
- string destdir = Path.Combine(destinationDirectory, folder);
- if (!Directory.Exists(destdir))
- {
- Directory.CreateDirectory(destdir);
- }
- destinationFileName = Path.Combine(destdir, file);
- }
- else
- {
- destinationFileName = Path.Combine(destinationDirectory, file);
- }
- entry.WriteToFile(destinationFileName, options);
- }
-
- ///
- /// Extract to specific file
- ///
- public static void WriteToFile(this IArchiveEntry entry, string destinationFileName,
- ExtractOptions options = ExtractOptions.Overwrite)
- {
- if (entry.IsDirectory)
- {
- return;
- }
- FileMode fm = FileMode.Create;
-
- if (!options.HasFlag(ExtractOptions.Overwrite))
- {
- fm = FileMode.CreateNew;
- }
- using (FileStream fs = File.Open(destinationFileName, fm))
- {
- entry.WriteTo(fs);
- }
-
- if (options.HasFlag(ExtractOptions.PreserveFileTime) || options.HasFlag(ExtractOptions.PreserveAttributes))
- {
- // update file time to original packed time
- FileInfo nf = new FileInfo(destinationFileName);
- if (nf.Exists)
- {
- if (options.HasFlag(ExtractOptions.PreserveFileTime))
- {
- if (entry.CreatedTime.HasValue)
- {
- nf.CreationTime = entry.CreatedTime.Value;
- }
-
- if (entry.LastModifiedTime.HasValue)
- {
- nf.LastWriteTime = entry.LastModifiedTime.Value;
- }
-
- if (entry.LastAccessedTime.HasValue)
- {
- nf.LastAccessTime = entry.CreatedTime.Value;
- }
- }
-
- if (options.HasFlag(ExtractOptions.PreserveAttributes))
- {
- if (entry.Attrib.HasValue)
- {
- nf.Attributes = (FileAttributes)System.Enum.ToObject(typeof(FileAttributes), entry.Attrib.Value);
- }
- }
- }
- }
- }
-#endif
- }
+using System.IO;
+using SharpCompress.Common;
+using SharpCompress.IO;
+
+namespace SharpCompress.Archive
+{
+ public static class IArchiveEntryExtensions
+ {
+ public static void WriteTo(this IArchiveEntry archiveEntry, Stream streamToWriteTo)
+ {
+ if (archiveEntry.Archive.Type == ArchiveType.Rar && archiveEntry.Archive.IsSolid)
+ {
+ throw new InvalidFormatException("Cannot use Archive random access on SOLID Rar files.");
+ }
+
+ if (archiveEntry.IsDirectory)
+ {
+ throw new ExtractionException("Entry is a file directory and cannot be extracted.");
+ }
+
+ var streamListener = archiveEntry.Archive as IArchiveExtractionListener;
+ streamListener.EnsureEntriesLoaded();
+ streamListener.FireEntryExtractionBegin(archiveEntry);
+ streamListener.FireFilePartExtractionBegin(archiveEntry.Key, archiveEntry.Size, archiveEntry.CompressedSize);
+ var entryStream = archiveEntry.OpenEntryStream();
+ if (entryStream == null)
+ {
+ return;
+ }
+ using(entryStream)
+ using (Stream s = new ListeningStream(streamListener, entryStream))
+ {
+ s.TransferTo(streamToWriteTo);
+ }
+ streamListener.FireEntryExtractionEnd(archiveEntry);
+ }
+
+#if !DOTNET51
+ ///
+ /// Extract to specific directory, retaining filename
+ ///
+ public static void WriteToDirectory(this IArchiveEntry entry, string destinationDirectory,
+ ExtractOptions options = ExtractOptions.Overwrite)
+ {
+ string destinationFileName;
+ string file = Path.GetFileName(entry.Key);
+
+
+ if (options.HasFlag(ExtractOptions.ExtractFullPath))
+ {
+ string folder = Path.GetDirectoryName(entry.Key);
+ string destdir = Path.Combine(destinationDirectory, folder);
+ if (!Directory.Exists(destdir))
+ {
+ Directory.CreateDirectory(destdir);
+ }
+ destinationFileName = Path.Combine(destdir, file);
+ }
+ else
+ {
+ destinationFileName = Path.Combine(destinationDirectory, file);
+ }
+ entry.WriteToFile(destinationFileName, options);
+ }
+
+ ///
+ /// Extract to specific file
+ ///
+ public static void WriteToFile(this IArchiveEntry entry, string destinationFileName,
+ ExtractOptions options = ExtractOptions.Overwrite)
+ {
+ if (entry.IsDirectory)
+ {
+ return;
+ }
+ FileMode fm = FileMode.Create;
+
+ if (!options.HasFlag(ExtractOptions.Overwrite))
+ {
+ fm = FileMode.CreateNew;
+ }
+ using (FileStream fs = File.Open(destinationFileName, fm))
+ {
+ entry.WriteTo(fs);
+ }
+
+ if (options.HasFlag(ExtractOptions.PreserveFileTime) || options.HasFlag(ExtractOptions.PreserveAttributes))
+ {
+ // update file time to original packed time
+ FileInfo nf = new FileInfo(destinationFileName);
+ if (nf.Exists)
+ {
+ if (options.HasFlag(ExtractOptions.PreserveFileTime))
+ {
+ if (entry.CreatedTime.HasValue)
+ {
+ nf.CreationTime = entry.CreatedTime.Value;
+ }
+
+ if (entry.LastModifiedTime.HasValue)
+ {
+ nf.LastWriteTime = entry.LastModifiedTime.Value;
+ }
+
+ if (entry.LastAccessedTime.HasValue)
+ {
+ nf.LastAccessTime = entry.CreatedTime.Value;
+ }
+ }
+
+ if (options.HasFlag(ExtractOptions.PreserveAttributes))
+ {
+ if (entry.Attrib.HasValue)
+ {
+ nf.Attributes = (FileAttributes)System.Enum.ToObject(typeof(FileAttributes), entry.Attrib.Value);
+ }
+ }
+ }
+ }
+ }
+#endif
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/IArchiveEntry.cs b/src/SharpCompress/Archive/IArchiveEntry.cs
similarity index 96%
rename from SharpCompress/Archive/IArchiveEntry.cs
rename to src/SharpCompress/Archive/IArchiveEntry.cs
index b9f04364..ac52485b 100644
--- a/SharpCompress/Archive/IArchiveEntry.cs
+++ b/src/SharpCompress/Archive/IArchiveEntry.cs
@@ -1,24 +1,24 @@
-using System.IO;
-using SharpCompress.Common;
-
-namespace SharpCompress.Archive
-{
- public interface IArchiveEntry : IEntry
- {
- ///
- /// Opens the current entry as a stream that will decompress as it is read.
- /// Read the entire stream or use SkipEntry on EntryStream.
- ///
- Stream OpenEntryStream();
-
- ///
- /// The archive can find all the parts of the archive needed to extract this entry.
- ///
- bool IsComplete { get; }
-
- ///
- /// The archive instance this entry belongs to
- ///
- IArchive Archive { get; }
- }
+using System.IO;
+using SharpCompress.Common;
+
+namespace SharpCompress.Archive
+{
+ public interface IArchiveEntry : IEntry
+ {
+ ///
+ /// Opens the current entry as a stream that will decompress as it is read.
+ /// Read the entire stream or use SkipEntry on EntryStream.
+ ///
+ Stream OpenEntryStream();
+
+ ///
+ /// The archive can find all the parts of the archive needed to extract this entry.
+ ///
+ bool IsComplete { get; }
+
+ ///
+ /// The archive instance this entry belongs to
+ ///
+ IArchive Archive { get; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/IArchiveExtractionListener.cs b/src/SharpCompress/Archive/IArchiveExtractionListener.cs
similarity index 96%
rename from SharpCompress/Archive/IArchiveExtractionListener.cs
rename to src/SharpCompress/Archive/IArchiveExtractionListener.cs
index aa15a875..12a1e9ff 100644
--- a/SharpCompress/Archive/IArchiveExtractionListener.cs
+++ b/src/SharpCompress/Archive/IArchiveExtractionListener.cs
@@ -1,11 +1,11 @@
-using SharpCompress.Common;
-
-namespace SharpCompress.Archive
-{
- internal interface IArchiveExtractionListener : IExtractionListener
- {
- void EnsureEntriesLoaded();
- void FireEntryExtractionBegin(IArchiveEntry entry);
- void FireEntryExtractionEnd(IArchiveEntry entry);
- }
+using SharpCompress.Common;
+
+namespace SharpCompress.Archive
+{
+ internal interface IArchiveExtractionListener : IExtractionListener
+ {
+ void EnsureEntriesLoaded();
+ void FireEntryExtractionBegin(IArchiveEntry entry);
+ void FireEntryExtractionEnd(IArchiveEntry entry);
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/IWritableArchive.Extensions.cs b/src/SharpCompress/Archive/IWritableArchive.Extensions.cs
similarity index 100%
rename from SharpCompress/Archive/IWritableArchive.Extensions.cs
rename to src/SharpCompress/Archive/IWritableArchive.Extensions.cs
diff --git a/SharpCompress/Archive/IWritableArchive.cs b/src/SharpCompress/Archive/IWritableArchive.cs
similarity index 100%
rename from SharpCompress/Archive/IWritableArchive.cs
rename to src/SharpCompress/Archive/IWritableArchive.cs
diff --git a/SharpCompress/Archive/IWritableArchiveEntry.cs b/src/SharpCompress/Archive/IWritableArchiveEntry.cs
similarity index 94%
rename from SharpCompress/Archive/IWritableArchiveEntry.cs
rename to src/SharpCompress/Archive/IWritableArchiveEntry.cs
index 2175fdae..74ebb935 100644
--- a/SharpCompress/Archive/IWritableArchiveEntry.cs
+++ b/src/SharpCompress/Archive/IWritableArchiveEntry.cs
@@ -1,9 +1,9 @@
-using System.IO;
-
-namespace SharpCompress.Archive
-{
- internal interface IWritableArchiveEntry
- {
- Stream Stream { get; }
- }
+using System.IO;
+
+namespace SharpCompress.Archive
+{
+ internal interface IWritableArchiveEntry
+ {
+ Stream Stream { get; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Rar/FileInfoRarArchiveVolume.cs b/src/SharpCompress/Archive/Rar/FileInfoRarArchiveVolume.cs
similarity index 96%
rename from SharpCompress/Archive/Rar/FileInfoRarArchiveVolume.cs
rename to src/SharpCompress/Archive/Rar/FileInfoRarArchiveVolume.cs
index ddfb8724..2b022d4b 100644
--- a/SharpCompress/Archive/Rar/FileInfoRarArchiveVolume.cs
+++ b/src/SharpCompress/Archive/Rar/FileInfoRarArchiveVolume.cs
@@ -1,48 +1,48 @@
-#if !DOTNET51
-using System.Collections.Generic;
-using System.IO;
-using SharpCompress.Common;
-using SharpCompress.Common.Rar;
-using SharpCompress.Common.Rar.Headers;
-using SharpCompress.IO;
-
-namespace SharpCompress.Archive.Rar
-{
- ///
- /// A rar part based on a FileInfo object
- ///
- internal class FileInfoRarArchiveVolume : RarVolume
- {
- internal FileInfoRarArchiveVolume(FileInfo fileInfo, string password, Options options)
- : base(StreamingMode.Seekable, fileInfo.OpenRead(), password, FixOptions(options))
- {
- FileInfo = fileInfo;
- FileParts = base.GetVolumeFileParts().ToReadOnly();
- }
-
- private static Options FixOptions(Options options)
- {
- //make sure we're closing streams with fileinfo
- if (options.HasFlag(Options.KeepStreamsOpen))
- {
- options = (Options) FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
- }
- return options;
- }
-
- internal ReadOnlyCollection FileParts { get; private set; }
-
- internal FileInfo FileInfo { get; private set; }
-
- internal override RarFilePart CreateFilePart(FileHeader fileHeader, MarkHeader markHeader)
- {
- return new FileInfoRarFilePart(this, markHeader, fileHeader, FileInfo);
- }
-
- internal override IEnumerable ReadFileParts()
- {
- return FileParts;
- }
- }
-}
+#if !DOTNET51
+using System.Collections.Generic;
+using System.IO;
+using SharpCompress.Common;
+using SharpCompress.Common.Rar;
+using SharpCompress.Common.Rar.Headers;
+using SharpCompress.IO;
+
+namespace SharpCompress.Archive.Rar
+{
+ ///
+ /// A rar part based on a FileInfo object
+ ///
+ internal class FileInfoRarArchiveVolume : RarVolume
+ {
+ internal FileInfoRarArchiveVolume(FileInfo fileInfo, string password, Options options)
+ : base(StreamingMode.Seekable, fileInfo.OpenRead(), password, FixOptions(options))
+ {
+ FileInfo = fileInfo;
+ FileParts = base.GetVolumeFileParts().ToReadOnly();
+ }
+
+ private static Options FixOptions(Options options)
+ {
+ //make sure we're closing streams with fileinfo
+ if (options.HasFlag(Options.KeepStreamsOpen))
+ {
+ options = (Options) FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
+ }
+ return options;
+ }
+
+ internal ReadOnlyCollection FileParts { get; private set; }
+
+ internal FileInfo FileInfo { get; private set; }
+
+ internal override RarFilePart CreateFilePart(FileHeader fileHeader, MarkHeader markHeader)
+ {
+ return new FileInfoRarFilePart(this, markHeader, fileHeader, FileInfo);
+ }
+
+ internal override IEnumerable ReadFileParts()
+ {
+ return FileParts;
+ }
+ }
+}
#endif
\ No newline at end of file
diff --git a/SharpCompress/Archive/Rar/FileInfoRarFilePart.cs b/src/SharpCompress/Archive/Rar/FileInfoRarFilePart.cs
similarity index 96%
rename from SharpCompress/Archive/Rar/FileInfoRarFilePart.cs
rename to src/SharpCompress/Archive/Rar/FileInfoRarFilePart.cs
index 0de3993f..9718e06a 100644
--- a/SharpCompress/Archive/Rar/FileInfoRarFilePart.cs
+++ b/src/SharpCompress/Archive/Rar/FileInfoRarFilePart.cs
@@ -1,31 +1,31 @@
-#if !DOTNET51
-using System.IO;
-using SharpCompress.Common.Rar;
-using SharpCompress.Common.Rar.Headers;
-
-namespace SharpCompress.Archive.Rar
-{
- internal class FileInfoRarFilePart : SeekableFilePart
- {
- private readonly FileInfoRarArchiveVolume volume;
-
- internal FileInfoRarFilePart(FileInfoRarArchiveVolume volume, MarkHeader mh, FileHeader fh, FileInfo fi)
- : base(mh, fh, volume.Stream, volume.Password)
- {
- this.volume = volume;
- FileInfo = fi;
- }
-
- internal FileInfo FileInfo { get; private set; }
-
- internal override string FilePartName
- {
- get
- {
- return "Rar File: " + FileInfo.FullName
- + " File Entry: " + FileHeader.FileName;
- }
- }
- }
-}
+#if !DOTNET51
+using System.IO;
+using SharpCompress.Common.Rar;
+using SharpCompress.Common.Rar.Headers;
+
+namespace SharpCompress.Archive.Rar
+{
+ internal class FileInfoRarFilePart : SeekableFilePart
+ {
+ private readonly FileInfoRarArchiveVolume volume;
+
+ internal FileInfoRarFilePart(FileInfoRarArchiveVolume volume, MarkHeader mh, FileHeader fh, FileInfo fi)
+ : base(mh, fh, volume.Stream, volume.Password)
+ {
+ this.volume = volume;
+ FileInfo = fi;
+ }
+
+ internal FileInfo FileInfo { get; private set; }
+
+ internal override string FilePartName
+ {
+ get
+ {
+ return "Rar File: " + FileInfo.FullName
+ + " File Entry: " + FileHeader.FileName;
+ }
+ }
+ }
+}
#endif
\ No newline at end of file
diff --git a/SharpCompress/Archive/Rar/RarArchive.Extensions.cs b/src/SharpCompress/Archive/Rar/RarArchive.Extensions.cs
similarity index 97%
rename from SharpCompress/Archive/Rar/RarArchive.Extensions.cs
rename to src/SharpCompress/Archive/Rar/RarArchive.Extensions.cs
index bb9d952b..38db8bee 100644
--- a/SharpCompress/Archive/Rar/RarArchive.Extensions.cs
+++ b/src/SharpCompress/Archive/Rar/RarArchive.Extensions.cs
@@ -1,23 +1,23 @@
-using System.Linq;
-
-namespace SharpCompress.Archive.Rar
-{
- public static class RarArchiveExtensions
- {
- ///
- /// RarArchive is the first volume of a multi-part archive. If MultipartVolume is true and IsFirstVolume is false then the first volume file must be missing.
- ///
- public static bool IsFirstVolume(this RarArchive archive)
- {
- return archive.Volumes.First().IsFirstVolume;
- }
-
- ///
- /// RarArchive is part of a multi-part archive.
- ///
- public static bool IsMultipartVolume(this RarArchive archive)
- {
- return archive.Volumes.First().IsMultiVolume;
- }
- }
+using System.Linq;
+
+namespace SharpCompress.Archive.Rar
+{
+ public static class RarArchiveExtensions
+ {
+ ///
+ /// RarArchive is the first volume of a multi-part archive. If MultipartVolume is true and IsFirstVolume is false then the first volume file must be missing.
+ ///
+ public static bool IsFirstVolume(this RarArchive archive)
+ {
+ return archive.Volumes.First().IsFirstVolume;
+ }
+
+ ///
+ /// RarArchive is part of a multi-part archive.
+ ///
+ public static bool IsMultipartVolume(this RarArchive archive)
+ {
+ return archive.Volumes.First().IsMultiVolume;
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Rar/RarArchive.cs b/src/SharpCompress/Archive/Rar/RarArchive.cs
similarity index 97%
rename from SharpCompress/Archive/Rar/RarArchive.cs
rename to src/SharpCompress/Archive/Rar/RarArchive.cs
index 09b0a2e7..57850546 100644
--- a/SharpCompress/Archive/Rar/RarArchive.cs
+++ b/src/SharpCompress/Archive/Rar/RarArchive.cs
@@ -1,170 +1,170 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using SharpCompress.Common;
-using SharpCompress.Common.Rar;
-using SharpCompress.Common.Rar.Headers;
-using SharpCompress.Compressor.Rar;
-using SharpCompress.IO;
-using SharpCompress.Reader;
-using SharpCompress.Reader.Rar;
-
-namespace SharpCompress.Archive.Rar
-{
- public class RarArchive : AbstractArchive
- {
- private readonly Unpack unpack = new Unpack();
-
- internal Unpack Unpack
- {
- get { return unpack; }
- }
-
-#if !DOTNET51
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- ///
- internal RarArchive(FileInfo fileInfo, Options options, string password)
- : base(ArchiveType.Rar, fileInfo, options, password)
- {
- }
-
- protected override IEnumerable LoadVolumes(FileInfo file, Options options)
- {
- return RarArchiveVolumeFactory.GetParts(file, Password, options);
- }
-#endif
-
- ///
- /// Takes multiple seekable Streams for a multi-part archive
- ///
- ///
- ///
- ///
- internal RarArchive(IEnumerable streams, Options options, string password)
- : base(ArchiveType.Rar, streams, options, password)
- {
- }
-
- protected override IEnumerable LoadEntries(IEnumerable volumes)
- {
- return RarArchiveEntryFactory.GetEntries(this, volumes);
- }
-
- protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
- {
- return RarArchiveVolumeFactory.GetParts(streams, Password, options);
- }
-
- protected override IReader CreateReaderForSolidExtraction()
- {
- var stream = Volumes.First().Stream;
- stream.Position = 0;
- return RarReader.Open(stream);
- }
-
- public override bool IsSolid
- {
- get { return Volumes.First().IsSolidArchive; }
- }
-
- #region Creation
-
-#if !DOTNET51
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- ///
- ///
- public static RarArchive Open(string filePath, Options options = Options.None, string password = null)
- {
- filePath.CheckNotNullOrEmpty("filePath");
- return Open(new FileInfo(filePath), options, password);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- ///
- public static RarArchive Open(FileInfo fileInfo, Options options = Options.None, string password = null)
- {
- fileInfo.CheckNotNull("fileInfo");
- return new RarArchive(fileInfo, options, password);
- }
-#endif
- ///
- /// Takes a seekable Stream as a source
- ///
- ///
- ///
- ///
- public static RarArchive Open(Stream stream, Options options = Options.KeepStreamsOpen, string password = null)
- {
- stream.CheckNotNull("stream");
- return Open(stream.AsEnumerable(), options, password);
- }
-
- ///
- /// Takes multiple seekable Streams for a multi-part archive
- ///
- ///
- ///
- ///
- public static RarArchive Open(IEnumerable streams, Options options = Options.KeepStreamsOpen, string password = null)
- {
- streams.CheckNotNull("streams");
- return new RarArchive(streams, options, password);
- }
-
-#if !DOTNET51
- public static bool IsRarFile(string filePath)
- {
- return IsRarFile(new FileInfo(filePath));
- }
-
- public static bool IsRarFile(FileInfo fileInfo)
- {
- if (!fileInfo.Exists)
- {
- return false;
- }
- using (Stream stream = fileInfo.OpenRead())
- {
- return IsRarFile(stream);
- }
- }
-#endif
-
- public static bool IsRarFile(Stream stream)
- {
- return IsRarFile(stream, Options.None);
- }
-
- public static bool IsRarFile(Stream stream, Options options)
- {
- try
- {
- var headerFactory = new RarHeaderFactory(StreamingMode.Seekable, options);
- RarHeader header = headerFactory.ReadHeaders(stream).FirstOrDefault();
- if (header == null)
- {
- return false;
- }
- return Enum.IsDefined(typeof (HeaderType), header.HeaderType);
- }
- catch
- {
- return false;
- }
- }
-
- #endregion
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using SharpCompress.Common;
+using SharpCompress.Common.Rar;
+using SharpCompress.Common.Rar.Headers;
+using SharpCompress.Compressor.Rar;
+using SharpCompress.IO;
+using SharpCompress.Reader;
+using SharpCompress.Reader.Rar;
+
+namespace SharpCompress.Archive.Rar
+{
+ public class RarArchive : AbstractArchive
+ {
+ private readonly Unpack unpack = new Unpack();
+
+ internal Unpack Unpack
+ {
+ get { return unpack; }
+ }
+
+#if !DOTNET51
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ ///
+ internal RarArchive(FileInfo fileInfo, Options options, string password)
+ : base(ArchiveType.Rar, fileInfo, options, password)
+ {
+ }
+
+ protected override IEnumerable LoadVolumes(FileInfo file, Options options)
+ {
+ return RarArchiveVolumeFactory.GetParts(file, Password, options);
+ }
+#endif
+
+ ///
+ /// Takes multiple seekable Streams for a multi-part archive
+ ///
+ ///
+ ///
+ ///
+ internal RarArchive(IEnumerable streams, Options options, string password)
+ : base(ArchiveType.Rar, streams, options, password)
+ {
+ }
+
+ protected override IEnumerable LoadEntries(IEnumerable volumes)
+ {
+ return RarArchiveEntryFactory.GetEntries(this, volumes);
+ }
+
+ protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
+ {
+ return RarArchiveVolumeFactory.GetParts(streams, Password, options);
+ }
+
+ protected override IReader CreateReaderForSolidExtraction()
+ {
+ var stream = Volumes.First().Stream;
+ stream.Position = 0;
+ return RarReader.Open(stream);
+ }
+
+ public override bool IsSolid
+ {
+ get { return Volumes.First().IsSolidArchive; }
+ }
+
+ #region Creation
+
+#if !DOTNET51
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ ///
+ ///
+ public static RarArchive Open(string filePath, Options options = Options.None, string password = null)
+ {
+ filePath.CheckNotNullOrEmpty("filePath");
+ return Open(new FileInfo(filePath), options, password);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ ///
+ public static RarArchive Open(FileInfo fileInfo, Options options = Options.None, string password = null)
+ {
+ fileInfo.CheckNotNull("fileInfo");
+ return new RarArchive(fileInfo, options, password);
+ }
+#endif
+ ///
+ /// Takes a seekable Stream as a source
+ ///
+ ///
+ ///
+ ///
+ public static RarArchive Open(Stream stream, Options options = Options.KeepStreamsOpen, string password = null)
+ {
+ stream.CheckNotNull("stream");
+ return Open(stream.AsEnumerable(), options, password);
+ }
+
+ ///
+ /// Takes multiple seekable Streams for a multi-part archive
+ ///
+ ///
+ ///
+ ///
+ public static RarArchive Open(IEnumerable streams, Options options = Options.KeepStreamsOpen, string password = null)
+ {
+ streams.CheckNotNull("streams");
+ return new RarArchive(streams, options, password);
+ }
+
+#if !DOTNET51
+ public static bool IsRarFile(string filePath)
+ {
+ return IsRarFile(new FileInfo(filePath));
+ }
+
+ public static bool IsRarFile(FileInfo fileInfo)
+ {
+ if (!fileInfo.Exists)
+ {
+ return false;
+ }
+ using (Stream stream = fileInfo.OpenRead())
+ {
+ return IsRarFile(stream);
+ }
+ }
+#endif
+
+ public static bool IsRarFile(Stream stream)
+ {
+ return IsRarFile(stream, Options.None);
+ }
+
+ public static bool IsRarFile(Stream stream, Options options)
+ {
+ try
+ {
+ var headerFactory = new RarHeaderFactory(StreamingMode.Seekable, options);
+ RarHeader header = headerFactory.ReadHeaders(stream).FirstOrDefault();
+ if (header == null)
+ {
+ return false;
+ }
+ return Enum.IsDefined(typeof (HeaderType), header.HeaderType);
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Rar/RarArchiveEntry.cs b/src/SharpCompress/Archive/Rar/RarArchiveEntry.cs
similarity index 96%
rename from SharpCompress/Archive/Rar/RarArchiveEntry.cs
rename to src/SharpCompress/Archive/Rar/RarArchiveEntry.cs
index 17f32170..9234e569 100644
--- a/SharpCompress/Archive/Rar/RarArchiveEntry.cs
+++ b/src/SharpCompress/Archive/Rar/RarArchiveEntry.cs
@@ -1,93 +1,93 @@
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using SharpCompress.Common;
-using SharpCompress.Common.Rar;
-using SharpCompress.Common.Rar.Headers;
-using SharpCompress.Compressor.Rar;
-
-namespace SharpCompress.Archive.Rar
-{
- public class RarArchiveEntry : RarEntry, IArchiveEntry
- {
- private readonly ICollection parts;
- private readonly RarArchive archive;
-
- internal RarArchiveEntry(RarArchive archive, IEnumerable parts)
- {
- this.parts = parts.ToList();
- this.archive = archive;
- }
-
- public override CompressionType CompressionType
- {
- get { return CompressionType.Rar; }
- }
-
- public IArchive Archive
- {
- get
- {
- return archive;
- }
- }
-
- internal override IEnumerable Parts
- {
- get { return parts.Cast(); }
- }
-
- internal override FileHeader FileHeader
- {
- get { return parts.First().FileHeader; }
- }
-
- public override long Crc
- {
- get
- {
- CheckIncomplete();
- return parts.Select(fp => fp.FileHeader)
- .Single(fh => !fh.FileFlags.HasFlag(FileFlags.SPLIT_AFTER)).FileCRC;
- }
- }
-
-
- public override long Size
- {
- get
- {
- CheckIncomplete();
- return parts.First().FileHeader.UncompressedSize;
- }
- }
-
- public override long CompressedSize
- {
- get
- {
- CheckIncomplete();
- return parts.Aggregate(0L, (total, fp) => { return total + fp.FileHeader.CompressedSize; });
- }
- }
-
- public Stream OpenEntryStream()
- {
- return new RarStream(archive.Unpack, FileHeader,
- new MultiVolumeReadOnlyStream(Parts.Cast(), archive));
- }
-
- public bool IsComplete
- {
- get { return parts.Select(fp => fp.FileHeader).Any(fh => !fh.FileFlags.HasFlag(FileFlags.SPLIT_AFTER)); }
- }
-
- private void CheckIncomplete()
- {
- if (!IsComplete)
- {
- throw new IncompleteArchiveException("ArchiveEntry is incomplete and cannot perform this operation.");
- }
- }
- }
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using SharpCompress.Common;
+using SharpCompress.Common.Rar;
+using SharpCompress.Common.Rar.Headers;
+using SharpCompress.Compressor.Rar;
+
+namespace SharpCompress.Archive.Rar
+{
+ public class RarArchiveEntry : RarEntry, IArchiveEntry
+ {
+ private readonly ICollection parts;
+ private readonly RarArchive archive;
+
+ internal RarArchiveEntry(RarArchive archive, IEnumerable parts)
+ {
+ this.parts = parts.ToList();
+ this.archive = archive;
+ }
+
+ public override CompressionType CompressionType
+ {
+ get { return CompressionType.Rar; }
+ }
+
+ public IArchive Archive
+ {
+ get
+ {
+ return archive;
+ }
+ }
+
+ internal override IEnumerable Parts
+ {
+ get { return parts.Cast(); }
+ }
+
+ internal override FileHeader FileHeader
+ {
+ get { return parts.First().FileHeader; }
+ }
+
+ public override long Crc
+ {
+ get
+ {
+ CheckIncomplete();
+ return parts.Select(fp => fp.FileHeader)
+ .Single(fh => !fh.FileFlags.HasFlag(FileFlags.SPLIT_AFTER)).FileCRC;
+ }
+ }
+
+
+ public override long Size
+ {
+ get
+ {
+ CheckIncomplete();
+ return parts.First().FileHeader.UncompressedSize;
+ }
+ }
+
+ public override long CompressedSize
+ {
+ get
+ {
+ CheckIncomplete();
+ return parts.Aggregate(0L, (total, fp) => { return total + fp.FileHeader.CompressedSize; });
+ }
+ }
+
+ public Stream OpenEntryStream()
+ {
+ return new RarStream(archive.Unpack, FileHeader,
+ new MultiVolumeReadOnlyStream(Parts.Cast(), archive));
+ }
+
+ public bool IsComplete
+ {
+ get { return parts.Select(fp => fp.FileHeader).Any(fh => !fh.FileFlags.HasFlag(FileFlags.SPLIT_AFTER)); }
+ }
+
+ private void CheckIncomplete()
+ {
+ if (!IsComplete)
+ {
+ throw new IncompleteArchiveException("ArchiveEntry is incomplete and cannot perform this operation.");
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Rar/RarArchiveEntryFactory.cs b/src/SharpCompress/Archive/Rar/RarArchiveEntryFactory.cs
similarity index 97%
rename from SharpCompress/Archive/Rar/RarArchiveEntryFactory.cs
rename to src/SharpCompress/Archive/Rar/RarArchiveEntryFactory.cs
index 9f6ca64a..ec55c28d 100644
--- a/SharpCompress/Archive/Rar/RarArchiveEntryFactory.cs
+++ b/src/SharpCompress/Archive/Rar/RarArchiveEntryFactory.cs
@@ -1,49 +1,49 @@
-using System.Collections.Generic;
-using SharpCompress.Common;
-using SharpCompress.Common.Rar;
-using SharpCompress.Common.Rar.Headers;
-
-namespace SharpCompress.Archive.Rar
-{
- internal static class RarArchiveEntryFactory
- {
- private static IEnumerable GetFileParts(IEnumerable parts)
- {
- foreach (RarVolume rarPart in parts)
- {
- foreach (RarFilePart fp in rarPart.ReadFileParts())
- {
- yield return fp;
- }
- }
- }
-
- private static IEnumerable> GetMatchedFileParts(IEnumerable parts)
- {
- var groupedParts = new List();
- foreach (RarFilePart fp in GetFileParts(parts))
- {
- groupedParts.Add(fp);
-
- if (!FlagUtility.HasFlag((long) fp.FileHeader.FileFlags, (long) FileFlags.SPLIT_AFTER))
- {
- yield return groupedParts;
- groupedParts = new List();
- }
- }
- if (groupedParts.Count > 0)
- {
- yield return groupedParts;
- }
- }
-
- internal static IEnumerable GetEntries(RarArchive archive,
- IEnumerable rarParts)
- {
- foreach (var groupedParts in GetMatchedFileParts(rarParts))
- {
- yield return new RarArchiveEntry(archive, groupedParts);
- }
- }
- }
+using System.Collections.Generic;
+using SharpCompress.Common;
+using SharpCompress.Common.Rar;
+using SharpCompress.Common.Rar.Headers;
+
+namespace SharpCompress.Archive.Rar
+{
+ internal static class RarArchiveEntryFactory
+ {
+ private static IEnumerable GetFileParts(IEnumerable parts)
+ {
+ foreach (RarVolume rarPart in parts)
+ {
+ foreach (RarFilePart fp in rarPart.ReadFileParts())
+ {
+ yield return fp;
+ }
+ }
+ }
+
+ private static IEnumerable> GetMatchedFileParts(IEnumerable parts)
+ {
+ var groupedParts = new List();
+ foreach (RarFilePart fp in GetFileParts(parts))
+ {
+ groupedParts.Add(fp);
+
+ if (!FlagUtility.HasFlag((long) fp.FileHeader.FileFlags, (long) FileFlags.SPLIT_AFTER))
+ {
+ yield return groupedParts;
+ groupedParts = new List();
+ }
+ }
+ if (groupedParts.Count > 0)
+ {
+ yield return groupedParts;
+ }
+ }
+
+ internal static IEnumerable GetEntries(RarArchive archive,
+ IEnumerable rarParts)
+ {
+ foreach (var groupedParts in GetMatchedFileParts(rarParts))
+ {
+ yield return new RarArchiveEntry(archive, groupedParts);
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Rar/RarArchiveVolumeFactory.cs b/src/SharpCompress/Archive/Rar/RarArchiveVolumeFactory.cs
similarity index 97%
rename from SharpCompress/Archive/Rar/RarArchiveVolumeFactory.cs
rename to src/SharpCompress/Archive/Rar/RarArchiveVolumeFactory.cs
index 7568e386..9c4ab885 100644
--- a/SharpCompress/Archive/Rar/RarArchiveVolumeFactory.cs
+++ b/src/SharpCompress/Archive/Rar/RarArchiveVolumeFactory.cs
@@ -1,145 +1,145 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using SharpCompress.Common.Rar.Headers;
-using SharpCompress.Common;
-using SharpCompress.Common.Rar;
-
-namespace SharpCompress.Archive.Rar
-{
- internal static class RarArchiveVolumeFactory
- {
- internal static IEnumerable GetParts(IEnumerable streams, string password, Options options)
- {
- foreach (Stream s in streams)
- {
- if (!s.CanRead || !s.CanSeek)
- {
- throw new ArgumentException("Stream is not readable and seekable");
- }
- StreamRarArchiveVolume part = new StreamRarArchiveVolume(s, password, options);
- yield return part;
- }
- }
-
-#if !DOTNET51
- internal static IEnumerable GetParts(FileInfo fileInfo, string password, Options options)
- {
- FileInfoRarArchiveVolume part = new FileInfoRarArchiveVolume(fileInfo, password, options);
- yield return part;
-
- if (!part.ArchiveHeader.ArchiveHeaderFlags.HasFlag(ArchiveFlags.VOLUME))
- {
- yield break; //if file isn't volume then there is no reason to look
- }
- ArchiveHeader ah = part.ArchiveHeader;
- fileInfo = GetNextFileInfo(ah, part.FileParts.FirstOrDefault() as FileInfoRarFilePart);
- //we use fileinfo because rar is dumb and looks at file names rather than archive info for another volume
- while (fileInfo != null && fileInfo.Exists)
- {
- part = new FileInfoRarArchiveVolume(fileInfo, password, options);
-
- fileInfo = GetNextFileInfo(ah, part.FileParts.FirstOrDefault() as FileInfoRarFilePart);
- yield return part;
- }
- }
-
- private static FileInfo GetNextFileInfo(ArchiveHeader ah, FileInfoRarFilePart currentFilePart)
- {
- if (currentFilePart == null)
- {
- return null;
- }
- bool oldNumbering = !ah.ArchiveHeaderFlags.HasFlag(ArchiveFlags.NEWNUMBERING)
- || currentFilePart.MarkHeader.OldFormat;
- if (oldNumbering)
- {
- return FindNextFileWithOldNumbering(currentFilePart.FileInfo);
- }
- else
- {
- return FindNextFileWithNewNumbering(currentFilePart.FileInfo);
- }
- }
-
- private static FileInfo FindNextFileWithOldNumbering(FileInfo currentFileInfo)
- {
- // .rar, .r00, .r01, ...
- string extension = currentFileInfo.Extension;
-
- StringBuilder buffer = new StringBuilder(currentFileInfo.FullName.Length);
- buffer.Append(currentFileInfo.FullName.Substring(0,
- currentFileInfo.FullName.Length - extension.Length));
- if (string.Compare(extension, ".rar", StringComparison.OrdinalIgnoreCase) == 0)
- {
- buffer.Append(".r00");
- }
- else
- {
- int num = 0;
- if (int.TryParse(extension.Substring(2, 2), out num))
- {
- num++;
- buffer.Append(".r");
- if (num < 10)
- {
- buffer.Append('0');
- }
- buffer.Append(num);
- }
- else
- {
- ThrowInvalidFileName(currentFileInfo);
- }
- }
- return new FileInfo(buffer.ToString());
- }
-
- private static FileInfo FindNextFileWithNewNumbering(FileInfo currentFileInfo)
- {
- // part1.rar, part2.rar, ...
- string extension = currentFileInfo.Extension;
- if (string.Compare(extension, ".rar", StringComparison.OrdinalIgnoreCase) != 0)
- {
- throw new ArgumentException("Invalid extension, expected 'rar': " + currentFileInfo.FullName);
- }
- int startIndex = currentFileInfo.FullName.LastIndexOf(".part");
- if (startIndex < 0)
- {
- ThrowInvalidFileName(currentFileInfo);
- }
- StringBuilder buffer = new StringBuilder(currentFileInfo.FullName.Length);
- buffer.Append(currentFileInfo.FullName, 0, startIndex);
- int num = 0;
- string numString = currentFileInfo.FullName.Substring(startIndex + 5,
- currentFileInfo.FullName.IndexOf('.', startIndex + 5) -
- startIndex - 5);
- buffer.Append(".part");
- if (int.TryParse(numString, out num))
- {
- num++;
- for (int i = 0; i < numString.Length - num.ToString().Length; i++)
- {
- buffer.Append('0');
- }
- buffer.Append(num);
- }
- else
- {
- ThrowInvalidFileName(currentFileInfo);
- }
- buffer.Append(".rar");
- return new FileInfo(buffer.ToString());
- }
-
- private static void ThrowInvalidFileName(FileInfo fileInfo)
- {
- throw new ArgumentException("Filename invalid or next archive could not be found:"
- + fileInfo.FullName);
- }
-
-#endif
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using SharpCompress.Common.Rar.Headers;
+using SharpCompress.Common;
+using SharpCompress.Common.Rar;
+
+namespace SharpCompress.Archive.Rar
+{
+ internal static class RarArchiveVolumeFactory
+ {
+ internal static IEnumerable GetParts(IEnumerable streams, string password, Options options)
+ {
+ foreach (Stream s in streams)
+ {
+ if (!s.CanRead || !s.CanSeek)
+ {
+ throw new ArgumentException("Stream is not readable and seekable");
+ }
+ StreamRarArchiveVolume part = new StreamRarArchiveVolume(s, password, options);
+ yield return part;
+ }
+ }
+
+#if !DOTNET51
+ internal static IEnumerable GetParts(FileInfo fileInfo, string password, Options options)
+ {
+ FileInfoRarArchiveVolume part = new FileInfoRarArchiveVolume(fileInfo, password, options);
+ yield return part;
+
+ if (!part.ArchiveHeader.ArchiveHeaderFlags.HasFlag(ArchiveFlags.VOLUME))
+ {
+ yield break; //if file isn't volume then there is no reason to look
+ }
+ ArchiveHeader ah = part.ArchiveHeader;
+ fileInfo = GetNextFileInfo(ah, part.FileParts.FirstOrDefault() as FileInfoRarFilePart);
+ //we use fileinfo because rar is dumb and looks at file names rather than archive info for another volume
+ while (fileInfo != null && fileInfo.Exists)
+ {
+ part = new FileInfoRarArchiveVolume(fileInfo, password, options);
+
+ fileInfo = GetNextFileInfo(ah, part.FileParts.FirstOrDefault() as FileInfoRarFilePart);
+ yield return part;
+ }
+ }
+
+ private static FileInfo GetNextFileInfo(ArchiveHeader ah, FileInfoRarFilePart currentFilePart)
+ {
+ if (currentFilePart == null)
+ {
+ return null;
+ }
+ bool oldNumbering = !ah.ArchiveHeaderFlags.HasFlag(ArchiveFlags.NEWNUMBERING)
+ || currentFilePart.MarkHeader.OldFormat;
+ if (oldNumbering)
+ {
+ return FindNextFileWithOldNumbering(currentFilePart.FileInfo);
+ }
+ else
+ {
+ return FindNextFileWithNewNumbering(currentFilePart.FileInfo);
+ }
+ }
+
+ private static FileInfo FindNextFileWithOldNumbering(FileInfo currentFileInfo)
+ {
+ // .rar, .r00, .r01, ...
+ string extension = currentFileInfo.Extension;
+
+ StringBuilder buffer = new StringBuilder(currentFileInfo.FullName.Length);
+ buffer.Append(currentFileInfo.FullName.Substring(0,
+ currentFileInfo.FullName.Length - extension.Length));
+ if (string.Compare(extension, ".rar", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ buffer.Append(".r00");
+ }
+ else
+ {
+ int num = 0;
+ if (int.TryParse(extension.Substring(2, 2), out num))
+ {
+ num++;
+ buffer.Append(".r");
+ if (num < 10)
+ {
+ buffer.Append('0');
+ }
+ buffer.Append(num);
+ }
+ else
+ {
+ ThrowInvalidFileName(currentFileInfo);
+ }
+ }
+ return new FileInfo(buffer.ToString());
+ }
+
+ private static FileInfo FindNextFileWithNewNumbering(FileInfo currentFileInfo)
+ {
+ // part1.rar, part2.rar, ...
+ string extension = currentFileInfo.Extension;
+ if (string.Compare(extension, ".rar", StringComparison.OrdinalIgnoreCase) != 0)
+ {
+ throw new ArgumentException("Invalid extension, expected 'rar': " + currentFileInfo.FullName);
+ }
+ int startIndex = currentFileInfo.FullName.LastIndexOf(".part");
+ if (startIndex < 0)
+ {
+ ThrowInvalidFileName(currentFileInfo);
+ }
+ StringBuilder buffer = new StringBuilder(currentFileInfo.FullName.Length);
+ buffer.Append(currentFileInfo.FullName, 0, startIndex);
+ int num = 0;
+ string numString = currentFileInfo.FullName.Substring(startIndex + 5,
+ currentFileInfo.FullName.IndexOf('.', startIndex + 5) -
+ startIndex - 5);
+ buffer.Append(".part");
+ if (int.TryParse(numString, out num))
+ {
+ num++;
+ for (int i = 0; i < numString.Length - num.ToString().Length; i++)
+ {
+ buffer.Append('0');
+ }
+ buffer.Append(num);
+ }
+ else
+ {
+ ThrowInvalidFileName(currentFileInfo);
+ }
+ buffer.Append(".rar");
+ return new FileInfo(buffer.ToString());
+ }
+
+ private static void ThrowInvalidFileName(FileInfo fileInfo)
+ {
+ throw new ArgumentException("Filename invalid or next archive could not be found:"
+ + fileInfo.FullName);
+ }
+
+#endif
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Rar/SeekableFilePart.cs b/src/SharpCompress/Archive/Rar/SeekableFilePart.cs
similarity index 96%
rename from SharpCompress/Archive/Rar/SeekableFilePart.cs
rename to src/SharpCompress/Archive/Rar/SeekableFilePart.cs
index e097a0c2..d89fb1ba 100644
--- a/SharpCompress/Archive/Rar/SeekableFilePart.cs
+++ b/src/SharpCompress/Archive/Rar/SeekableFilePart.cs
@@ -1,35 +1,35 @@
-using System;
-using System.IO;
-using SharpCompress.Common.Rar;
-using SharpCompress.Common.Rar.Headers;
-
-namespace SharpCompress.Archive.Rar
-{
- internal class SeekableFilePart : RarFilePart
- {
- private readonly Stream stream;
- private readonly string password;
-
- internal SeekableFilePart(MarkHeader mh, FileHeader fh, Stream stream, string password)
- : base(mh, fh)
- {
- this.stream = stream;
- this.password = password;
- }
-
- internal override Stream GetCompressedStream()
- {
- stream.Position = FileHeader.DataStartPosition;
- if (FileHeader.Salt != null)
- {
- return new RarCryptoWrapper(stream, password, FileHeader.Salt);
- }
- return stream;
- }
-
- internal override string FilePartName
- {
- get { return "Unknown Stream - File Entry: " + FileHeader.FileName; }
- }
- }
+using System;
+using System.IO;
+using SharpCompress.Common.Rar;
+using SharpCompress.Common.Rar.Headers;
+
+namespace SharpCompress.Archive.Rar
+{
+ internal class SeekableFilePart : RarFilePart
+ {
+ private readonly Stream stream;
+ private readonly string password;
+
+ internal SeekableFilePart(MarkHeader mh, FileHeader fh, Stream stream, string password)
+ : base(mh, fh)
+ {
+ this.stream = stream;
+ this.password = password;
+ }
+
+ internal override Stream GetCompressedStream()
+ {
+ stream.Position = FileHeader.DataStartPosition;
+ if (FileHeader.Salt != null)
+ {
+ return new RarCryptoWrapper(stream, password, FileHeader.Salt);
+ }
+ return stream;
+ }
+
+ internal override string FilePartName
+ {
+ get { return "Unknown Stream - File Entry: " + FileHeader.FileName; }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Rar/StreamRarArchiveVolume.cs b/src/SharpCompress/Archive/Rar/StreamRarArchiveVolume.cs
similarity index 96%
rename from SharpCompress/Archive/Rar/StreamRarArchiveVolume.cs
rename to src/SharpCompress/Archive/Rar/StreamRarArchiveVolume.cs
index d33ffdd8..3b499f12 100644
--- a/SharpCompress/Archive/Rar/StreamRarArchiveVolume.cs
+++ b/src/SharpCompress/Archive/Rar/StreamRarArchiveVolume.cs
@@ -1,27 +1,27 @@
-using System.Collections.Generic;
-using System.IO;
-using SharpCompress.Common;
-using SharpCompress.Common.Rar;
-using SharpCompress.Common.Rar.Headers;
-using SharpCompress.IO;
-
-namespace SharpCompress.Archive.Rar
-{
- internal class StreamRarArchiveVolume : RarVolume
- {
- internal StreamRarArchiveVolume(Stream stream, string password, Options options)
- : base(StreamingMode.Seekable, stream, password, options)
- {
- }
-
- internal override IEnumerable ReadFileParts()
- {
- return GetVolumeFileParts();
- }
-
- internal override RarFilePart CreateFilePart(FileHeader fileHeader, MarkHeader markHeader)
- {
- return new SeekableFilePart(markHeader, fileHeader, Stream, Password);
- }
- }
+using System.Collections.Generic;
+using System.IO;
+using SharpCompress.Common;
+using SharpCompress.Common.Rar;
+using SharpCompress.Common.Rar.Headers;
+using SharpCompress.IO;
+
+namespace SharpCompress.Archive.Rar
+{
+ internal class StreamRarArchiveVolume : RarVolume
+ {
+ internal StreamRarArchiveVolume(Stream stream, string password, Options options)
+ : base(StreamingMode.Seekable, stream, password, options)
+ {
+ }
+
+ internal override IEnumerable ReadFileParts()
+ {
+ return GetVolumeFileParts();
+ }
+
+ internal override RarFilePart CreateFilePart(FileHeader fileHeader, MarkHeader markHeader)
+ {
+ return new SeekableFilePart(markHeader, fileHeader, Stream, Password);
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/SevenZip/SevenZipArchive.cs b/src/SharpCompress/Archive/SevenZip/SevenZipArchive.cs
similarity index 96%
rename from SharpCompress/Archive/SevenZip/SevenZipArchive.cs
rename to src/SharpCompress/Archive/SevenZip/SevenZipArchive.cs
index cc2f1b42..5d5f6778 100644
--- a/SharpCompress/Archive/SevenZip/SevenZipArchive.cs
+++ b/src/SharpCompress/Archive/SevenZip/SevenZipArchive.cs
@@ -1,252 +1,252 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using SharpCompress.Common;
-using SharpCompress.Common.SevenZip;
-using SharpCompress.IO;
-using SharpCompress.Reader;
-
-namespace SharpCompress.Archive.SevenZip
-{
- public class SevenZipArchive : AbstractArchive
- {
- private ArchiveDatabase database;
-#if !DOTNET51
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- public static SevenZipArchive Open(string filePath)
- {
- return Open(filePath, Options.None);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- public static SevenZipArchive Open(FileInfo fileInfo)
- {
- return Open(fileInfo, Options.None);
- }
-
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- ///
- public static SevenZipArchive Open(string filePath, Options options)
- {
- filePath.CheckNotNullOrEmpty("filePath");
- return Open(new FileInfo(filePath), options);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- public static SevenZipArchive Open(FileInfo fileInfo, Options options)
- {
- fileInfo.CheckNotNull("fileInfo");
- return new SevenZipArchive(fileInfo, options);
- }
-#endif
-
- ///
- /// Takes a seekable Stream as a source
- ///
- ///
- public static SevenZipArchive Open(Stream stream)
- {
- stream.CheckNotNull("stream");
- return Open(stream, Options.None);
- }
-
- ///
- /// Takes a seekable Stream as a source
- ///
- ///
- ///
- public static SevenZipArchive Open(Stream stream, Options options)
- {
- stream.CheckNotNull("stream");
- return new SevenZipArchive(stream, options);
- }
-
-#if !DOTNET51
- internal SevenZipArchive(FileInfo fileInfo, Options options)
- : base(ArchiveType.SevenZip, fileInfo, options, null)
- {
- }
-
- protected override IEnumerable LoadVolumes(FileInfo file, Options options)
- {
- if (FlagUtility.HasFlag(options, Options.KeepStreamsOpen))
- {
- options = (Options)FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
- }
- return new SevenZipVolume(file.OpenRead(), options).AsEnumerable();
- }
-
- public static bool IsSevenZipFile(string filePath)
- {
- return IsSevenZipFile(new FileInfo(filePath));
- }
-
- public static bool IsSevenZipFile(FileInfo fileInfo)
- {
- if (!fileInfo.Exists)
- {
- return false;
- }
- using (Stream stream = fileInfo.OpenRead())
- {
- return IsSevenZipFile(stream);
- }
- }
-#endif
-
- internal SevenZipArchive(Stream stream, Options options)
- : base(ArchiveType.SevenZip, stream.AsEnumerable(), options, null)
- {
- }
-
- internal SevenZipArchive()
- : base(ArchiveType.SevenZip)
- {
- }
-
- protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
- {
- foreach (Stream s in streams)
- {
- if (!s.CanRead || !s.CanSeek)
- {
- throw new ArgumentException("Stream is not readable and seekable");
- }
- SevenZipVolume volume = new SevenZipVolume(s, options);
- yield return volume;
- }
- }
-
- protected override IEnumerable LoadEntries(IEnumerable volumes)
- {
- var stream = volumes.Single().Stream;
- LoadFactory(stream);
- for (int i = 0; i < database.Files.Count; i++)
- {
- var file = database.Files[i];
- if (!file.IsDir)
- {
- yield return new SevenZipArchiveEntry(this, new SevenZipFilePart(stream, database, i, file));
- }
- }
- }
-
- private void LoadFactory(Stream stream)
- {
- if (database == null)
- {
- stream.Position = 0;
- var reader = new ArchiveReader();
- reader.Open(stream);
- database = reader.ReadDatabase(null);
- }
- }
-
-
- public static bool IsSevenZipFile(Stream stream)
- {
- try
- {
- return SignatureMatch(stream);
- }
- catch
- {
- return false;
- }
- }
-
- private static readonly byte[] SIGNATURE = new byte[] {(byte) '7', (byte) 'z', 0xBC, 0xAF, 0x27, 0x1C};
-
- private static bool SignatureMatch(Stream stream)
- {
- BinaryReader reader = new BinaryReader(stream);
- byte[] signatureBytes = reader.ReadBytes(6);
- return signatureBytes.BinaryEquals(SIGNATURE);
- }
-
- protected override IReader CreateReaderForSolidExtraction()
- {
- return new SevenZipReader(this);
- }
-
- public override bool IsSolid
- {
- get { return Entries.Where(x => !x.IsDirectory).GroupBy(x => x.FilePart.Folder).Count() > 1; }
- }
-
- public override long TotalSize
- {
- get
- {
- int i = Entries.Count;
- return database.PackSizes.Aggregate(0L, (total, packSize) => total + packSize);
- }
- }
-
- private class SevenZipReader : AbstractReader
- {
- private readonly SevenZipArchive archive;
- private CFolder currentFolder;
- private Stream currentStream;
- private CFileItem currentItem;
-
- internal SevenZipReader(SevenZipArchive archive)
- : base(Options.KeepStreamsOpen, ArchiveType.SevenZip)
- {
- this.archive = archive;
- }
-
-
- public override SevenZipVolume Volume
- {
- get { return archive.Volumes.Single(); }
- }
-
- internal override IEnumerable GetEntries(Stream stream)
- {
- List entries = archive.Entries.ToList();
- stream.Position = 0;
- foreach (var dir in entries.Where(x => x.IsDirectory))
- {
- yield return dir;
- }
- foreach (var group in entries.Where(x => !x.IsDirectory).GroupBy(x => x.FilePart.Folder))
- {
- currentFolder = group.Key;
- if (group.Key == null)
- {
- currentStream = Stream.Null;
- }
- else
- {
- currentStream = archive.database.GetFolderStream(stream, currentFolder, null);
- }
- foreach (var entry in group)
- {
- currentItem = entry.FilePart.Header;
- yield return entry;
- }
- }
- }
-
- protected override EntryStream GetEntryStream()
- {
- return CreateEntryStream(new ReadOnlySubStream(currentStream, currentItem.Size));
- }
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using SharpCompress.Common;
+using SharpCompress.Common.SevenZip;
+using SharpCompress.IO;
+using SharpCompress.Reader;
+
+namespace SharpCompress.Archive.SevenZip
+{
+ public class SevenZipArchive : AbstractArchive
+ {
+ private ArchiveDatabase database;
+#if !DOTNET51
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ public static SevenZipArchive Open(string filePath)
+ {
+ return Open(filePath, Options.None);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ public static SevenZipArchive Open(FileInfo fileInfo)
+ {
+ return Open(fileInfo, Options.None);
+ }
+
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ ///
+ public static SevenZipArchive Open(string filePath, Options options)
+ {
+ filePath.CheckNotNullOrEmpty("filePath");
+ return Open(new FileInfo(filePath), options);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ public static SevenZipArchive Open(FileInfo fileInfo, Options options)
+ {
+ fileInfo.CheckNotNull("fileInfo");
+ return new SevenZipArchive(fileInfo, options);
+ }
+#endif
+
+ ///
+ /// Takes a seekable Stream as a source
+ ///
+ ///
+ public static SevenZipArchive Open(Stream stream)
+ {
+ stream.CheckNotNull("stream");
+ return Open(stream, Options.None);
+ }
+
+ ///
+ /// Takes a seekable Stream as a source
+ ///
+ ///
+ ///
+ public static SevenZipArchive Open(Stream stream, Options options)
+ {
+ stream.CheckNotNull("stream");
+ return new SevenZipArchive(stream, options);
+ }
+
+#if !DOTNET51
+ internal SevenZipArchive(FileInfo fileInfo, Options options)
+ : base(ArchiveType.SevenZip, fileInfo, options, null)
+ {
+ }
+
+ protected override IEnumerable LoadVolumes(FileInfo file, Options options)
+ {
+ if (FlagUtility.HasFlag(options, Options.KeepStreamsOpen))
+ {
+ options = (Options)FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
+ }
+ return new SevenZipVolume(file.OpenRead(), options).AsEnumerable();
+ }
+
+ public static bool IsSevenZipFile(string filePath)
+ {
+ return IsSevenZipFile(new FileInfo(filePath));
+ }
+
+ public static bool IsSevenZipFile(FileInfo fileInfo)
+ {
+ if (!fileInfo.Exists)
+ {
+ return false;
+ }
+ using (Stream stream = fileInfo.OpenRead())
+ {
+ return IsSevenZipFile(stream);
+ }
+ }
+#endif
+
+ internal SevenZipArchive(Stream stream, Options options)
+ : base(ArchiveType.SevenZip, stream.AsEnumerable(), options, null)
+ {
+ }
+
+ internal SevenZipArchive()
+ : base(ArchiveType.SevenZip)
+ {
+ }
+
+ protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
+ {
+ foreach (Stream s in streams)
+ {
+ if (!s.CanRead || !s.CanSeek)
+ {
+ throw new ArgumentException("Stream is not readable and seekable");
+ }
+ SevenZipVolume volume = new SevenZipVolume(s, options);
+ yield return volume;
+ }
+ }
+
+ protected override IEnumerable LoadEntries(IEnumerable volumes)
+ {
+ var stream = volumes.Single().Stream;
+ LoadFactory(stream);
+ for (int i = 0; i < database.Files.Count; i++)
+ {
+ var file = database.Files[i];
+ if (!file.IsDir)
+ {
+ yield return new SevenZipArchiveEntry(this, new SevenZipFilePart(stream, database, i, file));
+ }
+ }
+ }
+
+ private void LoadFactory(Stream stream)
+ {
+ if (database == null)
+ {
+ stream.Position = 0;
+ var reader = new ArchiveReader();
+ reader.Open(stream);
+ database = reader.ReadDatabase(null);
+ }
+ }
+
+
+ public static bool IsSevenZipFile(Stream stream)
+ {
+ try
+ {
+ return SignatureMatch(stream);
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+ private static readonly byte[] SIGNATURE = new byte[] {(byte) '7', (byte) 'z', 0xBC, 0xAF, 0x27, 0x1C};
+
+ private static bool SignatureMatch(Stream stream)
+ {
+ BinaryReader reader = new BinaryReader(stream);
+ byte[] signatureBytes = reader.ReadBytes(6);
+ return signatureBytes.BinaryEquals(SIGNATURE);
+ }
+
+ protected override IReader CreateReaderForSolidExtraction()
+ {
+ return new SevenZipReader(this);
+ }
+
+ public override bool IsSolid
+ {
+ get { return Entries.Where(x => !x.IsDirectory).GroupBy(x => x.FilePart.Folder).Count() > 1; }
+ }
+
+ public override long TotalSize
+ {
+ get
+ {
+ int i = Entries.Count;
+ return database.PackSizes.Aggregate(0L, (total, packSize) => total + packSize);
+ }
+ }
+
+ private class SevenZipReader : AbstractReader
+ {
+ private readonly SevenZipArchive archive;
+ private CFolder currentFolder;
+ private Stream currentStream;
+ private CFileItem currentItem;
+
+ internal SevenZipReader(SevenZipArchive archive)
+ : base(Options.KeepStreamsOpen, ArchiveType.SevenZip)
+ {
+ this.archive = archive;
+ }
+
+
+ public override SevenZipVolume Volume
+ {
+ get { return archive.Volumes.Single(); }
+ }
+
+ internal override IEnumerable GetEntries(Stream stream)
+ {
+ List entries = archive.Entries.ToList();
+ stream.Position = 0;
+ foreach (var dir in entries.Where(x => x.IsDirectory))
+ {
+ yield return dir;
+ }
+ foreach (var group in entries.Where(x => !x.IsDirectory).GroupBy(x => x.FilePart.Folder))
+ {
+ currentFolder = group.Key;
+ if (group.Key == null)
+ {
+ currentStream = Stream.Null;
+ }
+ else
+ {
+ currentStream = archive.database.GetFolderStream(stream, currentFolder, null);
+ }
+ foreach (var entry in group)
+ {
+ currentItem = entry.FilePart.Header;
+ yield return entry;
+ }
+ }
+ }
+
+ protected override EntryStream GetEntryStream()
+ {
+ return CreateEntryStream(new ReadOnlySubStream(currentStream, currentItem.Size));
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/SevenZip/SevenZipArchiveEntry.cs b/src/SharpCompress/Archive/SevenZip/SevenZipArchiveEntry.cs
similarity index 96%
rename from SharpCompress/Archive/SevenZip/SevenZipArchiveEntry.cs
rename to src/SharpCompress/Archive/SevenZip/SevenZipArchiveEntry.cs
index ca893e22..e921733a 100644
--- a/SharpCompress/Archive/SevenZip/SevenZipArchiveEntry.cs
+++ b/src/SharpCompress/Archive/SevenZip/SevenZipArchiveEntry.cs
@@ -1,33 +1,33 @@
-using System.IO;
-using SharpCompress.Common.SevenZip;
-
-namespace SharpCompress.Archive.SevenZip
-{
- public class SevenZipArchiveEntry : SevenZipEntry, IArchiveEntry
- {
- internal SevenZipArchiveEntry(SevenZipArchive archive, SevenZipFilePart part)
- : base(part)
- {
- Archive = archive;
- }
-
- public Stream OpenEntryStream()
- {
- return FilePart.GetCompressedStream();
- }
- public IArchive Archive { get; private set; }
-
- public bool IsComplete
- {
- get { return true; }
- }
-
- ///
- /// This is a 7Zip Anti item
- ///
- public bool IsAnti
- {
- get { return FilePart.Header.IsAnti; }
- }
- }
+using System.IO;
+using SharpCompress.Common.SevenZip;
+
+namespace SharpCompress.Archive.SevenZip
+{
+ public class SevenZipArchiveEntry : SevenZipEntry, IArchiveEntry
+ {
+ internal SevenZipArchiveEntry(SevenZipArchive archive, SevenZipFilePart part)
+ : base(part)
+ {
+ Archive = archive;
+ }
+
+ public Stream OpenEntryStream()
+ {
+ return FilePart.GetCompressedStream();
+ }
+ public IArchive Archive { get; private set; }
+
+ public bool IsComplete
+ {
+ get { return true; }
+ }
+
+ ///
+ /// This is a 7Zip Anti item
+ ///
+ public bool IsAnti
+ {
+ get { return FilePart.Header.IsAnti; }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Tar/TarArchive.cs b/src/SharpCompress/Archive/Tar/TarArchive.cs
similarity index 97%
rename from SharpCompress/Archive/Tar/TarArchive.cs
rename to src/SharpCompress/Archive/Tar/TarArchive.cs
index 236988d9..07311d85 100644
--- a/SharpCompress/Archive/Tar/TarArchive.cs
+++ b/src/SharpCompress/Archive/Tar/TarArchive.cs
@@ -1,231 +1,231 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using SharpCompress.Common;
-using SharpCompress.Common.Tar;
-using SharpCompress.Common.Tar.Headers;
-using SharpCompress.IO;
-using SharpCompress.Reader;
-using SharpCompress.Reader.Tar;
-using SharpCompress.Writer.Tar;
-
-namespace SharpCompress.Archive.Tar
-{
- public class TarArchive : AbstractWritableArchive
- {
-#if !DOTNET51
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- public static TarArchive Open(string filePath)
- {
- return Open(filePath, Options.None);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- public static TarArchive Open(FileInfo fileInfo)
- {
- return Open(fileInfo, Options.None);
- }
-
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- ///
- public static TarArchive Open(string filePath, Options options)
- {
- filePath.CheckNotNullOrEmpty("filePath");
- return Open(new FileInfo(filePath), options);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- public static TarArchive Open(FileInfo fileInfo, Options options)
- {
- fileInfo.CheckNotNull("fileInfo");
- return new TarArchive(fileInfo, options);
- }
-#endif
-
- ///
- /// Takes a seekable Stream as a source
- ///
- ///
- public static TarArchive Open(Stream stream)
- {
- stream.CheckNotNull("stream");
- return Open(stream, Options.None);
- }
-
- ///
- /// Takes a seekable Stream as a source
- ///
- ///
- ///
- public static TarArchive Open(Stream stream, Options options)
- {
- stream.CheckNotNull("stream");
- return new TarArchive(stream, options);
- }
-
-#if !DOTNET51
- public static bool IsTarFile(string filePath)
- {
- return IsTarFile(new FileInfo(filePath));
- }
-
- public static bool IsTarFile(FileInfo fileInfo)
- {
- if (!fileInfo.Exists)
- {
- return false;
- }
- using (Stream stream = fileInfo.OpenRead())
- {
- return IsTarFile(stream);
- }
- }
-#endif
-
- public static bool IsTarFile(Stream stream)
- {
- try
- {
- TarHeader tar = new TarHeader();
- tar.Read(new BinaryReader(stream));
- return tar.Name.Length > 0 && Enum.IsDefined(typeof (EntryType), tar.EntryType);
- }
- catch
- {
- }
- return false;
- }
-
-#if !DOTNET51
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- internal TarArchive(FileInfo fileInfo, Options options)
- : base(ArchiveType.Tar, fileInfo, options)
- {
- }
-
- protected override IEnumerable LoadVolumes(FileInfo file, Options options)
- {
- if (FlagUtility.HasFlag(options, Options.KeepStreamsOpen))
- {
- options = (Options)FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
- }
- return new TarVolume(file.OpenRead(), options).AsEnumerable();
- }
-#endif
-
- ///
- /// Takes multiple seekable Streams for a multi-part archive
- ///
- ///
- ///
- internal TarArchive(Stream stream, Options options)
- : base(ArchiveType.Tar, stream, options)
- {
- }
-
- internal TarArchive()
- : base(ArchiveType.Tar)
- {
- }
-
- protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
- {
- return new TarVolume(streams.First(), options).AsEnumerable();
- }
-
- protected override IEnumerable LoadEntries(IEnumerable volumes)
- {
- Stream stream = volumes.Single().Stream;
- TarHeader previousHeader = null;
- foreach (TarHeader header in TarHeaderFactory.ReadHeader(StreamingMode.Seekable, stream))
- {
- if (header != null)
- {
- if (header.EntryType == EntryType.LongName)
- {
- previousHeader = header;
- }
- else
- {
- if (previousHeader != null)
- {
- var entry = new TarArchiveEntry(this, new TarFilePart(previousHeader, stream),
- CompressionType.None);
-
- var oldStreamPos = stream.Position;
-
- using(var entryStream = entry.OpenEntryStream())
- using(var memoryStream = new MemoryStream())
- {
- entryStream.TransferTo(memoryStream);
- memoryStream.Position = 0;
- var bytes = memoryStream.ToArray();
-
- header.Name = ArchiveEncoding.Default.GetString(bytes, 0, bytes.Length).TrimNulls();
- }
-
- stream.Position = oldStreamPos;
-
- previousHeader = null;
- }
- yield return new TarArchiveEntry(this, new TarFilePart(header, stream), CompressionType.None);
- }
- }
- }
- }
-
- public static TarArchive Create()
- {
- return new TarArchive();
- }
-
- protected override TarArchiveEntry CreateEntryInternal(string filePath, Stream source,
- long size, DateTime? modified, bool closeStream)
- {
- return new TarWritableArchiveEntry(this, source, CompressionType.Unknown, filePath, size, modified,
- closeStream);
- }
-
- protected override void SaveTo(Stream stream, CompressionInfo compressionInfo,
- IEnumerable oldEntries,
- IEnumerable newEntries)
- {
- using (var writer = new TarWriter(stream, compressionInfo))
- {
- foreach (var entry in oldEntries.Concat(newEntries)
- .Where(x => !x.IsDirectory))
- {
- using (var entryStream = entry.OpenEntryStream())
- {
- writer.Write(entry.Key, entryStream, entry.LastModifiedTime, entry.Size);
- }
- }
- }
- }
-
- protected override IReader CreateReaderForSolidExtraction()
- {
- var stream = Volumes.Single().Stream;
- stream.Position = 0;
- return TarReader.Open(stream);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using SharpCompress.Common;
+using SharpCompress.Common.Tar;
+using SharpCompress.Common.Tar.Headers;
+using SharpCompress.IO;
+using SharpCompress.Reader;
+using SharpCompress.Reader.Tar;
+using SharpCompress.Writer.Tar;
+
+namespace SharpCompress.Archive.Tar
+{
+ public class TarArchive : AbstractWritableArchive
+ {
+#if !DOTNET51
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ public static TarArchive Open(string filePath)
+ {
+ return Open(filePath, Options.None);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ public static TarArchive Open(FileInfo fileInfo)
+ {
+ return Open(fileInfo, Options.None);
+ }
+
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ ///
+ public static TarArchive Open(string filePath, Options options)
+ {
+ filePath.CheckNotNullOrEmpty("filePath");
+ return Open(new FileInfo(filePath), options);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ public static TarArchive Open(FileInfo fileInfo, Options options)
+ {
+ fileInfo.CheckNotNull("fileInfo");
+ return new TarArchive(fileInfo, options);
+ }
+#endif
+
+ ///
+ /// Takes a seekable Stream as a source
+ ///
+ ///
+ public static TarArchive Open(Stream stream)
+ {
+ stream.CheckNotNull("stream");
+ return Open(stream, Options.None);
+ }
+
+ ///
+ /// Takes a seekable Stream as a source
+ ///
+ ///
+ ///
+ public static TarArchive Open(Stream stream, Options options)
+ {
+ stream.CheckNotNull("stream");
+ return new TarArchive(stream, options);
+ }
+
+#if !DOTNET51
+ public static bool IsTarFile(string filePath)
+ {
+ return IsTarFile(new FileInfo(filePath));
+ }
+
+ public static bool IsTarFile(FileInfo fileInfo)
+ {
+ if (!fileInfo.Exists)
+ {
+ return false;
+ }
+ using (Stream stream = fileInfo.OpenRead())
+ {
+ return IsTarFile(stream);
+ }
+ }
+#endif
+
+ public static bool IsTarFile(Stream stream)
+ {
+ try
+ {
+ TarHeader tar = new TarHeader();
+ tar.Read(new BinaryReader(stream));
+ return tar.Name.Length > 0 && Enum.IsDefined(typeof (EntryType), tar.EntryType);
+ }
+ catch
+ {
+ }
+ return false;
+ }
+
+#if !DOTNET51
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ internal TarArchive(FileInfo fileInfo, Options options)
+ : base(ArchiveType.Tar, fileInfo, options)
+ {
+ }
+
+ protected override IEnumerable LoadVolumes(FileInfo file, Options options)
+ {
+ if (FlagUtility.HasFlag(options, Options.KeepStreamsOpen))
+ {
+ options = (Options)FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
+ }
+ return new TarVolume(file.OpenRead(), options).AsEnumerable();
+ }
+#endif
+
+ ///
+ /// Takes multiple seekable Streams for a multi-part archive
+ ///
+ ///
+ ///
+ internal TarArchive(Stream stream, Options options)
+ : base(ArchiveType.Tar, stream, options)
+ {
+ }
+
+ internal TarArchive()
+ : base(ArchiveType.Tar)
+ {
+ }
+
+ protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
+ {
+ return new TarVolume(streams.First(), options).AsEnumerable();
+ }
+
+ protected override IEnumerable LoadEntries(IEnumerable volumes)
+ {
+ Stream stream = volumes.Single().Stream;
+ TarHeader previousHeader = null;
+ foreach (TarHeader header in TarHeaderFactory.ReadHeader(StreamingMode.Seekable, stream))
+ {
+ if (header != null)
+ {
+ if (header.EntryType == EntryType.LongName)
+ {
+ previousHeader = header;
+ }
+ else
+ {
+ if (previousHeader != null)
+ {
+ var entry = new TarArchiveEntry(this, new TarFilePart(previousHeader, stream),
+ CompressionType.None);
+
+ var oldStreamPos = stream.Position;
+
+ using(var entryStream = entry.OpenEntryStream())
+ using(var memoryStream = new MemoryStream())
+ {
+ entryStream.TransferTo(memoryStream);
+ memoryStream.Position = 0;
+ var bytes = memoryStream.ToArray();
+
+ header.Name = ArchiveEncoding.Default.GetString(bytes, 0, bytes.Length).TrimNulls();
+ }
+
+ stream.Position = oldStreamPos;
+
+ previousHeader = null;
+ }
+ yield return new TarArchiveEntry(this, new TarFilePart(header, stream), CompressionType.None);
+ }
+ }
+ }
+ }
+
+ public static TarArchive Create()
+ {
+ return new TarArchive();
+ }
+
+ protected override TarArchiveEntry CreateEntryInternal(string filePath, Stream source,
+ long size, DateTime? modified, bool closeStream)
+ {
+ return new TarWritableArchiveEntry(this, source, CompressionType.Unknown, filePath, size, modified,
+ closeStream);
+ }
+
+ protected override void SaveTo(Stream stream, CompressionInfo compressionInfo,
+ IEnumerable oldEntries,
+ IEnumerable newEntries)
+ {
+ using (var writer = new TarWriter(stream, compressionInfo))
+ {
+ foreach (var entry in oldEntries.Concat(newEntries)
+ .Where(x => !x.IsDirectory))
+ {
+ using (var entryStream = entry.OpenEntryStream())
+ {
+ writer.Write(entry.Key, entryStream, entry.LastModifiedTime, entry.Size);
+ }
+ }
+ }
+ }
+
+ protected override IReader CreateReaderForSolidExtraction()
+ {
+ var stream = Volumes.Single().Stream;
+ stream.Position = 0;
+ return TarReader.Open(stream);
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Tar/TarArchiveEntry.cs b/src/SharpCompress/Archive/Tar/TarArchiveEntry.cs
similarity index 96%
rename from SharpCompress/Archive/Tar/TarArchiveEntry.cs
rename to src/SharpCompress/Archive/Tar/TarArchiveEntry.cs
index cf07aad4..16585964 100644
--- a/SharpCompress/Archive/Tar/TarArchiveEntry.cs
+++ b/src/SharpCompress/Archive/Tar/TarArchiveEntry.cs
@@ -1,31 +1,31 @@
-using System.IO;
-using System.Linq;
-using SharpCompress.Common;
-using SharpCompress.Common.Tar;
-
-namespace SharpCompress.Archive.Tar
-{
- public class TarArchiveEntry : TarEntry, IArchiveEntry
- {
- internal TarArchiveEntry(TarArchive archive, TarFilePart part, CompressionType compressionType)
- : base(part, compressionType)
- {
- Archive = archive;
- }
-
- public virtual Stream OpenEntryStream()
- {
- return Parts.Single().GetCompressedStream();
- }
-
- #region IArchiveEntry Members
- public IArchive Archive { get; private set; }
-
- public bool IsComplete
- {
- get { return true; }
- }
-
- #endregion
- }
+using System.IO;
+using System.Linq;
+using SharpCompress.Common;
+using SharpCompress.Common.Tar;
+
+namespace SharpCompress.Archive.Tar
+{
+ public class TarArchiveEntry : TarEntry, IArchiveEntry
+ {
+ internal TarArchiveEntry(TarArchive archive, TarFilePart part, CompressionType compressionType)
+ : base(part, compressionType)
+ {
+ Archive = archive;
+ }
+
+ public virtual Stream OpenEntryStream()
+ {
+ return Parts.Single().GetCompressedStream();
+ }
+
+ #region IArchiveEntry Members
+ public IArchive Archive { get; private set; }
+
+ public bool IsComplete
+ {
+ get { return true; }
+ }
+
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Tar/TarWritableArchiveEntry.cs b/src/SharpCompress/Archive/Tar/TarWritableArchiveEntry.cs
similarity index 96%
rename from SharpCompress/Archive/Tar/TarWritableArchiveEntry.cs
rename to src/SharpCompress/Archive/Tar/TarWritableArchiveEntry.cs
index b1b1d608..5830fb68 100644
--- a/SharpCompress/Archive/Tar/TarWritableArchiveEntry.cs
+++ b/src/SharpCompress/Archive/Tar/TarWritableArchiveEntry.cs
@@ -1,110 +1,110 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using SharpCompress.Common;
-using SharpCompress.IO;
-
-namespace SharpCompress.Archive.Tar
-{
- internal class TarWritableArchiveEntry : TarArchiveEntry, IWritableArchiveEntry
- {
- private readonly string path;
- private readonly long size;
- private readonly DateTime? lastModified;
- private readonly bool closeStream;
- private readonly Stream stream;
-
- internal TarWritableArchiveEntry(TarArchive archive, Stream stream, CompressionType compressionType,
- string path, long size, DateTime? lastModified, bool closeStream)
- : base(archive, null, compressionType)
- {
- this.stream = stream;
- this.path = path;
- this.size = size;
- this.lastModified = lastModified;
- this.closeStream = closeStream;
- }
-
- public override long Crc
- {
- get { return 0; }
- }
-
- public override string Key
- {
- get { return path; }
- }
-
- public override long CompressedSize
- {
- get { return 0; }
- }
-
- public override long Size
- {
- get { return size; }
- }
-
- public override DateTime? LastModifiedTime
- {
- get { return lastModified; }
- }
-
- public override DateTime? CreatedTime
- {
- get { return null; }
- }
-
- public override DateTime? LastAccessedTime
- {
- get { return null; }
- }
-
- public override DateTime? ArchivedTime
- {
- get { return null; }
- }
-
- public override bool IsEncrypted
- {
- get { return false; }
- }
-
- public override bool IsDirectory
- {
- get { return false; }
- }
-
- public override bool IsSplit
- {
- get { return false; }
- }
-
- internal override IEnumerable Parts
- {
- get { throw new NotImplementedException(); }
- }
- Stream IWritableArchiveEntry.Stream
- {
- get
- {
- return stream;
- }
- }
-
- public override Stream OpenEntryStream()
- {
- //ensure new stream is at the start, this could be reset
- stream.Seek(0, SeekOrigin.Begin);
- return new NonDisposingStream(stream);
- }
-
- internal override void Close()
- {
- if (closeStream)
- {
- stream.Dispose();
- }
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using SharpCompress.Common;
+using SharpCompress.IO;
+
+namespace SharpCompress.Archive.Tar
+{
+ internal class TarWritableArchiveEntry : TarArchiveEntry, IWritableArchiveEntry
+ {
+ private readonly string path;
+ private readonly long size;
+ private readonly DateTime? lastModified;
+ private readonly bool closeStream;
+ private readonly Stream stream;
+
+ internal TarWritableArchiveEntry(TarArchive archive, Stream stream, CompressionType compressionType,
+ string path, long size, DateTime? lastModified, bool closeStream)
+ : base(archive, null, compressionType)
+ {
+ this.stream = stream;
+ this.path = path;
+ this.size = size;
+ this.lastModified = lastModified;
+ this.closeStream = closeStream;
+ }
+
+ public override long Crc
+ {
+ get { return 0; }
+ }
+
+ public override string Key
+ {
+ get { return path; }
+ }
+
+ public override long CompressedSize
+ {
+ get { return 0; }
+ }
+
+ public override long Size
+ {
+ get { return size; }
+ }
+
+ public override DateTime? LastModifiedTime
+ {
+ get { return lastModified; }
+ }
+
+ public override DateTime? CreatedTime
+ {
+ get { return null; }
+ }
+
+ public override DateTime? LastAccessedTime
+ {
+ get { return null; }
+ }
+
+ public override DateTime? ArchivedTime
+ {
+ get { return null; }
+ }
+
+ public override bool IsEncrypted
+ {
+ get { return false; }
+ }
+
+ public override bool IsDirectory
+ {
+ get { return false; }
+ }
+
+ public override bool IsSplit
+ {
+ get { return false; }
+ }
+
+ internal override IEnumerable Parts
+ {
+ get { throw new NotImplementedException(); }
+ }
+ Stream IWritableArchiveEntry.Stream
+ {
+ get
+ {
+ return stream;
+ }
+ }
+
+ public override Stream OpenEntryStream()
+ {
+ //ensure new stream is at the start, this could be reset
+ stream.Seek(0, SeekOrigin.Begin);
+ return new NonDisposingStream(stream);
+ }
+
+ internal override void Close()
+ {
+ if (closeStream)
+ {
+ stream.Dispose();
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Zip/ZipArchive.cs b/src/SharpCompress/Archive/Zip/ZipArchive.cs
similarity index 97%
rename from SharpCompress/Archive/Zip/ZipArchive.cs
rename to src/SharpCompress/Archive/Zip/ZipArchive.cs
index 52fef9ef..40f1ff4e 100644
--- a/SharpCompress/Archive/Zip/ZipArchive.cs
+++ b/src/SharpCompress/Archive/Zip/ZipArchive.cs
@@ -1,245 +1,245 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using SharpCompress.Common;
-using SharpCompress.Common.Zip;
-using SharpCompress.Common.Zip.Headers;
-using SharpCompress.Compressor.Deflate;
-using SharpCompress.Reader;
-using SharpCompress.Reader.Zip;
-using SharpCompress.Writer.Zip;
-
-namespace SharpCompress.Archive.Zip
-{
- public class ZipArchive : AbstractWritableArchive
- {
- private readonly SeekableZipHeaderFactory headerFactory;
-
- ///
- /// Gets or sets the compression level applied to files added to the archive,
- /// if the compression method is set to deflate
- ///
- public CompressionLevel DeflateCompressionLevel { get; set; }
-
-#if !DOTNET51
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- ///
- public static ZipArchive Open(string filePath, string password = null)
- {
- return Open(filePath, Options.None, password);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- public static ZipArchive Open(FileInfo fileInfo, string password = null)
- {
- return Open(fileInfo, Options.None, password);
- }
-
- ///
- /// Constructor expects a filepath to an existing file.
- ///
- ///
- ///
- ///
- public static ZipArchive Open(string filePath, Options options, string password = null)
- {
- filePath.CheckNotNullOrEmpty("filePath");
- return Open(new FileInfo(filePath), options, password);
- }
-
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- ///
- public static ZipArchive Open(FileInfo fileInfo, Options options, string password = null)
- {
- fileInfo.CheckNotNull("fileInfo");
- return new ZipArchive(fileInfo, options, password);
- }
-#endif
-
- ///
- /// Takes a seekable Stream as a source
- ///
- ///
- ///
- public static ZipArchive Open(Stream stream, string password = null)
- {
- stream.CheckNotNull("stream");
- return Open(stream, Options.None, password);
- }
-
- ///
- /// Takes a seekable Stream as a source
- ///
- ///
- ///
- ///
- public static ZipArchive Open(Stream stream, Options options, string password = null)
- {
- stream.CheckNotNull("stream");
- return new ZipArchive(stream, options, password);
- }
-
-#if !DOTNET51
- public static bool IsZipFile(string filePath, string password = null)
- {
- return IsZipFile(new FileInfo(filePath), password);
- }
-
- public static bool IsZipFile(FileInfo fileInfo, string password = null)
- {
- if (!fileInfo.Exists)
- {
- return false;
- }
- using (Stream stream = fileInfo.OpenRead())
- {
- return IsZipFile(stream, password);
- }
- }
-#endif
-
- public static bool IsZipFile(Stream stream, string password = null)
- {
- StreamingZipHeaderFactory headerFactory = new StreamingZipHeaderFactory(password);
- try
- {
- ZipHeader header =
- headerFactory.ReadStreamHeader(stream).FirstOrDefault(x => x.ZipHeaderType != ZipHeaderType.Split);
- if (header == null)
- {
- return false;
- }
- return Enum.IsDefined(typeof (ZipHeaderType), header.ZipHeaderType);
- }
- catch (CryptographicException)
- {
- return true;
- }
- catch
- {
- return false;
- }
- }
-
-#if !DOTNET51
- ///
- /// Constructor with a FileInfo object to an existing file.
- ///
- ///
- ///
- ///
- internal ZipArchive(FileInfo fileInfo, Options options, string password = null)
- : base(ArchiveType.Zip, fileInfo, options)
- {
- headerFactory = new SeekableZipHeaderFactory(password);
- }
-
- protected override IEnumerable LoadVolumes(FileInfo file, Options options)
- {
- if (FlagUtility.HasFlag(options, Options.KeepStreamsOpen))
- {
- options = (Options)FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
- }
- return new ZipVolume(file.OpenRead(), options).AsEnumerable();
- }
-#endif
-
- internal ZipArchive()
- : base(ArchiveType.Zip)
- {
- }
-
- ///
- /// Takes multiple seekable Streams for a multi-part archive
- ///
- ///
- ///
- ///
- internal ZipArchive(Stream stream, Options options, string password = null)
- : base(ArchiveType.Zip, stream, options)
- {
- headerFactory = new SeekableZipHeaderFactory(password);
- }
-
- protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
- {
- return new ZipVolume(streams.First(), options).AsEnumerable();
- }
-
- protected override IEnumerable LoadEntries(IEnumerable volumes)
- {
- var volume = volumes.Single();
- Stream stream = volume.Stream;
- foreach (ZipHeader h in headerFactory.ReadSeekableHeader(stream))
- {
- if (h != null)
- {
- switch (h.ZipHeaderType)
- {
- case ZipHeaderType.DirectoryEntry:
- {
- yield return new ZipArchiveEntry(this,
- new SeekableZipFilePart(headerFactory,
- h as DirectoryEntryHeader,
- stream));
- }
- break;
- case ZipHeaderType.DirectoryEnd:
- {
- byte[] bytes = (h as DirectoryEndHeader).Comment;
- volume.Comment = ArchiveEncoding.Default.GetString(bytes, 0, bytes.Length);
- yield break;
- }
- }
- }
- }
- }
-
- protected override void SaveTo(Stream stream, CompressionInfo compressionInfo,
- IEnumerable oldEntries,
- IEnumerable newEntries)
- {
- using (var writer = new ZipWriter(stream, compressionInfo, string.Empty))
- {
- foreach (var entry in oldEntries.Concat(newEntries)
- .Where(x => !x.IsDirectory))
- {
- using (var entryStream = entry.OpenEntryStream())
- {
- writer.Write(entry.Key, entryStream, entry.LastModifiedTime, string.Empty);
- }
- }
- }
- }
-
- protected override ZipArchiveEntry CreateEntryInternal(string filePath, Stream source, long size, DateTime? modified,
- bool closeStream)
- {
- return new ZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream);
- }
-
- public static ZipArchive Create()
- {
- return new ZipArchive();
- }
-
- protected override IReader CreateReaderForSolidExtraction()
- {
- var stream = Volumes.Single().Stream;
- stream.Position = 0;
- return ZipReader.Open(stream);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using SharpCompress.Common;
+using SharpCompress.Common.Zip;
+using SharpCompress.Common.Zip.Headers;
+using SharpCompress.Compressor.Deflate;
+using SharpCompress.Reader;
+using SharpCompress.Reader.Zip;
+using SharpCompress.Writer.Zip;
+
+namespace SharpCompress.Archive.Zip
+{
+ public class ZipArchive : AbstractWritableArchive
+ {
+ private readonly SeekableZipHeaderFactory headerFactory;
+
+ ///
+ /// Gets or sets the compression level applied to files added to the archive,
+ /// if the compression method is set to deflate
+ ///
+ public CompressionLevel DeflateCompressionLevel { get; set; }
+
+#if !DOTNET51
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ ///
+ public static ZipArchive Open(string filePath, string password = null)
+ {
+ return Open(filePath, Options.None, password);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ public static ZipArchive Open(FileInfo fileInfo, string password = null)
+ {
+ return Open(fileInfo, Options.None, password);
+ }
+
+ ///
+ /// Constructor expects a filepath to an existing file.
+ ///
+ ///
+ ///
+ ///
+ public static ZipArchive Open(string filePath, Options options, string password = null)
+ {
+ filePath.CheckNotNullOrEmpty("filePath");
+ return Open(new FileInfo(filePath), options, password);
+ }
+
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ ///
+ public static ZipArchive Open(FileInfo fileInfo, Options options, string password = null)
+ {
+ fileInfo.CheckNotNull("fileInfo");
+ return new ZipArchive(fileInfo, options, password);
+ }
+#endif
+
+ ///
+ /// Takes a seekable Stream as a source
+ ///
+ ///
+ ///
+ public static ZipArchive Open(Stream stream, string password = null)
+ {
+ stream.CheckNotNull("stream");
+ return Open(stream, Options.None, password);
+ }
+
+ ///
+ /// Takes a seekable Stream as a source
+ ///
+ ///
+ ///
+ ///
+ public static ZipArchive Open(Stream stream, Options options, string password = null)
+ {
+ stream.CheckNotNull("stream");
+ return new ZipArchive(stream, options, password);
+ }
+
+#if !DOTNET51
+ public static bool IsZipFile(string filePath, string password = null)
+ {
+ return IsZipFile(new FileInfo(filePath), password);
+ }
+
+ public static bool IsZipFile(FileInfo fileInfo, string password = null)
+ {
+ if (!fileInfo.Exists)
+ {
+ return false;
+ }
+ using (Stream stream = fileInfo.OpenRead())
+ {
+ return IsZipFile(stream, password);
+ }
+ }
+#endif
+
+ public static bool IsZipFile(Stream stream, string password = null)
+ {
+ StreamingZipHeaderFactory headerFactory = new StreamingZipHeaderFactory(password);
+ try
+ {
+ ZipHeader header =
+ headerFactory.ReadStreamHeader(stream).FirstOrDefault(x => x.ZipHeaderType != ZipHeaderType.Split);
+ if (header == null)
+ {
+ return false;
+ }
+ return Enum.IsDefined(typeof (ZipHeaderType), header.ZipHeaderType);
+ }
+ catch (CryptographicException)
+ {
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+#if !DOTNET51
+ ///
+ /// Constructor with a FileInfo object to an existing file.
+ ///
+ ///
+ ///
+ ///
+ internal ZipArchive(FileInfo fileInfo, Options options, string password = null)
+ : base(ArchiveType.Zip, fileInfo, options)
+ {
+ headerFactory = new SeekableZipHeaderFactory(password);
+ }
+
+ protected override IEnumerable LoadVolumes(FileInfo file, Options options)
+ {
+ if (FlagUtility.HasFlag(options, Options.KeepStreamsOpen))
+ {
+ options = (Options)FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
+ }
+ return new ZipVolume(file.OpenRead(), options).AsEnumerable();
+ }
+#endif
+
+ internal ZipArchive()
+ : base(ArchiveType.Zip)
+ {
+ }
+
+ ///
+ /// Takes multiple seekable Streams for a multi-part archive
+ ///
+ ///
+ ///
+ ///
+ internal ZipArchive(Stream stream, Options options, string password = null)
+ : base(ArchiveType.Zip, stream, options)
+ {
+ headerFactory = new SeekableZipHeaderFactory(password);
+ }
+
+ protected override IEnumerable LoadVolumes(IEnumerable streams, Options options)
+ {
+ return new ZipVolume(streams.First(), options).AsEnumerable();
+ }
+
+ protected override IEnumerable LoadEntries(IEnumerable volumes)
+ {
+ var volume = volumes.Single();
+ Stream stream = volume.Stream;
+ foreach (ZipHeader h in headerFactory.ReadSeekableHeader(stream))
+ {
+ if (h != null)
+ {
+ switch (h.ZipHeaderType)
+ {
+ case ZipHeaderType.DirectoryEntry:
+ {
+ yield return new ZipArchiveEntry(this,
+ new SeekableZipFilePart(headerFactory,
+ h as DirectoryEntryHeader,
+ stream));
+ }
+ break;
+ case ZipHeaderType.DirectoryEnd:
+ {
+ byte[] bytes = (h as DirectoryEndHeader).Comment;
+ volume.Comment = ArchiveEncoding.Default.GetString(bytes, 0, bytes.Length);
+ yield break;
+ }
+ }
+ }
+ }
+ }
+
+ protected override void SaveTo(Stream stream, CompressionInfo compressionInfo,
+ IEnumerable oldEntries,
+ IEnumerable newEntries)
+ {
+ using (var writer = new ZipWriter(stream, compressionInfo, string.Empty))
+ {
+ foreach (var entry in oldEntries.Concat(newEntries)
+ .Where(x => !x.IsDirectory))
+ {
+ using (var entryStream = entry.OpenEntryStream())
+ {
+ writer.Write(entry.Key, entryStream, entry.LastModifiedTime, string.Empty);
+ }
+ }
+ }
+ }
+
+ protected override ZipArchiveEntry CreateEntryInternal(string filePath, Stream source, long size, DateTime? modified,
+ bool closeStream)
+ {
+ return new ZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream);
+ }
+
+ public static ZipArchive Create()
+ {
+ return new ZipArchive();
+ }
+
+ protected override IReader CreateReaderForSolidExtraction()
+ {
+ var stream = Volumes.Single().Stream;
+ stream.Position = 0;
+ return ZipReader.Open(stream);
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Zip/ZipArchiveEntry.cs b/src/SharpCompress/Archive/Zip/ZipArchiveEntry.cs
similarity index 95%
rename from SharpCompress/Archive/Zip/ZipArchiveEntry.cs
rename to src/SharpCompress/Archive/Zip/ZipArchiveEntry.cs
index 70d4b229..607f7a58 100644
--- a/SharpCompress/Archive/Zip/ZipArchiveEntry.cs
+++ b/src/SharpCompress/Archive/Zip/ZipArchiveEntry.cs
@@ -1,36 +1,36 @@
-using System.IO;
-using System.Linq;
-using SharpCompress.Common.Zip;
-
-namespace SharpCompress.Archive.Zip
-{
- public class ZipArchiveEntry : ZipEntry, IArchiveEntry
- {
- internal ZipArchiveEntry(ZipArchive archive, SeekableZipFilePart part)
- : base(part)
- {
- Archive = archive;
- }
-
- public virtual Stream OpenEntryStream()
- {
- return Parts.Single().GetCompressedStream();
- }
-
- #region IArchiveEntry Members
-
- public IArchive Archive { get; private set; }
-
- public bool IsComplete
- {
- get { return true; }
- }
-
- #endregion
-
- public string Comment
- {
- get { return (Parts.Single() as SeekableZipFilePart).Comment; }
- }
- }
+using System.IO;
+using System.Linq;
+using SharpCompress.Common.Zip;
+
+namespace SharpCompress.Archive.Zip
+{
+ public class ZipArchiveEntry : ZipEntry, IArchiveEntry
+ {
+ internal ZipArchiveEntry(ZipArchive archive, SeekableZipFilePart part)
+ : base(part)
+ {
+ Archive = archive;
+ }
+
+ public virtual Stream OpenEntryStream()
+ {
+ return Parts.Single().GetCompressedStream();
+ }
+
+ #region IArchiveEntry Members
+
+ public IArchive Archive { get; private set; }
+
+ public bool IsComplete
+ {
+ get { return true; }
+ }
+
+ #endregion
+
+ public string Comment
+ {
+ get { return (Parts.Single() as SeekableZipFilePart).Comment; }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs b/src/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs
similarity index 95%
rename from SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs
rename to src/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs
index ce99ce40..f1946e7a 100644
--- a/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs
+++ b/src/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs
@@ -1,113 +1,113 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using SharpCompress.Common;
-using SharpCompress.IO;
-
-namespace SharpCompress.Archive.Zip
-{
- internal class ZipWritableArchiveEntry : ZipArchiveEntry, IWritableArchiveEntry
- {
- private readonly string path;
- private readonly long size;
- private readonly DateTime? lastModified;
- private readonly bool closeStream;
- private readonly Stream stream;
- private bool isDisposed;
-
- internal ZipWritableArchiveEntry(ZipArchive archive, Stream stream, string path, long size,
- DateTime? lastModified, bool closeStream)
- : base(archive, null)
- {
- this.stream = stream;
- this.path = path;
- this.size = size;
- this.lastModified = lastModified;
- this.closeStream = closeStream;
- }
-
- public override long Crc
- {
- get { return 0; }
- }
-
- public override string Key
- {
- get { return path; }
- }
-
- public override long CompressedSize
- {
- get { return 0; }
- }
-
- public override long Size
- {
- get { return size; }
- }
-
- public override DateTime? LastModifiedTime
- {
- get { return lastModified; }
- }
-
- public override DateTime? CreatedTime
- {
- get { return null; }
- }
-
- public override DateTime? LastAccessedTime
- {
- get { return null; }
- }
-
- public override DateTime? ArchivedTime
- {
- get { return null; }
- }
-
- public override bool IsEncrypted
- {
- get { return false; }
- }
-
- public override bool IsDirectory
- {
- get { return false; }
- }
-
- public override bool IsSplit
- {
- get { return false; }
- }
-
- internal override IEnumerable Parts
- {
- get { throw new NotImplementedException(); }
- }
-
- Stream IWritableArchiveEntry.Stream
- {
- get
- {
- return stream;
- }
- }
-
- public override Stream OpenEntryStream()
- {
- //ensure new stream is at the start, this could be reset
- stream.Seek(0, SeekOrigin.Begin);
- return new NonDisposingStream(stream);
- }
-
- internal override void Close()
- {
- if (closeStream && !isDisposed)
- {
- stream.Dispose();
- isDisposed = true;
- }
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using SharpCompress.Common;
+using SharpCompress.IO;
+
+namespace SharpCompress.Archive.Zip
+{
+ internal class ZipWritableArchiveEntry : ZipArchiveEntry, IWritableArchiveEntry
+ {
+ private readonly string path;
+ private readonly long size;
+ private readonly DateTime? lastModified;
+ private readonly bool closeStream;
+ private readonly Stream stream;
+ private bool isDisposed;
+
+ internal ZipWritableArchiveEntry(ZipArchive archive, Stream stream, string path, long size,
+ DateTime? lastModified, bool closeStream)
+ : base(archive, null)
+ {
+ this.stream = stream;
+ this.path = path;
+ this.size = size;
+ this.lastModified = lastModified;
+ this.closeStream = closeStream;
+ }
+
+ public override long Crc
+ {
+ get { return 0; }
+ }
+
+ public override string Key
+ {
+ get { return path; }
+ }
+
+ public override long CompressedSize
+ {
+ get { return 0; }
+ }
+
+ public override long Size
+ {
+ get { return size; }
+ }
+
+ public override DateTime? LastModifiedTime
+ {
+ get { return lastModified; }
+ }
+
+ public override DateTime? CreatedTime
+ {
+ get { return null; }
+ }
+
+ public override DateTime? LastAccessedTime
+ {
+ get { return null; }
+ }
+
+ public override DateTime? ArchivedTime
+ {
+ get { return null; }
+ }
+
+ public override bool IsEncrypted
+ {
+ get { return false; }
+ }
+
+ public override bool IsDirectory
+ {
+ get { return false; }
+ }
+
+ public override bool IsSplit
+ {
+ get { return false; }
+ }
+
+ internal override IEnumerable Parts
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ Stream IWritableArchiveEntry.Stream
+ {
+ get
+ {
+ return stream;
+ }
+ }
+
+ public override Stream OpenEntryStream()
+ {
+ //ensure new stream is at the start, this could be reset
+ stream.Seek(0, SeekOrigin.Begin);
+ return new NonDisposingStream(stream);
+ }
+
+ internal override void Close()
+ {
+ if (closeStream && !isDisposed)
+ {
+ stream.Dispose();
+ isDisposed = true;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/AssemblyInfo.cs b/src/SharpCompress/AssemblyInfo.cs
similarity index 96%
rename from SharpCompress/AssemblyInfo.cs
rename to src/SharpCompress/AssemblyInfo.cs
index 2caef4ba..8978eeba 100644
--- a/SharpCompress/AssemblyInfo.cs
+++ b/src/SharpCompress/AssemblyInfo.cs
@@ -1,13 +1,13 @@
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-
-[assembly: AssemblyTitle("SharpCompress")]
-[assembly: AssemblyProduct("SharpCompress")]
-
-
-[assembly: InternalsVisibleTo("SharpCompress.Test")]
-[assembly: InternalsVisibleTo("SharpCompress.Test.Portable")]
-
-[assembly: CLSCompliant(true)]
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+
+[assembly: AssemblyTitle("SharpCompress")]
+[assembly: AssemblyProduct("SharpCompress")]
+
+
+[assembly: InternalsVisibleTo("SharpCompress.Test")]
+[assembly: InternalsVisibleTo("SharpCompress.Test.Portable")]
+
+[assembly: CLSCompliant(true)]
diff --git a/SharpCompress/Common/ArchiveEncoding.cs b/src/SharpCompress/Common/ArchiveEncoding.cs
similarity index 96%
rename from SharpCompress/Common/ArchiveEncoding.cs
rename to src/SharpCompress/Common/ArchiveEncoding.cs
index 98cb6f7d..c973c7cb 100644
--- a/SharpCompress/Common/ArchiveEncoding.cs
+++ b/src/SharpCompress/Common/ArchiveEncoding.cs
@@ -1,23 +1,23 @@
-using System.Text;
-
-namespace SharpCompress.Common
-{
- public static class ArchiveEncoding
- {
- ///
- /// Default encoding to use when archive format doesn't specify one.
- ///
- public static Encoding Default { get; set; }
-
- ///
- /// Encoding used by encryption schemes which don't comply with RFC 2898.
- ///
- public static Encoding Password { get; set; }
-
- static ArchiveEncoding()
- {
- Default = Encoding.UTF8;
- Password = Encoding.UTF8;
- }
- }
+using System.Text;
+
+namespace SharpCompress.Common
+{
+ public static class ArchiveEncoding
+ {
+ ///
+ /// Default encoding to use when archive format doesn't specify one.
+ ///
+ public static Encoding Default { get; set; }
+
+ ///
+ /// Encoding used by encryption schemes which don't comply with RFC 2898.
+ ///
+ public static Encoding Password { get; set; }
+
+ static ArchiveEncoding()
+ {
+ Default = Encoding.UTF8;
+ Password = Encoding.UTF8;
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/ArchiveException.cs b/src/SharpCompress/Common/ArchiveException.cs
similarity index 94%
rename from SharpCompress/Common/ArchiveException.cs
rename to src/SharpCompress/Common/ArchiveException.cs
index 3a969784..18207c64 100644
--- a/SharpCompress/Common/ArchiveException.cs
+++ b/src/SharpCompress/Common/ArchiveException.cs
@@ -1,12 +1,12 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public class ArchiveException : Exception
- {
- public ArchiveException(string message)
- : base(message)
- {
- }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public class ArchiveException : Exception
+ {
+ public ArchiveException(string message)
+ : base(message)
+ {
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/ArchiveExtractionEventArgs.cs b/src/SharpCompress/Common/ArchiveExtractionEventArgs.cs
similarity index 95%
rename from SharpCompress/Common/ArchiveExtractionEventArgs.cs
rename to src/SharpCompress/Common/ArchiveExtractionEventArgs.cs
index 1a4cba25..7295fdf4 100644
--- a/SharpCompress/Common/ArchiveExtractionEventArgs.cs
+++ b/src/SharpCompress/Common/ArchiveExtractionEventArgs.cs
@@ -1,14 +1,14 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public class ArchiveExtractionEventArgs : EventArgs
- {
- internal ArchiveExtractionEventArgs(T entry)
- {
- Item = entry;
- }
-
- public T Item { get; private set; }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public class ArchiveExtractionEventArgs : EventArgs
+ {
+ internal ArchiveExtractionEventArgs(T entry)
+ {
+ Item = entry;
+ }
+
+ public T Item { get; private set; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/ArchiveType.cs b/src/SharpCompress/Common/ArchiveType.cs
similarity index 93%
rename from SharpCompress/Common/ArchiveType.cs
rename to src/SharpCompress/Common/ArchiveType.cs
index 2b405356..ca905f42 100644
--- a/SharpCompress/Common/ArchiveType.cs
+++ b/src/SharpCompress/Common/ArchiveType.cs
@@ -1,11 +1,11 @@
-namespace SharpCompress.Common
-{
- public enum ArchiveType
- {
- Rar,
- Zip,
- Tar,
- SevenZip,
- GZip,
- }
+namespace SharpCompress.Common
+{
+ public enum ArchiveType
+ {
+ Rar,
+ Zip,
+ Tar,
+ SevenZip,
+ GZip,
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/CompressedBytesReadEventArgs.cs b/src/SharpCompress/Common/CompressedBytesReadEventArgs.cs
similarity index 96%
rename from SharpCompress/Common/CompressedBytesReadEventArgs.cs
rename to src/SharpCompress/Common/CompressedBytesReadEventArgs.cs
index 7c8ed598..fdae9c4d 100644
--- a/SharpCompress/Common/CompressedBytesReadEventArgs.cs
+++ b/src/SharpCompress/Common/CompressedBytesReadEventArgs.cs
@@ -1,17 +1,17 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public class CompressedBytesReadEventArgs : EventArgs
- {
- ///
- /// Compressed bytes read for the current entry
- ///
- public long CompressedBytesRead { get; internal set; }
-
- ///
- /// Current file part read for Multipart files (e.g. Rar)
- ///
- public long CurrentFilePartCompressedBytesRead { get; internal set; }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public class CompressedBytesReadEventArgs : EventArgs
+ {
+ ///
+ /// Compressed bytes read for the current entry
+ ///
+ public long CompressedBytesRead { get; internal set; }
+
+ ///
+ /// Current file part read for Multipart files (e.g. Rar)
+ ///
+ public long CurrentFilePartCompressedBytesRead { get; internal set; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/CompressionInfo.cs b/src/SharpCompress/Common/CompressionInfo.cs
similarity index 96%
rename from SharpCompress/Common/CompressionInfo.cs
rename to src/SharpCompress/Common/CompressionInfo.cs
index f62ea405..2ad5703b 100644
--- a/SharpCompress/Common/CompressionInfo.cs
+++ b/src/SharpCompress/Common/CompressionInfo.cs
@@ -1,30 +1,30 @@
-using SharpCompress.Compressor.Deflate;
-
-namespace SharpCompress.Common
-{
- ///
- /// Detailed compression properties when saving.
- ///
- public class CompressionInfo
- {
- public CompressionInfo()
- {
- DeflateCompressionLevel = CompressionLevel.Default;
- }
-
- ///
- /// The algorthm to use. Must be valid for the format type.
- ///
- public CompressionType Type { get; set; }
-
- ///
- /// When CompressionType.Deflate is used, this property is referenced. Defaults to CompressionLevel.Default.
- ///
- public CompressionLevel DeflateCompressionLevel { get; set; }
-
- public static implicit operator CompressionInfo(CompressionType compressionType)
- {
- return new CompressionInfo() {Type = compressionType};
- }
- }
+using SharpCompress.Compressor.Deflate;
+
+namespace SharpCompress.Common
+{
+ ///
+ /// Detailed compression properties when saving.
+ ///
+ public class CompressionInfo
+ {
+ public CompressionInfo()
+ {
+ DeflateCompressionLevel = CompressionLevel.Default;
+ }
+
+ ///
+ /// The algorthm to use. Must be valid for the format type.
+ ///
+ public CompressionType Type { get; set; }
+
+ ///
+ /// When CompressionType.Deflate is used, this property is referenced. Defaults to CompressionLevel.Default.
+ ///
+ public CompressionLevel DeflateCompressionLevel { get; set; }
+
+ public static implicit operator CompressionInfo(CompressionType compressionType)
+ {
+ return new CompressionInfo() {Type = compressionType};
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/CompressionType.cs b/src/SharpCompress/Common/CompressionType.cs
similarity index 93%
rename from SharpCompress/Common/CompressionType.cs
rename to src/SharpCompress/Common/CompressionType.cs
index d51e6545..20d59a2b 100644
--- a/SharpCompress/Common/CompressionType.cs
+++ b/src/SharpCompress/Common/CompressionType.cs
@@ -1,16 +1,16 @@
-namespace SharpCompress.Common
-{
- public enum CompressionType
- {
- None,
- GZip,
- BZip2,
- PPMd,
- Deflate,
- Rar,
- LZMA,
- BCJ,
- BCJ2,
- Unknown,
- }
+namespace SharpCompress.Common
+{
+ public enum CompressionType
+ {
+ None,
+ GZip,
+ BZip2,
+ PPMd,
+ Deflate,
+ Rar,
+ LZMA,
+ BCJ,
+ BCJ2,
+ Unknown,
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/CryptographicException.cs b/src/SharpCompress/Common/CryptographicException.cs
similarity index 95%
rename from SharpCompress/Common/CryptographicException.cs
rename to src/SharpCompress/Common/CryptographicException.cs
index 4e17f303..450cd237 100644
--- a/SharpCompress/Common/CryptographicException.cs
+++ b/src/SharpCompress/Common/CryptographicException.cs
@@ -1,12 +1,12 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public class CryptographicException : Exception
- {
- public CryptographicException(string message)
- : base(message)
- {
- }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public class CryptographicException : Exception
+ {
+ public CryptographicException(string message)
+ : base(message)
+ {
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Entry.cs b/src/SharpCompress/Common/Entry.cs
similarity index 96%
rename from SharpCompress/Common/Entry.cs
rename to src/SharpCompress/Common/Entry.cs
index 42d90faf..3f1aac1b 100644
--- a/SharpCompress/Common/Entry.cs
+++ b/src/SharpCompress/Common/Entry.cs
@@ -1,85 +1,85 @@
-using System;
-using System.Collections.Generic;
-
-namespace SharpCompress.Common
-{
- public abstract class Entry : IEntry
- {
- ///
- /// The File's 32 bit CRC Hash
- ///
- public abstract long Crc { get; }
-
- ///
- /// The string key of the file internal to the Archive.
- ///
- public abstract string Key { get; }
-
- ///
- /// The compressed file size
- ///
- public abstract long CompressedSize { get; }
-
- ///
- /// The compression type
- ///
- public abstract CompressionType CompressionType { get; }
-
- ///
- /// The uncompressed file size
- ///
- public abstract long Size { get; }
-
- ///
- /// The entry last modified time in the archive, if recorded
- ///
- public abstract DateTime? LastModifiedTime { get; }
-
- ///
- /// The entry create time in the archive, if recorded
- ///
- public abstract DateTime? CreatedTime { get; }
-
- ///
- /// The entry last accessed time in the archive, if recorded
- ///
- public abstract DateTime? LastAccessedTime { get; }
-
- ///
- /// The entry time when archived, if recorded
- ///
- public abstract DateTime? ArchivedTime { get; }
-
- ///
- /// Entry is password protected and encrypted and cannot be extracted.
- ///
- public abstract bool IsEncrypted { get; }
-
- ///
- /// Entry is password protected and encrypted and cannot be extracted.
- ///
- public abstract bool IsDirectory { get; }
-
- ///
- /// Entry is split among multiple volumes
- ///
- public abstract bool IsSplit { get; }
-
- internal abstract IEnumerable Parts { get; }
- internal bool IsSolid { get; set; }
-
- internal virtual void Close()
- {
-
- }
-
- ///
- /// Entry file attribute.
- ///
- public virtual int? Attrib
- {
- get { throw new NotImplementedException(); }
- }
-
- }
+using System;
+using System.Collections.Generic;
+
+namespace SharpCompress.Common
+{
+ public abstract class Entry : IEntry
+ {
+ ///
+ /// The File's 32 bit CRC Hash
+ ///
+ public abstract long Crc { get; }
+
+ ///
+ /// The string key of the file internal to the Archive.
+ ///
+ public abstract string Key { get; }
+
+ ///
+ /// The compressed file size
+ ///
+ public abstract long CompressedSize { get; }
+
+ ///
+ /// The compression type
+ ///
+ public abstract CompressionType CompressionType { get; }
+
+ ///
+ /// The uncompressed file size
+ ///
+ public abstract long Size { get; }
+
+ ///
+ /// The entry last modified time in the archive, if recorded
+ ///
+ public abstract DateTime? LastModifiedTime { get; }
+
+ ///
+ /// The entry create time in the archive, if recorded
+ ///
+ public abstract DateTime? CreatedTime { get; }
+
+ ///
+ /// The entry last accessed time in the archive, if recorded
+ ///
+ public abstract DateTime? LastAccessedTime { get; }
+
+ ///
+ /// The entry time when archived, if recorded
+ ///
+ public abstract DateTime? ArchivedTime { get; }
+
+ ///
+ /// Entry is password protected and encrypted and cannot be extracted.
+ ///
+ public abstract bool IsEncrypted { get; }
+
+ ///
+ /// Entry is password protected and encrypted and cannot be extracted.
+ ///
+ public abstract bool IsDirectory { get; }
+
+ ///
+ /// Entry is split among multiple volumes
+ ///
+ public abstract bool IsSplit { get; }
+
+ internal abstract IEnumerable Parts { get; }
+ internal bool IsSolid { get; set; }
+
+ internal virtual void Close()
+ {
+
+ }
+
+ ///
+ /// Entry file attribute.
+ ///
+ public virtual int? Attrib
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/EntryStream.cs b/src/SharpCompress/Common/EntryStream.cs
similarity index 96%
rename from SharpCompress/Common/EntryStream.cs
rename to src/SharpCompress/Common/EntryStream.cs
index 86e50978..f3fd99ac 100644
--- a/SharpCompress/Common/EntryStream.cs
+++ b/src/SharpCompress/Common/EntryStream.cs
@@ -1,103 +1,103 @@
-using System;
-using System.IO;
-using SharpCompress.Reader;
-
-namespace SharpCompress.Common
-{
- public class EntryStream : Stream
- {
- public IReader Reader { get; private set; }
- private Stream stream;
- private bool completed;
- private bool isDisposed;
-
- internal EntryStream(IReader reader, Stream stream)
- {
- this.Reader = reader;
- this.stream = stream;
- }
-
- ///
- /// When reading a stream from OpenEntryStream, the stream must be completed so use this to finish reading the entire entry.
- ///
- public void SkipEntry()
- {
- var buffer = new byte[4096];
- while (Read(buffer, 0, buffer.Length) > 0)
- {
- }
- completed = true;
- }
-
- protected override void Dispose(bool disposing)
- {
- if (!(completed || Reader.Cancelled))
- {
- SkipEntry();
- }
- if (isDisposed)
- {
- return;
- }
- isDisposed = true;
- base.Dispose(disposing);
- stream.Dispose();
- }
-
- public override bool CanRead
- {
- get { return true; }
- }
-
- public override bool CanSeek
- {
- get { return false; }
- }
-
- public override bool CanWrite
- {
- get { return false; }
- }
-
- public override void Flush()
- {
- throw new NotSupportedException();
- }
-
- public override long Length
- {
- get { throw new NotSupportedException(); }
- }
-
- public override long Position
- {
- get { throw new NotSupportedException(); }
- set { throw new NotSupportedException(); }
- }
-
- public override int Read(byte[] buffer, int offset, int count)
- {
- int read = stream.Read(buffer, offset, count);
- if (read <= 0)
- {
- completed = true;
- }
- return read;
- }
-
- public override long Seek(long offset, SeekOrigin origin)
- {
- throw new NotSupportedException();
- }
-
- public override void SetLength(long value)
- {
- throw new NotSupportedException();
- }
-
- public override void Write(byte[] buffer, int offset, int count)
- {
- throw new NotSupportedException();
- }
- }
+using System;
+using System.IO;
+using SharpCompress.Reader;
+
+namespace SharpCompress.Common
+{
+ public class EntryStream : Stream
+ {
+ public IReader Reader { get; private set; }
+ private Stream stream;
+ private bool completed;
+ private bool isDisposed;
+
+ internal EntryStream(IReader reader, Stream stream)
+ {
+ this.Reader = reader;
+ this.stream = stream;
+ }
+
+ ///
+ /// When reading a stream from OpenEntryStream, the stream must be completed so use this to finish reading the entire entry.
+ ///
+ public void SkipEntry()
+ {
+ var buffer = new byte[4096];
+ while (Read(buffer, 0, buffer.Length) > 0)
+ {
+ }
+ completed = true;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (!(completed || Reader.Cancelled))
+ {
+ SkipEntry();
+ }
+ if (isDisposed)
+ {
+ return;
+ }
+ isDisposed = true;
+ base.Dispose(disposing);
+ stream.Dispose();
+ }
+
+ public override bool CanRead
+ {
+ get { return true; }
+ }
+
+ public override bool CanSeek
+ {
+ get { return false; }
+ }
+
+ public override bool CanWrite
+ {
+ get { return false; }
+ }
+
+ public override void Flush()
+ {
+ throw new NotSupportedException();
+ }
+
+ public override long Length
+ {
+ get { throw new NotSupportedException(); }
+ }
+
+ public override long Position
+ {
+ get { throw new NotSupportedException(); }
+ set { throw new NotSupportedException(); }
+ }
+
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ int read = stream.Read(buffer, offset, count);
+ if (read <= 0)
+ {
+ completed = true;
+ }
+ return read;
+ }
+
+ public override long Seek(long offset, SeekOrigin origin)
+ {
+ throw new NotSupportedException();
+ }
+
+ public override void SetLength(long value)
+ {
+ throw new NotSupportedException();
+ }
+
+ public override void Write(byte[] buffer, int offset, int count)
+ {
+ throw new NotSupportedException();
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/ExtractOptions.cs b/src/SharpCompress/Common/ExtractOptions.cs
similarity index 95%
rename from SharpCompress/Common/ExtractOptions.cs
rename to src/SharpCompress/Common/ExtractOptions.cs
index 0aff140e..85c92668 100644
--- a/SharpCompress/Common/ExtractOptions.cs
+++ b/src/SharpCompress/Common/ExtractOptions.cs
@@ -1,30 +1,30 @@
-using System;
-
-namespace SharpCompress.Common
-{
- [Flags]
- public enum ExtractOptions
- {
- None = 0,
-
- ///
- /// overwrite target if it exists
- ///
- Overwrite = 1 << 0,
-
- ///
- /// extract with internal directory structure
- ///
- ExtractFullPath = 1 << 1,
-
- ///
- /// preserve file time
- ///
- PreserveFileTime = 1 << 2,
-
- ///
- /// preserve windows file attributes
- ///
- PreserveAttributes = 1 << 3,
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ [Flags]
+ public enum ExtractOptions
+ {
+ None = 0,
+
+ ///
+ /// overwrite target if it exists
+ ///
+ Overwrite = 1 << 0,
+
+ ///
+ /// extract with internal directory structure
+ ///
+ ExtractFullPath = 1 << 1,
+
+ ///
+ /// preserve file time
+ ///
+ PreserveFileTime = 1 << 2,
+
+ ///
+ /// preserve windows file attributes
+ ///
+ PreserveAttributes = 1 << 3,
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/ExtractionException.cs b/src/SharpCompress/Common/ExtractionException.cs
similarity index 95%
rename from SharpCompress/Common/ExtractionException.cs
rename to src/SharpCompress/Common/ExtractionException.cs
index 15224d4d..be5e688c 100644
--- a/SharpCompress/Common/ExtractionException.cs
+++ b/src/SharpCompress/Common/ExtractionException.cs
@@ -1,17 +1,17 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public class ExtractionException : Exception
- {
- public ExtractionException(string message)
- : base(message)
- {
- }
-
- public ExtractionException(string message, Exception inner)
- : base(message, inner)
- {
- }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public class ExtractionException : Exception
+ {
+ public ExtractionException(string message)
+ : base(message)
+ {
+ }
+
+ public ExtractionException(string message, Exception inner)
+ : base(message, inner)
+ {
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/FilePart.cs b/src/SharpCompress/Common/FilePart.cs
similarity index 95%
rename from SharpCompress/Common/FilePart.cs
rename to src/SharpCompress/Common/FilePart.cs
index c9bbd636..b57ef613 100644
--- a/SharpCompress/Common/FilePart.cs
+++ b/src/SharpCompress/Common/FilePart.cs
@@ -1,12 +1,12 @@
-using System.IO;
-
-namespace SharpCompress.Common
-{
- public abstract class FilePart
- {
- internal abstract string FilePartName { get; }
-
- internal abstract Stream GetCompressedStream();
- internal abstract Stream GetRawStream();
- }
+using System.IO;
+
+namespace SharpCompress.Common
+{
+ public abstract class FilePart
+ {
+ internal abstract string FilePartName { get; }
+
+ internal abstract Stream GetCompressedStream();
+ internal abstract Stream GetRawStream();
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/FilePartExtractionBeginEventArgs.cs b/src/SharpCompress/Common/FilePartExtractionBeginEventArgs.cs
similarity index 96%
rename from SharpCompress/Common/FilePartExtractionBeginEventArgs.cs
rename to src/SharpCompress/Common/FilePartExtractionBeginEventArgs.cs
index b5742b6c..913f2093 100644
--- a/SharpCompress/Common/FilePartExtractionBeginEventArgs.cs
+++ b/src/SharpCompress/Common/FilePartExtractionBeginEventArgs.cs
@@ -1,22 +1,22 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public class FilePartExtractionBeginEventArgs : EventArgs
- {
- ///
- /// File name for the part for the current entry
- ///
- public string Name { get; internal set; }
-
- ///
- /// Uncompressed size of the current entry in the part
- ///
- public long Size { get; internal set; }
-
- ///
- /// Compressed size of the current entry in the part
- ///
- public long CompressedSize { get; internal set; }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public class FilePartExtractionBeginEventArgs : EventArgs
+ {
+ ///
+ /// File name for the part for the current entry
+ ///
+ public string Name { get; internal set; }
+
+ ///
+ /// Uncompressed size of the current entry in the part
+ ///
+ public long Size { get; internal set; }
+
+ ///
+ /// Compressed size of the current entry in the part
+ ///
+ public long CompressedSize { get; internal set; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/FlagUtility.cs b/src/SharpCompress/Common/FlagUtility.cs
similarity index 97%
rename from SharpCompress/Common/FlagUtility.cs
rename to src/SharpCompress/Common/FlagUtility.cs
index e4568348..b6fc8664 100644
--- a/SharpCompress/Common/FlagUtility.cs
+++ b/src/SharpCompress/Common/FlagUtility.cs
@@ -1,109 +1,109 @@
-using System;
-
-namespace SharpCompress.Common
-{
- internal static class FlagUtility
- {
- ///
- /// Returns true if the flag is set on the specified bit field.
- /// Currently only works with 32-bit bitfields.
- ///
- /// Enumeration with Flags attribute
- /// Flagged variable
- /// Flag to test
- ///
- public static bool HasFlag(long bitField, T flag)
- where T : struct
- {
- return HasFlag(bitField, flag);
- }
-
- ///
- /// Returns true if the flag is set on the specified bit field.
- /// Currently only works with 32-bit bitfields.
- ///
- /// Enumeration with Flags attribute
- /// Flagged variable
- /// Flag to test
- ///
- public static bool HasFlag(ulong bitField, T flag)
- where T : struct
- {
- return HasFlag(bitField, flag);
- }
-
- ///
- /// Returns true if the flag is set on the specified bit field.
- /// Currently only works with 32-bit bitfields.
- ///
- /// Flagged variable
- /// Flag to test
- ///
- public static bool HasFlag(ulong bitField, ulong flag)
- {
- return ((bitField & flag) == flag);
- }
-
- public static bool HasFlag(short bitField, short flag)
- {
- return ((bitField & flag) == flag);
- }
-
- ///
- /// Returns true if the flag is set on the specified bit field.
- /// Currently only works with 32-bit bitfields.
- ///
- /// Enumeration with Flags attribute
- /// Flagged variable
- /// Flag to test
- ///
- public static bool HasFlag(T bitField, T flag)
- where T : struct
- {
- return HasFlag(Convert.ToInt64(bitField), Convert.ToInt64(flag));
- }
-
- ///
- /// Returns true if the flag is set on the specified bit field.
- /// Currently only works with 32-bit bitfields.
- ///
- /// Flagged variable
- /// Flag to test
- ///
- public static bool HasFlag(long bitField, long flag)
- {
- return ((bitField & flag) == flag);
- }
-
-
- ///
- /// Sets a bit-field to either on or off for the specified flag.
- ///
- /// Flagged variable
- /// Flag to change
- /// bool
- /// The flagged variable with the flag changed
- public static long SetFlag(long bitField, long flag, bool @on)
- {
- if (@on)
- {
- return bitField | flag;
- }
- return bitField & (~flag);
- }
-
- ///
- /// Sets a bit-field to either on or off for the specified flag.
- ///
- /// Enumeration with Flags attribute
- /// Flagged variable
- /// Flag to change
- /// bool
- /// The flagged variable with the flag changed
- public static long SetFlag(T bitField, T flag, bool @on)
- where T : struct
- {
- return SetFlag(Convert.ToInt64(bitField), Convert.ToInt64(flag), @on);
- }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ internal static class FlagUtility
+ {
+ ///
+ /// Returns true if the flag is set on the specified bit field.
+ /// Currently only works with 32-bit bitfields.
+ ///
+ /// Enumeration with Flags attribute
+ /// Flagged variable
+ /// Flag to test
+ ///
+ public static bool HasFlag(long bitField, T flag)
+ where T : struct
+ {
+ return HasFlag(bitField, flag);
+ }
+
+ ///
+ /// Returns true if the flag is set on the specified bit field.
+ /// Currently only works with 32-bit bitfields.
+ ///
+ /// Enumeration with Flags attribute
+ /// Flagged variable
+ /// Flag to test
+ ///
+ public static bool HasFlag(ulong bitField, T flag)
+ where T : struct
+ {
+ return HasFlag(bitField, flag);
+ }
+
+ ///
+ /// Returns true if the flag is set on the specified bit field.
+ /// Currently only works with 32-bit bitfields.
+ ///
+ /// Flagged variable
+ /// Flag to test
+ ///
+ public static bool HasFlag(ulong bitField, ulong flag)
+ {
+ return ((bitField & flag) == flag);
+ }
+
+ public static bool HasFlag(short bitField, short flag)
+ {
+ return ((bitField & flag) == flag);
+ }
+
+ ///
+ /// Returns true if the flag is set on the specified bit field.
+ /// Currently only works with 32-bit bitfields.
+ ///
+ /// Enumeration with Flags attribute
+ /// Flagged variable
+ /// Flag to test
+ ///
+ public static bool HasFlag(T bitField, T flag)
+ where T : struct
+ {
+ return HasFlag(Convert.ToInt64(bitField), Convert.ToInt64(flag));
+ }
+
+ ///
+ /// Returns true if the flag is set on the specified bit field.
+ /// Currently only works with 32-bit bitfields.
+ ///
+ /// Flagged variable
+ /// Flag to test
+ ///
+ public static bool HasFlag(long bitField, long flag)
+ {
+ return ((bitField & flag) == flag);
+ }
+
+
+ ///
+ /// Sets a bit-field to either on or off for the specified flag.
+ ///
+ /// Flagged variable
+ /// Flag to change
+ /// bool
+ /// The flagged variable with the flag changed
+ public static long SetFlag(long bitField, long flag, bool @on)
+ {
+ if (@on)
+ {
+ return bitField | flag;
+ }
+ return bitField & (~flag);
+ }
+
+ ///
+ /// Sets a bit-field to either on or off for the specified flag.
+ ///
+ /// Enumeration with Flags attribute
+ /// Flagged variable
+ /// Flag to change
+ /// bool
+ /// The flagged variable with the flag changed
+ public static long SetFlag(T bitField, T flag, bool @on)
+ where T : struct
+ {
+ return SetFlag(Convert.ToInt64(bitField), Convert.ToInt64(flag), @on);
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/GZip/GZipEntry.cs b/src/SharpCompress/Common/GZip/GZipEntry.cs
similarity index 95%
rename from SharpCompress/Common/GZip/GZipEntry.cs
rename to src/SharpCompress/Common/GZip/GZipEntry.cs
index f6408f5c..3d3a23e6 100644
--- a/SharpCompress/Common/GZip/GZipEntry.cs
+++ b/src/SharpCompress/Common/GZip/GZipEntry.cs
@@ -1,86 +1,86 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-namespace SharpCompress.Common.GZip
-{
- public class GZipEntry : Entry
- {
- private readonly GZipFilePart filePart;
-
- internal GZipEntry(GZipFilePart filePart)
- {
- this.filePart = filePart;
- }
-
- public override CompressionType CompressionType
- {
- get { return CompressionType.GZip; }
- }
-
- public override long Crc
- {
- get { return 0; }
- }
-
- public override string Key
- {
- get { return filePart.FilePartName; }
- }
-
- public override long CompressedSize
- {
- get { return 0; }
- }
-
- public override long Size
- {
- get { return 0; }
- }
-
- public override DateTime? LastModifiedTime
- {
- get { return filePart.DateModified; }
- }
-
- public override DateTime? CreatedTime
- {
- get { return null; }
- }
-
- public override DateTime? LastAccessedTime
- {
- get { return null; }
- }
-
- public override DateTime? ArchivedTime
- {
- get { return null; }
- }
-
- public override bool IsEncrypted
- {
- get { return false; }
- }
-
- public override bool IsDirectory
- {
- get { return false; }
- }
-
- public override bool IsSplit
- {
- get { return false; }
- }
-
- internal override IEnumerable Parts
- {
- get { return filePart.AsEnumerable(); }
- }
-
- internal static IEnumerable GetEntries(Stream stream)
- {
- yield return new GZipEntry(new GZipFilePart(stream));
- }
- }
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace SharpCompress.Common.GZip
+{
+ public class GZipEntry : Entry
+ {
+ private readonly GZipFilePart filePart;
+
+ internal GZipEntry(GZipFilePart filePart)
+ {
+ this.filePart = filePart;
+ }
+
+ public override CompressionType CompressionType
+ {
+ get { return CompressionType.GZip; }
+ }
+
+ public override long Crc
+ {
+ get { return 0; }
+ }
+
+ public override string Key
+ {
+ get { return filePart.FilePartName; }
+ }
+
+ public override long CompressedSize
+ {
+ get { return 0; }
+ }
+
+ public override long Size
+ {
+ get { return 0; }
+ }
+
+ public override DateTime? LastModifiedTime
+ {
+ get { return filePart.DateModified; }
+ }
+
+ public override DateTime? CreatedTime
+ {
+ get { return null; }
+ }
+
+ public override DateTime? LastAccessedTime
+ {
+ get { return null; }
+ }
+
+ public override DateTime? ArchivedTime
+ {
+ get { return null; }
+ }
+
+ public override bool IsEncrypted
+ {
+ get { return false; }
+ }
+
+ public override bool IsDirectory
+ {
+ get { return false; }
+ }
+
+ public override bool IsSplit
+ {
+ get { return false; }
+ }
+
+ internal override IEnumerable Parts
+ {
+ get { return filePart.AsEnumerable(); }
+ }
+
+ internal static IEnumerable GetEntries(Stream stream)
+ {
+ yield return new GZipEntry(new GZipFilePart(stream));
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/GZip/GZipFilePart.cs b/src/SharpCompress/Common/GZip/GZipFilePart.cs
similarity index 96%
rename from SharpCompress/Common/GZip/GZipFilePart.cs
rename to src/SharpCompress/Common/GZip/GZipFilePart.cs
index 5aab3dba..1500d83a 100644
--- a/SharpCompress/Common/GZip/GZipFilePart.cs
+++ b/src/SharpCompress/Common/GZip/GZipFilePart.cs
@@ -1,103 +1,103 @@
-using System;
-using System.IO;
-using SharpCompress.Common.Tar.Headers;
-using SharpCompress.Compressor;
-using SharpCompress.Compressor.Deflate;
-
-namespace SharpCompress.Common.GZip
-{
- internal class GZipFilePart : FilePart
- {
- private string name;
- private readonly Stream stream;
-
- internal GZipFilePart(Stream stream)
- {
- ReadAndValidateGzipHeader(stream);
- this.stream = stream;
- }
-
- internal DateTime? DateModified { get; private set; }
-
- internal override string FilePartName
- {
- get { return name; }
- }
-
- internal override Stream GetCompressedStream()
- {
- return new DeflateStream(stream, CompressionMode.Decompress, CompressionLevel.Default, false);
- }
-
- internal override Stream GetRawStream()
- {
- return stream;
- }
-
- private void ReadAndValidateGzipHeader(Stream stream)
- {
- // read the header on the first read
- byte[] header = new byte[10];
- int n = stream.Read(header, 0, header.Length);
-
- // workitem 8501: handle edge case (decompress empty stream)
- if (n == 0)
- return;
-
- if (n != 10)
- throw new ZlibException("Not a valid GZIP stream.");
-
- if (header[0] != 0x1F || header[1] != 0x8B || header[2] != 8)
- throw new ZlibException("Bad GZIP header.");
-
- Int32 timet = BitConverter.ToInt32(header, 4);
- DateModified = TarHeader.Epoch.AddSeconds(timet);
- if ((header[3] & 0x04) == 0x04)
- {
- // read and discard extra field
- n = stream.Read(header, 0, 2); // 2-byte length field
-
- Int16 extraLength = (Int16) (header[0] + header[1]*256);
- byte[] extra = new byte[extraLength];
- n = stream.Read(extra, 0, extra.Length);
- if (n != extraLength)
- {
- throw new ZlibException("Unexpected end-of-file reading GZIP header.");
- }
- }
- if ((header[3] & 0x08) == 0x08)
- name = ReadZeroTerminatedString(stream);
- if ((header[3] & 0x10) == 0x010)
- ReadZeroTerminatedString(stream);
- if ((header[3] & 0x02) == 0x02)
- stream.ReadByte(); // CRC16, ignore
- }
-
-
- private static string ReadZeroTerminatedString(Stream stream)
- {
- byte[] buf1 = new byte[1];
- var list = new System.Collections.Generic.List();
- bool done = false;
- do
- {
- // workitem 7740
- int n = stream.Read(buf1, 0, 1);
- if (n != 1)
- {
- throw new ZlibException("Unexpected EOF reading GZIP header.");
- }
- if (buf1[0] == 0)
- {
- done = true;
- }
- else
- {
- list.Add(buf1[0]);
- }
- } while (!done);
- byte[] a = list.ToArray();
- return ArchiveEncoding.Default.GetString(a, 0, a.Length);
- }
- }
+using System;
+using System.IO;
+using SharpCompress.Common.Tar.Headers;
+using SharpCompress.Compressor;
+using SharpCompress.Compressor.Deflate;
+
+namespace SharpCompress.Common.GZip
+{
+ internal class GZipFilePart : FilePart
+ {
+ private string name;
+ private readonly Stream stream;
+
+ internal GZipFilePart(Stream stream)
+ {
+ ReadAndValidateGzipHeader(stream);
+ this.stream = stream;
+ }
+
+ internal DateTime? DateModified { get; private set; }
+
+ internal override string FilePartName
+ {
+ get { return name; }
+ }
+
+ internal override Stream GetCompressedStream()
+ {
+ return new DeflateStream(stream, CompressionMode.Decompress, CompressionLevel.Default, false);
+ }
+
+ internal override Stream GetRawStream()
+ {
+ return stream;
+ }
+
+ private void ReadAndValidateGzipHeader(Stream stream)
+ {
+ // read the header on the first read
+ byte[] header = new byte[10];
+ int n = stream.Read(header, 0, header.Length);
+
+ // workitem 8501: handle edge case (decompress empty stream)
+ if (n == 0)
+ return;
+
+ if (n != 10)
+ throw new ZlibException("Not a valid GZIP stream.");
+
+ if (header[0] != 0x1F || header[1] != 0x8B || header[2] != 8)
+ throw new ZlibException("Bad GZIP header.");
+
+ Int32 timet = BitConverter.ToInt32(header, 4);
+ DateModified = TarHeader.Epoch.AddSeconds(timet);
+ if ((header[3] & 0x04) == 0x04)
+ {
+ // read and discard extra field
+ n = stream.Read(header, 0, 2); // 2-byte length field
+
+ Int16 extraLength = (Int16) (header[0] + header[1]*256);
+ byte[] extra = new byte[extraLength];
+ n = stream.Read(extra, 0, extra.Length);
+ if (n != extraLength)
+ {
+ throw new ZlibException("Unexpected end-of-file reading GZIP header.");
+ }
+ }
+ if ((header[3] & 0x08) == 0x08)
+ name = ReadZeroTerminatedString(stream);
+ if ((header[3] & 0x10) == 0x010)
+ ReadZeroTerminatedString(stream);
+ if ((header[3] & 0x02) == 0x02)
+ stream.ReadByte(); // CRC16, ignore
+ }
+
+
+ private static string ReadZeroTerminatedString(Stream stream)
+ {
+ byte[] buf1 = new byte[1];
+ var list = new System.Collections.Generic.List();
+ bool done = false;
+ do
+ {
+ // workitem 7740
+ int n = stream.Read(buf1, 0, 1);
+ if (n != 1)
+ {
+ throw new ZlibException("Unexpected EOF reading GZIP header.");
+ }
+ if (buf1[0] == 0)
+ {
+ done = true;
+ }
+ else
+ {
+ list.Add(buf1[0]);
+ }
+ } while (!done);
+ byte[] a = list.ToArray();
+ return ArchiveEncoding.Default.GetString(a, 0, a.Length);
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/GZip/GZipVolume.cs b/src/SharpCompress/Common/GZip/GZipVolume.cs
similarity index 95%
rename from SharpCompress/Common/GZip/GZipVolume.cs
rename to src/SharpCompress/Common/GZip/GZipVolume.cs
index 5b8b6fcc..17adc11d 100644
--- a/SharpCompress/Common/GZip/GZipVolume.cs
+++ b/src/SharpCompress/Common/GZip/GZipVolume.cs
@@ -1,34 +1,34 @@
-using System.IO;
-
-namespace SharpCompress.Common.GZip
-{
- public class GZipVolume : Volume
- {
-#if !DOTNET51
- private readonly FileInfo fileInfo;
-#endif
-
- public GZipVolume(Stream stream, Options options)
- : base(stream, options)
- {
- }
-
-#if !DOTNET51
- public GZipVolume(FileInfo fileInfo, Options options)
- : base(fileInfo.OpenRead(), options)
- {
- this.fileInfo = fileInfo;
- }
-#endif
-
- public override bool IsFirstVolume
- {
- get { return true; }
- }
-
- public override bool IsMultiVolume
- {
- get { return true; }
- }
- }
+using System.IO;
+
+namespace SharpCompress.Common.GZip
+{
+ public class GZipVolume : Volume
+ {
+#if !DOTNET51
+ private readonly FileInfo fileInfo;
+#endif
+
+ public GZipVolume(Stream stream, Options options)
+ : base(stream, options)
+ {
+ }
+
+#if !DOTNET51
+ public GZipVolume(FileInfo fileInfo, Options options)
+ : base(fileInfo.OpenRead(), options)
+ {
+ this.fileInfo = fileInfo;
+ }
+#endif
+
+ public override bool IsFirstVolume
+ {
+ get { return true; }
+ }
+
+ public override bool IsMultiVolume
+ {
+ get { return true; }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/IEntry.cs b/src/SharpCompress/Common/IEntry.cs
similarity index 96%
rename from SharpCompress/Common/IEntry.cs
rename to src/SharpCompress/Common/IEntry.cs
index 22a18c50..ac15828c 100644
--- a/SharpCompress/Common/IEntry.cs
+++ b/src/SharpCompress/Common/IEntry.cs
@@ -1,21 +1,21 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public interface IEntry
- {
- CompressionType CompressionType { get; }
- DateTime? ArchivedTime { get; }
- long CompressedSize { get; }
- long Crc { get; }
- DateTime? CreatedTime { get; }
- string Key { get; }
- bool IsDirectory { get; }
- bool IsEncrypted { get; }
- bool IsSplit { get; }
- DateTime? LastAccessedTime { get; }
- DateTime? LastModifiedTime { get; }
- long Size { get; }
- int? Attrib { get; }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public interface IEntry
+ {
+ CompressionType CompressionType { get; }
+ DateTime? ArchivedTime { get; }
+ long CompressedSize { get; }
+ long Crc { get; }
+ DateTime? CreatedTime { get; }
+ string Key { get; }
+ bool IsDirectory { get; }
+ bool IsEncrypted { get; }
+ bool IsSplit { get; }
+ DateTime? LastAccessedTime { get; }
+ DateTime? LastModifiedTime { get; }
+ long Size { get; }
+ int? Attrib { get; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/IExtractionListener.cs b/src/SharpCompress/Common/IExtractionListener.cs
similarity index 97%
rename from SharpCompress/Common/IExtractionListener.cs
rename to src/SharpCompress/Common/IExtractionListener.cs
index b46a37e4..b6fb50fc 100644
--- a/SharpCompress/Common/IExtractionListener.cs
+++ b/src/SharpCompress/Common/IExtractionListener.cs
@@ -1,8 +1,8 @@
-namespace SharpCompress.Common
-{
- internal interface IExtractionListener
- {
- void FireFilePartExtractionBegin(string name, long size, long compressedSize);
- void FireCompressedBytesRead(long currentPartCompressedBytes, long compressedReadBytes);
- }
+namespace SharpCompress.Common
+{
+ internal interface IExtractionListener
+ {
+ void FireFilePartExtractionBegin(string name, long size, long compressedSize);
+ void FireCompressedBytesRead(long currentPartCompressedBytes, long compressedReadBytes);
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/IVolume.cs b/src/SharpCompress/Common/IVolume.cs
similarity index 93%
rename from SharpCompress/Common/IVolume.cs
rename to src/SharpCompress/Common/IVolume.cs
index 5b3ae795..bf373383 100644
--- a/SharpCompress/Common/IVolume.cs
+++ b/src/SharpCompress/Common/IVolume.cs
@@ -1,11 +1,11 @@
-using System;
-#if !DOTNET51
-using System.IO;
-#endif
-
-namespace SharpCompress.Common
-{
- public interface IVolume : IDisposable
- {
- }
+using System;
+#if !DOTNET51
+using System.IO;
+#endif
+
+namespace SharpCompress.Common
+{
+ public interface IVolume : IDisposable
+ {
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/IncompleteArchiveException.cs b/src/SharpCompress/Common/IncompleteArchiveException.cs
similarity index 96%
rename from SharpCompress/Common/IncompleteArchiveException.cs
rename to src/SharpCompress/Common/IncompleteArchiveException.cs
index 21b24cfd..78d567f4 100644
--- a/SharpCompress/Common/IncompleteArchiveException.cs
+++ b/src/SharpCompress/Common/IncompleteArchiveException.cs
@@ -1,10 +1,10 @@
-namespace SharpCompress.Common
-{
- public class IncompleteArchiveException : ArchiveException
- {
- public IncompleteArchiveException(string message)
- : base(message)
- {
- }
- }
+namespace SharpCompress.Common
+{
+ public class IncompleteArchiveException : ArchiveException
+ {
+ public IncompleteArchiveException(string message)
+ : base(message)
+ {
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/InvalidFormatException.cs b/src/SharpCompress/Common/InvalidFormatException.cs
similarity index 95%
rename from SharpCompress/Common/InvalidFormatException.cs
rename to src/SharpCompress/Common/InvalidFormatException.cs
index d0b16865..fa141cb4 100644
--- a/SharpCompress/Common/InvalidFormatException.cs
+++ b/src/SharpCompress/Common/InvalidFormatException.cs
@@ -1,17 +1,17 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public class InvalidFormatException : ExtractionException
- {
- public InvalidFormatException(string message)
- : base(message)
- {
- }
-
- public InvalidFormatException(string message, Exception inner)
- : base(message, inner)
- {
- }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public class InvalidFormatException : ExtractionException
+ {
+ public InvalidFormatException(string message)
+ : base(message)
+ {
+ }
+
+ public InvalidFormatException(string message, Exception inner)
+ : base(message, inner)
+ {
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/MultiVolumeExtractionException.cs b/src/SharpCompress/Common/MultiVolumeExtractionException.cs
similarity index 95%
rename from SharpCompress/Common/MultiVolumeExtractionException.cs
rename to src/SharpCompress/Common/MultiVolumeExtractionException.cs
index a0ea22ac..d9b97fa3 100644
--- a/SharpCompress/Common/MultiVolumeExtractionException.cs
+++ b/src/SharpCompress/Common/MultiVolumeExtractionException.cs
@@ -1,17 +1,17 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public class MultiVolumeExtractionException : ExtractionException
- {
- public MultiVolumeExtractionException(string message)
- : base(message)
- {
- }
-
- public MultiVolumeExtractionException(string message, Exception inner)
- : base(message, inner)
- {
- }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public class MultiVolumeExtractionException : ExtractionException
+ {
+ public MultiVolumeExtractionException(string message)
+ : base(message)
+ {
+ }
+
+ public MultiVolumeExtractionException(string message, Exception inner)
+ : base(message, inner)
+ {
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/MultipartStreamRequiredException.cs b/src/SharpCompress/Common/MultipartStreamRequiredException.cs
similarity index 96%
rename from SharpCompress/Common/MultipartStreamRequiredException.cs
rename to src/SharpCompress/Common/MultipartStreamRequiredException.cs
index 2c441407..cf030ed6 100644
--- a/SharpCompress/Common/MultipartStreamRequiredException.cs
+++ b/src/SharpCompress/Common/MultipartStreamRequiredException.cs
@@ -1,10 +1,10 @@
-namespace SharpCompress.Common
-{
- public class MultipartStreamRequiredException : ExtractionException
- {
- public MultipartStreamRequiredException(string message)
- : base(message)
- {
- }
- }
+namespace SharpCompress.Common
+{
+ public class MultipartStreamRequiredException : ExtractionException
+ {
+ public MultipartStreamRequiredException(string message)
+ : base(message)
+ {
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Options.cs b/src/SharpCompress/Common/Options.cs
similarity index 96%
rename from SharpCompress/Common/Options.cs
rename to src/SharpCompress/Common/Options.cs
index d7d4b372..32ec2d0c 100644
--- a/SharpCompress/Common/Options.cs
+++ b/src/SharpCompress/Common/Options.cs
@@ -1,23 +1,23 @@
-using System;
-
-namespace SharpCompress.Common
-{
- [Flags]
- public enum Options
- {
- ///
- /// No options specified
- ///
- None = 0,
-
- ///
- /// SharpCompress will keep the supplied streams open
- ///
- KeepStreamsOpen = 1,
-
- ///
- /// Look for RarArchive (Check for self-extracting archives or cases where RarArchive isn't at the start of the file)
- ///
- LookForHeader = 2,
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ [Flags]
+ public enum Options
+ {
+ ///
+ /// No options specified
+ ///
+ None = 0,
+
+ ///
+ /// SharpCompress will keep the supplied streams open
+ ///
+ KeepStreamsOpen = 1,
+
+ ///
+ /// Look for RarArchive (Check for self-extracting archives or cases where RarArchive isn't at the start of the file)
+ ///
+ LookForHeader = 2,
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/PasswordProtectedException.cs b/src/SharpCompress/Common/PasswordProtectedException.cs
similarity index 95%
rename from SharpCompress/Common/PasswordProtectedException.cs
rename to src/SharpCompress/Common/PasswordProtectedException.cs
index cfd3a809..58dc7660 100644
--- a/SharpCompress/Common/PasswordProtectedException.cs
+++ b/src/SharpCompress/Common/PasswordProtectedException.cs
@@ -1,17 +1,17 @@
-using System;
-
-namespace SharpCompress.Common
-{
- public class PasswordProtectedException : ExtractionException
- {
- public PasswordProtectedException(string message)
- : base(message)
- {
- }
-
- public PasswordProtectedException(string message, Exception inner)
- : base(message, inner)
- {
- }
- }
+using System;
+
+namespace SharpCompress.Common
+{
+ public class PasswordProtectedException : ExtractionException
+ {
+ public PasswordProtectedException(string message)
+ : base(message)
+ {
+ }
+
+ public PasswordProtectedException(string message, Exception inner)
+ : base(message, inner)
+ {
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/AVHeader.cs b/src/SharpCompress/Common/Rar/Headers/AVHeader.cs
similarity index 96%
rename from SharpCompress/Common/Rar/Headers/AVHeader.cs
rename to src/SharpCompress/Common/Rar/Headers/AVHeader.cs
index d3ff7580..acb878ba 100644
--- a/SharpCompress/Common/Rar/Headers/AVHeader.cs
+++ b/src/SharpCompress/Common/Rar/Headers/AVHeader.cs
@@ -1,20 +1,20 @@
-using SharpCompress.IO;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- internal class SignHeader : RarHeader
- {
- protected override void ReadFromReader(MarkingBinaryReader reader)
- {
- CreationTime = reader.ReadInt32();
- ArcNameSize = reader.ReadInt16();
- UserNameSize = reader.ReadInt16();
- }
-
- internal int CreationTime { get; private set; }
-
- internal short ArcNameSize { get; private set; }
-
- internal short UserNameSize { get; private set; }
- }
+using SharpCompress.IO;
+
+namespace SharpCompress.Common.Rar.Headers
+{
+ internal class SignHeader : RarHeader
+ {
+ protected override void ReadFromReader(MarkingBinaryReader reader)
+ {
+ CreationTime = reader.ReadInt32();
+ ArcNameSize = reader.ReadInt16();
+ UserNameSize = reader.ReadInt16();
+ }
+
+ internal int CreationTime { get; private set; }
+
+ internal short ArcNameSize { get; private set; }
+
+ internal short UserNameSize { get; private set; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/ArchiveHeader.cs b/src/SharpCompress/Common/Rar/Headers/ArchiveHeader.cs
similarity index 96%
rename from SharpCompress/Common/Rar/Headers/ArchiveHeader.cs
rename to src/SharpCompress/Common/Rar/Headers/ArchiveHeader.cs
index 7c79f072..2de02de0 100644
--- a/SharpCompress/Common/Rar/Headers/ArchiveHeader.cs
+++ b/src/SharpCompress/Common/Rar/Headers/ArchiveHeader.cs
@@ -1,36 +1,36 @@
-using SharpCompress.IO;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- internal class ArchiveHeader : RarHeader
- {
- internal const short mainHeaderSizeWithEnc = 7;
- internal const short mainHeaderSize = 6;
-
- protected override void ReadFromReader(MarkingBinaryReader reader)
- {
- HighPosAv = reader.ReadInt16();
- PosAv = reader.ReadInt32();
- if (ArchiveHeaderFlags.HasFlag(ArchiveFlags.ENCRYPTVER))
- {
- EncryptionVersion = reader.ReadByte();
- }
- }
-
- internal ArchiveFlags ArchiveHeaderFlags
- {
- get { return (ArchiveFlags) base.Flags; }
- }
-
- internal short HighPosAv { get; private set; }
-
- internal int PosAv { get; private set; }
-
- internal byte EncryptionVersion { get; private set; }
-
- public bool HasPassword
- {
- get { return ArchiveHeaderFlags.HasFlag(ArchiveFlags.PASSWORD); }
- }
- }
+using SharpCompress.IO;
+
+namespace SharpCompress.Common.Rar.Headers
+{
+ internal class ArchiveHeader : RarHeader
+ {
+ internal const short mainHeaderSizeWithEnc = 7;
+ internal const short mainHeaderSize = 6;
+
+ protected override void ReadFromReader(MarkingBinaryReader reader)
+ {
+ HighPosAv = reader.ReadInt16();
+ PosAv = reader.ReadInt32();
+ if (ArchiveHeaderFlags.HasFlag(ArchiveFlags.ENCRYPTVER))
+ {
+ EncryptionVersion = reader.ReadByte();
+ }
+ }
+
+ internal ArchiveFlags ArchiveHeaderFlags
+ {
+ get { return (ArchiveFlags) base.Flags; }
+ }
+
+ internal short HighPosAv { get; private set; }
+
+ internal int PosAv { get; private set; }
+
+ internal byte EncryptionVersion { get; private set; }
+
+ public bool HasPassword
+ {
+ get { return ArchiveHeaderFlags.HasFlag(ArchiveFlags.PASSWORD); }
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/CommentHeader.cs b/src/SharpCompress/Common/Rar/Headers/CommentHeader.cs
similarity index 96%
rename from SharpCompress/Common/Rar/Headers/CommentHeader.cs
rename to src/SharpCompress/Common/Rar/Headers/CommentHeader.cs
index b170e6e4..c9943bde 100644
--- a/SharpCompress/Common/Rar/Headers/CommentHeader.cs
+++ b/src/SharpCompress/Common/Rar/Headers/CommentHeader.cs
@@ -1,22 +1,22 @@
-using SharpCompress.IO;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- internal class CommentHeader : RarHeader
- {
- protected override void ReadFromReader(MarkingBinaryReader reader)
- {
- UnpSize = reader.ReadInt16();
- UnpVersion = reader.ReadByte();
- UnpMethod = reader.ReadByte();
- CommCRC = reader.ReadInt16();
- }
-
- internal short UnpSize { get; private set; }
-
- internal byte UnpVersion { get; private set; }
-
- internal byte UnpMethod { get; private set; }
- internal short CommCRC { get; private set; }
- }
+using SharpCompress.IO;
+
+namespace SharpCompress.Common.Rar.Headers
+{
+ internal class CommentHeader : RarHeader
+ {
+ protected override void ReadFromReader(MarkingBinaryReader reader)
+ {
+ UnpSize = reader.ReadInt16();
+ UnpVersion = reader.ReadByte();
+ UnpMethod = reader.ReadByte();
+ CommCRC = reader.ReadInt16();
+ }
+
+ internal short UnpSize { get; private set; }
+
+ internal byte UnpVersion { get; private set; }
+
+ internal byte UnpMethod { get; private set; }
+ internal short CommCRC { get; private set; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/EndArchiveHeader.cs b/src/SharpCompress/Common/Rar/Headers/EndArchiveHeader.cs
similarity index 96%
rename from SharpCompress/Common/Rar/Headers/EndArchiveHeader.cs
rename to src/SharpCompress/Common/Rar/Headers/EndArchiveHeader.cs
index 7ae9c06e..95bc6f07 100644
--- a/SharpCompress/Common/Rar/Headers/EndArchiveHeader.cs
+++ b/src/SharpCompress/Common/Rar/Headers/EndArchiveHeader.cs
@@ -1,28 +1,28 @@
-using SharpCompress.IO;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- internal class EndArchiveHeader : RarHeader
- {
- protected override void ReadFromReader(MarkingBinaryReader reader)
- {
- if (EndArchiveFlags.HasFlag(EndArchiveFlags.EARC_DATACRC))
- {
- ArchiveCRC = reader.ReadInt32();
- }
- if (EndArchiveFlags.HasFlag(EndArchiveFlags.EARC_VOLNUMBER))
- {
- VolumeNumber = reader.ReadInt16();
- }
- }
-
- internal EndArchiveFlags EndArchiveFlags
- {
- get { return (EndArchiveFlags) base.Flags; }
- }
-
- internal int? ArchiveCRC { get; private set; }
-
- internal short? VolumeNumber { get; private set; }
- }
+using SharpCompress.IO;
+
+namespace SharpCompress.Common.Rar.Headers
+{
+ internal class EndArchiveHeader : RarHeader
+ {
+ protected override void ReadFromReader(MarkingBinaryReader reader)
+ {
+ if (EndArchiveFlags.HasFlag(EndArchiveFlags.EARC_DATACRC))
+ {
+ ArchiveCRC = reader.ReadInt32();
+ }
+ if (EndArchiveFlags.HasFlag(EndArchiveFlags.EARC_VOLNUMBER))
+ {
+ VolumeNumber = reader.ReadInt16();
+ }
+ }
+
+ internal EndArchiveFlags EndArchiveFlags
+ {
+ get { return (EndArchiveFlags) base.Flags; }
+ }
+
+ internal int? ArchiveCRC { get; private set; }
+
+ internal short? VolumeNumber { get; private set; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/FileHeader.cs b/src/SharpCompress/Common/Rar/Headers/FileHeader.cs
similarity index 97%
rename from SharpCompress/Common/Rar/Headers/FileHeader.cs
rename to src/SharpCompress/Common/Rar/Headers/FileHeader.cs
index 9276d48a..c76c005d 100644
--- a/SharpCompress/Common/Rar/Headers/FileHeader.cs
+++ b/src/SharpCompress/Common/Rar/Headers/FileHeader.cs
@@ -1,233 +1,233 @@
-using System;
-using System.IO;
-using SharpCompress.IO;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- internal class FileHeader : RarHeader
- {
- private const byte SALT_SIZE = 8;
-
- private const byte NEWLHD_SIZE = 32;
-
- protected override void ReadFromReader(MarkingBinaryReader reader)
- {
- uint lowUncompressedSize = reader.ReadUInt32();
-
- HostOS = (HostOS)reader.ReadByte();
-
- FileCRC = reader.ReadUInt32();
-
- FileLastModifiedTime = Utility.DosDateToDateTime(reader.ReadInt32());
-
- RarVersion = reader.ReadByte();
- PackingMethod = reader.ReadByte();
-
- short nameSize = reader.ReadInt16();
-
- FileAttributes = reader.ReadInt32();
-
- uint highCompressedSize = 0;
- uint highUncompressedkSize = 0;
- if (FileFlags.HasFlag(FileFlags.LARGE))
- {
- highCompressedSize = reader.ReadUInt32();
- highUncompressedkSize = reader.ReadUInt32();
- }
- else
- {
- if (lowUncompressedSize == 0xffffffff)
- {
- lowUncompressedSize = 0xffffffff;
- highUncompressedkSize = int.MaxValue;
- }
- }
- CompressedSize = UInt32To64(highCompressedSize, AdditionalSize);
- UncompressedSize = UInt32To64(highUncompressedkSize, lowUncompressedSize);
-
- nameSize = nameSize > 4 * 1024 ? (short)(4 * 1024) : nameSize;
-
- byte[] fileNameBytes = reader.ReadBytes(nameSize);
-
- switch (HeaderType)
- {
- case HeaderType.FileHeader:
- {
- if (FileFlags.HasFlag(FileFlags.UNICODE))
- {
- int length = 0;
- while (length < fileNameBytes.Length
- && fileNameBytes[length] != 0)
- {
- length++;
- }
- if (length != nameSize)
- {
- length++;
- FileName = FileNameDecoder.Decode(fileNameBytes, length);
- }
- else
- {
- FileName = DecodeDefault(fileNameBytes);
- }
- }
- else
- {
- FileName = DecodeDefault(fileNameBytes);
- }
- FileName = ConvertPath(FileName, HostOS);
- }
- break;
- case HeaderType.NewSubHeader:
- {
- int datasize = HeaderSize - NEWLHD_SIZE - nameSize;
- if (FileFlags.HasFlag(FileFlags.SALT))
- {
- datasize -= SALT_SIZE;
- }
- if (datasize > 0)
- {
- SubData = reader.ReadBytes(datasize);
- }
-
- if (NewSubHeaderType.SUBHEAD_TYPE_RR.Equals(fileNameBytes))
- {
- RecoverySectors = SubData[8] + (SubData[9] << 8)
- + (SubData[10] << 16) + (SubData[11] << 24);
- }
- }
- break;
- }
-
- if (FileFlags.HasFlag(FileFlags.SALT))
- {
- Salt = reader.ReadBytes(SALT_SIZE);
- }
- if (FileFlags.HasFlag(FileFlags.EXTTIME))
- {
- // verify that the end of the header hasn't been reached before reading the Extended Time.
- // some tools incorrectly omit Extended Time despite specifying FileFlags.EXTTIME, which most parsers tolerate.
- if (ReadBytes + reader.CurrentReadByteCount <= HeaderSize - 2)
- {
- ushort extendedFlags = reader.ReadUInt16();
- FileLastModifiedTime = ProcessExtendedTime(extendedFlags, FileLastModifiedTime, reader, 0);
- FileCreatedTime = ProcessExtendedTime(extendedFlags, null, reader, 1);
- FileLastAccessedTime = ProcessExtendedTime(extendedFlags, null, reader, 2);
- FileArchivedTime = ProcessExtendedTime(extendedFlags, null, reader, 3);
- }
- }
- }
-
- //only the full .net framework will do other code pages than unicode/utf8
- private string DecodeDefault(byte[] bytes)
- {
- return ArchiveEncoding.Default.GetString(bytes, 0, bytes.Length);
- }
-
- private long UInt32To64(uint x, uint y)
- {
- long l = x;
- l <<= 32;
- return l + y;
- }
-
- private static DateTime? ProcessExtendedTime(ushort extendedFlags, DateTime? time, MarkingBinaryReader reader,
- int i)
- {
- uint rmode = (uint)extendedFlags >> (3 - i) * 4;
- if ((rmode & 8) == 0)
- {
- return null;
- }
- if (i != 0)
- {
- uint DosTime = reader.ReadUInt32();
- time = Utility.DosDateToDateTime(DosTime);
- }
- if ((rmode & 4) == 0)
- {
- time = time.Value.AddSeconds(1);
- }
- uint nanosecondHundreds = 0;
- int count = (int)rmode & 3;
- for (int j = 0; j < count; j++)
- {
- byte b = reader.ReadByte();
- nanosecondHundreds |= (((uint)b) << ((j + 3 - count) * 8));
- }
- //10^-7 to 10^-3
- return time.Value.AddMilliseconds(nanosecondHundreds * Math.Pow(10, -4));
- }
-
- private static string ConvertPath(string path, HostOS os)
- {
-#if DOTNET51
- return path.Replace('\\', '/');
-#else
- switch (os)
- {
- case HostOS.MacOS:
- case HostOS.Unix:
- {
- if (Path.DirectorySeparatorChar == '\\')
- {
- return path.Replace('/', '\\');
- }
- }
- break;
- default:
- {
- if (Path.DirectorySeparatorChar == '/')
- {
- return path.Replace('\\', '/');
- }
- }
- break;
- }
- return path;
-#endif
- }
-
- internal long DataStartPosition { get; set; }
- internal HostOS HostOS { get; private set; }
-
- internal uint FileCRC { get; private set; }
-
- internal DateTime? FileLastModifiedTime { get; private set; }
-
- internal DateTime? FileCreatedTime { get; private set; }
-
- internal DateTime? FileLastAccessedTime { get; private set; }
-
- internal DateTime? FileArchivedTime { get; private set; }
-
- internal byte RarVersion { get; private set; }
-
- internal byte PackingMethod { get; private set; }
-
- internal int FileAttributes { get; private set; }
-
- internal FileFlags FileFlags
- {
- get { return (FileFlags)base.Flags; }
- }
-
- internal long CompressedSize { get; private set; }
- internal long UncompressedSize { get; private set; }
-
- internal string FileName { get; private set; }
-
- internal byte[] SubData { get; private set; }
-
- internal int RecoverySectors { get; private set; }
-
- internal byte[] Salt { get; private set; }
-
- public override string ToString()
- {
- return FileName;
- }
-
- public Stream PackedStream { get; set; }
- }
+using System;
+using System.IO;
+using SharpCompress.IO;
+
+namespace SharpCompress.Common.Rar.Headers
+{
+ internal class FileHeader : RarHeader
+ {
+ private const byte SALT_SIZE = 8;
+
+ private const byte NEWLHD_SIZE = 32;
+
+ protected override void ReadFromReader(MarkingBinaryReader reader)
+ {
+ uint lowUncompressedSize = reader.ReadUInt32();
+
+ HostOS = (HostOS)reader.ReadByte();
+
+ FileCRC = reader.ReadUInt32();
+
+ FileLastModifiedTime = Utility.DosDateToDateTime(reader.ReadInt32());
+
+ RarVersion = reader.ReadByte();
+ PackingMethod = reader.ReadByte();
+
+ short nameSize = reader.ReadInt16();
+
+ FileAttributes = reader.ReadInt32();
+
+ uint highCompressedSize = 0;
+ uint highUncompressedkSize = 0;
+ if (FileFlags.HasFlag(FileFlags.LARGE))
+ {
+ highCompressedSize = reader.ReadUInt32();
+ highUncompressedkSize = reader.ReadUInt32();
+ }
+ else
+ {
+ if (lowUncompressedSize == 0xffffffff)
+ {
+ lowUncompressedSize = 0xffffffff;
+ highUncompressedkSize = int.MaxValue;
+ }
+ }
+ CompressedSize = UInt32To64(highCompressedSize, AdditionalSize);
+ UncompressedSize = UInt32To64(highUncompressedkSize, lowUncompressedSize);
+
+ nameSize = nameSize > 4 * 1024 ? (short)(4 * 1024) : nameSize;
+
+ byte[] fileNameBytes = reader.ReadBytes(nameSize);
+
+ switch (HeaderType)
+ {
+ case HeaderType.FileHeader:
+ {
+ if (FileFlags.HasFlag(FileFlags.UNICODE))
+ {
+ int length = 0;
+ while (length < fileNameBytes.Length
+ && fileNameBytes[length] != 0)
+ {
+ length++;
+ }
+ if (length != nameSize)
+ {
+ length++;
+ FileName = FileNameDecoder.Decode(fileNameBytes, length);
+ }
+ else
+ {
+ FileName = DecodeDefault(fileNameBytes);
+ }
+ }
+ else
+ {
+ FileName = DecodeDefault(fileNameBytes);
+ }
+ FileName = ConvertPath(FileName, HostOS);
+ }
+ break;
+ case HeaderType.NewSubHeader:
+ {
+ int datasize = HeaderSize - NEWLHD_SIZE - nameSize;
+ if (FileFlags.HasFlag(FileFlags.SALT))
+ {
+ datasize -= SALT_SIZE;
+ }
+ if (datasize > 0)
+ {
+ SubData = reader.ReadBytes(datasize);
+ }
+
+ if (NewSubHeaderType.SUBHEAD_TYPE_RR.Equals(fileNameBytes))
+ {
+ RecoverySectors = SubData[8] + (SubData[9] << 8)
+ + (SubData[10] << 16) + (SubData[11] << 24);
+ }
+ }
+ break;
+ }
+
+ if (FileFlags.HasFlag(FileFlags.SALT))
+ {
+ Salt = reader.ReadBytes(SALT_SIZE);
+ }
+ if (FileFlags.HasFlag(FileFlags.EXTTIME))
+ {
+ // verify that the end of the header hasn't been reached before reading the Extended Time.
+ // some tools incorrectly omit Extended Time despite specifying FileFlags.EXTTIME, which most parsers tolerate.
+ if (ReadBytes + reader.CurrentReadByteCount <= HeaderSize - 2)
+ {
+ ushort extendedFlags = reader.ReadUInt16();
+ FileLastModifiedTime = ProcessExtendedTime(extendedFlags, FileLastModifiedTime, reader, 0);
+ FileCreatedTime = ProcessExtendedTime(extendedFlags, null, reader, 1);
+ FileLastAccessedTime = ProcessExtendedTime(extendedFlags, null, reader, 2);
+ FileArchivedTime = ProcessExtendedTime(extendedFlags, null, reader, 3);
+ }
+ }
+ }
+
+ //only the full .net framework will do other code pages than unicode/utf8
+ private string DecodeDefault(byte[] bytes)
+ {
+ return ArchiveEncoding.Default.GetString(bytes, 0, bytes.Length);
+ }
+
+ private long UInt32To64(uint x, uint y)
+ {
+ long l = x;
+ l <<= 32;
+ return l + y;
+ }
+
+ private static DateTime? ProcessExtendedTime(ushort extendedFlags, DateTime? time, MarkingBinaryReader reader,
+ int i)
+ {
+ uint rmode = (uint)extendedFlags >> (3 - i) * 4;
+ if ((rmode & 8) == 0)
+ {
+ return null;
+ }
+ if (i != 0)
+ {
+ uint DosTime = reader.ReadUInt32();
+ time = Utility.DosDateToDateTime(DosTime);
+ }
+ if ((rmode & 4) == 0)
+ {
+ time = time.Value.AddSeconds(1);
+ }
+ uint nanosecondHundreds = 0;
+ int count = (int)rmode & 3;
+ for (int j = 0; j < count; j++)
+ {
+ byte b = reader.ReadByte();
+ nanosecondHundreds |= (((uint)b) << ((j + 3 - count) * 8));
+ }
+ //10^-7 to 10^-3
+ return time.Value.AddMilliseconds(nanosecondHundreds * Math.Pow(10, -4));
+ }
+
+ private static string ConvertPath(string path, HostOS os)
+ {
+#if DOTNET51
+ return path.Replace('\\', '/');
+#else
+ switch (os)
+ {
+ case HostOS.MacOS:
+ case HostOS.Unix:
+ {
+ if (Path.DirectorySeparatorChar == '\\')
+ {
+ return path.Replace('/', '\\');
+ }
+ }
+ break;
+ default:
+ {
+ if (Path.DirectorySeparatorChar == '/')
+ {
+ return path.Replace('\\', '/');
+ }
+ }
+ break;
+ }
+ return path;
+#endif
+ }
+
+ internal long DataStartPosition { get; set; }
+ internal HostOS HostOS { get; private set; }
+
+ internal uint FileCRC { get; private set; }
+
+ internal DateTime? FileLastModifiedTime { get; private set; }
+
+ internal DateTime? FileCreatedTime { get; private set; }
+
+ internal DateTime? FileLastAccessedTime { get; private set; }
+
+ internal DateTime? FileArchivedTime { get; private set; }
+
+ internal byte RarVersion { get; private set; }
+
+ internal byte PackingMethod { get; private set; }
+
+ internal int FileAttributes { get; private set; }
+
+ internal FileFlags FileFlags
+ {
+ get { return (FileFlags)base.Flags; }
+ }
+
+ internal long CompressedSize { get; private set; }
+ internal long UncompressedSize { get; private set; }
+
+ internal string FileName { get; private set; }
+
+ internal byte[] SubData { get; private set; }
+
+ internal int RecoverySectors { get; private set; }
+
+ internal byte[] Salt { get; private set; }
+
+ public override string ToString()
+ {
+ return FileName;
+ }
+
+ public Stream PackedStream { get; set; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/FileNameDecoder.cs b/src/SharpCompress/Common/Rar/Headers/FileNameDecoder.cs
similarity index 97%
rename from SharpCompress/Common/Rar/Headers/FileNameDecoder.cs
rename to src/SharpCompress/Common/Rar/Headers/FileNameDecoder.cs
index 97d6644a..a9cb6ebc 100644
--- a/SharpCompress/Common/Rar/Headers/FileNameDecoder.cs
+++ b/src/SharpCompress/Common/Rar/Headers/FileNameDecoder.cs
@@ -1,78 +1,78 @@
-using System.Text;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- ///
- /// This is for the crazy Rar encoding that I don't understand
- ///
- internal static class FileNameDecoder
- {
- internal static int GetChar(byte[] name, int pos)
- {
- return name[pos] & 0xff;
- }
-
- internal static string Decode(byte[] name, int encPos)
- {
- int decPos = 0;
- int flags = 0;
- int flagBits = 0;
-
- int low = 0;
- int high = 0;
- int highByte = GetChar(name, encPos++);
- StringBuilder buf = new StringBuilder();
- while (encPos < name.Length)
- {
- if (flagBits == 0)
- {
- flags = GetChar(name, encPos++);
- flagBits = 8;
- }
- switch (flags >> 6)
- {
- case 0:
- buf.Append((char) (GetChar(name, encPos++)));
- ++decPos;
- break;
-
- case 1:
- buf.Append((char) (GetChar(name, encPos++) + (highByte << 8)));
- ++decPos;
- break;
-
- case 2:
- low = GetChar(name, encPos);
- high = GetChar(name, encPos + 1);
- buf.Append((char) ((high << 8) + low));
- ++decPos;
- encPos += 2;
- break;
-
- case 3:
- int length = GetChar(name, encPos++);
- if ((length & 0x80) != 0)
- {
- int correction = GetChar(name, encPos++);
- for (length = (length & 0x7f) + 2; length > 0 && decPos < name.Length; length--, decPos++)
- {
- low = (GetChar(name, decPos) + correction) & 0xff;
- buf.Append((char) ((highByte << 8) + low));
- }
- }
- else
- {
- for (length += 2; length > 0 && decPos < name.Length; length--, decPos++)
- {
- buf.Append((char) (GetChar(name, decPos)));
- }
- }
- break;
- }
- flags = (flags << 2) & 0xff;
- flagBits -= 2;
- }
- return buf.ToString();
- }
- }
+using System.Text;
+
+namespace SharpCompress.Common.Rar.Headers
+{
+ ///
+ /// This is for the crazy Rar encoding that I don't understand
+ ///
+ internal static class FileNameDecoder
+ {
+ internal static int GetChar(byte[] name, int pos)
+ {
+ return name[pos] & 0xff;
+ }
+
+ internal static string Decode(byte[] name, int encPos)
+ {
+ int decPos = 0;
+ int flags = 0;
+ int flagBits = 0;
+
+ int low = 0;
+ int high = 0;
+ int highByte = GetChar(name, encPos++);
+ StringBuilder buf = new StringBuilder();
+ while (encPos < name.Length)
+ {
+ if (flagBits == 0)
+ {
+ flags = GetChar(name, encPos++);
+ flagBits = 8;
+ }
+ switch (flags >> 6)
+ {
+ case 0:
+ buf.Append((char) (GetChar(name, encPos++)));
+ ++decPos;
+ break;
+
+ case 1:
+ buf.Append((char) (GetChar(name, encPos++) + (highByte << 8)));
+ ++decPos;
+ break;
+
+ case 2:
+ low = GetChar(name, encPos);
+ high = GetChar(name, encPos + 1);
+ buf.Append((char) ((high << 8) + low));
+ ++decPos;
+ encPos += 2;
+ break;
+
+ case 3:
+ int length = GetChar(name, encPos++);
+ if ((length & 0x80) != 0)
+ {
+ int correction = GetChar(name, encPos++);
+ for (length = (length & 0x7f) + 2; length > 0 && decPos < name.Length; length--, decPos++)
+ {
+ low = (GetChar(name, decPos) + correction) & 0xff;
+ buf.Append((char) ((highByte << 8) + low));
+ }
+ }
+ else
+ {
+ for (length += 2; length > 0 && decPos < name.Length; length--, decPos++)
+ {
+ buf.Append((char) (GetChar(name, decPos)));
+ }
+ }
+ break;
+ }
+ flags = (flags << 2) & 0xff;
+ flagBits -= 2;
+ }
+ return buf.ToString();
+ }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/Flags.cs b/src/SharpCompress/Common/Rar/Headers/Flags.cs
similarity index 95%
rename from SharpCompress/Common/Rar/Headers/Flags.cs
rename to src/SharpCompress/Common/Rar/Headers/Flags.cs
index 477a096d..421e983a 100644
--- a/SharpCompress/Common/Rar/Headers/Flags.cs
+++ b/src/SharpCompress/Common/Rar/Headers/Flags.cs
@@ -1,85 +1,85 @@
-using System;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- internal enum HeaderType
- {
- MarkHeader = 0x72,
- ArchiveHeader = 0x73,
- FileHeader = 0x74,
- CommHeader = 0x75,
- AvHeader = 0x76,
- SubHeader = 0x77,
- ProtectHeader = 0x78,
- SignHeader = 0x79,
- NewSubHeader = 0x7a,
- EndArchiveHeader = 0x7b,
- }
-
- internal enum HeaderFlags : short
- {
- LONG_BLOCK = -0x8000,
- }
-
- [Flags]
- internal enum ArchiveFlags
- {
- VOLUME = 0x0001,
- COMMENT = 0x0002,
- LOCK = 0x0004,
- SOLID = 0x0008,
- NEWNUMBERING = 0x0010,
- AV = 0x0020,
- PROTECT = 0x0040,
- PASSWORD = 0x0080,
- FIRSTVOLUME = 0x0100,
- ENCRYPTVER = 0x0200,
- }
-
- internal enum HostOS
- {
- MSDOS = 0,
- OS2 = 1,
- Win32 = 2,
- Unix = 3,
- MacOS = 4,
- BeOS = 5
- }
-
- [Flags]
- internal enum FileFlags : ushort
- {
- SPLIT_BEFORE = 0x0001,
- SPLIT_AFTER = 0x0002,
- PASSWORD = 0x0004,
- COMMENT = 0x0008,
- SOLID = 0x0010,
-
- WINDOWMASK = 0x00e0,
- WINDOW64 = 0x0000,
- WINDOW128 = 0x0020,
- WINDOW256 = 0x0040,
- WINDOW512 = 0x0060,
- WINDOW1024 = 0x0080,
- WINDOW2048 = 0x00a0,
- WINDOW4096 = 0x00c0,
- DIRECTORY = 0x00e0,
-
- LARGE = 0x0100,
- UNICODE = 0x0200,
- SALT = 0x0400,
- VERSION = 0x0800,
- EXTTIME = 0x1000,
- EXTFLAGS = 0x2000,
- }
-
-
- [Flags]
- internal enum EndArchiveFlags
- {
- EARC_NEXT_VOLUME = 0x0001,
- EARC_DATACRC = 0x0002,
- EARC_REVSPACE = 0x0004,
- EARC_VOLNUMBER = 0x0008,
- }
+using System;
+
+namespace SharpCompress.Common.Rar.Headers
+{
+ internal enum HeaderType
+ {
+ MarkHeader = 0x72,
+ ArchiveHeader = 0x73,
+ FileHeader = 0x74,
+ CommHeader = 0x75,
+ AvHeader = 0x76,
+ SubHeader = 0x77,
+ ProtectHeader = 0x78,
+ SignHeader = 0x79,
+ NewSubHeader = 0x7a,
+ EndArchiveHeader = 0x7b,
+ }
+
+ internal enum HeaderFlags : short
+ {
+ LONG_BLOCK = -0x8000,
+ }
+
+ [Flags]
+ internal enum ArchiveFlags
+ {
+ VOLUME = 0x0001,
+ COMMENT = 0x0002,
+ LOCK = 0x0004,
+ SOLID = 0x0008,
+ NEWNUMBERING = 0x0010,
+ AV = 0x0020,
+ PROTECT = 0x0040,
+ PASSWORD = 0x0080,
+ FIRSTVOLUME = 0x0100,
+ ENCRYPTVER = 0x0200,
+ }
+
+ internal enum HostOS
+ {
+ MSDOS = 0,
+ OS2 = 1,
+ Win32 = 2,
+ Unix = 3,
+ MacOS = 4,
+ BeOS = 5
+ }
+
+ [Flags]
+ internal enum FileFlags : ushort
+ {
+ SPLIT_BEFORE = 0x0001,
+ SPLIT_AFTER = 0x0002,
+ PASSWORD = 0x0004,
+ COMMENT = 0x0008,
+ SOLID = 0x0010,
+
+ WINDOWMASK = 0x00e0,
+ WINDOW64 = 0x0000,
+ WINDOW128 = 0x0020,
+ WINDOW256 = 0x0040,
+ WINDOW512 = 0x0060,
+ WINDOW1024 = 0x0080,
+ WINDOW2048 = 0x00a0,
+ WINDOW4096 = 0x00c0,
+ DIRECTORY = 0x00e0,
+
+ LARGE = 0x0100,
+ UNICODE = 0x0200,
+ SALT = 0x0400,
+ VERSION = 0x0800,
+ EXTTIME = 0x1000,
+ EXTFLAGS = 0x2000,
+ }
+
+
+ [Flags]
+ internal enum EndArchiveFlags
+ {
+ EARC_NEXT_VOLUME = 0x0001,
+ EARC_DATACRC = 0x0002,
+ EARC_REVSPACE = 0x0004,
+ EARC_VOLNUMBER = 0x0008,
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/MarkHeader.cs b/src/SharpCompress/Common/Rar/Headers/MarkHeader.cs
similarity index 96%
rename from SharpCompress/Common/Rar/Headers/MarkHeader.cs
rename to src/SharpCompress/Common/Rar/Headers/MarkHeader.cs
index 41214b46..c8290bdb 100644
--- a/SharpCompress/Common/Rar/Headers/MarkHeader.cs
+++ b/src/SharpCompress/Common/Rar/Headers/MarkHeader.cs
@@ -1,59 +1,59 @@
-using SharpCompress.IO;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- internal class MarkHeader : RarHeader
- {
- protected override void ReadFromReader(MarkingBinaryReader reader)
- {
- }
-
- internal bool IsValid()
- {
- if (!(HeadCRC == 0x6152))
- {
- return false;
- }
- if (!(HeaderType == HeaderType.MarkHeader))
- {
- return false;
- }
- if (!(Flags == 0x1a21))
- {
- return false;
- }
- if (!(HeaderSize == BaseBlockSize))
- {
- return false;
- }
- return true;
- }
-
- internal bool IsSignature()
- {
- bool valid = false;
- /*byte[] d = new byte[BaseBlock.BaseBlockSize];
- BinaryWriter writer = new BinaryWriter();
- writer.Write(HeadCRC);
- writer.Write((byte)HeaderType);
- writer.Write(flags);
- writer.Write(HeaderSize);
- writer.Flush
-
- if (d[0] == 0x52) {
- if (d[1]==0x45 && d[2]==0x7e && d[3]==0x5e) {
- oldFormat=true;
- valid=true;
- }
- else if (d[1]==0x61 && d[2]==0x72 && d[3]==0x21 && d[4]==0x1a &&
- d[5]==0x07 && d[6]==0x00) {
- oldFormat=false;
- valid=true;
- }
- }*/
- return valid;
- }
-
- internal bool OldFormat { get; private set; }
- }
+using SharpCompress.IO;
+
+namespace SharpCompress.Common.Rar.Headers
+{
+ internal class MarkHeader : RarHeader
+ {
+ protected override void ReadFromReader(MarkingBinaryReader reader)
+ {
+ }
+
+ internal bool IsValid()
+ {
+ if (!(HeadCRC == 0x6152))
+ {
+ return false;
+ }
+ if (!(HeaderType == HeaderType.MarkHeader))
+ {
+ return false;
+ }
+ if (!(Flags == 0x1a21))
+ {
+ return false;
+ }
+ if (!(HeaderSize == BaseBlockSize))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ internal bool IsSignature()
+ {
+ bool valid = false;
+ /*byte[] d = new byte[BaseBlock.BaseBlockSize];
+ BinaryWriter writer = new BinaryWriter();
+ writer.Write(HeadCRC);
+ writer.Write((byte)HeaderType);
+ writer.Write(flags);
+ writer.Write(HeaderSize);
+ writer.Flush
+
+ if (d[0] == 0x52) {
+ if (d[1]==0x45 && d[2]==0x7e && d[3]==0x5e) {
+ oldFormat=true;
+ valid=true;
+ }
+ else if (d[1]==0x61 && d[2]==0x72 && d[3]==0x21 && d[4]==0x1a &&
+ d[5]==0x07 && d[6]==0x00) {
+ oldFormat=false;
+ valid=true;
+ }
+ }*/
+ return valid;
+ }
+
+ internal bool OldFormat { get; private set; }
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/NewSubHeader.cs b/src/SharpCompress/Common/Rar/Headers/NewSubHeader.cs
similarity index 97%
rename from SharpCompress/Common/Rar/Headers/NewSubHeader.cs
rename to src/SharpCompress/Common/Rar/Headers/NewSubHeader.cs
index 23bf6247..e259e837 100644
--- a/SharpCompress/Common/Rar/Headers/NewSubHeader.cs
+++ b/src/SharpCompress/Common/Rar/Headers/NewSubHeader.cs
@@ -1,59 +1,59 @@
-using System;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- internal class NewSubHeaderType : IEquatable
- {
- internal static readonly NewSubHeaderType SUBHEAD_TYPE_CMT = new NewSubHeaderType('C', 'M', 'T');
-
- //internal static final NewSubHeaderType SUBHEAD_TYPE_ACL = new NewSubHeaderType(new byte[]{'A','C','L'});
-
- //internal static final NewSubHeaderType SUBHEAD_TYPE_STREAM = new NewSubHeaderType(new byte[]{'S','T','M'});
-
- //internal static final NewSubHeaderType SUBHEAD_TYPE_UOWNER = new NewSubHeaderType(new byte[]{'U','O','W'});
-
- //internal static final NewSubHeaderType SUBHEAD_TYPE_AV = new NewSubHeaderType(new byte[]{'A','V'});
-
- internal static readonly NewSubHeaderType SUBHEAD_TYPE_RR = new NewSubHeaderType('R', 'R');
-
- //internal static final NewSubHeaderType SUBHEAD_TYPE_OS2EA = new NewSubHeaderType(new byte[]{'E','A','2'});
-
- //internal static final NewSubHeaderType SUBHEAD_TYPE_BEOSEA = new NewSubHeaderType(new byte[]{'E','A','B','E'});
-
- private byte[] bytes;
-
- private NewSubHeaderType(params char[] chars)
- {
- bytes = new byte[chars.Length];
- for (int i = 0; i < chars.Length; ++i)
- {
- bytes[i] = (byte) chars[i];
- }
- }
-
- internal bool Equals(byte[] bytes)
- {
- if (this.bytes.Length != bytes.Length)
- {
- return false;
- }
- for (int i = 0; i < bytes.Length; ++i)
- {
- if (this.bytes[i] != bytes[i])
- {
- return false;
- }
- }
- return true;
- }
-
- #region IEquatable Members
-
- public bool Equals(NewSubHeaderType other)
- {
- return Equals(other.bytes);
- }
-
- #endregion
- }
+using System;
+
+namespace SharpCompress.Common.Rar.Headers
+{
+ internal class NewSubHeaderType : IEquatable
+ {
+ internal static readonly NewSubHeaderType SUBHEAD_TYPE_CMT = new NewSubHeaderType('C', 'M', 'T');
+
+ //internal static final NewSubHeaderType SUBHEAD_TYPE_ACL = new NewSubHeaderType(new byte[]{'A','C','L'});
+
+ //internal static final NewSubHeaderType SUBHEAD_TYPE_STREAM = new NewSubHeaderType(new byte[]{'S','T','M'});
+
+ //internal static final NewSubHeaderType SUBHEAD_TYPE_UOWNER = new NewSubHeaderType(new byte[]{'U','O','W'});
+
+ //internal static final NewSubHeaderType SUBHEAD_TYPE_AV = new NewSubHeaderType(new byte[]{'A','V'});
+
+ internal static readonly NewSubHeaderType SUBHEAD_TYPE_RR = new NewSubHeaderType('R', 'R');
+
+ //internal static final NewSubHeaderType SUBHEAD_TYPE_OS2EA = new NewSubHeaderType(new byte[]{'E','A','2'});
+
+ //internal static final NewSubHeaderType SUBHEAD_TYPE_BEOSEA = new NewSubHeaderType(new byte[]{'E','A','B','E'});
+
+ private byte[] bytes;
+
+ private NewSubHeaderType(params char[] chars)
+ {
+ bytes = new byte[chars.Length];
+ for (int i = 0; i < chars.Length; ++i)
+ {
+ bytes[i] = (byte) chars[i];
+ }
+ }
+
+ internal bool Equals(byte[] bytes)
+ {
+ if (this.bytes.Length != bytes.Length)
+ {
+ return false;
+ }
+ for (int i = 0; i < bytes.Length; ++i)
+ {
+ if (this.bytes[i] != bytes[i])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ #region IEquatable Members
+
+ public bool Equals(NewSubHeaderType other)
+ {
+ return Equals(other.bytes);
+ }
+
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/SharpCompress/Common/Rar/Headers/ProtectHeader.cs b/src/SharpCompress/Common/Rar/Headers/ProtectHeader.cs
similarity index 100%
rename from SharpCompress/Common/Rar/Headers/ProtectHeader.cs
rename to src/SharpCompress/Common/Rar/Headers/ProtectHeader.cs
diff --git a/SharpCompress/Common/Rar/Headers/RarHeader.cs b/src/SharpCompress/Common/Rar/Headers/RarHeader.cs
similarity index 96%
rename from SharpCompress/Common/Rar/Headers/RarHeader.cs
rename to src/SharpCompress/Common/Rar/Headers/RarHeader.cs
index 65803cd1..8e3b60f5 100644
--- a/SharpCompress/Common/Rar/Headers/RarHeader.cs
+++ b/src/SharpCompress/Common/Rar/Headers/RarHeader.cs
@@ -1,95 +1,95 @@
-using System.IO;
-using SharpCompress.IO;
-
-namespace SharpCompress.Common.Rar.Headers
-{
- internal class RarHeader
- {
- internal const short BaseBlockSize = 7;
- internal const short LONG_BLOCK = -0x8000;
-
- private void FillBase(RarHeader baseHeader)
- {
- HeadCRC = baseHeader.HeadCRC;
- HeaderType = baseHeader.HeaderType;
- Flags = baseHeader.Flags;
- HeaderSize = baseHeader.HeaderSize;
- AdditionalSize = baseHeader.AdditionalSize;
- ReadBytes = baseHeader.ReadBytes;
- }
-
- internal static RarHeader Create(MarkingBinaryReader reader)
- {
- try
- {
- RarHeader header = new RarHeader();
-
- reader.Mark();
- header.ReadFromReader(reader);
- header.ReadBytes += reader.CurrentReadByteCount;
-
- return header;
- }
- catch (EndOfStreamException)
- {
- return null;
- }
- }
- protected virtual void ReadFromReader(MarkingBinaryReader reader)
- {
- HeadCRC = reader.ReadInt16();
- HeaderType = (HeaderType)(reader.ReadByte() & 0xff);
- Flags = reader.ReadInt16();
- HeaderSize = reader.ReadInt16();
- if (FlagUtility.HasFlag(Flags, LONG_BLOCK))
- {
- AdditionalSize = reader.ReadUInt32();
- }
- }
-
- internal T PromoteHeader