Class ZipExtraData
A class to handle the extra data field for Zip entries
Inheritance
Implements
Inherited Members
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 SourceZipExtraData()
Initialise a default instance.
Declaration
public ZipExtraData()
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 SourceCurrentReadIndex
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().
Length
Gets the current extra data length.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
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 |
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 SourceAddData(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
| Improve this Doc View SourceAddData(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
| Improve this Doc View SourceAddEntry(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. |
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.
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
| Improve this Doc View SourceAddLeLong(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
| Improve this Doc View SourceAddLeShort(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
| Improve this Doc View SourceAddNewEntry(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. |
Clear()
Clear the stored data.
Declaration
public void Clear()
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. |
Dispose()
Dispose of this instance.
Declaration
public void Dispose()
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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)