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:             outStream.CloseEntry()
          addEntry prepareEntry afterEntry outStream
  
      /// Wraps an output stream with a tar container store.
      let storeStream inner = new TarOutputStream(inner)
  
      /// Wraps an input stream with a tar container extractor.
      let extractStream inner = new TarInputStream(inner)
  
      /// Creates a `TarOutputStream` wrapping a file using the given parameters.
      /// ## Parameters
      ///  - `file` - The `FileInfo` describing the location to which the archive should be written. Will be overwritten if it exists.
      let createFile (file : FileInfo) =
          tracefn "Creating tar archive: %s" file.FullName
          createArchiveStream storeStream file
  
      /// Constructs a function that will create a tar archive from a set of files.
      let store file items =
          createArchive createFile addEntry file items
  
      let rec private getNextEntry (extractDir : DirectoryInfo) (stream : TarInputStream) =
  