# IRsFileChunk Interface Reference

Inherits IUnknown.

List of all members.

## Public Member Functions
HRESULT | ChunkID ([out, retval] IID *piidChunk)
HRESULT | CustomID ([out, retval] RtChunkCustomId *pCustomID)
HRESULT | Address ([out, retval] RtQWORD *pqwVal)
HRESULT | Length ([out, retval] RtQWORD *pqwVal)
HRESULT | SaveToStream ([in] IStream *pStream,[in] RtBOOL bSaveChunkIID,[in] RtBOOL fClearDirty)
HRESULT | LoadFromStream ([in] IStream *pStream)

## Detailed Description

Rosetta defines these pre-defined chunk types:

- Header
- Index Table
- Thumbnail
- Rosetta Object
- Tags
- History
- System
- Unknown Chunk

Each application or package can define its own chunk types as necessary. The chunk object have to aggregate IRsFileChunk that implements these interfaces:

IRsDataObject IRsPersistStream IRsCloneable

So chunk object is a data object. While system is deserializing the chunk, it uses the ChunkID for Data Object Factory to create it. Then it calls the IRsPersistStream interface. If the object is not created, then it is deserialized as Unknown Chunk.

## Member Function Documentation

HRESULT IRsFileChunk::ChunkID | ( | [out, retval] IID * | piidChunk | ) |

Use to get chunk IID. The IID identify chunk type.

Parameters:

  | pId | [out, retval] returns the chunk Id.

Returns:
  Standard HRESULT processing can be applied to the result.

HRESULT IRsFileChunk::CustomID | ( | [out, retval] RtChunkCustomId * | pCustomID | ) |

Use to get chunk's custom IID. The id is an optional identification that can be used by chunk author for quick identification in case stream/file contains more chunks of the same type.

Parameters:

  | pId | [out, retval]Returns the chunk Id.

Returns:
  Standard HRESULT processing can be applied to the result.

HRESULT IRsFileChunk::Address | ( | [out, retval] RtQWORD * | pqwVal | ) |

Use to get chunk's start address.

Parameters:

  | pqwVal | [out, retval] Returns start address of the chunk in the stream. If it is unknown or invalid, -1 is returned.

Returns:
  S_OK - if the address value is valid.
  S_FALSE - if the address is not known or invalid.
  other error - in this case the returned value is -1.

Remarks:
  The chunk's address is known only after saving to stream or after load. Then, when it is modified again, new serialization/deserialization is required.

HRESULT IRsFileChunk::Length | ( | [out, retval] RtQWORD * | pqwVal | ) |

Use to get chunk's length.

Parameters:

  | pqwVal | [out, retval] Returns length of the chunk. If it is unknown or invalid, -1 is returned.

Returns:
  S_OK - if the length value is valid.
  S_FALSE - if the length is not known or invalid.
  other error - in this case the returned value is -1.

Remarks:
  The chunk's length is known only after saving to stream or after load. Then, when it is modified again, new serialization/deserialization is required.

HRESULT IRsFileChunk::SaveToStream | ( | [in] IStream * | pStream,
|  | [in] RtBOOL | bSaveChunkIID,
|  | [in] RtBOOL | fClearDirty |
| ) |  |  |

Save chunk into stream.

Parameters:

  | pStream | [in] The target stream.
  | bSaveChunkIID | [in] If true, the chunk's IID is extracted and written as well. In case of false length of the chunk and its start address are computed without the chunk's IID size.
  | fClearDirty | [in] If true, the dirty flag is cleared after successful write operation.

Returns:
  Standard HRESULT processing can be applied to the result.

HRESULT IRsFileChunk::LoadFromStream | ( | [in] IStream * | pStream | ) |

Load chunk from stream. The stream has to be pointed after the chunk's IID.

Parameters:

  | pStream | [in] The source stream.

Returns:
  S_OK - if the chunk was loaded properly.
  S_FALSE - if the chunk was loaded properly, but length does not match with the written one or other error.