KCMS CMM Reference Manual


The following code shows you some examples of how to use these KcsChunkSet class member functions: getChunkSet(), getChunkSize(), readChunk(), and writeChunk().

Example 3-1 Getting, Reading and Writing a Chunk

KcsChunkId				myChunkId;
 KcsStatus				aStat;
 KcsChunkSet*				chunkSet;
 char*				mftData;
 u_long				mftSize;
 u_long				mftWanted;

 // Get the chunk data
 chunkSet = getChunkSet();
 if (chunkSet == NULL)

 //Get the size
 mftSize = chunkSet->getChunkSize(&aStat, myChunkId);
 if (aStat != KCS_SUCCESS)

 //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,
 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);