コード例 #1
0
/*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;
	}
コード例 #2
0
/**
@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;
	}
コード例 #3
0
EXPORT_C void CMMFFormatSelectionParameters::SetMatchToFileNameL(const TDesC& aFileName)
	{
	delete iMatchReqData;
	iMatchReqData = NULL;
	iMatchDataType = EMatchAny;	
	// Extract the extension from the data passed in

	// Parse the path and extract the extension
	_LIT( KDot, "." ) ;
	_LIT8( KDot8, "." );

	// If there is no dot "." in aFileName then assume that we have been passed the extension only (if KMaxExtLen or less)
	if ( (aFileName.Length() <= KMaxExtLen) && (aFileName.Find( KDot ) == KErrNotFound) )
		{
		RBuf8 temp;
		CleanupClosePushL(temp);
		temp.CreateL(aFileName.Length()+1);
		User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName));
		temp.Insert(0,KDot8);
		
		iMatchReqData = CMatchData::CreateL();
		iMatchReqData->SetMatchDataL(temp);
		
		CleanupStack::PopAndDestroy(&temp);
		
		}
	else if ( aFileName.Find( KDot ) == 0 )  // the first character is dot so assume extension only
		{
		RBuf8 temp;
		CleanupClosePushL(temp);
		temp.CreateL(aFileName.Length());
		User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName));
			
		iMatchReqData = CMatchData::CreateL();
		iMatchReqData->SetMatchDataL(temp);
		
		CleanupStack::PopAndDestroy(&temp);
		
		}
	else // We have been given the whole filename.  Use TParse to extract the extension.
		{
		TParse parser ;
		parser.Set( aFileName, NULL, NULL ) ;
		if ( !( parser.NamePresent() ) )
			User::Leave( KErrBadName ) ;
		if ( !( parser.PathPresent() ) )
			{
			RFs fsSession ;
			User::LeaveIfError(fsSession.Connect());
			TInt error = fsSession.Parse(aFileName, parser);
			fsSession.Close();
			User::LeaveIfError(error);
			}
		// Parser should now have the full filename and path
		TPtrC extension = parser.Ext();
		
		RBuf8 temp;
		CleanupClosePushL(temp);
		temp.CreateL(extension.Length());
		User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, extension));
			
		iMatchReqData = CMatchData::CreateL();
		iMatchReqData->SetMatchDataL(temp);
		
		CleanupStack::PopAndDestroy(&temp);
		
		}

	// If we're here, we must now have the file extension
	iMatchDataType = EMatchFileExtension;
	}
コード例 #4
0
/**
 *
 * Open a log.
 *
 * @param	"const TDesC& aLogName"
 *			The log name
 *
 * @param	"TInt aLogMode"
 *			The log mode (as bitmask of TTestFrameworkLogMode)
 *
 * @xxxx
 *
 */
void CTestFrameworkServer::OpenLogL(const TDesC& aLogName, TInt aLogMode)
{
    // NB we need to check if a console is already open - if so, we do NOT
    // create another one. Ditto with file / port.

    if(aLogMode & ELogToConsole)
    {
        if(!iConsole)
        {
            iConsole = CServerConsole::NewL(aLogName);

            CConsoleBase* theConsole = iConsole->Console();
            theConsole->Printf(_L("%S : Server log starting\n"), &aLogName);

            iLogMode |= ELogToConsole;

            if (aLogMode & ELogConsoleFull)
                iLogMode |= ELogConsoleFull;
        }
    }

    // NB relative paths will not work with TParse (there is no file server open).
    // Exception is a bare filename (with no path) : this will be found in root of C:

    // NOTE! We have no mechanism to notify this error. The console will display
    // and then exit. The log file cannot be opened.

    // TO BE ENHANCED - if console is made active, then we can pause

    if(aLogMode & ELogToFile)
    {
        if(!iFileLogger)
        {
            TRAPD(err, iFileLogger = CFileLogger::NewL());
            if(err != KErrNone)
            {
                // if we can't create a logger, we panic
                User::Panic(_L("TestFrameworkServer"), 1);
            }

            _LIT(KLogPath, "C:\\Logs\\TestResults");
            _LIT(KDefault, "C:\\.htm");

            TParse parseLogName;
            parseLogName.Set(aLogName, NULL, NULL);

            TFileName logFilePath;
            logFilePath = KLogPath;

            if(parseLogName.PathPresent())
                logFilePath.Append(parseLogName.Path());
            else
                logFilePath.Append(_L("\\"));


            // overwrite extension if supplied with .htm
            TParse logFileFullName;
            TInt returnCode = logFileFullName.Set(KDefault, &logFilePath, &aLogName);
            if (returnCode == KErrNone)
            {
                TInt ret = iFileLogger->Connect();
                if (ret == KErrNone)
                {
                    iFileLogger->CreateLog(logFilePath, logFileFullName.NameAndExt());
                    iLogMode |= ELogToFile;
                }
            }
        }
    }

    if(aLogMode & ELogToPort)
    {
        // RDebug::Print will deal with the serial port, we don't do anything special here
        iLogMode |= ELogToPort;
    }
}