Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override int Read(Span<byte> buffer)
/// <summary>Begins an asynchronous read operation. (Consider using the <see cref="System.IO.Stream.ReadAsync(byte[],int,int)" /> method instead.)</summary>
/// <param name="buffer">The buffer from which data will be read.</param>
/// <param name="offset">The byte offset in <paramref name="buffer" /> at which to begin reading data from the stream.</param>
/// <param name="count">To maximum number of bytes to read.</param>
/// <param name="count">The maximum number of bytes to read.</param>
/// <param name="asyncCallback">An optional asynchronous callback, to be called when the read operation is complete.</param>
/// <param name="asyncState">A user-provided object that distinguishes this particular asynchronous read request from other requests.</param>
/// <returns>An object that represents the asynchronous read operation, which could still be pending.</returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public override void EndWrite(IAsyncResult asyncResult) =>
/// <param name="count">The maximum number of bytes to write.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="System.Threading.CancellationToken.None" />.</param>
/// <returns>A task that represents the asynchronous write operation.</returns>
/// <exception cref="System.ArgumentNullException"><paramref name="buffer" /> is <see langword="null" />.</exception>
/// <exception cref="System.ArgumentOutOfRangeException"><paramref name="offset" /> or <paramref name="count" /> is negative.</exception>
/// <exception cref="System.ArgumentException">The sum of <paramref name="offset" /> and <paramref name="count" /> is greater than the buffer length.</exception>
/// <exception cref="System.ObjectDisposedException">The write operation cannot be performed because the stream is closed.</exception>
/// <remarks><para>This method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in apps where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.</para>
Comment on lines +128 to 132
/// <para>Use the <see cref="System.IO.Compression.BrotliStream.CanWrite" /> property to determine whether the current instance supports writing.</para>
/// <para>If the operation is canceled before it completes, the returned task contains the <see cref="System.Threading.Tasks.TaskStatus.Canceled" /> value for the <see cref="System.Threading.Tasks.Task.Status" /> property.</para></remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

namespace System.IO.Compression
{
/// <summary>
/// Specifies whether to compress or decompress the underlying stream.
/// </summary>
public enum CompressionMode
{
/// <summary>Decompresses the underlying stream.</summary>
Decompress = 0,

/// <summary>Compresses the underlying stream.</summary>
Compress = 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ internal ZipArchiveEntry(ZipArchive archive, string entryName)
/// </summary>
public ZipArchive Archive => _archive;

/// <summary>
/// Gets the CRC-32 checksum of the uncompressed entry data.
/// </summary>
[CLSCompliant(false)]
public uint Crc32 => _crc32;

Expand Down Expand Up @@ -270,6 +273,12 @@ public long CompressedLength
}
}

/// <summary>
/// Gets or sets the external file attributes of the entry, whose meaning depends on the platform
/// that created the archive (for example, Unix file mode bits or Windows file attributes).
/// </summary>
/// <exception cref="InvalidOperationException">The entry has been deleted from the archive.</exception>
/// <exception cref="ObjectDisposedException">The archive that the entry belongs to has been disposed.</exception>
public int ExternalAttributes
{
get
Expand Down Expand Up @@ -510,6 +519,28 @@ public Stream Open(FileAccess access)
return OpenCore(access);
}

/// <summary>
/// Opens the entry for reading or updating with the specified access mode and password.
/// This allows for more granular control over the returned stream's capabilities.
/// If the entry is not encrypted, the password is ignored and the entry is opened normally.
/// </summary>
/// <param name="access">The file access mode for the returned stream.</param>
/// <param name="password">The password used to decrypt the entry. If the entry is not encrypted, this parameter is ignored.</param>
/// <returns>A <see cref="Stream"/> that represents the contents of the entry with the specified access capabilities.</returns>
/// <remarks>
/// <para>The allowed <paramref name="access"/> values depend on the <see cref="ZipArchiveMode"/>:</para>
/// <list type="bullet">
/// <item><description><see cref="ZipArchiveMode.Read"/>: Only <see cref="FileAccess.Read"/> is allowed.</description></item>
/// <item><description><see cref="ZipArchiveMode.Create"/>: <see cref="FileAccess.Write"/> and <see cref="FileAccess.ReadWrite"/> are allowed (both write-only).</description></item>
/// <item><description><see cref="ZipArchiveMode.Update"/>: All values are allowed. <see cref="FileAccess.Read"/> provides a read-only stream over the entry's current content, including any modifications made in the current session. <see cref="FileAccess.Write"/> discards existing content and provides an empty writable stream. <see cref="FileAccess.ReadWrite"/> loads existing content into memory (equivalent to <see cref="Open(ReadOnlySpan{char})"/>).</description></item>
/// </list>
/// </remarks>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="access"/> is not a valid <see cref="FileAccess"/> value.</exception>
/// <exception cref="ArgumentException">The entry is encrypted and <paramref name="password"/> is empty.</exception>
/// <exception cref="InvalidOperationException">The requested access is not compatible with the archive's open mode.</exception>
/// <exception cref="IOException">The entry is already currently open for writing. -or- The entry has been deleted from the archive. -or- The archive that this entry belongs to was opened in ZipArchiveMode.Create, and this entry has already been written to once.</exception>
/// <exception cref="InvalidDataException">The entry is missing from the archive or is corrupt and cannot be read. -or- The entry has been compressed using a compression method that is not supported.</exception>
/// <exception cref="ObjectDisposedException">The ZipArchive that this entry belongs to has been disposed.</exception>
public Stream Open(FileAccess access, ReadOnlySpan<char> password)
{
ThrowIfInvalidArchive();
Expand Down
Loading