Thank you for your reply, it was just what I was over-looking.
↧
New Post: How to decompress a compressed string?
↧
New Post: Invalid compression output for PpmdStream
Test for version 0.10.3, .net4.0:
And there is assertion in Debug.Assert(l == buff.Length), l=965 and biff.Length=1000.
static byte[] Pack(byte[] data)
{
var ppmdProp = new PpmdProperties();
using(var mem = new MemoryStream())
using (var ppmd = new PpmdStream(ppmdProp, mem, true))
{
ppmd.Write(data, 0, data.Length);
return mem.ToArray();
}
}
static byte[] UnPack(byte[] data, int origSize)
{
var ppmdProp = new PpmdProperties();
var buff = new byte[origSize];
using(var mem = new MemoryStream(data))
using (var ppmd = new PpmdStream(ppmdProp, mem, false))
{
var l = ppmd.Read(buff, 0, origSize);
Debug.Assert(l == buff.Length);
return buff;
}
}
[Test]
public void _01_Ppmd()
{
var tb = new byte[]{1,2,3,4,5,6,7,8,9,0};
var pp = Pack(tb);
var up = UnPack(pp, tb.Length);
Assert.AreEqual(tb,up);
}
[Test]
public void _02_Ppmd()
{
var tb = Enumerable.Range(0, 1000).Select(p => (byte) p).ToArray();
var pp = Pack(tb);
var up = UnPack(pp, tb.Length);
Assert.AreEqual(tb,up);
}
In first test up = {1,2,3,4,5,6,7,8,9,10}, i.e. 10!=0.And there is assertion in Debug.Assert(l == buff.Length), l=965 and biff.Length=1000.
↧
↧
New Post: Invalid compression output for PpmdStream
I have to confess I don't know if that is a valid test or not. The PpmdProperties might need to be different for packing or unpacking in your code.
The PPMD implementation was provided by another contributor and in usage with Archives it all seems to be okay.
The PPMD implementation was provided by another contributor and in usage with Archives it all seems to be okay.
↧
New Post: Avoiding SkipEntry when Disposing
I have to agree with the OP. The requirement to call SkipEntry() breaks the design pattern for streams, and for any IDisposable. If an object owns an IDisposable, it should be able to dispose it, without knowledge of its precise implementation. So although I agree it's a bit annoying that StreamReader owns the stream, it's not incorrect, as long as it is well documented.
In my case, I pass the EntryStream to pre-existing code, which has no idea that it comes from a zip. It creates and disposes a StreamReader, so tries to dispose the stream as well, at which point the exception is thrown. It deliberately does not always read the whole stream. Also, if an exception is thrown while processing the data, it gets wiped out by the "not fully consumed" exception, and so never gets noticed.
I understand the point about not wanting to leave the compressed stream at an unknown point. But usually the whole archive will be closed, so would not be a problem anyway. So I suppose there are 2 possible changes:
In my case, I pass the EntryStream to pre-existing code, which has no idea that it comes from a zip. It creates and disposes a StreamReader, so tries to dispose the stream as well, at which point the exception is thrown. It deliberately does not always read the whole stream. Also, if an exception is thrown while processing the data, it gets wiped out by the "not fully consumed" exception, and so never gets noticed.
I understand the point about not wanting to leave the compressed stream at an unknown point. But usually the whole archive will be closed, so would not be a problem anyway. So I suppose there are 2 possible changes:
- Call "SkipEntry()" from inside EntryStream.Dispose(), if not complete. Not ideal. The files I am currently reading are huge, and if an exception occurs while reading, it is quite likely to be on line 1. So it's hugely inefficient to read and discard the whole stream.
-
Leave the stream where it is, but have the reader throw an exception if/when the next entry is requested, if the previous EntryStream did not complete. Not exactly sure the best way to do that - maybe add a boolean property "EntryComplete" to the reader, assigned from the EntryStream on dispose.
↧
New Post: Avoiding SkipEntry when Disposing
Your points are valid. The second sounds the most reasonable. How difficult it is to implement is the question :)
↧
↧
New Post: Multi part extraction in combination with password
Hi,
First of all, very nice library!!
I am wondering whether it is possible to extract multipart rars in combination with a password. Currently I'm using streams to achieve the multipart extraction, and that works fine but when I use a IEnumerable<FileStream> it is not possible to use a password. That is only possible with a single stream. Or am I terribly wrong?
Hope someone can help.
First of all, very nice library!!
I am wondering whether it is possible to extract multipart rars in combination with a password. Currently I'm using streams to achieve the multipart extraction, and that works fine but when I use a IEnumerable<FileStream> it is not possible to use a password. That is only possible with a single stream. Or am I terribly wrong?
Hope someone can help.
↧
New Post: Detect is Zip needs password?
Hello
I use this library in Windows Phone 8 and I cannot find the way how I can detect does file need password? There is no way to set password after I open stream
var zip=SharpCompress.Archive.Zip.ZipArchive.Open(fs);
I can use EntryExtractionBegin to check if entry needs password, but I cannot set it in this event.
What can I do?
I use this library in Windows Phone 8 and I cannot find the way how I can detect does file need password? There is no way to set password after I open stream
var zip=SharpCompress.Archive.Zip.ZipArchive.Open(fs);
I can use EntryExtractionBegin to check if entry needs password, but I cannot set it in this event.
What can I do?
↧
New Post: Detect is Zip needs password?
Sorry, I currently don't have a way to detect if a zip file requires a password other than not providing one then catching the CryptographicException.
To set the password, ZipArchive.Open has an overload (Stream, string) where the string is the password.
To set the password, ZipArchive.Open has an overload (Stream, string) where the string is the password.
↧
New Post: Multi part extraction in combination with password
I just added the facility to extract password protected archives on the RarArchive interface. However, the multi-archive encrypted archives aren't working for some reason.
You're welcome to try to fix it as I added a test. However, this test currently just tests for an exception to tell users that multi-archive decryption isn't working.
check out the source or wait for a new release: https://github.com/adamhathcock/sharpcompress
You're welcome to try to fix it as I added a test. However, this test currently just tests for an exception to tell users that multi-archive decryption isn't working.
check out the source or wait for a new release: https://github.com/adamhathcock/sharpcompress
↧
↧
New Post: Add Index for IEntry
Hi,
Would it be possible to add a property Index respresenting the index value of a IEntry ?
Thanks
Would it be possible to add a property Index respresenting the index value of a IEntry ?
Thanks
↧
New Post: Rar archives and password
Hi,
First of all, thanks for your hard work !
Forgive my bad english : I'm French =)
Now I have a question :
Is it possible to know if a password is ok or not while reading entries?
In the RarReader object, or in the Entry object?
Thanks in advance.
First of all, thanks for your hard work !
Forgive my bad english : I'm French =)
Now I have a question :
Is it possible to know if a password is ok or not while reading entries?
In the RarReader object, or in the Entry object?
Thanks in advance.
↧
New Post: Help with crc property
Sorry about my english
I'm trying to get the CRC32 of a file ownership. However, the return shows a wrong result.
here's the code
This code prints this value on label 4263732290 as if CRC
In Winrar, the value pointed to as CRC is FE236442, which is the same value I get when I calculate the uncompressed file.
then used the SevenZipSharp with the following code
Is there something I'm doing wrong? I need to do another treatment with the warmth of the property to extract the calculation of CRC32??
Another thing I noticed in testing is that the other properties return the correct value (FilePath, CompressedSize, Size) everything works perfectly, minus the CRC32
Thanks for the help
I'm trying to get the CRC32 of a file ownership. However, the return shows a wrong result.
here's the code
Stream stream = File.OpenRead(@"C:\Test.rar");
var reader = ReaderFactory.Open(stream);
while(reader.MoveToNextEntry())
{
Label1.Content = reader.Entry.Crc.ToString();
}
The RAR file has only one file inside to test.This code prints this value on label 4263732290 as if CRC
In Winrar, the value pointed to as CRC is FE236442, which is the same value I get when I calculate the uncompressed file.
then used the SevenZipSharp with the following code
SevenZipCompressor.SetLibraryPath(@"C:\7z.dll");
SevenZipExtractor zip = new SevenZipExtractor("Test.rar");
Label1.Content = zip.ArchiveFileData[0].Crc.ToString();
To my death, I got the same result (4263732290). Is there something I'm doing wrong? I need to do another treatment with the warmth of the property to extract the calculation of CRC32??
Another thing I noticed in testing is that the other properties return the correct value (FilePath, CompressedSize, Size) everything works perfectly, minus the CRC32
Thanks for the help
↧
New Post: Add/Remove entry in WinRT
Hi... is there any code example about doing this operations in WinRT? I'm unable to infer this code :(
BTW this is a zip file with password
BTW this is a zip file with password
↧
↧
New Post: Add Index for IEntry
This really doesn't apply to most things. Dealing with items with the IEnumerable interface is the most efficient way across all formats.
↧
New Post: Rar archives and password
Sorry, the only way to test the password is to try to actually decrypt the entries.
↧
New Post: Help with crc property
CRC is broken in most places. I really haven't done the work to correct CRC for entries. Please add an issue on the Github site https://github.com/adamhathcock/sharpcompress
↧
New Post: Monitoring zip progress with delegates?
Hey there!
I'm really liking the flexibility of this library, but I was just wondering if there are delegates to monitor zipping progress? I'm looking through the code and can't seem to find any...
Thanks!
I'm really liking the flexibility of this library, but I was just wondering if there are delegates to monitor zipping progress? I'm looking through the code and can't seem to find any...
Thanks!
↧
↧
New Post: Multipart argument exception
I have been trying for some time now to get multipart extraction to work. I have a folder with a two part rar, a.rar and a.r00. Heres the code I am trying to use.
EDIT: Seems somehow my rar is corrupt? Extracts with WinRar throws this exception with SharpCompress.
var archive = RarArchive.Open(@"F:\unrar\a.rar");
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory(@"F:\unrar\", ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
When I point to a single file rar archive there are no problems. When the archive is multipart I end up with this exception. Filename invalid or next archive could not be found:F:\unrar\a.rar.EDIT: Seems somehow my rar is corrupt? Extracts with WinRar throws this exception with SharpCompress.
↧
New Post: Help with crc property
Dear Cesar,
I don't see any issue at all.
The CRC you are seeing (generated by the lib.) , is the same value reported in winrar.
4263732290 is decimal.
FE236442 is hex.
If you convert the number 4263732290 , from base-10 to hex, you'll see the light. (How to convert)
=D
I don't see any issue at all.
The CRC you are seeing (generated by the lib.) , is the same value reported in winrar.
4263732290 is decimal.
FE236442 is hex.
If you convert the number 4263732290 , from base-10 to hex, you'll see the light. (How to convert)
=D
↧
New Post: Monitoring zip progress with delegates?
I used my own method to know the progress. May be not the best one but it works fine for me.:
var archive = SharpCompress.Archive.ArchiveFactory.Open(fileStream);
int totalFileCount = archive.Entries.Count();
int fileCount = 0;
int currentPercentage = 0;
foreach (var entry in archive.Entries)
{
///Your action
fileCount++;
currentPercentage = (fileCount * 100)/ totalFileCount;
//Update UI or Delegate etc.
}
↧