Show / Hide Table of Contents

Class ZipExtraData

A class to handle the extra data field for Zip entries

Inheritance
System.Object
ZipExtraData
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ICSharpCode.SharpZipLib.Zip
Assembly: ICSharpCode.SharpZipLib.dll
Syntax
public sealed class ZipExtraData : IDisposable
Remarks

Extra data contains 0 or more values each prefixed by a header tag and length. They contain zero or more bytes of actual data. The data is held internally using a copy on write strategy. This is more efficient but means that for extra data created by passing in data can have the values modified by the caller in some circumstances.

Constructors

| Improve this Doc View Source

ZipExtraData()

Initialise a default instance.

Declaration
public ZipExtraData()
| Improve this Doc View Source

ZipExtraData(Byte[])

Initialise with known extra data.

Declaration
public ZipExtraData(byte[] data)
Parameters
Type Name Description
System.Byte[] data

The extra data.

Properties

| Improve this Doc View Source

CurrentReadIndex

Get the index for the current read value.

Declaration
public int CurrentReadIndex { get; }
Property Value
Type Description
System.Int32
Remarks

This is only valid if Find(Int32) has previously returned true. Initially the result will be the index of the first byte of actual data. The value is updated after calls to ReadInt(), ReadShort() and ReadLong().

| Improve this Doc View Source

Length

Gets the current extra data length.

Declaration
public int Length { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

UnreadCount

Get the number of bytes remaining to be read for the current value;

Declaration
public int UnreadCount { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

ValueLength

Get the length of the last value found by Find(Int32)

Declaration
public int ValueLength { get; }
Property Value
Type Description
System.Int32
Remarks

This is only valid if Find(Int32) has previously returned true.

Methods

| Improve this Doc View Source

AddData(Byte)

Add a byte of data to the pending new entry.

Declaration
public void AddData(byte data)
Parameters
Type Name Description
System.Byte data

The byte to add.

See Also
StartNewEntry()
| Improve this Doc View Source

AddData(Byte[])

Add data to a pending new entry.

Declaration
public void AddData(byte[] data)
Parameters
Type Name Description
System.Byte[] data

The data to add.

See Also
StartNewEntry()
| Improve this Doc View Source

AddEntry(ITaggedData)

Add a new entry to extra data.

Declaration
public void AddEntry(ITaggedData taggedData)
Parameters
Type Name Description
ITaggedData taggedData

The ITaggedData value to add.

| Improve this Doc View Source

AddEntry(Int32, Byte[])

Add a new entry to extra data

Declaration
public void AddEntry(int headerID, byte[] fieldData)
Parameters
Type Name Description
System.Int32 headerID

The ID for this entry.

System.Byte[] fieldData

The data to add.

Remarks

If the ID already exists its contents are replaced.

| Improve this Doc View Source

AddLeInt(Int32)

Add an integer value in little endian order to the pending new entry.

Declaration
public void AddLeInt(int toAdd)
Parameters
Type Name Description
System.Int32 toAdd

The data to add.

See Also
StartNewEntry()
| Improve this Doc View Source

AddLeLong(Int64)

Add a long value in little endian order to the pending new entry.

Declaration
public void AddLeLong(long toAdd)
Parameters
Type Name Description
System.Int64 toAdd

The data to add.

See Also
StartNewEntry()
| Improve this Doc View Source

AddLeShort(Int32)

Add a short value in little endian order to the pending new entry.

Declaration
public void AddLeShort(int toAdd)
Parameters
Type Name Description
System.Int32 toAdd

The data to add.

See Also
StartNewEntry()
| Improve this Doc View Source

AddNewEntry(Int32)

Add entry data added since StartNewEntry() using the ID passed.

Declaration
public void AddNewEntry(int headerID)
Parameters
Type Name Description
System.Int32 headerID

The identifier to use for this entry.

| Improve this Doc View Source

Clear()

Clear the stored data.

Declaration
public void Clear()
| Improve this Doc View Source

Delete(Int32)

Delete an extra data field.

Declaration
public bool Delete(int headerID)
Parameters
Type Name Description
System.Int32 headerID

The identifier of the field to delete.

Returns
Type Description
System.Boolean

Returns true if the field was found and deleted.

| Improve this Doc View Source

Dispose()

Dispose of this instance.

Declaration
public void Dispose()
| Improve this Doc View Source

Find(Int32)

Find an extra data value

Declaration
public bool Find(int headerID)
Parameters
Type Name Description
System.Int32 headerID

The identifier for the value to find.

Returns
Type Description
System.Boolean

Returns true if the value was found; false otherwise.

| Improve this Doc View Source

GetData<T>()

Get the tagged data for a tag.

Declaration
public T GetData<T>()
    where T : class, ITaggedData, new()
Returns
Type Description
T

Returns a tagged value or null if none found.

Type Parameters
Name Description
T

The tag to search for.

| Improve this Doc View Source

GetEntryData()

Get the raw extra data value

Declaration
public byte[] GetEntryData()
Returns
Type Description
System.Byte[]

Returns the raw byte[] extra data this instance represents.

| Improve this Doc View Source

GetStreamForTag(Int32)

Get a read-only System.IO.Stream for the associated tag.

Declaration
public Stream GetStreamForTag(int tag)
Parameters
Type Name Description
System.Int32 tag

The tag to locate data for.

Returns
Type Description
System.IO.Stream

Returns a System.IO.Stream containing tag data or null if no tag was found.

| Improve this Doc View Source

ReadByte()

Read a byte from an extra data

Declaration
public int ReadByte()
Returns
Type Description
System.Int32

The byte value read or -1 if the end of data has been reached.

| Improve this Doc View Source

ReadInt()

Read an integer in little endian form from the last found data value.

Declaration
public int ReadInt()
Returns
Type Description
System.Int32

Returns the integer read.

| Improve this Doc View Source

ReadLong()

Read a long in little endian form from the last found data value

Declaration
public long ReadLong()
Returns
Type Description
System.Int64

Returns the long value read.

| Improve this Doc View Source

ReadShort()

Read a short value in little endian form from the last found data value.

Declaration
public int ReadShort()
Returns
Type Description
System.Int32

Returns the short value read.

| Improve this Doc View Source

Skip(Int32)

Skip data during reading.

Declaration
public void Skip(int amount)
Parameters
Type Name Description
System.Int32 amount

The number of bytes to skip.

| Improve this Doc View Source

StartNewEntry()

Start adding a new entry.

Declaration
public void StartNewEntry()
Remarks

Add data using AddData(Byte[]), AddLeShort(Int32), AddLeInt(Int32), or AddLeLong(Int64). The new entry is completed and actually added by calling AddNewEntry(Int32)

See Also
AddEntry(ITaggedData)

Implements

System.IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2000-2022 SharpZipLib Contributors