// ----------------------------------------------------------------------------- // CSecModUIModel::AddResourceFileL() // ----------------------------------------------------------------------------- // void CSecModUIModel::AddResourceFileL() { LOG_ENTERFN("CSecModUIModel::AddResourceFileL()"); // Resource file loading RFs& fs = iEikEnv->FsSession(); TFileName fileName; TParse parse; // secmodui.rsc parse.Set(KResourceFile, &KDC_RESOURCE_FILES_DIR, NULL); fileName = parse.FullName(); BaflUtils::NearestLanguageFile( fs, fileName ); iResourceFileOffset = iEikEnv->AddResourceFileL( fileName ); // CertManUI.rsc parse.Set(KResourceFile2, &KDC_RESOURCE_FILES_DIR, NULL); fileName = parse.FullName(); BaflUtils::NearestLanguageFile( fs, fileName ); iResourceFileOffset2 = iEikEnv->AddResourceFileL( fileName ); // CTSecDlg.rsc parse.Set(KResourceFile3, &KDC_RESOURCE_FILES_DIR, NULL); fileName = parse.FullName(); BaflUtils::NearestLanguageFile( fs, fileName ); iResourceFileOffset3 = iEikEnv->AddResourceFileL( fileName ); LOG_LEAVEFN("CSecModUIModel::AddResourceFileL()"); }
LOCAL_C TParse DataFile() #endif { #ifdef _DRM_TESTING TRAP_IGNORE( WriteL(_L8("DataFile")) ); #endif TParse p; #ifndef RD_MULTIPLE_DRIVE p.Set(KDbFileLocation,NULL,NULL); #else //RD_MULTIPLE_DRIVE TInt driveNumber( -1 ); TChar driveLetter; DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber ); aFs.DriveToChar( driveNumber, driveLetter ); TFileName dbFile; dbFile.Format( KDbFileLoc, (TUint)driveLetter ); p.Set(dbFile,NULL,NULL); #endif return p; }
// ----------------------------------------------------------------------------- // 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; }
void ThreadTestL(TInt aThread) { RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive())); TParse testIniFile; testIniFile.Set(drive.Name(), &KTestIniFile, NULL); TIniData data; CDictionaryStore* dict=CDictionaryFileStore::OpenLC(fs,testIniFile.FullName(),KTestUid); data.LoadL(*dict); CleanupStack::PopAndDestroy(); // dict TParse threadTestPath; threadTestPath.Set(drive.Name(), &KThreadTestPath, NULL); TFileName name; name.Format(threadTestPath.FullName(),aThread); dict=CDictionaryFileStore::OpenLC(fs,name,KTestUid); data.SaveL(*dict); dict->CommitL(); CleanupStack::PopAndDestroy(); TReal x=0.501; for (TInt ii=0;ii<1000;++ii) x=4.0*x*(1.0-x); dict=CDictionaryFileStore::OpenLC(fs,name,KTestUid); data.LoadL(*dict); CleanupStack::PopAndDestroy(); // dict fs.Delete(name); CleanupStack::PopAndDestroy(); // fs }
void CStateDownload::ScanDirectory(RFs& aFs, const TDesC& aDir, const TDesC& aWild, CDesCArray* aFilesArray) { TParse parse; parse.Set(aWild, &aDir, NULL); TPtrC spec(parse.FullName()); TFindFile FindFile(aFs); CDir* dir; if (FindFile.FindWildByPath(parse.FullName(), NULL, dir) == KErrNone) { CleanupStack::PushL(dir); TInt count=dir->Count(); for(TInt i = 0; i < count; i++) { parse.Set((*dir)[i].iName, &spec, NULL); TEntry entry; if(aFs.Entry(parse.FullName(),entry) == KErrNone) { if(!entry.IsDir()) { //InsertIsqL raises a KErrAlreadyExists (-11) when inserting a duplicate TRAPD(err,aFilesArray->InsertIsqL(parse.FullName())); } } } CleanupStack::PopAndDestroy(dir); } }
LOCAL_C void ScanDirL(RFs& aFs, const TDesC& aDir) { User::After(1000000); TParse parse; parse.Set(_L("t_*.exe"), &aDir, NULL); TPtrC spec(parse.FullName()); test.Start(parse.DriveAndPath()); TFindFile find(aFs); CDir* dir; if (!find.FindWildByPath(parse.FullName(), NULL, dir)) { CleanupStack::PushL(dir); for(int i = 0; i < dir->Count(); i++) { parse.Set((*dir)[i].iName, &spec, NULL); if (i == 0) test.Start(parse.FullName()); else test.Next(parse.FullName()); LaunchAndWaitL(parse.FullName()); } CleanupStack::PopAndDestroy(); // dir } test.End(); }
// ---------------------------------------------------------------------------- // 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); }
LOCAL_C void TestInstallL(TInt aDrive) { // Clear the BIF folders theUtils->ClearBifFoldersL(); // Create BIF database CBIODatabase* db = CBIODatabase::NewLC(theUtils->FileSession()); // Create observer CBifObserver* obs = new(ELeave)CBifObserver; CleanupStack::PushL(obs); CBifChangeObserver* change = CBifChangeObserver::NewL(*obs, theUtils->FileSession()); CleanupStack::PushL(change); change->Start(); // Check the test BIO isn't installed test(!theUtils->BifInstalledL(*db, KTestBif)); test(!obs->iFlag); // Short delay to check that the observer isn't fired CTestTimer* timer = CTestTimer::NewL(); timer->After(10000000); CActiveScheduler::Start(); delete timer; // Check the test BIO still isn't installed test(!theUtils->BifInstalledL(*db, KTestBif)); test(!obs->iFlag); // Get the name of the drive TDriveUnit unit(aDrive); TPtrC drive(unit.Name()); TParse src; TParse dst; // Copy the bif file theUtils->FindFileL(src, KTestDir, KTestBif1Src); User::LeaveIfError(dst.Set(drive, &KBifDir, &KTestBifDst)); theUtils->FileSession().MkDirAll(dst.FullName()); User::LeaveIfError(BaflUtils::CopyFile(theUtils->FileSession(), src.FullName(), dst.FullName())); // Copy the Mbm file theUtils->FindFileL(src, KTestDir, KTestMbm1Src); User::LeaveIfError(dst.Set(drive, &KBifDir, &KTestMbmDst)); theUtils->FileSession().MkDirAll(dst.FullName()); User::LeaveIfError(BaflUtils::CopyFile(theUtils->FileSession(), src.FullName(), dst.FullName())); // Wait for the notification to come through CActiveScheduler::Start(); test(obs->iFlag); test(obs->iBioUid == KTestBif); test(obs->iEvent == MBifChangeObserver::EBifAdded); CleanupStack::PopAndDestroy(3); // change, obs, db }
TFileName CMobileOfficeAppUi::GetAppPath() { TParse parse; //On WINS the application is on the z drive #ifdef __WINSCW__ TFileName appfullname = Application()->AppFullName(); parse.Set(_L("c:"), &appfullname, NULL); #else parse.Set( Application()->AppFullName(), NULL, NULL); #endif return ( parse.DriveAndPath() ); //Base }
// --------------------------------------------------------------------------- // CNSmlDmFotaAdapterDb::ConstructL() // Second phase constructor. // --------------------------------------------------------------------------- // void CNSmlDmFotaAdapterDb::ConstructL() { _DBG_FILE("CNSmlDmFotaAdapterDb::ConstructL(): begin"); User::LeaveIfError( iFsSession.Connect() ); User::LeaveIfError( iRdbSession.Connect() ); iFsSession.SetSessionToPrivate( KNSmlFotaAdapterDbDrive ); TParse name; #ifdef SYMBIAN_SECURE_DBMS name.Set( KNSmlFotaAdapterDbName(), NULL, NULL ); #else name.Set( KNSmlFotaAdapterDbName(), KNSmlDatabasesNonSecurePath, NULL ); #endif TInt err = iDatabase.Open( iRdbSession, name.FullName(), KNSmlDBMSSecureMDHostOneID ); if ( err == KErrNotFound ) { CreateDatabaseL( name.FullName() ); err = iDatabase.Open( iRdbSession, name.FullName(), KNSmlDBMSSecureMDHostOneID ); User::LeaveIfError( err ); } else { if ( ( err == KErrEof ) || ( err == KErrCorrupt ) || ( err == KErrArgument ) ) { // something seriously wrong with the db, delete it and try // to create new iRdbSession.DeleteDatabase( name.FullName(), KNSmlDMHostOnePolicyUID ); CreateDatabaseL( name.FullName() ); err = iDatabase.Open( iRdbSession, name.FullName(), KNSmlDBMSSecureMDHostOneID ); } User::LeaveIfError( err ); } User::LeaveIfError( iFwObjectTable.Open( iDatabase, KNSmlTableFwMgmtObject ) ); iColSet = iFwObjectTable.ColSetL(); _DBG_FILE("CNSmlDmFotaAdapterDb::ConstructL(): end"); }
void CT_MruStep::setup() { #if defined(__EPOC32__) // if we're on the rack create the directories we need TFullName filePath=_L("c:\\docs\\tstapp.doc"); TFullName tempPath=_L("c:\\system\\temp\\"); TParse parser; parser.Set(filePath,NULL,NULL); iFs.MkDirAll(parser.DriveAndPath()); parser.Set(tempPath,NULL,NULL); iFs.MkDirAll(parser.DriveAndPath()); #endif }
void CMsvIndexContext::DoChangeDriveL(TUint aNewDriveIndex, TBool aIsRemovePartial, TDriveNumber& aNewDriveNumber) { iObserverStatus = NULL; TMsvPreferredDrive driveEntry; CMsvPreferredDriveList::GetDriveList()->DriveInfoL(aNewDriveIndex, driveEntry); aNewDriveNumber = driveEntry.driveNum; if(EMsvMessageStoreUnavailableStatus == driveEntry.status) { // Create the database and all standard table. CMsvDBAdapter::CreateDBL(driveEntry.driveNum); // Update the drive status. CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aNewDriveIndex, EMsvMessageStoreAvailableStatus); TParse parse; TPtrC drive(TDriveUnit(driveEntry.driveNum).Name()); parse.Set(KMsvDefaultIndexFile2(), &drive, NULL); iMessageFolder = parse.DriveAndPath(); ResetAndCreateNewMailStoreL(); iRunMailInit = ETrue; // Perform ChangeDrive operation. iIndexAdapter->ChangeDriveL(aNewDriveIndex, aIsRemovePartial); // Read initial entries from resources CreateStandardEntriesFromResourceFileL(KCurrentDriveId); iIndexAdapter->SetLocalServiceComplete(); } else { // Update the message folder local variable. TParse parse; TPtrC drive(TDriveUnit(driveEntry.driveNum).Name()); parse.Set(KMsvDefaultIndexFile2(), &drive, NULL); iMessageFolder = parse.DriveAndPath(); ResetAndCreateNewMailStoreL(EFalse); // Perform ChangeDrive operation. iIndexAdapter->ChangeDriveL(aNewDriveIndex, aIsRemovePartial); iRunMailInit = EFalse; } // Create service directories in new drive. TRAP_IGNORE(DoCreateServiceDirsL(KCurrentDriveId)); TRAP_IGNORE(LocalizeStandardFoldersL()); }
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")); }
// --------------------------------------------------------- // 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 } }
/** @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); \ }\ );
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()); }
/** @SYMTestCaseID SYSLIB-STORE-CT-1187 @SYMTestCaseDesc Tests for creating a new file and adding an entry into it @SYMTestPriority High @SYMTestActions Execute tests for create,open and check the contents and reopening Check for ErrNone flag during the open operation. @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void generalTestsL() { // set things up... TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive())); TParse dicFilePath; dicFilePath.Set(drive.Name(), &KDicFilePath, NULL); TInt ret = TheFs.MkDirAll(dicFilePath.FullName()); test((ret==KErrNone)||(ret==KErrAlreadyExists)); TheFs.Delete(dicFilePath.FullName()); // delete the file if it already exists // // test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1187 Create a new file and put an entry in it ")); // create a new dictionary file CDictionaryFileStore* dicFile=NULL; TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid)); test(ret==KErrNone); //Check that file is NULL Test4L(dicFile); Test1L(dicFile); // open it and check the contents TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid)); test(ret==KErrNone); Test2L(dicFile); // open it again and check the contents TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid)); test(ret==KErrNone); Test3L(dicFile); //open it again and check that contents is not NUll TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid)); test(ret==KErrNone); Test5L(dicFile); }
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; }
EXPORT_C TInt CTestConfig::ResolveFile(RFs& aFs, const TDesC& aComponent, const TDesC& aFileName, TParse& aParseOut) { TFileName* savedPath = new TFileName; TFileName* fileName = new TFileName; if ((savedPath == NULL) || (fileName == NULL)) { delete savedPath; delete fileName; return KErrNoMemory; } fileName->Append(KScriptPathSep); // fileName->Append(KSmsTestFileInputBase); // fileName->Append(KScriptPathSep); fileName->Append(aComponent); fileName->Append(KScriptPathSep); fileName->Append(aFileName); // file finder will look in the session drive first, then Y->A,Z // so set session drive to Y (save old and restore it afterwards) aFs.SessionPath(*savedPath); _LIT(KTopDrive,"Y:\\"); aFs.SetSessionPath(KTopDrive); TFindFile file_finder(aFs); TInt err = file_finder.FindByDir(*fileName,KNullDesC); if(err==KErrNone) aParseOut.Set(file_finder.File(),NULL,NULL); aFs.SetSessionPath(*savedPath); delete savedPath; delete fileName; return(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; }
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); }
/** 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; }
/** 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 }
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"); }
EXPORT_C TInt CTestUtils::ResolveLogFile(const TDesC& aFileName, TParse& aParseOut) { TFileName* savedPath = new TFileName; TFileName* fileName = new TFileName; if ((savedPath == NULL) || (fileName == NULL)) return KErrNoMemory; fileName->Append(KMsvPathSep); fileName->Append(KMsvTestFileOutputBase); fileName->Append(KMsvPathSep); // file finder will look in the session drive first, then Y->A,Z // so set session drive to Y (save old and restore it afterwards) iFs.SessionPath(*savedPath); _LIT(KTopDrive,"Y:\\"); iFs.SetSessionPath(KTopDrive); TFindFile file_finder(iFs); TInt err = file_finder.FindByDir(*fileName,KNullDesC); if(err==KErrNone) { fileName->Copy(file_finder.File()); AppendTestName(*fileName); fileName->Append(KMsvPathSep); fileName->Append(aFileName); iFs.MkDirAll(*fileName); aParseOut.Set(*fileName,NULL,NULL); } iFs.SetSessionPath(*savedPath); delete savedPath; delete fileName; return(err); }
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)); }
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 }
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); }
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(); } }
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; }*/ }