public static PackagePhysicalFileMetadata Build(string fullFilePath, PackageFileNameMetadata identity) { if (identity == null) { return(null); } try { using (var stream = new FileStream(fullFilePath, FileMode.Open, FileAccess.Read)) { return(new PackagePhysicalFileMetadata(identity, fullFilePath, HashCalculator.Hash(stream), stream.Length)); } } catch (IOException) { return(null); } }
private IPackageExtractor FindByExtension(PackageFileNameMetadata packageFile) { return(Extractors.FirstOrDefault(p => p.Extensions.Any(ext => packageFile.Extension.Equals(ext, StringComparison.OrdinalIgnoreCase)))); }
public PackagePhysicalFileMetadata(PackageFileNameMetadata identity, string fullFilePath, string hash, long size) : base(identity.PackageId, identity.Version, identity.Extension) { FullFilePath = fullFilePath; Hash = hash; Size = size; }