예제 #1
0
        private void CreatePart(ZipArchive package, string path, Stream sourceStream, DateTimeOffset lastWriteTime)
        {
            if (PackageHelper.IsNuspec(path))
            {
                return;
            }

            string entryName = CreatePartEntryName(path);
            var    entry     = CreatePackageFileEntry(package, entryName, lastWriteTime, CompressionLevel.Optimal);

            using (var stream = entry.Open())
            {
                sourceStream.CopyTo(stream);
            }
        }
예제 #2
0
        private static void CreatePart(ZipArchive package, string path, Stream sourceStream)
        {
            if (PackageHelper.IsNuspec(path))
            {
                return;
            }

            string entryName = CreatePartEntryName(path);

            var entry = package.CreateEntry(entryName, CompressionLevel.Optimal);

            using (var stream = entry.Open())
            {
                sourceStream.CopyTo(stream);
            }
        }
예제 #3
0
        private static bool ShouldInclude(
            string fullName,
            string hashFileName)
        {
            // Not all the files from a zip file are needed
            // So, files such as '.rels' and '[Content_Types].xml' are not extracted
            var fileName = Path.GetFileName(fullName);

            if (fileName != null)
            {
                if (fileName == ".rels")
                {
                    return(false);
                }
                if (fileName == "[Content_Types].xml")
                {
                    return(false);
                }
            }

            var extension = Path.GetExtension(fullName);

            if (extension == ".psmdcp")
            {
                return(false);
            }

            if (string.Equals(fullName, hashFileName, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            // Skip nupkgs and nuspec files found in the root, the valid ones are already extracted
            if (PackageHelper.IsRoot(fullName) &&
                (PackageHelper.IsNuspec(fullName) ||
                 fullName.EndsWith(PackagingCoreConstants.NupkgExtension, StringComparison.OrdinalIgnoreCase)))
            {
                return(false);
            }

            return(true);
        }
예제 #4
0
        private static void CreatePart(ZipArchive package, IPackageFile file, Stream sourceStream)
        {
            if (PackageHelper.IsNuspec(file.Path))
            {
                return;
            }

            string entryName = CreatePartEntryName(file.Path);

            var entry         = package.CreateEntry(entryName, CompressionLevel.Optimal);
            var physicalFile  = file as PhysicalPackageFile;
            var lastWriteTime = physicalFile?.GetLastWriteTime();

            if (lastWriteTime.HasValue)
            {
                entry.LastWriteTime = lastWriteTime.Value;
            }
            using (var stream = entry.Open())
            {
                sourceStream.CopyTo(stream);
            }
        }