anchor.diff:  ﻿/// Provides utility tasks for storing and compressing files in archives.
   module Fake.ArchiveHelper
   
  -open System
   open System.IO
  -open ICSharpCode.SharpZipLib.Core
   
   [<Literal>]
   let private DefaultBufferSize = 32768
  
positive.code:             let outFile = extractDir.FullName @@ entry.Name |> fileInfo
              Some { OutputFile = outFile; ArchiveEntryPath = entry.Name; EntrySize = entry.Size }
  
      let extract (extractDir : DirectoryInfo) (archiveFile : FileInfo) =
          openArchiveStream extractStream archiveFile
          |> extractEntries (getNextEntry extractDir)
          logfn "Extracted %s" archiveFile.FullName
  
      /// Extracts a tar archive to a given directory.
      /// ## Parameters
      ///  - `targetDir` - The directory into which the archived files will be extracted.
      ///  - `archivePath` - The archive to be extracted.
      let Extract targetDir archivePath =
          extract targetDir archivePath
  
      /// Creates a tar archive with the given files.
      /// ## Parameters
      ///  - `flatten` - If set to true then all subfolders are merged into the root folder of the archive.
  
negative.code:     let CompressDirWithDefaults (baseDir : DirectoryInfo) archiveFile =
          allFilesInDirectory baseDir |> CompressWithDefaults baseDir archiveFile
  
  /// Operations and tasks for working with gzip compressed files.
  module GZip =
      open ICSharpCode.SharpZipLib.GZip
  
      /// The gzip archive compression parameters.
      type GZipCompressionParams = { Level : CompressionLevel.T }
  
      /// The default gzip archive compression parameters
      /// ## Defaults
      ///  - `Level` - `CompressionLevel.Default`
      let GZipCompressionDefaults = { Level = CompressionLevel.Default }
  
      /// Wraps an output stream with a gzip compressor.
      let compressStream { Level = level } inner =
          let gzipStream = new GZipOutputStream(inner)
          gzipStream.SetLevel <| CompressionLevel.value level
          gzipStream
  
      /// Wraps an input stream with a zip decompressor.
      let extractStream inner = new GZipInputStream(inner)
  
      /// Creates a `GZipOutputStream` wrapping a file using the given parameters.
      /// ## Parameters
      ///  - `gzipParams` - The gzip compression parameters.
      ///  - `file` - The `FileInfo` describing the location to which the compressed file should be written. Will be overwritten if it exists.
      let createFile gzipParams (file : FileInfo) =
          tracefn "Creating gz archive: %s (%A)" file.FullName gzipParams.Level
          createArchiveStream (compressStream gzipParams) file
  