| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.IO.Compression |
| | | 5 | | { |
| | | 6 | | /// <summary>Provides compression options to be used with Zstandard compression.</summary> |
| | | 7 | | [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] |
| | | 8 | | [System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] |
| | | 9 | | public sealed class ZstandardCompressionOptions |
| | | 10 | | { |
| | | 11 | | /// <summary>Gets the default compression quality level.</summary> |
| | 0 | 12 | | public static int DefaultQuality => ZstandardUtils.Quality_Default; |
| | | 13 | | |
| | | 14 | | /// <summary>Gets the minimum compression quality level.</summary> |
| | 0 | 15 | | public static int MinQuality => ZstandardUtils.Quality_Min; |
| | | 16 | | |
| | | 17 | | /// <summary>Gets the maximum compression quality level.</summary> |
| | 0 | 18 | | public static int MaxQuality => ZstandardUtils.Quality_Max; |
| | | 19 | | |
| | | 20 | | /// <summary>Gets the default base-2 logarithm of the window size to use for Zstandard compression.</summary> |
| | 0 | 21 | | public static int DefaultWindowLog2 => ZstandardUtils.WindowLog_Default; |
| | | 22 | | |
| | | 23 | | /// <summary>Gets the minimum base-2 logarithm of the window size to use for Zstandard compression.</summary> |
| | 0 | 24 | | public static int MinWindowLog2 => ZstandardUtils.WindowLog_Min; |
| | | 25 | | |
| | | 26 | | /// <summary>Gets the maximum base-2 logarithm of the window size to use for Zstandard compression.</summary> |
| | 0 | 27 | | public static int MaxWindowLog2 => ZstandardUtils.WindowLog_Max; |
| | | 28 | | |
| | | 29 | | /// <summary>Initializes a new instance of the <see cref="ZstandardCompressionOptions"/> class.</summary> |
| | 0 | 30 | | public ZstandardCompressionOptions() |
| | 0 | 31 | | { |
| | 0 | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary>Gets or sets the compression quality to use for Zstandard compression.</summary> |
| | | 35 | | /// <value>The compression quality. The valid range is from <see cref="MinQuality"/> to <see cref="MaxQuality"/> |
| | | 36 | | /// <remarks> |
| | | 37 | | /// The compression quality determines the compression ratio and speed. |
| | | 38 | | /// Negative values extend the range of speed versus ratio preferences, where lower levels are faster but provid |
| | | 39 | | /// Value 0 indicates the implementation-defined default quality. |
| | | 40 | | /// Values 1-22 are normal compression levels, with <see cref="DefaultQuality"/> being the default. |
| | | 41 | | /// Values 20-22 require more memory and should be used with caution. |
| | | 42 | | /// </remarks> |
| | | 43 | | /// <exception cref="ArgumentOutOfRangeException">The value is not 0 and is not between <see cref="MinQuality"/> |
| | | 44 | | public int Quality |
| | | 45 | | { |
| | 0 | 46 | | get; |
| | | 47 | | set |
| | 0 | 48 | | { |
| | 0 | 49 | | if (value != 0) |
| | 0 | 50 | | { |
| | 0 | 51 | | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ZstandardUtils.Quality_Max, nameof(value)); |
| | 0 | 52 | | ArgumentOutOfRangeException.ThrowIfLessThan(value, ZstandardUtils.Quality_Min, nameof(value)); |
| | 0 | 53 | | } |
| | | 54 | | |
| | 0 | 55 | | field = value; |
| | 0 | 56 | | } |
| | | 57 | | } |
| | | 58 | | |
| | | 59 | | /// <summary>Gets or sets the base-2 logarithm of the window size to use for Zstandard compression.</summary> |
| | | 60 | | /// <value>The base-2 logarithm of the window size for compression.</value> |
| | | 61 | | /// <remarks> |
| | | 62 | | /// The window size determines how much data the compressor can reference for finding matches. |
| | | 63 | | /// Larger window sizes can improve compression ratios for large files but require more memory. |
| | | 64 | | /// The valid range is from <see cref="MinWindowLog2"/> to <see cref="MaxWindowLog2"/>. |
| | | 65 | | /// Value 0 indicates the implementation-defined default window size. |
| | | 66 | | /// </remarks> |
| | | 67 | | /// <exception cref="ArgumentOutOfRangeException">The value is not 0 and is not between <see cref="MinWindowLog2 |
| | | 68 | | public int WindowLog2 |
| | | 69 | | { |
| | 0 | 70 | | get; |
| | | 71 | | set |
| | 0 | 72 | | { |
| | 0 | 73 | | if (value != 0) |
| | 0 | 74 | | { |
| | 0 | 75 | | ArgumentOutOfRangeException.ThrowIfLessThan(value, ZstandardUtils.WindowLog_Min, nameof(value)); |
| | 0 | 76 | | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ZstandardUtils.WindowLog_Max, nameof(value)); |
| | 0 | 77 | | } |
| | | 78 | | |
| | 0 | 79 | | field = value; |
| | 0 | 80 | | } |
| | | 81 | | } |
| | | 82 | | |
| | | 83 | | /// <summary>Gets or sets the dictionary to use for compression. If set, the quality specified during dictionary |
| | | 84 | | /// <value>The compression dictionary, or null if no dictionary is used.</value> |
| | 0 | 85 | | public ZstandardDictionary? Dictionary { get; set; } |
| | | 86 | | |
| | | 87 | | /// <summary>Gets or sets a hint for the size of the block sizes that the encoder will output. Smaller size lead |
| | | 88 | | /// <value>The target block size in bytes. Valid range is from 1340 to 131072 (2^17). A value of 0 indicates no |
| | | 89 | | public int TargetBlockSize |
| | | 90 | | { |
| | 0 | 91 | | get; |
| | | 92 | | set |
| | 0 | 93 | | { |
| | 0 | 94 | | if (value != 0) |
| | 0 | 95 | | { |
| | 0 | 96 | | ArgumentOutOfRangeException.ThrowIfLessThan(value, ZstandardUtils.TargetBlockSize_Min, nameof(value) |
| | 0 | 97 | | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ZstandardUtils.TargetBlockSize_Max, nameof(val |
| | 0 | 98 | | } |
| | | 99 | | |
| | 0 | 100 | | field = value; |
| | 0 | 101 | | } |
| | | 102 | | } |
| | | 103 | | |
| | | 104 | | /// <summary>Gets or sets a value indicating whether a 32-bit checksum will be appended at the end of the compre |
| | 0 | 105 | | public bool AppendChecksum { get; set; } |
| | | 106 | | |
| | | 107 | | /// <summary>Gets or sets a value indicating whether long-distance matching is enabled.</summary> |
| | | 108 | | /// <value><see langword="true"/> if long-distance matching is enabled; otherwise, <see langword="false"/>.</val |
| | | 109 | | /// <remarks>Setting this property to <see langword="true" /> might improve compression ratios for large files a |
| | 0 | 110 | | public bool EnableLongDistanceMatching { get; set; } |
| | | 111 | | } |
| | | 112 | | } |