// --------------------------------------------------------------------------- // Restore the file from given directory and given index // --------------------------------------------------------------------------- // EXPORT_C CXIMPApiEventBase* CXIMPTestFileTool::PluginRestoreLC( TInt aObjIndex ) { HBufC* fileName = GetFileNameLC( KFileToolPluginDirBase, aObjIndex ); // try to instantiate it RFileReadStream in; CleanupClosePushL( in ); in.Open( iFs, *fileName, EFileStream ); TInt len = in.ReadUint32L(); HBufC8* buffer = HBufC8::NewLC( len ); TPtr8 ptr = buffer->Des(); in.ReadL( ptr ); // instantiate the object TInt32 dummy = 0; CXIMPApiEventBase* object = XIMPEventCodec::UnPackL( *buffer, dummy ); CleanupStack::PopAndDestroy( 2 ); // buffer, in // delete the just read object iFs.Delete( *fileName ); CleanupStack::PopAndDestroy( fileName ); CleanupStack::PushL( object ); return object; }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // void CNcdProviderUtils::ReadDatabaseVersionsL( const TDesC& aRootPath, TUint32& aGeneralVersion, TUint32& aPurchaseHistoryVersion ) { DLTRACEIN(("")); RBuf path; AppendPathsLC( path, aRootPath, NcdProviderDefines::KNcdDatabaseVersionFile ); RFileReadStream stream; CleanupClosePushL( stream ); User::LeaveIfError( stream.Open( FileSession(), path, EFileRead ) ); aGeneralVersion = stream.ReadUint32L(); aPurchaseHistoryVersion = stream.ReadUint32L(); CleanupStack::PopAndDestroy( 2, &path ); // stream, path DLTRACEOUT(("Versions, general: %d, purchase history: %d", aGeneralVersion, aPurchaseHistoryVersion )); }
void GetIconInfo(const TDesC& FileName, RFs& Fs, RFile& File, RFileReadStream& s, RArray<TInt>& Offsets, int round) { TBuf<50> c=_L("GetIconInfo round "); c.AppendNum(round); TInt table_offset=0; { TInt err=File.Open(Fs, FileName, EFileRead|EFileShareAny); if (err!=KErrNone) { err=File.Open(Fs, FileName, EFileRead); } User::LeaveIfError(err); RFile f0=File; s.Attach(f0, 0); TInt uid=s.ReadUint32L(); TUid file_uid={ uid }; if (file_uid==KMultiBitmapRomImageUid) { table_offset=0x4; } else { uid=s.ReadUint32L(); // uid2 uid=s.ReadUint32L(); // uid3 uid=s.ReadUint32L(); // uid4 == checksum table_offset=s.ReadUint32L(); } } TInt size=0; { c=_L("GetIconInfo::2::"); c.AppendNum(table_offset); RFile f=File; s.Attach(f, table_offset); size=s.ReadUint32L(); Offsets.Reset(); } /* MApp_context* ctx=GetContext(); c=_L("offset::"); c.AppendNum(table_offset); c.Append(_L(" ")); c.Append(_L("size::")); c.AppendNum(size); c.Append(_L(" i::0")); */ int i=0; for (i=0; i<size; i++) { TInt offset=s.ReadUint32L(); User::LeaveIfError(Offsets.Append(offset)); /* c=_L("offset::"); c.AppendNum(table_offset); c.Append(_L(" ")); c.Append(_L("size::")); c.AppendNum(size); c.Append(_L(" i::")); c.AppendNum(i); */ } }
void CApaAppListServer::InternalizeNonNativeApplicationTypeArrayL() { RFile file; CleanupClosePushL(file); const TInt error=file.Open(iFs, iNonNativeApplicationTypeRegistry, EFileShareReadersOnly|EFileStream|EFileRead); if (error==KErrNone) // don't leave if the file can't be opened (because it doesn't exist, or because the directory we're looking for it in doesn't exist) { RFileReadStream sourceStream; sourceStream.Attach(file); // file gets closed by this call, but that's okay, we don't need it any more (sourceStream has its own copy of this RFile object that it owns) CleanupClosePushL(sourceStream); TCardinality arrayCount; arrayCount.InternalizeL(sourceStream); for (TInt i=0; i<TInt(arrayCount); ++i) { SNonNativeApplicationType nonNativeApplicationType; nonNativeApplicationType.iTypeUid.iUid=sourceStream.ReadUint32L(); nonNativeApplicationType.iNativeExecutable=HBufC::NewLC(sourceStream, KMaxFileName); iNonNativeApplicationTypeArray.AppendL(nonNativeApplicationType); CleanupStack::Pop(nonNativeApplicationType.iNativeExecutable); } CleanupStack::PopAndDestroy(&sourceStream); } CleanupStack::PopAndDestroy(&file); }
// --------------------------------------------------------------------------- // CLbtCleanupHandler::ReadCleanupDataFromFileL // --------------------------------------------------------------------------- // void CLbtCleanupHandler::ReadCleanupDataFromFileL() { FUNC_ENTER("CLbtCleanupHandler::ReadCleanupDataFromFileL"); // First reset the cleanup data iCleanupItems.ResetAndDestroy(); // Open handle to file system RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); // Obtain the file path TFileName file; // Gets the path in which the file can be created fs.SessionPath(file); // Create the file Directory ie the private directory of the process fs.MkDirAll(file); // Append the name of the file file.Append(KLbtAppCleanupFileName); // Open read stream RFileReadStream readStream; TInt error = readStream.Open( fs, file, EFileRead ); if( error != KErrNone ) { // File may not exists ERROR("Opening of cleanup file failed with : %d", error); readStream.Close(); CleanupStack::PopAndDestroy(); //fs return; } CleanupClosePushL( readStream ); // Get the count in the cleanup array TInt count = readStream.ReadInt16L(); for(TInt i=0; i<count; ++i) { RArray<TLbtTriggerId> triggers; CleanupClosePushL(triggers); // Read the trigger ids TInt triggerCount = readStream.ReadInt16L(); for(TInt j=0;j<triggerCount;++j) { triggers.Append( readStream.ReadUint32L() ); } // Read the universal time TInt year = readStream.ReadInt32L(); TMonth month = static_cast<TMonth>( readStream.ReadInt32L() ); TInt day = readStream.ReadInt32L(); TDateTime dateTime( year, month, day, 0, 0, 0, 0 ); TTime time( dateTime ); CLbtCleanupItem* cleanupItem = new (ELeave) CLbtCleanupItem(); cleanupItem->AddCleanupItem( triggers, time ); CleanupStack::Pop(); // triggers triggers.Close(); // Append cleanup item to the cleaup items array iCleanupItems.Append( cleanupItem ); } CleanupStack::PopAndDestroy(2); // fs and readStream }