void CTorrentRecognizer::DoRecognizeL(const TDesC &aName, const TDesC8 &/*aBuffer*/) { iConfidence = ECertain; TParse parse; parse.Set(aName, NULL, NULL); TPtrC ext = parse.Ext(); if (ext.CompareF(KTorrentExtension) == 0) { iConfidence = ECertain; iDataType = TDataType(KTorrentType); } else { iConfidence = ENotRecognized; iDataType = TDataType(); } /*TFileName name=aName; name.LowerCase(); if (name.Right(KTorrentExtension().Length()) == KTorrentExtension) { iDataType = TDataType(KTorrentType); return; }*/ }
EXPORT_C #if defined (_DEBUG) /** Function to create log file @param aFileName The descriptor that holds the name of the log file to be created. @param aShowDate If set to 1, the date of creation of the log file is recorded. @param aShowTime If set to 1, the time of creation of the log file is recorded. */ void THttpLogger::CreateFlogger(const TDesC& aFileName, TInt aShowDate, TInt aShowTime) // // Create log file in directory KLogsdir\KWapLogsDirName - Note: ingore Drive and Path of aFilename { if(!iLogger) { iLogger = new RFileLogger; } if(iLogger) { TInt error = iLogger->Connect(); if(error == KErrNone) { TParse p; p.Set(aFileName, NULL, NULL); iLogger->CreateLog(KHttpLogsDirName, p.NameAndExt(), EFileLoggingModeOverwrite); iLogger->SetDateAndTime(aShowDate, aShowTime); iLogger->Write(KTestHeader); } else User::InfoPrint(_L("Flogger connect failed")); } else User::InfoPrint(_L("Flogger create failed")); }
TInt CTestUtils::AppendMainLogL() { _LIT(KDisplayLogFile,"Log File %S\n"); TParse loglocation; TFileName logfile; TInt err=ResolveLogFile(KNullDesC, loglocation); if(err!=KErrNone) { iFs.MkDirAll(KMsvTestFileDefaultOutputBase); err=ResolveLogFile(KNullDesC, loglocation); } User::LeaveIfError(err); logfile.Copy(loglocation.FullName()); logfile.Delete(logfile.Length()-1,1); AppendVariantName(logfile); iRTest.Printf(KDisplayLogFile, &logfile); iFs.MkDirAll(logfile); iLogBuf=HBufC::NewL(KMaxLogLineLength); iLogBuf8=HBufC8::NewL(KMaxLogLineLength); TInt pos=0; TInt ret=KErrNone; ret=iFile.Open(iFs,logfile,EFileWrite|EFileShareAny); if (ret==KErrNotFound) ret=iFile.Create(iFs,logfile,EFileWrite|EFileShareAny); if (ret==KErrNone) return(iFile.Seek(ESeekEnd,pos)); else return(ret); }
EXPORT_C void CPrintSetup::AddPrinterDriverDirL(const TDesC& aDriverDir) /** Adds a search path for printer drivers. This function must be called before a model name list can be created. It can be called repeatedly to add a number of paths to the search list. When a printer model name list is requested (using ModelNameListL()), the directories specified in each of the search paths are scanned on all non-remote drives for .pdr files, indicating the models supported. If any path contains a drive, that drive alone is searched. @param aDriverDir Path which specifies a directory in which to search for printer drivers. Any filename in the path is ignored. If the path is already in the list, it is not added again. @leave KErrNoMemory There is insufficient memory to perform the operation. */ { TParse parser; parser.Set(aDriverDir,NULL,NULL); for (TInt i=iDriverDirList->Count()-1 ; i>=0 ; i--) { if ( (*iDriverDirList)[i].CompareF(parser.DriveAndPath())==0 ) return; // its already on the list, so dont add it again } iDriverDirList->AppendL(parser.DriveAndPath()); }
// ----------------------------------------------------------------------------- // CWPInternetAPDB::CreateandOpenL // ----------------------------------------------------------------------------- // void CSCOMOAdapterDb::CreateandOpenL(TParse& name) { TInt err; #ifdef SYMBIAN_SECURE_DBMS iDatabase.Create(iRdbSession, name.FullName(), KDBMSSecureID); #else if( SysUtil::FFSSpaceBelowCriticalLevelL( &iFsSession, KEmptyDbSizeEstimate ) ) { User::Leave( KErrDiskFull ); } iDatabase.Create(iFsSession, name.FullName()); #endif CreateTableL(iDatabase); iDatabase.Close(); #ifdef SYMBIAN_SECURE_DBMS err = iDatabase.Open(iRdbSession, name.FullName(), KDBMSSecureID); #else err = iDatabase.Open(iFsSession, DBFileName); #endif //Debug if (err != KErrNone) { User::LeaveIfError(err); } }
// ----------------------------------------------------------------------------- // CbsUtils::FindAndOpenDefaultResourceFileLC // Searches and opens the DLL default resource file. // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CbsUtils::FindAndOpenDefaultResourceFileLC( RFs& aFs, RResourceFile& aResFile ) { // default resource file path _LIT(KDirAndFile,"z:CbsServer.rsc"); TParse* fp = new(ELeave) TParse(); fp->Set(KDirAndFile, &KDC_RESOURCE_FILES_DIR, NULL); static const TInt KDefResFileSignature = 4; // Find the resource file TFileName fileName( fp->FullName() ); BaflUtils::NearestLanguageFile( aFs, fileName ); // Open the resource file aResFile.OpenL( aFs, fileName ); // Push close operation in tbe cleanup stack CleanupClosePushL( aResFile ); aResFile.ConfirmSignatureL( KDefResFileSignature ); delete fp; }
LOCAL_C void MainL() /** * Main implementation */ { CActiveScheduler* sched=NULL; sched=new(ELeave) CActiveScheduler; CActiveScheduler::Install(sched); CTeIpUpsSuite* server = NULL; CCommandLineArguments* args = CCommandLineArguments::NewLC(); TPtrC exeName = args->Arg(0); TParse fullName; fullName.Set(exeName, NULL, NULL); CleanupStack::PopAndDestroy(args); // Create the CTestServer derived server TRAPD(err,server = CTeIpUpsSuite::NewL(fullName.Name())); if(!err) { // Sync with the client and enter the active scheduler RProcess::Rendezvous(KErrNone); sched->Start(); } delete server; delete sched; }
void CQualityProfileApi_ProfileReadStep::InitializeQualityProfileInfoL() { RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); TBuf<32> privatePath; User::LeaveIfError(fs.PrivatePath(privatePath)); TParse parse; parse.Set(privatePath, NULL, NULL); parse.AddDir(KLbsDir); RArray<TQualityProfile> qualityArray; CleanupClosePushL(qualityArray); qualityArray.Reserve(5); // Only want to use the first file that is found. // The way TFindFile::FindByDir works, it will search // C: and D: before Z:, which is what we want. TFindFile findFile(fs); TInt err = findFile.FindByDir(KQualityProfileIniName, parse.Path()); if (err == KErrNone) { GetQualityProfileInfoL(fs, qualityArray, findFile.File()); } // Publish the quality profile info LbsQualityProfile::InitializeL(qualityArray); CleanupStack::PopAndDestroy(&qualityArray); CleanupStack::PopAndDestroy(&fs); }
HBufC* CScriptFile::ReadFileLC(const TDesC& aScript) const { HBufC8* file = NULL; TRAPD(err, file = ReadFileL(aScript)); if (err) { TParse fileOut; err = iTestUtils.ResolveFile(*iComponent, aScript, fileOut); if (err) { iTestUtils.Test().Printf(_L("Cannot read file %S. Error=%d"), &aScript, err); User::Leave(err); } file = ReadFileL(fileOut.FullName()); } CleanupStack::PushL(file); HBufC* buf = HBufC::NewL(file->Length()); buf->Des().Copy(*file); CleanupStack::PopAndDestroy(file); CleanupStack::PushL(buf); return buf; }
void CNSmlDSSettings::CreateHiddenProfilesL() { TFileName fileName; Dll::FileName( fileName ); TParse parse; parse.Set( KNSmlDSProfilesRsc, &fileName, NULL ); fileName = parse.FullName(); RResourceFile resourceFile; BaflUtils::NearestLanguageFile( iFsSession, fileName ); TRAPD(leavecode,resourceFile.OpenL( iFsSession,fileName)); if(leavecode != 0) { return; } CleanupClosePushL(resourceFile); HBufC8* profileRes = resourceFile.AllocReadLC( NSML_DS_PROFILES ); TResourceReader reader; reader.SetBuffer( profileRes ); CNSmlDSResourceProfiles* profileResReader = CNSmlDSResourceProfiles::NewLC( reader, this ); profileResReader->SaveProfilesL(iResourceProfileArray); CleanupStack::PopAndDestroy(3); // profileResReader, profileRes, resourceFile }
// ----------------------------------------------------------------------------- // DataFileL // return data filename as a TParse // ----------------------------------------------------------------------------- // LOCAL_C TParse DataFileL(RFs& aFs) { TBuf<256> path; TParse p; User::LeaveIfError(aFs.PrivatePath(path)); #ifndef RD_MULTIPLE_DRIVE p.Set(KHelperServerDataStorage,&path,NULL); #else //RD_MULTIPLE_DRIVE TInt driveNumber( -1 ); TChar driveLetter; DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber ); aFs.DriveToChar( driveNumber, driveLetter ); TFileName helperServerDataStorage; helperServerDataStorage.Format( KHelperServerDataStorage, (TUint)driveLetter ); p.Set( helperServerDataStorage, &path, NULL ); #endif return p; }
/** Test CDictionaryFileStore construction, forcing a leave error at each possible stage of the process. @SYMTestCaseID SYSLIB-STORE-CT-1190 @SYMTestCaseDesc Tests for CDictionaryFileStore construction under low memory conditions. @SYMTestPriority High @SYMTestActions Attempt for construction under low memory conditions. @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void TestOOML() { test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1190 Construction under low memory conditions ")); TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive())); TParse dicFilePath; dicFilePath.Set(drive.Name(), &KDicFilePath, NULL); TheFs.Delete(dicFilePath.FullName()); // delete the file TInt failRate=0; for (failRate=1;;failRate++) { __UHEAP_SETFAIL(RHeap::EDeterministic,failRate); __UHEAP_MARK; TRAPD(ret, AddEntryL()); __UHEAP_MARKEND; if (ret==KErrNone) break; test (ret==KErrNoMemory); __UHEAP_RESET; test (!CheckEntryL()); } __UHEAP_RESET; test (CheckEntryL()); test.Printf(_L(" #allocs for update: %d\n"),failRate-1); // // tidy up }
// --------------------------------------------------------- // CNSmlDsProvisioningAdapter::GetTitleL // --------------------------------------------------------- void CNSmlDsProvisioningAdapter::GetTitleL() { if( iTitle == 0 ) { RFs fs; User::LeaveIfError( fs.Connect() ); CleanupClosePushL( fs ); TFileName fileName; TParse parse; parse.Set( KNSmlDsPovisioningDirAndResource, &KDC_RESOURCE_FILES_DIR, NULL ); fileName = parse.FullName(); RResourceFile resourceFile; BaflUtils::NearestLanguageFile( fs, fileName ); resourceFile.OpenL( fs, fileName ); CleanupClosePushL( resourceFile ); HBufC8* dataBuffer = resourceFile.AllocReadLC( R_SYNC_PROVISIONING_TITLE ); TResourceReader reader; reader.SetBuffer( dataBuffer ); iTitle = reader.ReadHBufC16L(); CleanupStack::PopAndDestroy( 3 ); //fs, resourcefile, databuffer } }
void CSupLoginServiceProvider::ConstructL() { __LOGSTR_TOFILE("CSupLoginServiceProvider::ConstructL() begins"); // Form full path to credentials settings file RFs &fs = CCoeEnv::Static()->FsSession(); TFileName privatePath; fs.PrivatePath(privatePath); TParse parser; TFileName processFileName(RProcess().FileName()); User::LeaveIfError(parser.Set(KLoginProviderSettingsFilename, &privatePath, &processFileName)); iSettingsFile = parser.FullName(); // Read credentials from settings file ReadDataFromFileL(); if (iMemberID && iUsername && iPassword) iLogged = ETrue; // Discover and retrieve description of the web service CSenXmlServiceDescription* serviceDesc = CSenXmlServiceDescription::NewLC( KServiceEndpointMemberId, KNullDesC8 ); serviceDesc->SetFrameworkIdL(KDefaultBasicWebServicesFrameworkID); // Create connection to web service iConnection = CSenServiceConnection::NewL(*this, *serviceDesc); CleanupStack::PopAndDestroy(); // serviceDesc __LOGSTR_TOFILE("CSupLoginServiceProvider::ConstructL() ends"); }
void CSmsSendRecvTest::TestAddBifL(const TDesC& aBifName) { iSmsTest.Printf(_L("\tAdd BIF: %S\n"), &aBifName); RFs& fs = iSmsTest.FileSession(); TInt err = fs.MkDir(KBifDir); if (err != KErrAlreadyExists) User::LeaveIfError(err); TParse fileOut; err = iSmsTest.ResolveFile(KSmsComponent, aBifName, fileOut); if (err) { iSmsTest.Printf(_L("Test BIF %S not found! Continuing without this test\n"), &aBifName); return; } CFileMan* fileMan = CFileMan::NewL(fs); CleanupStack::PushL(fileMan); err = fileMan->Copy(fileOut.FullName(), KBifDir); if (err != KErrAlreadyExists) User::LeaveIfError(err); CleanupStack::PopAndDestroy(fileMan); User::After(KBifWait); }
void CTap2MenuAppUi::ReadExceptions() { TInt err=KErrNone; iExceptions.Reset(); if (BaflUtils::FileExists(CEikonEnv::Static()->FsSession(),KExceptionsPath)) //!!!!!!!!!!!!!!!!!!!!!!!!!!! { TBuf<255> val; TLex conv; TUint32 IntVal; RFile filesave; TBuf<255> t; TFileText ft; filesave.Open(CEikonEnv::Static()->FsSession(), KExceptionsPath, EFileRead); ft.Set(filesave); while (ft.Read(val)==KErrNone) { conv.Assign(val); conv.Val(IntVal,EHex); iExceptions.AppendL(TUid::Uid(IntVal)); } filesave.Close(); } else { TParse parse; CEikonEnv::Static()->FsSession().Parse(KExceptionsPath,parse); if (!BaflUtils::FolderExists(CEikonEnv::Static()->FsSession(),parse.DriveAndPath())) { CEikonEnv::Static()->FsSession().MkDirAll(parse.DriveAndPath()); } } }
// ----------------------------------------------------------------------------- // CbsUtils::ExistsL // Returns ETrue, if the file aFile exists. // (other items were commented in a header). // ----------------------------------------------------------------------------- // TBool CbsUtils::ExistsL( const RFs& aFs, const TDesC& aFile ) { TParse filename; aFs.Parse( aFile, filename ); TBool returnCode( EFalse ); TUint attributes; TInt result( aFs.Att( filename.FullName(), attributes ) ); if ( result == KErrNone ) { returnCode = ETrue; } else if ( result == KErrNotFound ) { returnCode = EFalse; } else { User::Leave( result ); } return returnCode; }
// --------------------------------------------------------- // CCookieManagerServer::CheckDiskSpace // --------------------------------------------------------- // TBool CCookieManagerServer::CheckDiskSpace( RFs& aFileSystem, const TDesC& aFileName ) const { TInt err; TParse parse; err = parse.SetNoWild( aFileName, NULL, NULL ); if ( err == KErrNone ) { // This is in the form : drive-letter: (letter + semi-colon) TBuf<2> driveBuf( parse.Drive() ); TCharF driveLetter( driveBuf[0] ); TCharF driveALetter( 'A' ); TDriveNumber driveNum = (TDriveNumber)( (TUint)(driveLetter) - (TUint)(driveALetter) ); TBool noSpace = EFalse; TRAP( err, noSpace = SysUtil::DiskSpaceBelowCriticalLevelL ( &aFileSystem, KCookieMaxFileLength, driveNum ) ); if ( err == KErrNone && noSpace ) { err = KErrDiskFull; } } return ( err == KErrNone ? ETrue : EFalse ); }
void CAddObexAttachmentAsEntryState::StartL(TRequestStatus& aStatus) { // Add an attachment as a child entry CBaseMtm& clientMtm = iClientTest.ObexTestUtils().GetCurrentObexClientMtm(); CMsvEntry& entry = clientMtm.Entry(); CMsvStore* store = entry.EditStoreL(); CleanupStack::PushL(store); CAsyncWaiter* waiter = CAsyncWaiter::NewL(); CleanupStack::PushL(waiter); CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); CleanupStack::PushL(attachment); TParse fileNameParser; User::LeaveIfError(fileNameParser.Set(iFileName, NULL, NULL)); attachment->SetAttachmentNameL(fileNameParser.NameAndExt()); store->AttachmentManagerL().AddAttachmentL(iFileName, attachment, waiter->iStatus); CleanupStack::Pop(attachment); waiter->StartAndWait(); User::LeaveIfError(waiter->Result()); CleanupStack::PopAndDestroy(waiter); store->CommitL(); CleanupStack::PopAndDestroy(store); TRequestStatus* status = &aStatus; User::RequestComplete(status, KErrNone); }
void CAknFileSettingPage::SetFolderL(const TDesC& aFolder) { TParse parse; TFileName file; TDesC* pos=NULL; parse.SetNoWild(iFileValue,NULL,NULL); if(aFolder.CompareF(KFolderUp)==0) { if(iFileValue.Length()) { if(parse.PopDir()==KErrNone) { TParse parse2; parse2.SetNoWild(iFileValue,NULL,NULL); TPtrC ptr=parse2.DriveAndPath(); file=ptr.Left(ptr.Length()-1); parse2.SetNoWild(file,NULL,NULL); file=parse2.NameAndExt(); pos=&file; iFileValue=parse.DriveAndPath(); } else iFileValue.Zero(); } } else { iFileValue=parse.DriveAndPath(); iFileValue.Append(aFolder); iFileValue.Append('\\'); } ReadFilesL(pos); }
HBufC8* CTestConfig::ReadFileL(const TDesC& aFile) const { //Returns a HBufC8 with the contents of aFile RFile file; const TInt err = file.Open(iFs, aFile, EFileShareAny | EFileRead); if (err != KErrNone) { TParse fileOut; User::LeaveIfError(ResolveFile(iFs, *iComponent, aFile, fileOut)); User::LeaveIfError(file.Open(iFs, fileOut.FullName(), EFileShareAny | EFileRead)); } CleanupClosePushL(file); TInt size = 0; User::LeaveIfError(file.Size(size)); HBufC8* contents = HBufC8::NewLC(size + 4); TPtr8 contentsPtr(contents->Des()); User::LeaveIfError(file.Read(0, contentsPtr)); CleanupStack::Pop(contents); CleanupStack::PopAndDestroy(&file); return contents; }
void CAknFileSettingPage::ConstructL(void) { BaseConstructL(); //listbox icons CAknIconArray* icons=new(ELeave)CAknIconArray(2); CleanupStack::PushL(icons); icons->ConstructFromResourceL(R_CLOCKAPP_EXTRA_SETTING_ICONS); FileControl()->ItemDrawer()->ColumnData()->SetIconArray(icons); CleanupStack::Pop(); //icons //listbox items iFiles=new(ELeave)CDesCArrayFlat(32); CTextListBoxModel* model=FileControl()->Model(); model->SetItemTextArray(iFiles); //old text array deleted by owner model->SetOwnershipType(ELbmOwnsItemArray); //transfer ownership TParse parse; parse.SetNoWild(iFileValue,NULL,NULL); TPtrC name=parse.NameAndExt(),path=parse.DriveAndPath(); TDesC* pos=&name; if(!BaflUtils::PathExists(iFs,path)) { pos=NULL; iFileValue.Zero(); } ReadFilesL(pos); }
// ---------------------------------------------------------------------------- // Symbian 2nd phase constructor can leave. // ---------------------------------------------------------------------------- // void CWrtHarvester::ConstructL() { User::LeaveIfError( iApaSession.Connect() ); iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState ); iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered ); User::LeaveIfError( iFs.Connect() ); iWidgetUsbListener = CWrtUsbHandler::NewL( this, iFs ); iWidgetUsbListener->Start(); SetMSMode(0); TFileName resourceFileName; TParse parse; Dll::FileName (resourceFileName); parse.Set(KResourceFileName, &resourceFileName, NULL); resourceFileName = parse.FullName(); CCoeEnv* coeEnv = CCoeEnv::Static(); BaflUtils::NearestLanguageFile(coeEnv->FsSession(), resourceFileName); if ( !BaflUtils::FileExists( coeEnv->FsSession(), resourceFileName ) ) { // Use resource file on the Z drive instead parse.Set( KResourceDir, &KDC_RESOURCE_FILES_DIR, NULL ); resourceFileName = parse.FullName(); BaflUtils::NearestLanguageFile( coeEnv->FsSession(),resourceFileName ); } iResourceFileOffset = coeEnv->AddResourceFileL(resourceFileName); }
void CMtfTestActionAddAttachmentAsLink::RunTestL() { CMsvStore* paramStore = ObtainParameterReferenceL<CMsvStore>(TestCase(),ActionParameters().Parameter(0)); HBufC* paramFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1)); HBufC8* paramMimeType = ObtainParameterReferenceL<HBufC8>(TestCase(),ActionParameters().Parameter(2)); CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); CleanupStack::PushL(waiter); CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile); CleanupStack::PushL(attachment); attachment->SetMimeTypeL(*paramMimeType); TParse fileNameParser; User::LeaveIfError(fileNameParser.Set(*paramFilePath, NULL, NULL)); attachment->SetAttachmentNameL(fileNameParser.NameAndExt()); MMsvAttachmentManager& manager = paramStore->AttachmentManagerL(); manager.AddLinkedAttachmentL(*paramFilePath, attachment, waiter->iStatus); CleanupStack::Pop(attachment); // ownership passed to manager waiter->StartAndWait(); User::LeaveIfError(waiter->Result()); CleanupStack::PopAndDestroy(waiter); TMsvAttachmentId attachmentId = attachment->Id(); paramStore->CommitL(); StoreParameterL<TMsvAttachmentId>(TestCase(),attachmentId,ActionParameters().Parameter(3)); }
/** @SYMTestCaseID SYSLIB-STORE-CT-3350 @SYMTestCaseDesc Direct file store verification test @SYMTestPriority High @SYMTestActions Open a corrupted direct store file @SYMTestExpectedResults the function called leaves with KErrNotSupported @SYMDEF DEF100757 */ LOCAL_C void DirectFileL() { Test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-3350 Creating Direct File Store ")); TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive())); TParse parse; parse.Set(drive.Name(), &KTestDirectFileName, NULL); // create a direct file store TheStore=CDirectFileStore::ReplaceLC(TheFs,parse.FullName(),EFileWrite); TheStore->SetTypeL(TheStore->Layout()); TInt8 val=100; TStreamId id=TheSink.CreateL(*TheStore); TheSink<<val; TheSink.Close(); TheStore->SetRootL(id); TheStore->CommitL(); CleanupStack::PopAndDestroy(TheStore); // corrupt the store file RFile file; User::LeaveIfError(file.Open(TheFs,parse.FullName(),EFileWrite)); CleanupClosePushL(file); User::LeaveIfError(file.Write(KTestJunkData,sizeof(TCheckedUid))); CleanupStack::PopAndDestroy(&file); // the CDirectFileStore::OpenLC should leave if passed the corrupted store file name TheStore = NULL; TRAPD(r, \ {\ TheStore=CDirectFileStore::OpenLC(TheFs,parse.FullName(),EFileRead);\ CleanupStack::PopAndDestroy(TheStore); \ }\ );
void CPreModifierPlugin::FsReadFileSectionL(TFsPluginRequest& aRequest) { TInt err = KErrNone; TInt length = 0; TInt64 pos = 0; TFileName filename; TParse parse; TBuf<256> testfilename1; //setting up test files testfilename1.Append(iDriveToTest); testfilename1.Append(_L(":\\Data\\test.txt")); filename = aRequest.Src().FullName(); err = aRequest.Read(TFsPluginRequest::ELength, length); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL err = aRequest.Read(TFsPluginRequest::EPosition, pos); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL parse.Set(filename, NULL, NULL); _LOG2(_L("CPreModifierPlugin::FsReadFileSectionL, file: %S"), &filename); if (aRequest.IsPostOperation()) { _LOG(_L("CPreModifierPlugin::FsReadFileSectionL, post intercept - enter")); RFilePlugin fileplugin2(aRequest,ETrue); //open a second file err = fileplugin2.Open(testfilename1, EFileWrite); _LOG3(_L("CPreModifierPlugin::FsReadFileSectionL - RFilePlugin::Open for %S returned %d"), &testfilename1, err); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL TInt64 size=0; err = fileplugin2.Size(size); _LOG3(_L("CPreModifierPlugin::FsReadFileSectionL - RFilePlugin::Size for %S returned %d"), &testfilename1, err); iLastError = err; iLineNumber = __LINE__; if(err!=KErrNone) User::Leave(err); //trapped in DoRequestL //close the second file fileplugin2.Close(); _LOG(_L("CPreModifierPlugin::FsReadFileSectionL - post intercept - exit")); } else { User::Invariant(); } }
TInt CTestUtils::OpenMainLogL() { _LIT(KDisplayLogFile,"Log File %S\n"); TParse loglocation; TFileName logfile; TInt err=ResolveLogFile(KNullDesC, loglocation); if(err!=KErrNone) { TChar driveChar=RFs::GetSystemDriveChar(); TBuf<2> systemDrive; systemDrive.Append(driveChar); systemDrive.Append(KDriveDelimiter); TPath pathName(systemDrive) ; pathName.Append(KMsvTestFileDefaultOutputBase); iFs.MkDirAll(pathName); err=ResolveLogFile(KNullDesC, loglocation); } User::LeaveIfError(err); logfile.Copy(loglocation.FullName()); logfile.Delete(logfile.Length()-1,1); AppendVariantName(logfile); iRTest.Printf(KDisplayLogFile, &logfile); iFs.MkDirAll(logfile); iLogBuf=HBufC::NewL(KMaxLogLineLength); iLogBuf8=HBufC8::NewL(KMaxLogLineLength); return(iFile.Replace(iFs,logfile,EFileWrite|EFileShareAny)); }
/** Load a factory and check the Uid etc function always opens factory CObject if successful */ CPktDrvFactory* CLANLinkCommon::DoCreateDriverFactoryL(TUid aUid2,const TDesC& aFilename) { TParse parse; User::LeaveIfError(parse.Set(aFilename,0,0)); CPktDrvFactory* f=0; TAutoClose<RLibrary> lib; User::LeaveIfError(lib.iObj.Load(aFilename)); lib.PushL(); // The Uid check if(lib.iObj.Type()[1]!=aUid2) User::Leave(KErrBadLibraryEntryPoint); TPktDrvFactoryNewL libEntry=(TPktDrvFactoryNewL)lib.iObj.Lookup(1); if (libEntry==NULL) User::Leave(KErrNoMemory); f =(*libEntry)(); // Opens CObject (can leave) CleanupStack::PushL(f); f->Install(lib.iObj); // Transfers the library object if successful // Can pop the library now - auto close will have no effect because handle is null CleanupStack::Pop(); lib.Pop(); return f; }
LOCAL_C void doDeferredLoadingL(const TDesC& aName) { TParse filestorename; fsSession.Parse(aName,filestorename); // construct file store object - specifying the file // containing the store. CFileStore* store = CPermanentFileStore::OpenLC(fsSession,filestorename.FullName(),EFileRead); // Construct an object of type CCompound. // The loading of its components is deferred // until needed. CCompound* thecompound = CCompound::NewLC(*store,store->Root()); // Display component A. // The component is loaded in from the // stream if not already loaded. _LIT(KTxtFirstDisplay," (first display)"); thecompound->DisplayAL(KTxtFirstDisplay); // Re-Display component A // The component should now be in memory. _LIT(KTxtSecondDisplay," (second display)"); thecompound->DisplayAL(KTxtSecondDisplay); console->Printf(KTxtNewLine); // Destroy: // 1. the CCompound object // 2. the store object (this also closes // the file containing the store) // Remove both from the cleanup stack CleanupStack::PopAndDestroy(2); }
void CMsvIndexContext::CreateStoreDeleteFile() #endif { #if (!defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT) TDriveNumber aDriveNum = (TDriveNumber)(TInt) Config().iDrive; #endif RFs& fs = iServer.FileSession(); TInt err = fs.SetSessionToPrivate(aDriveNum); if(err == KErrNone) { RFile storeDeletedFile; #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE) TParse parse; TPtrC drive(TDriveUnit(aDriveNum).Name()); parse.Set(KStoreDeletedFile, &drive, NULL); TFileName fileName = parse.FullName(); #else TFileName fileName(KStoreDeletedFile); #endif // #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE) err = storeDeletedFile.Replace(fs, fileName, EFileShareExclusive); if(err == KErrNone) { _LIT8(KMsvIndexStoreDeleted,"StoreDeleted"); storeDeletedFile.Write(KMsvIndexStoreDeleted); } storeDeletedFile.Close(); } }