TarReader.GetNextEntryAsync(Boolean, CancellationToken) Method

Definition

Asynchronously retrieves the next entry from the archive stream.

public System.Threading.Tasks.ValueTask<System.Formats.Tar.TarEntry?> GetNextEntryAsync (bool copyData = false, System.Threading.CancellationToken cancellationToken = default);
member this.GetNextEntryAsync : bool * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Formats.Tar.TarEntry>
Public Function GetNextEntryAsync (Optional copyData As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TarEntry)

Parameters

copyData
Boolean

true to copy the data of the entry into a new MemoryStream. This is helpful when the underlying archive stream does not support seeking, and the data needs to be accessed later.

false if the data should not be copied into a new stream. If the underlying stream does not support seeking, the user has the responsibility of reading and processing the DataStream immediately after calling this method.

The default value is false.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

A value task containing a TarEntry instance if a valid entry was found, or null if the end of the archive has been reached.

Exceptions

The archive is malformed.

-or-

The archive contains entries in different formats.

-or-

More than one Global Extended Attributes Entry was found in the current Pax archive.

-or-

Two or more Extended Attributes entries were found consecutively in the current Pax archive.

An I/O problem occurred.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by GetNextEntry(Boolean).

Applies to