size_t AOS_Bitstream_PDU::addFill(const size_t fillIdx, const ACE_UINT8 fillVal /* = 0xE0 */) { long fillCount = getDataLength() - fillIdx; if ( fillCount > 0 ) { ACE_OS::memset(ptrData() + fillIdx, fillVal, fillCount); return fillCount; } return 0; }
/** "Erase" a region of the media. Effectively just fills the selected region with the specified pattern. @param aPos media position start @param aLength length of the media region to fill @param aFill filler byte. @return EPOC error code. */ TInt CWinMediaDeviceBase::Erase(TInt64 aPos, TUint32 aLength, TUint8 aFill) { //-- this method is called to "format" media. //-- Because Windows is absolute sux on everythins that concerns formattin the media (IOCTL_DISK_FORMAT_TRACKS seems to be applicable only //-- to floppy disks) we have to perform formatting by just filling media region with a given byte. //-- This can be very slow for flash - based removable media (e.g. usb flash drives) so, there is a possibility to check //-- if the given media region is already filled with the pattern and write only if not. See bCheckReadBeforeErase switch. Mem::Fill(ipScratchBuf, KScratchBufSz, aFill); TUint32 rem = aLength; TInt nRes = KErrNone; //-- if True, we firstly will read media region and check if it is already filled with the given byte. //-- this is useful for slow - write media or sparse files on NTFS. //TBool bCheckReadBeforeErase = EFalse; TBool bCheckReadBeforeErase = ETrue; while(rem) { const TUint32 bytesToWrite = Min(KScratchBufSz, rem); TPtr8 ptrData(ipScratchBuf, bytesToWrite, bytesToWrite); if(bCheckReadBeforeErase) {//-- try to read data first and check if we need to write anything ptrData.SetLength(0); nRes = Read(aPos, bytesToWrite, ptrData); if(nRes != KErrNone) break; if(!CheckBufFill(ptrData, aFill)) { Mem::Fill(ipScratchBuf, KScratchBufSz, aFill); nRes = Write(aPos, bytesToWrite, ptrData); if(nRes != KErrNone) break; } } else {//-- no need to read first nRes = Write(aPos, bytesToWrite, ptrData); if(nRes != KErrNone) break; } rem-=bytesToWrite; aPos+=bytesToWrite; } return nRes; }
void CIAUpdateNodeDetails::SetDetailsL( const MNcdNodeMetadata* aData ) { ClearAll(); // Get information from metadata. // Notice, ownership of the aData is not transferred here. if( aData ) { // Get the reference to the key value pair array // that contains all the details of the metadata. const RPointerArray< CNcdKeyValuePair >& details( aData->Details() ); for( TInt i = 0; i < details.Count(); ++i ) { // Get the first key value pair from the list. CNcdKeyValuePair* pair( details[ i ] ); if( pair->Key() == IAUpdateProtocolConsts::KImportanceKey() ) { // The pair describes the importance of the node. // Check and set the correct importance. if( pair->Value().CompareF( IAUpdateProtocolConsts::KImportanceMandatory() ) == 0 ) { iImportance = MIAUpdateBaseNode::EMandatory; } else if( pair->Value().CompareF( IAUpdateProtocolConsts::KImportanceCritical() ) == 0 ) { iImportance = MIAUpdateBaseNode::ECritical; } else if( pair->Value().CompareF( IAUpdateProtocolConsts::KImportanceRecommended() ) == 0 ) { iImportance = MIAUpdateBaseNode::ERecommended; } else if( pair->Value().CompareF( IAUpdateProtocolConsts::KImportanceHidden() ) == 0 ) { iImportance = MIAUpdateBaseNode::EHidden; } else { iImportance = MIAUpdateBaseNode::ENormal; } } else if( pair->Key() == IAUpdateProtocolConsts::KPackageTypeKey() ) { // The pair describes the content package type. // Check and set the correct type. if( pair->Value().CompareF( IAUpdateProtocolConsts::KPackageTypeSP() ) == 0 ) { iType = MIAUpdateNode::EPackageTypeSP; } else if( pair->Value().CompareF( IAUpdateProtocolConsts::KPackageTypePU() ) == 0 ) { iType = MIAUpdateNode::EPackageTypePU; } else { iType = MIAUpdateNode::EPackageTypeSA; } } else if ( pair->Key() == IAUpdateProtocolConsts::KSearchCriteriaKey() ) { // The pair describes the search criteria. // Get the criteria. delete iSearchCriteria; iSearchCriteria = NULL; iSearchCriteria = pair->Value().AllocL(); } else if ( pair->Key() == IAUpdateProtocolConsts::KDependencyKey() ) { // Create the descriptor for the dependencies data. // In order to make the data to be inside one root XML element, // insert required XML element tags to the beginning and to the end. const TDesC& dependenciesXmlData( pair->Value() ); HBufC* data( HBufC::NewLC( IAUpdateProtocolConsts::KDependenciesPrefix().Length() + dependenciesXmlData.Length() + IAUpdateProtocolConsts::KDependenciesPostfix().Length() ) ); TPtr ptrData( data->Des() ); ptrData.Copy( IAUpdateProtocolConsts::KDependenciesPrefix() ); ptrData.Append( dependenciesXmlData ); ptrData.Append( IAUpdateProtocolConsts::KDependenciesPostfix() ); // Create parser that will insert dependency information to the // given parameter objects. // Notice, that ClearAll() was called in the beginning of this function. // So, now dependency array and platform dependency contain their defaults. CIAUpdateDependencyXmlParser* parser( CIAUpdateDependencyXmlParser::NewLC( iDependencies, *iPlatformDependency ) ); parser->ParseL( ptrData ); CleanupStack::PopAndDestroy( parser ); CleanupStack::PopAndDestroy( data ); } else if ( pair->Key() == IAUpdateProtocolConsts::KFirmwareVersion1Key ) { // The pair describes the firmware version 1. // Get the value. delete iFwVersion1; iFwVersion1 = NULL; iFwVersion1 = pair->Value().AllocL(); } else if ( pair->Key() == IAUpdateProtocolConsts::KFirmwareVersion2Key ) { // The pair describes the firmware version 2. // Get the value. delete iFwVersion2; iFwVersion2 = NULL; iFwVersion2 = pair->Value().AllocL(); } else if ( pair->Key() == IAUpdateProtocolConsts::KFirmwareVersion3Key ) { // The pair describes the firmware version 3. // Get the value. delete iFwVersion3; iFwVersion3 = NULL; iFwVersion3 = pair->Value().AllocL(); } else if ( pair->Key ()== IAUpdateProtocolConsts::KRebootAfterInstallKey ) { if( pair->Value() == IAUpdateProtocolConsts::KRebootAfterInstallNeeded ) { iRebootAfterInstall = ETrue; } } } } }