This chapter describes the KCMS framework KcsChunkSet class. You can manage blocks (or chunks) of data arranged in tagged file format with Chunk classes. The ICC profile format is directly analogous to the KcsChunkSet. The KcsChunkSet class is derived from the KcsShareable class. See Chapter 1, KcsShareable Class for a description of the KcsShareable class.
As you read this chapter, you will find it helpful to have access to the following header files:
kcsshare.h
kcsio.h and kcsmblk.h
kcschu.h and kcschunk.h
It is highly recommended that you do not use any of the variables and functions for handle-based memory in the these header files. Handle-based memory is not required on the Solaris system.
The header file for the class is kcschunk.h. The constant and #define identifiers for this class are defined in the kcsids.h header file as:
const KcsId KcsSharChkSId = {(0x43686B53UL)}; /* 'ChkS' */ #define KcsSharChkSIdd (0x43686B53UL) /* 'ChkS' */
In addition to the KcsShareable methods overridden by this class, there are methods for managing chunks of data. The protected and public members are described.
The KcsChunkSet class has the following protected members.
Table 3-1 KcsChunkSet Protected Members
Protected Member |
Description |
---|---|
virtual KcsStatus readChunkBuffer(const KcsChunkId aChunkId, void *aChunk,unsigned long *aSizeRead, unsigned long aSizeWanted = 0); |
Reads a chunk of bytes indicated by a chunk Id. KCS_CHUNK_ID_ERR is returned if no chunk Ids match in the profile. Assumes the aChunk buffer is allocated. Get the buffer size with getChunkSize() which is defined in Table 3-2. |
virtual KcsStatus writeChunkBuffer(const KcsChunkId aChunkId, void *aChunk, const unsigned long aSize, KcsCompressBoolean aCompress = KcsCompress, KcsLocationEnum aLocationEnum = KcsLocationUnspecified, long aOffset = KcsNoOffsetSpecified); |
Writes a chunk of bytes to a new chunk in the profile, given a void *. Returns a new chunk Id. If a particular location or offset is specified, other chunks are moved to write this chunk at the specified location. |
The KcsChunkSet class has the following public members.
Table 3-2 KcsChunkSet Public Members
The following code shows you some examples of how to use these KcsChunkSet class member functions: getChunkSet(), getChunkSize(), readChunk(), and writeChunk().
KcsChunkId myChunkId; KcsStatus aStat; KcsChunkSet* chunkSet; char* mftData; u_long mftSize; u_long mftWanted; // Get the chunk data chunkSet = getChunkSet(); if (chunkSet == NULL) return (KCS_INTERNAL_CLASS_CORRUPTED); //Get the size mftSize = chunkSet->getChunkSize(&aStat, myChunkId); if (aStat != KCS_SUCCESS) return(aStat); //Make space for the data mftData = NULL; if ((mftData = malloc((u_int)mftSize)) == NULL) { return (KCS_MEM_ALLOC_ERR); } //Read it aStat = chunkSet->readChunk(myChunkId, mftData, &mftWanted, mftSize); if (aStat != KCS_SUCCESS) return (aStat); //Zero it out and write it back memset(mftData, 0, mftSize); aStat = chunkSet->writeChunk(myChunkId, mftData, mftSize); if (aStat != KCS_SUCCESS) return (aStat); |