public static FastZipPackage Open(string originalFilePath, IHashProvider hashProvider) { var result = new FastZipPackage(originalFilePath); using (var package = Package.Open(originalFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { var packageRelationship = package.GetRelationshipsByType("http://schemas.microsoft.com/packaging/2010/07/manifest").SingleOrDefault(); if (packageRelationship == null) throw new InvalidOperationException("Package does not contain a manifest"); var part = package.GetPart(packageRelationship.TargetUri); using (var stream2 = part.GetStream()) result.ReadManifest(stream2); } using (var stream = new FileStream(originalFilePath, FileMode.Open, FileAccess.Read)) { result.Hash = hashProvider.CalculateHash(stream); } var info = new FileInfo(originalFilePath); result.Created = info.CreationTimeUtc; result.Size = info.Length; return result; }
private static FastZipPackage Open(string fileLocation, Stream stream, byte[] hash) { if (!stream.CanRead) { throw new ArgumentException("Stream.CanRead must be supported.", "stream"); } if (!stream.CanSeek) { throw new ArgumentException("Stream.CanSeek must be supported.", "stream"); } var fastZipPackage = new FastZipPackage { FileLocation = fileLocation }; using (var package = Package.Open(stream, FileMode.Open, FileAccess.Read)) { fastZipPackage.ProcessManifest(package); fastZipPackage.ProcessPackageContents(package); } stream.Seek(0, SeekOrigin.Begin); fastZipPackage.ProcessFileMetadata(stream); fastZipPackage.Size = stream.Length; fastZipPackage.Hash = hash; return fastZipPackage; }
private static FastZipPackage Open(string fileLocation, Stream stream, byte[] hash) { if (!stream.CanRead) { throw new ArgumentException("Stream.CanRead must be supported.", "stream"); } if (!stream.CanSeek) { throw new ArgumentException("Stream.CanSeek must be supported.", "stream"); } var fastZipPackage = new FastZipPackage { FileLocation = fileLocation }; using (var package = Package.Open(stream, FileMode.Open, FileAccess.Read)) { fastZipPackage.ProcessManifest(package); fastZipPackage.ProcessPackageContents(package); } stream.Seek(0, SeekOrigin.Begin); fastZipPackage.ProcessFileMetadata(stream); fastZipPackage.Size = stream.Length; fastZipPackage.Hash = hash; return(fastZipPackage); }
protected virtual IPackage OpenPackage(string path) { if (DisablePackageHash) { return(FastZipPackage.Open(path, new byte[0])); } return(FastZipPackage.Open(path, HashProvider)); }
protected override IPackage OpenPackage(string path) { if (DisablePackageHash) { return(FastZipPackage.Open(path, new byte[0])); } else { return(FastZipPackage.Open(path, HashProvider)); } }
public virtual IFastZipPackage LoadStagedPackage(HashingWriteStream packageStream) { packageStream.Dispose(); return(FastZipPackage.Open(packageStream.FileLocation, packageStream.Hash)); }
protected override IPackage OpenPackage(string path) { return(FastZipPackage.Open(path, HashProvider)); }