void CPopsTestHarness::CopyScriptFileL(const TDesC& aScriptFile) { TParse parsedScriptFile; parsedScriptFile.Set(aScriptFile,0,0); if (!parsedScriptFile.DrivePresent()) // This isn't a full path name so we need to resolve it { iTestUtils->ResolveFile(K_POPS_COMPONENT_NAME, aScriptFile, parsedScriptFile); } iTestUtils->CopyScriptFileL(parsedScriptFile.FullName(), _L("110")); }
/*static*/ TInt CJournalFile::CheckFileNameL(RFs&, const TDesC& aFileName) { TParse parse; User::LeaveIfError(parse.Set(aFileName, NULL, NULL)); if (!parse.DrivePresent()) User::Leave(KErrArgument); if (!parse.PathPresent()) User::Leave(KErrArgument); TDriveUnit drive(parse.Drive()); return drive; }
/** @SYMTestCaseID PDS-SQL-UT-4224 @SYMTestCaseDesc CSqlServer::GetBackUpListL() functional test @SYMTestPriority High @SYMTestActions Calls CSqlServer::GetBackUpListL() and tests the output, when the drive is read-only, when there is a sub-directory which name is matching the search pattern. @SYMTestExpectedResults Test must not fail */ void GetBackupListFunctionalTest() { CSqlServer* server = NULL; TRAPD(err, server = CreateSqlServerL()); TEST2(err, KErrNone); //Case 1: database with specified uid bellow do exist (on drive C). There will be one subdirectory matching the search pattern. const TDriveNumber KTestDrvNum1 = EDriveC; const TUid KDbUid = {0x98765432}; TDriveUnit testDrive(KTestDrvNum1); TDriveName testDriveName = testDrive.Name(); testDriveName.LowerCase(); //One test directory will be created, which name will be matching the search pattern. //The directory name should not be included in the list with the file names. TFileName testFileName; err = server->Fs().PrivatePath(testFileName); TEST2(err, KErrNone); testFileName.Append(KDbUid.Name()); _LIT(KTestPath, "t_startup\\"); testFileName.Append(KTestPath); testFileName.Append(_L("t_startup.db")); TParse parse; err = parse.Set(testFileName, &testDriveName, 0); TEST2(err, KErrNone); err = server->Fs().MkDirAll(parse.FullName()); TEST(err == KErrNone || err == KErrAlreadyExists); // RArray<HBufC*> files; TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum1, files)); TEST2(err, KErrNone); TInt fileCnt = files.Count(); for(TInt i=0;i<fileCnt;++i) { TPtrC fname = files[i]->Des(); TheTest.Printf(_L("Db: %S\r\n"), &fname); TEST(fname.FindF(KTestPath) < 0); //The name should include the full path + the drive err = parse.Set(fname, 0, 0); TEST2(err, KErrNone); TEST(parse.DrivePresent()); TEST(parse.PathPresent()); TDriveName driveName(parse.Drive()); driveName.LowerCase(); delete files[i]; TEST(driveName == testDriveName); } files.Close(); //Case 2: drive Z:. No files should be returned. const TDriveNumber KTestDrvNum2 = EDriveZ; TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum2, files)); TEST2(err, KErrNone); fileCnt = files.Count(); TEST2(fileCnt, 0); //Case 3: drive A:. The drive does not exist. No files should be returned. const TDriveNumber KTestDrvNum3 = EDriveA; TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum3, files)); TheTest.Printf(_L("Drive %d, err=%d\r\n"), KTestDrvNum3, err); fileCnt = files.Count(); TEST2(fileCnt, 0); // delete server; }
EXPORT_C CPrinterModelList* CPrintSetup::ModelNameListL(RFs& aFs) /** Gets the names of all printer models supported. The function scans all directories in the search path list which were added using AddPrinterDriverDirL(). It returns a list of the printer models supported by the .pdr files found in those directories. @param aFs A connection to a file server session. @leave KErrNoMemory There is insufficient memory to perform the operation. @return The list of printer models supported. */ { __ASSERT_ALWAYS(iDriverDirList->Count()>0,Panic(EPanicNoPrinterDirs)); // if (!iModelList) { CPdrModelList* modelList = CPdrModelList::NewL(); CleanupStack::PushL(modelList); // define some variables that are used in the loops, so it only gets done once TDriveList driveList; TDriveInfo driveInfo; TEntry entry; TParse parser; // get a list of available drives User::LeaveIfError(aFs.DriveList(driveList)); for (TInt i=iDriverDirList->Count()-1 ; i>=0 ; i--) { TInt err = parser.Set((*iDriverDirList)[i],NULL,NULL); if (err==KErrNone) { if (parser.DrivePresent()) {// if there is a drive present add the path straight err = aFs.Entry(parser.DriveAndPath(),entry); if (err==KErrNone) modelList->AddDirectoryL(parser.DriveAndPath()); // add dir } else { for (TInt n=0 ; n<KMaxDrives ; n++) {// if there's no drive scan all drives for matching directories if (driveList[n]!=0) { aFs.Drive(driveInfo,n); if (driveInfo.iType!=EMediaNotPresent && driveInfo.iType!=EMediaRemote) { TDriveUnit drive(n); err = parser.Set(drive.Name(),&(*iDriverDirList)[i],NULL); if (err==KErrNone) err = aFs.Entry(parser.DriveAndPath(),entry); if (err==KErrNone) modelList->AddDirectoryL(parser.DriveAndPath()); // add dir } } } } } } CleanupStack::Pop(); // modelList iModelList = modelList; } return iModelList->ScanForModelsL(); }