Compare commits

...

5 Commits

Author SHA1 Message Date
Adam Hathcock
84704e5ce2 Release packaging for 0.10.3 2013-12-15 11:42:54 +00:00
Adam Hathcock
059fe1f545 Test for previous change 2013-12-15 11:16:59 +00:00
Adam Hathcock
fe8c6aec5f Ensure adding always disposes 2013-12-15 11:16:48 +00:00
Adam Hathcock
3ab38fbfc2 If the requested amount of bytes was not read, assume end of stream 2013-11-24 09:40:38 +00:00
Adam Hathcock
b4bfde77d2 Version 0.10.2 2013-11-23 13:08:54 +00:00
9 changed files with 64 additions and 23 deletions

View File

@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>sharpcompress</id>
<version>0.10.1.3</version>
<version>0.10.3</version>
<title>SharpCompress - Pure C# Decompression/Compression</title>
<authors>Adam Hathcock</authors>
<owners>Adam Hathcock</owners>
@@ -12,11 +12,11 @@
<description>SharpCompress is a compression library for .NET/Mono/Silverlight/WP7/WindowsStore that can unrar, decompress 7zip, zip/unzip, tar/untar bzip2/unbzip2 and gzip/ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip is implemented.</description>
<releaseNotes />
<language>en-US</language>
<tags>rar unrar zip unzip bzip2 gzip tar 7zip .net40 .net35 sl4</tags>
<tags>rar unrar zip unzip bzip2 gzip tar 7zip</tags>
</metadata>
<files>
<file src="..\bin\Full\SharpCompress.dll" target="lib\net40\SharpCompress.dll" />
<file src="..\bin\WindowsStore\SharpCompress.dll" target="lib\netcore45\SharpCompress.dll" />
<file src="..\bin\Portable\SharpCompress.dll" target="lib\portable-net4+sl4+wp7+win8\SharpCompress.dll" />
<file src="..\bin\Portable\SharpCompress.dll" target="lib\portable-net4+sl5+wp8+win8\SharpCompress.dll" />
</files>
</package>

View File

@@ -21,6 +21,18 @@ TODOs (always lots):
* Zip64
* Multi-volume Zip support.
Version 0.10.3:
==============
- Finally fixed Disposal issue when creating a new archive with the Archive API
Version 0.10.2:
==============
- Fixed Rar Header reading for invalid extended time headers.
- Windows Store assembly is now strong named
- Known issues with Long Tar names being worked on
- Updated to VS2013
- Portable targets SL5 and Windows Phone 8 (up from SL4 and WP7)
Version 0.10.1:
==============
- Fixed 7Zip extraction performance problem

View File

@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -184,16 +185,32 @@ namespace SharpCompress.Test
[TestMethod]
public void Zip_Create_New()
{
string scratchPath = Path.Combine(SCRATCH_FILES_PATH, "Zip.deflate.noEmptyDirs.zip");
base.ResetScratch();
foreach (var file in Directory.EnumerateFiles(ORIGINAL_FILES_PATH, "*.*", SearchOption.AllDirectories))
{
var newFileName = file.Substring(ORIGINAL_FILES_PATH.Length);
if (newFileName.StartsWith(Path.DirectorySeparatorChar.ToString()))
{
newFileName = newFileName.Substring(1);
}
newFileName = Path.Combine(SCRATCH_FILES_PATH, newFileName);
var newDir = Path.GetDirectoryName(newFileName);
if (!Directory.Exists(newDir))
{
Directory.CreateDirectory(newDir);
}
File.Copy(file, newFileName);
}
string scratchPath = Path.Combine(SCRATCH2_FILES_PATH, "Zip.deflate.noEmptyDirs.zip");
string unmodified = Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.noEmptyDirs.zip");
base.ResetScratch();
using (var archive = ZipArchive.Create())
{
archive.AddAllFromDirectory(ORIGINAL_FILES_PATH);
archive.AddAllFromDirectory(SCRATCH_FILES_PATH);
archive.SaveTo(scratchPath, CompressionType.Deflate);
}
CompareArchivesByPath(unmodified, scratchPath);
Directory.Delete(SCRATCH_FILES_PATH, true);
}
[TestMethod]

View File

@@ -118,7 +118,7 @@ namespace SharpCompress.Archive
private bool disposed;
public void Dispose()
public virtual void Dispose()
{
if (!disposed)
{

View File

@@ -117,5 +117,13 @@ namespace SharpCompress.Archive
protected abstract void SaveTo(Stream stream, CompressionInfo compressionType,
IEnumerable<TEntry> oldEntries, IEnumerable<TEntry> newEntries);
public override void Dispose()
{
base.Dispose();
newEntries.Cast<Entry>().ForEach(x => x.Close());
removedEntries.Cast<Entry>().ForEach(x => x.Close());
modifiedEntries.Cast<Entry>().ForEach(x => x.Close());
}
}
}

View File

@@ -8,16 +8,17 @@ namespace SharpCompress.Archive.Zip
{
internal class ZipWritableArchiveEntry : ZipArchiveEntry
{
private string path;
private long size;
private DateTime? lastModified;
private bool closeStream;
private readonly string path;
private readonly long size;
private readonly DateTime? lastModified;
private readonly bool closeStream;
private bool isDisposed;
internal ZipWritableArchiveEntry(ZipArchive archive, Stream stream, string path, long size,
DateTime? lastModified, bool closeStream)
: base(archive, null)
{
this.Stream = stream;
Stream = stream;
this.path = path;
this.size = size;
this.lastModified = lastModified;
@@ -93,9 +94,10 @@ namespace SharpCompress.Archive.Zip
internal override void Close()
{
if (closeStream)
if (closeStream && !isDisposed)
{
Stream.Dispose();
isDisposed = true;
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace SharpCompress.Common
{
public abstract class Entry : SharpCompress.Common.IEntry
public abstract class Entry : IEntry
{
internal bool IsSolid { get; set; }

View File

@@ -21,14 +21,12 @@ namespace SharpCompress.IO
public override int Read()
{
CurrentReadByteCount += 4;
return base.Read();
throw new NotImplementedException();
}
public override int Read(byte[] buffer, int index, int count)
{
CurrentReadByteCount += count;
return base.Read(buffer, index, count);
throw new NotImplementedException();
}
public override int Read(char[] buffer, int index, int count)
@@ -38,8 +36,7 @@ namespace SharpCompress.IO
public override bool ReadBoolean()
{
CurrentReadByteCount++;
return base.ReadBoolean();
return BitConverter.ToBoolean(ReadBytes(1), 0);
}
public override byte ReadByte()
@@ -50,7 +47,12 @@ namespace SharpCompress.IO
public override byte[] ReadBytes(int count)
{
CurrentReadByteCount += count;
return base.ReadBytes(count);
var bytes = base.ReadBytes(count);
if (bytes.Length != count)
{
throw new EndOfStreamException(string.Format("Could not read the requested amount of bytes. End of stream reached. Requested: {0} Read: {1}", count, bytes.Length));
}
return bytes;
}
public override char ReadChar()

View File

@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright © Adam Hathcock")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.10.1.3")]
[assembly: AssemblyFileVersion("0.10.1.3")]
[assembly: AssemblyVersion("0.10.3.0")]
[assembly: AssemblyFileVersion("0.10.3.0")]