void CApaAppListServer::ExternalizeNonNativeApplicationTypeArrayL(TInt aIndexToIgnore/*=-1*/) const { RFs& fs=const_cast<RFs&>(iFs); fs.MkDirAll(iNonNativeApplicationTypeRegistry); // ignore any error RFile file; CleanupClosePushL(file); User::LeaveIfError(file.Replace(fs, iNonNativeApplicationTypeRegistry, EFileShareExclusive|EFileStream|EFileWrite)); RFileWriteStream targetStream; targetStream.Attach(file); // file gets closed by this call, but that's okay, we don't need it any more (targetStream has its own copy of this RFile object that it owns) CleanupClosePushL(targetStream); const TInt arrayCount(iNonNativeApplicationTypeArray.Count()); TInt arrayCountToExternalize=arrayCount; if (aIndexToIgnore>=0) { --arrayCountToExternalize; } TCardinality(arrayCountToExternalize).ExternalizeL(targetStream); for (TInt i=0; i<arrayCount; ++i) { if (i!=aIndexToIgnore) { const SNonNativeApplicationType& nonNativeApplicationType=iNonNativeApplicationTypeArray[i]; targetStream.WriteUint32L(nonNativeApplicationType.iTypeUid.iUid); targetStream << *nonNativeApplicationType.iNativeExecutable; } } targetStream.CommitL(); CleanupStack::PopAndDestroy(2, &file); }
void CCmdCustomCommand::WriteHandleToFileL(TInt aHandle) { const TChar sysDrive = RFs::GetSystemDriveChar(); RBuf filename; filename.CreateL(KNeverUnloadLibHandleFile().Length() + 1); filename.Append(sysDrive); filename.Append(KNeverUnloadLibHandleFile()); filename.CleanupClosePushL(); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); fs.MkDirAll(filename); // ignore any error RFile file; CleanupClosePushL(file); TInt err=KErrNone; TInt pos = 0; if(KErrNotFound == (err = file.Open(fs, filename, EFileShareExclusive|EFileStream|EFileWrite))) { User::LeaveIfError(file.Replace(fs, filename, EFileShareExclusive|EFileStream|EFileWrite)); } else { User::LeaveIfError(err); file.Seek(ESeekEnd, pos); } RFileWriteStream targetStream; targetStream.Attach(file, pos); // file gets closed by this call, but that's okay, we don't need it any more (targetStream has its own copy of this RFile object that it owns) CleanupClosePushL(targetStream); targetStream.WriteInt32L(aHandle); targetStream.CommitL(); CleanupStack::PopAndDestroy(4); }