<commit_before>﻿/// This module contains helper function to create and extract zip archives.
module Fake.IO.Zip

open System.IO
#if DOTNETCORE // Wait for SharpZipLib to become available for netcore
open System.IO.Compression
#if NETSTANDARD1_6
open System.Reflection
#endif
#else
// No SharpZipLib for netcore
open ICSharpCode.SharpZipLib.Zip
open ICSharpCode.SharpZipLib.Core
#endif
open System
open Fake.Core
open Fake.IO.FileSystem

/// The default zip level
let DefaultZipLevel = 7


#if DOTNETCORE // Wait for SharpZipLib to become available for netcore

type private MyClass () = class end

let private createZipP fileName comment level (items: (string * string) seq) =
    use stream = new ZipArchive (File.Create(fileName), ZipArchiveMode.Create)
    let zipLevel = min (max 0 level) 9
    //tracefn "Creating Zipfile: %s (Level: %d)" fileName zipLevel
    //stream.SetLevel zipLevel
    //if not (String.IsNullOrEmpty comment) then stream.SetComment comment
    let buffer = Array.create 32768 0uy
    for item, itemSpec in items do
        let info = FileInfo.ofPath item
        let entry = stream.CreateEntryFromFile(item, itemSpec)
        ()
        //entry.LastWriteTime <- DateTimeOffset(info.LastWriteTime)

let private createZip fileName comment level (items: (string* string) seq) =
#if NETSTANDARD1_6
//    let lc = System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(typeof<MyClass>.GetTypeInfo().Assembly)
//    let n = AssemblyName "System.IO.Compression.ZipFile"
//    lc.LoadFromAssemblyName(n) |> ignore
#endif
    createZipP fileName comment level items
#else

let private addZipEntry (stream : ZipOutputStream) (buffer : byte[]) (item : string) (itemSpec : string) =
    let info = FileInfo.ofPath item
    let itemSpec = ZipEntry.CleanName itemSpec
    //logfn "Adding File %s" itemSpec
    let entry = new ZipEntry(itemSpec)
    entry.DateTime <- info.LastWriteTime
    entry.Size <- info.Length
    use stream2 = info.OpenRead()
    stream.PutNextEntry(entry)
    let length = ref stream2.Length
    stream2.Seek(0L, SeekOrigin.Begin) |> ignore
    while !length > 0L do<commit_msg>add workaround<commit_after>﻿/// This module contains helper function to create and extract zip archives.
module Fake.IO.Zip

open System.IO
#if DOTNETCORE // Wait for SharpZipLib to become available for netcore
open System.IO.Compression
#if NETSTANDARD1_6
open System.Reflection
#endif
#else
// No SharpZipLib for netcore
open ICSharpCode.SharpZipLib.Zip
open ICSharpCode.SharpZipLib.Core
#endif
open System
open Fake.Core
open Fake.IO.FileSystem

/// The default zip level
let DefaultZipLevel = 7


#if DOTNETCORE // Wait for SharpZipLib to become available for netcore

type private MyClass () = class end

let private createZipP fileName comment level (items: (string * string) seq) =
    use stream = new ZipArchive (File.Create(fileName), ZipArchiveMode.Create)
    let zipLevel = min (max 0 level) 9
    //tracefn "Creating Zipfile: %s (Level: %d)" fileName zipLevel
    //stream.SetLevel zipLevel
    //if not (String.IsNullOrEmpty comment) then stream.SetComment comment
    let buffer = Array.create 32768 0uy
    for item, itemSpec in items do
        let info = FileInfo.ofPath item
        let entry = stream.CreateEntryFromFile(item, itemSpec)
        ()
        //entry.LastWriteTime <- DateTimeOffset(info.LastWriteTime)

let private createZip fileName comment level (items: (string* string) seq) =
#if NETSTANDARD1_6
    let lc = System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(typeof<MyClass>.GetTypeInfo().Assembly)
    let n = AssemblyName "System.IO.Compression.ZipFile"
    lc.LoadFromAssemblyName(n) |> ignore
#endif
    createZipP fileName comment level items
#else

let private addZipEntry (stream : ZipOutputStream) (buffer : byte[]) (item : string) (itemSpec : string) =
    let info = FileInfo.ofPath item
    let itemSpec = ZipEntry.CleanName itemSpec
    //logfn "Adding File %s" itemSpec
    let entry = new ZipEntry(itemSpec)
    entry.DateTime <- info.LastWriteTime
    entry.Size <- info.Length
    use stream2 = info.OpenRead()
    stream.PutNextEntry(entry)
    let length = ref stream2.Length
    stream2.Seek(0L, SeekOrigin.Begin) |> ignore
    while !length > 0L do
{'fraction_non_alphanumeric': 0.08835341365461848, 'fraction_numerical': 0.008504606661941885, 'mean_word_length': 3.7895927601809953, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '90894', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1252, 'n_words': 414}