当前位置: 首页>>代码示例>>C++>>正文


C++ TParse::PathPresent方法代码示例

本文整理汇总了C++中TParse::PathPresent方法的典型用法代码示例。如果您正苦于以下问题:C++ TParse::PathPresent方法的具体用法?C++ TParse::PathPresent怎么用?C++ TParse::PathPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TParse的用法示例。


在下文中一共展示了TParse::PathPresent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drive

/*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;
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:15,代码来源:journalfile.cpp

示例2: GetBackupListFunctionalTest

/**
@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;
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:69,代码来源:t_sqlstartup.cpp

示例3: SetMatchToFileNameL

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;
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:71,代码来源:mmfcontrollerpluginresolver.cpp

示例4: OpenLogL

/**
 *
 * 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;
    }
}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:89,代码来源:TestFrameworkServer.cpp


注:本文中的TParse::PathPresent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。