public ZipFile(IReadOnlyFileSystem context, string filename) { string name; IReadOnlyPackage p; if (!context.TryGetPackageContaining(filename, out p, out name)) throw new FileNotFoundException("Unable to find parent package for " + filename); Name = name; Parent = p as IReadWritePackage; // SharpZipLib breaks when asked to update archives loaded from outside streams or files // We can work around this by creating a clean in-memory-only file, cutting all outside references pkgStream = new MemoryStream(); using (var sourceStream = p.GetStream(name)) sourceStream.CopyTo(pkgStream); pkgStream.Position = 0; pkg = new SZipFile(pkgStream); }
public ZipFile(IReadOnlyFileSystem context, string filename) { string name; IReadOnlyPackage p; if (!context.TryGetPackageContaining(filename, out p, out name)) { throw new FileNotFoundException("Unable to find parent package for " + filename); } Name = name; Parent = p as IReadWritePackage; // SharpZipLib breaks when asked to update archives loaded from outside streams or files // We can work around this by creating a clean in-memory-only file, cutting all outside references pkgStream = new MemoryStream(); using (var sourceStream = p.GetStream(name)) sourceStream.CopyTo(pkgStream); pkgStream.Position = 0; pkg = new SZipFile(pkgStream); }