本文整理汇总了C++中TFileName::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ TFileName::Format方法的具体用法?C++ TFileName::Format怎么用?C++ TFileName::Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TFileName
的用法示例。
在下文中一共展示了TFileName::Format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecursiveRmDir
static void RecursiveRmDir(const TDesC& aDes)
//
// Delete directory contents recursively
//
{
CDir* pD;
TFileName n=aDes;
n.Append(_L("*"));
TInt r=TheFs.GetDir(n,KEntryAttMaskSupported,EDirsLast,pD);
if (r==KErrNotFound || r==KErrPathNotFound)
return;
test_KErrNone(r);
TInt count=pD->Count();
TInt i=0;
while (i<count)
{
const TEntry& e=(*pD)[i++];
if (e.IsDir())
{
TFileName dirName;
dirName.Format(_L("%S%S\\"),&aDes,&e.iName);
RecursiveRmDir(dirName);
}
else
{
TFileName fileName;
fileName.Format(_L("%S%S"),&aDes,&e.iName);
r=TheFs.Delete(fileName);
test_KErrNone(r);
}
}
delete pD;
r=TheFs.RmDir(aDes);
test_KErrNone(r);
}
示例2: WriteSolutionTagL
// -----------------------------------------------------------------------------
// CCapInfo::WriteSolutionTagL()
// Writes SyncSolutionsService solution data to capability object.
// -----------------------------------------------------------------------------
//
void CCapInfo::WriteSolutionTagL( const TDesC& aContentName,
const TSConSolutionInfo& aSolution )
{
TRACE_FUNC_ENTRY;
_LIT( KFormatUID, "UID=0x%08x" );
_LIT( KFormatName, "Name=%S" );
_LIT( KFormatDate, "Timestamp=%04d%02d%02dT%02d%02d%02dZ" );
WriteTagL( EExt, TXmlParser::EElementBegin );
WriteValueL( EXNam, aContentName );
TFileName temp;
temp.Format( KFormatUID, aSolution.iUid );
WriteValueL( EXVal, temp );
temp.Format( KFormatName, &aSolution.iSolutionName );
WriteValueL( EXVal, temp );
if ( aSolution.iTime.Int64() != 0 )
{
// write time
TDateTime time = aSolution.iTime.DateTime();
temp.Format( KFormatDate, time.Year(), time.Month() + 1,
time.Day() + 1, time.Hour(), time.Minute(), time.Second() );
WriteValueL( EXVal, temp );
}
WriteTagL( EExt, TXmlParser::EElementEnd );
TRACE_FUNC_EXIT;
}
示例3: certCount
void CPKCS12Handler::SaveCertificatesToDiskL()
{
LOG_("-> CPKCS12Handler::SaveCertificatesToDiskL()");
TInt certCount(0);
// first the CAs (if any; not required necessarily)
if (iCACerts)
{
certCount = iCACerts->Count();
LOG_1(" Saving %d CA Certificates", certCount);
for (TInt i = 0; i < certCount; i++)
{
CX509Certificate* cert = iCACerts->At(i);
// Generate filename with running identifier
// Use TFileName, because the function isn't stack
// critical
TFileName fn;
fn.Format(KCAFileNameStem(), i+1);
WriteToFileL(cert->Encoding(), fn);
}
}
LOG(else LOG_(" No CA Certs found!"));
// Then the user certs
if (iUserCerts)
{
certCount = iUserCerts->Count();
LOG_1(" Saving %d User Certificates", certCount);
for (TInt i = 0; i < certCount; i++)
{
CX509Certificate* cert = iUserCerts->At(i);
TFileName fn;
fn.Format(KUserCertFileNameStem(), i+1);
WriteToFileL(cert->Encoding(), fn);
}
}
LOG(else LOG_(" No User Certs found!"));
LOG_("<- CPKCS12Handler::SaveCertificatesToDiskL()");
}
示例4: ConstructL
// ---------------------------------------------------------------------------
// CTestStartupListUpdater::ConstructL
// ---------------------------------------------------------------------------
//
void CTestStartupListUpdater::ConstructL()
{
// Read settings to check if test case name is to be appended to file name.
RSettingServer settingsServer;
User::LeaveIfError( settingsServer.Connect() );
CleanupClosePushL( settingsServer );
TLoggerSettings loggerSettings;
User::LeaveIfError( settingsServer.GetLoggerSettings( loggerSettings ) );
CleanupStack::PopAndDestroy( &settingsServer );
TFileName logFileName;
if( loggerSettings.iAddTestCaseTitle )
{
TName title;
TestModuleIf().GetTestCaseTitleL( title );
logFileName.Format( KTestStartupListUpdaterLogFileWithTitle, &title );
}
else
{
logFileName.Copy( KTestStartupListUpdaterLogFile );
}
iLog = CStifLogger::NewL( KTestStartupListUpdaterLogPath, logFileName,
CStifLogger::ETxt, CStifLogger::EFile, EFalse );
SendTestClassVersion();
}
示例5: DataFileL
// -----------------------------------------------------------------------------
// 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;
}
示例6: Open
TInt TFileOps::Open(TChar aDrvCh, TInt aNum)
/// Open the file for testing, give error if there is not enough space for it.
/// @param aDrvCh Drive letter.
/// @param aNum File number suffix.
{
TVolumeInfo vol;
TInt drv;
TInt r = TheFs.CharToDrive(aDrvCh, drv);
if (r != KErrNone)
TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), (TUint)aDrvCh, r);
r = TheFs.Volume(vol, drv);
if (r != KErrNone)
TTest::Fail(HERE, _L("Volume(%c:) returned %d"), (TUint)aDrvCh, r);
iMax = I64LOW(vol.iFree / MAKE_TINT64(0,KBufLen)) / 2 - 1;
if (iMax < 10)
TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available"),
I64LOW(vol.iFree/1024));
Reset();
iName.Format(_L("%c:\\TEST_%d"), (TUint)aDrvCh, aNum);
r = iF.Replace(TheFs, iName, EFileStreamText | EFileWrite);
if (r == KErrNone)
iOpen = ETrue;
return r;
}
示例7: ThreadTestL
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
}
示例8: DataFile
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;
}
示例9: MakeFileName
LOCAL_C TInt MakeFileName(TInt aThreadId, TInt aFileNumber, RFs & aFs, TFileName& aName, TBool aMakeDir)
//
// creates a file name and makes all the directory components, if required
//
{
TFileName path;
path.Format(KPath, aThreadId);
TChar driveLetter;
TInt r;
r = aFs.DriveToChar(gDriveNumber, driveLetter);
if (r != KErrNone)
{
LogError(r, KDriveToChar, KNullDesC, driveLetter, 0);
aFs.Close();
return(r);
}
path[0] = (TText) driveLetter;
r = aFs.SetSessionPath(path);
if (r != KErrNone)
{
LogError(r, KSetSessPath, path, 0, 0);
aFs.Close();
return(r);
}
// add additional directories
TInt fileNumber;
fileNumber = aFileNumber;
r = AppendPath(path, fileNumber, 0);
if(r != KErrNone)
{
LogError(r, KAppendPath, path, fileNumber, 0);
aFs.Close();
return(r);
}
if(aMakeDir)
{
r = aFs.MkDirAll(path);
if (r != KErrNone && r != KErrAlreadyExists)
{
LogError(r, KMdAll, path, 0, 0);
aFs.Close();
return(r);
}
}
// and finally add file name
path.Append(KFilePrefix);
path.AppendNum(aFileNumber);
aName = path;
return(KErrNone);
}
示例10: RunTestCaseL
// -----------------------------------------------------------------------------
// CSifUiTest::RunTestCaseL
// -----------------------------------------------------------------------------
//
TInt CSifUiTest::RunTestCaseL( const TInt aCaseNumber,
const TFileName& /*aConfig*/, TTestResult& aResult )
{
if( !iVersionLogged )
{
SendTestModuleVersion();
iVersionLogged = ETrue;
}
TInt returnValue = KErrNone;
TCaseInfo caseInfo = Case ( aCaseNumber );
if( caseInfo.iMethod != NULL )
{
_LIT( KLogStartTC, "Starting testcase [%S]" );
iLog->Log( KLogStartTC, &caseInfo.iCaseName );
// Switch to use test case (TC) logger if necessary
if( iAddTestCaseTitleToLogName )
{
if( iTCLog )
{
delete iTCLog;
iTCLog = NULL;
}
TName title;
TestModuleIf().GetTestCaseTitleL( title );
TFileName logFileName;
logFileName.Format( KSifUiTestLogFileWithTitle, &title );
iTCLog = CStifLogger::NewL( KSifUiTestLogPath, logFileName );
iLog = iTCLog;
}
// Run test case
iMethod = caseInfo.iMethod;
TRAPD( err, returnValue = ( this->*iMethod )( aResult ) );
// Restore standard log and close test case logger
if( iAddTestCaseTitleToLogName )
{
iLog = iStdLog;
delete iTCLog;
iTCLog = NULL;
}
// Leave if the case execution failed
User::LeaveIfError( err );
}
else
{
returnValue = KErrNotFound;
}
// Return case execution status (not the result of the case execution)
return returnValue;
}
示例11: TestSpellL
void CBCTestPtiEngine::TestSpellL()
{
TBuf<8> spell;
TInt err=iEngine->GetSpelling(0x7684, spell, EPtiPinyin);
if(err==KErrNotSupported)
{
AssertTrueL(ETrue, _L("get spelling not support"));
}
else if(err==KErrNone)
{
spell.ZeroTerminate();
AssertTrueL(ETrue, spell);
}
else
{
AssertTrueL(ETrue, _L("get spelling failuer"));
}
//phonetic
iEngine->ClearCurrentWord();
SimuInput(iEngine, _L("wei"));
TInt number = iEngine->PhoneticSpellingCount();
TFileName msg;
msg.Format(_L("phonetic spelling count: %d"), number);
msg.ZeroTerminate();
AssertTrueL(ETrue, msg);
spell=iEngine->GetPhoneticSpelling(0);
AssertTrueL(ETrue, _L("get phonetic spelling for 0"));
TBool result = iEngine->SelectPhoneticSpelling(0);
AssertTrueL(ETrue, _L("select phonetic spelling for 0"));
number = iEngine->SelectedPhoneticSpelling();
msg.Format(_L("selected phonetic spelling: %d"), number);
msg.ZeroTerminate();
AssertTrueL(ETrue, msg);
CDesCArray* array = new (ELeave) CDesCArrayFlat(16);
CleanupStack::PushL(array);
iEngine->GetPhoneticSpellingsL(*array);
AssertTrueL(ETrue, _L("phonetic spellings got"));
CleanupStack::PopAndDestroy(); //array
}
示例12: ServiceInfoL
// -----------------------------------------------------------------------------
// CCapInfo::ServiceInfoL(const TDesC& aDir)
// Reads service xml-files from directory and writes them into capability
// document.
// -----------------------------------------------------------------------------
//
void CCapInfo::ServiceInfoL(const TDesC& aDir, const RArray<TFileName>& aExcludeList,
RArray<TFileName>& aFilesAdded)
{
TRACE_FUNC_ENTRY;
CCapList* capList=CapList();
RArray<TFileName> array( KDefaultArrayGranularity );
CleanupClosePushL(array);
CStringList* stringList=CStringList::NewLC();
CapUtil::GetFileListL(iFsSession, aDir, array);
_LIT(KFormat, "%S%S");
TFileName name;
TInt count=array.Count();
for (TInt i=0; i<count; i++)
{
TBool exludeFromList(EFalse);
// Check if file is already added to list
for ( TInt j=0; j<aExcludeList.Count() && !exludeFromList; j++ )
{
if ( array[i].CompareF(aExcludeList[j]) == 0 )
{
LOGGER_WRITE_1( "match found at pos %d", j);
exludeFromList = ETrue;
}
}
if ( !exludeFromList )
{
name.Format(KFormat, &aDir, &array[i]);
if (!CapUtil::CheckFileType(name, KXmlExtension))
{
continue; // only accept .xml files
}
capList->List()->Reset();
capList->List()->ReadFromFileL( iFsSession, name );
if (capList->FindServiceL(stringList))
{
WriteNewLineL();
WriteFromListL(stringList);
User::LeaveIfError( aFilesAdded.Append(array[i]) );
LOGGER_WRITE_1( "File '%S' added to list", &array[i] );
}
}
}
CleanupStack::PopAndDestroy(stringList);
CleanupStack::PopAndDestroy(&array);
TRACE_FUNC_EXIT;
}
示例13: CreateContentSubdirectoriesL
// ==========================================================================
// FUNCTION: CreateContentSubdirectoriesL
// ==========================================================================
void CContainerStoreContentManager::CreateContentSubdirectoriesL()
{
TFileName directoryName;
for( TInt i = 0; i < KNumberOfContentSubdirectories; i++ )
{
_LIT( KFormatString, "%SC%i\\" );
directoryName.Format( KFormatString, &iUtils.PrivatePath(), i );
BaflUtils::EnsurePathExistsL( iUtils.FileSystem(), directoryName );
} // end for
} // end CreateContentSubdirectoriesL
示例14: ConstructL
// -----------------------------------------------------------------------------
// Ctestsdktouchpane::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CTestSDKTouchPane::ConstructL()
{
iView = CTestSDKTPView::NewL();
iContainer = new( ELeave ) CTestSDKTPContainer();
iContainer->SetMopParent( iView );
iContainer->ConstructL( iView->ClientRect() );
CCoeEnv::Static()->AppUi()->AddToStackL( iContainer );
iContainer->MakeVisible( ETrue );
//Read logger settings to check whether test case name is to be
//appended to log file name.
RSettingServer settingServer;
CleanupClosePushL( settingServer );
TInt ret = settingServer.Connect();
if ( ret != KErrNone )
{
User::Leave(ret);
}
// Struct to StifLogger settigs.
TLoggerSettings loggerSettings;
// Parse StifLogger defaults from STIF initialization file.
ret = settingServer.GetLoggerSettings( loggerSettings );
if ( ret != KErrNone )
{
User::Leave( ret );
}
// Close Setting server session
settingServer.Close();
CleanupStack::PopAndDestroy( &settingServer );
TFileName logFileName;
if ( loggerSettings.iAddTestCaseTitle )
{
TName title;
TestModuleIf().GetTestCaseTitleL( title );
logFileName.Format( KtestsdktouchpaneLogFileWithTitle, &title );
}
else
{
logFileName.Copy( KtestsdktouchpaneLogFile );
}
iLog = CStifLogger::NewL( KtestsdktouchpaneLogPath,
logFileName,
CStifLogger::ETxt,
CStifLogger::EFile,
EFalse );
SendTestClassVersion();
iOffset = CCoeEnv::Static()->AddResourceFileL( _L( "C:\\resource\\testsdktouchpane.rsc" ) );
}
示例15: FolderServiceL
// -----------------------------------------------------------------------------
// CCapInfo::FolderServiceL()
// Writes folder service. Notice that this service is created in code because
// pathinfo component is used to get folder names.
// -----------------------------------------------------------------------------
//
void CCapInfo::FolderServiceL()
{
TRACE_FUNC_ENTRY;
TBuf<KBufSize> rootPath;
TBuf<KBufSize> memoryType(KNullDesC);
TFileName folderName;
_LIT( KFormat, "%S%S" );
WriteNewLineL();
WriteTagL(EService, TXmlParser::EElementBegin);
WriteValueL(EName, KFolderServiceName);
WriteValueL(EUUID, KFolderServiceUid);
WriteValueL(EVersion, KFolderServiceVersion);
WriteTagL(EObject, TXmlParser::EElementBegin);
WriteValueL(EType, KFolderServiceType);
WriteTagL(EObject, TXmlParser::EElementEnd);
TInt drive;
TInt err;
CapUtil::GetDefaultRootPathL( iFsSession, rootPath );
if( rootPath.Length() > 0 )
{
err = iFsSession.CharToDrive( rootPath[0], drive );
if( err == KErrNone )
{
CapUtil::GetMemoryType( iFsSession, memoryType, drive );
}
}
// EFolderImages
folderName.Format( KFormat, &rootPath, &PathInfo::ImagesPath() );
WriteFolderL( KFolderImages, folderName, memoryType );
// EFolderGraphics
folderName.Format( KFormat, &rootPath, &PathInfo::ImagesPath() );
WriteFolderL(KFolderGraphics, folderName, memoryType);
// EFolderTones
folderName.Format( KFormat, &rootPath, &PathInfo::DigitalSoundsPath() );
WriteFolderL(KFolderTones, folderName, memoryType);
// EFolderMusic
folderName.Format( KFormat, &rootPath, &PathInfo::SoundsPath() );
WriteFolderL(KFolderMusic, folderName, memoryType);
// EFolderVideos
folderName.Format( KFormat, &rootPath, &PathInfo::VideosPath() );
WriteFolderL(KFolderVideos, folderName, memoryType);
// EFolderInstalls
folderName.Format( KFormat, &rootPath, &PathInfo::InstallsPath() );
WriteFolderL(KFolderInstalls, folderName, memoryType);
WriteTagL(EService, TXmlParser::EElementEnd);
WriteNewLineL();
TRACE_FUNC_EXIT;
}