本文整理汇总了C++中TFileName::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ TFileName::Find方法的具体用法?C++ TFileName::Find怎么用?C++ TFileName::Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TFileName
的用法示例。
在下文中一共展示了TFileName::Find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValidateRequest
/**
Validate that nobody is trying to touch the virus scanner files.
@internalComponent
@return A value depending on whethe the virus scanner files are
being fiddled with.
@param aDriveNum The drive number of the request which called into
the test virus scanning hook.
@param aName The full pathname of the file being accessed by the
request to the file server hook.
*/
TInt CTestVirusHook::ValidateRequest(TFsPluginRequest& aRequest, TFileName& aFileName)
{
TInt driveNumber = aRequest.DriveNumber();
TInt err = GetName(&aRequest, aFileName);
if(err != KErrNone)
return(err);
if (driveNumber == EDriveC)
{
TInt r = aFileName.Find(_L("\\virusdef.txt"));
if (r != KErrNotFound)
{
//Do not allow the deletion of the virus definition file.
return KErrAccessDenied;
}
r = aFileName.Find(_L("\\system\\libs\\t_vshook.pxt"));
if (r != KErrNotFound)
{
//Do not allow the deletion of the this dll
return KErrAccessDenied;
}
r = aFileName.Find(_L("\\sys\\bin\\t_vshook.pxt"));
if (r != KErrNotFound)
{
//Do not allow the deletion of the this dll
return KErrAccessDenied;
}
}
return KErrNone;
}
示例2: E32Main
TInt E32Main()
{
TFileName cmdLine;
User::CommandLine(cmdLine);
TInt result = RProperty::Set(KFeaturePropCat, KFeaturePropKey, KNullDesC8);
if (cmdLine.Find(KTestResultNone) >= 0)
{
// result should already be KErrNone if succeeded
}
else if (cmdLine.Find(KTestResultPermissionDenied) >= 0)
{
if (result == KErrPermissionDenied)
{
result = KErrNone;
}
else
{
result = KErrGeneral;
}
}
else
{
result = KErrArgument;
}
return result;
}
示例3: VsDirRename
/**
@internalComponent
*/
TInt CTestVirusHook::VsDirRename(TFsPluginRequest& aRequest)
{
TFileName fileName;
TInt err = GetName(&aRequest, fileName);
if(err != KErrNone)
return(err);
err = fileName.Find(_L("\\system\\lib\\"));
if (err != KErrNotFound)
{
//Don't allow sys\bin to be ever renamed
return KErrAccessDenied;
}
err = fileName.Find(_L("\\sys\\bin\\"));
if (err != KErrNotFound)
{
//Don't allow sys\bin to be ever renamed
return KErrAccessDenied;
}
return err;
}
示例4: CreateLayoutNameL
TFileName CPixelMetricsMapperAppUi::CreateLayoutNameL(TFileText& aFileHandle) const
{
aFileHandle.Seek(ESeekStart);
// Layout data is deployed like this:
// first line - height
// second line - width
TFileName lines;
TFileName layoutName;
TInt height = -666;
TInt width = -666;
// Collect name information.
for (TInt i=0; i<6; i++)
{
User::LeaveIfError(aFileHandle.Read(lines));
// Remove pixel metrics name and ":"
lines = lines.Mid(lines.Find(KColon)+1);
// Remove tab
lines = lines.Mid(lines.Find(KTab)+1);
TLex myLexer(lines);
TInt error = KErrNone;
if (i==0) //height is first
{
error = myLexer.Val(height);
}
if (i==1) //width is second
{
error = myLexer.Val(width);
}
User::LeaveIfError(error);
}
// Interpret results and write name to buffer.
if ( (width == 240 && height == 320) ||
(width == 320 && height == 240))
{
layoutName.Append(_L("QVGA "));
}
else if ( (width == 360 && height == 640) ||
(width == 640 && height == 360))
{
layoutName.Append(_L("NHD "));
}
else if ( (width == 480 && height == 640) ||
(width == 640 && height == 480))
{
layoutName.Append(_L("VGA "));
}
else if ( (width == 800 && height == 352) ||
(width == 352 && height == 800))
{
layoutName.Append(_L("E90 "));
}
else if ( (width == 800 && height == 480) ||
(width == 480 && height == 800) ||
(width == 848 && height == 480) ||
(width == 480 && height == 848) ||
(width == 854 && height == 480) ||
(width == 480 && height == 854))
{
layoutName.Append(_L("WVGA "));
}
else if ( (width == 480 && height == 320) ||
(width == 320 && height == 480) ||
(width == 640 && height == 240) ||
(width == 240 && height == 640))
{
layoutName.Append(_L("HVGA "));
}
else
{
layoutName.Append(_L("Unknown "));
layoutName.AppendNum(height);
layoutName.Append(_L("x"));
layoutName.AppendNum(width);
}
if (width > height)
{
layoutName.Append(_L("Landscape"));
}
else
{
layoutName.Append(_L("Portrait"));
}
return layoutName;
}
示例5: CreateHeaderFileL
void CPixelMetricsMapperAppUi::CreateHeaderFileL() const
{
// Open/create resulting file.
RFile file;
HBufC* layoutFile = HBufC::NewLC( KMaxFileName );
*layoutFile = KLayoutSourceFileAndPath;
TFileName fileName = *layoutFile;
CleanupStack::PopAndDestroy(layoutFile);
RFs& fs = CEikonEnv::Static()->FsSession();
TInt error = file.Open(fs,fileName, EFileWrite|EFileShareAny|EFileStreamText );
if (error==KErrNotFound)
{
file.Create(fs,fileName, EFileWrite|EFileShareAny|EFileStreamText);
}
CleanupClosePushL( file );
file.SetSize( 0 );
// Make all writes as from textfile.
TFileText textFile;
textFile.Set( file );
textFile.Seek( ESeekStart );
// Take all layout files from private folder.
CDir* dirList;
User::LeaveIfError(fs.GetDir(
KPixelMetricsDataFiles,
KEntryAttMaskSupported,
ESortByName,
dirList));
TMySmallBuffer bufferLayoutHdr;
TMyBigBuffer bufferPMData;
TInt fileCount = dirList->Count();
for (TInt i=0;i<fileCount;i++)
{
// open sourcefile
RFile sourceFile;
TFileName layoutFile = (*dirList)[i].iName;
User::LeaveIfError( sourceFile.Open(
fs,layoutFile, EFileRead|EFileShareAny|EFileStreamText ));
CleanupClosePushL( sourceFile );
// Make all reads as from textfile.
TFileText textSourceFile;
textSourceFile.Set( sourceFile );
TFileName layoutName = CreateLayoutNameL( textSourceFile );
// rewind - just in case.
textSourceFile.Seek( ESeekStart );
TFileName oneline;
bufferLayoutHdr.Append(KOpenBrace);
bufferPMData.Append(KOpenBrace);
TInt loop = 0;
FOREVER
{
if( textSourceFile.Read(oneline) != KErrNone )
{
break;
}
// Add commas for all but first line
if (loop != 0)
{
if ( loop <= KHeaderValues-1)
{
bufferLayoutHdr.Append(KComma);
}
else
{
if (loop != KHeaderValues)
{
bufferPMData.Append(KComma);
}
}
if (loop==KHeaderValues)
{
bufferLayoutHdr.Append(_L(",QLatin1String(\""));
bufferLayoutHdr.Append(layoutName);
bufferLayoutHdr.Append(_L("\")"));
}
}
// Remove pixel metrics name and ":"
oneline = oneline.Mid(oneline.Find(KColon)+1);
// Remove tab
oneline = oneline.Mid(oneline.Find(KTab)+1);
// remove crap from the end of line
TLex lex(oneline);
TInt nextValue = -666;
User::LeaveIfError( lex.Val(nextValue) );
if ( loop <= KHeaderValues-1)
{
bufferLayoutHdr.AppendNum(nextValue);
}
else
{
if (nextValue == -909)
bufferPMData.Append(_L("ECommonStyleValue"));
else
bufferPMData.AppendNum(nextValue);
}
oneline.Zero();
//.........这里部分代码省略.........
示例6: OpenFileByDefault
void CFileExecuter::OpenFileByDefault(TFileName aFileName)
{
if (::FileIsExist(aFileName)==1)
{
iFileName.Zero ();
iFileName.Append(aFileName);
TInt i = aFileName.LocateReverseF('.');
if(i<0)
{
iMainEngine.ControlFactory().CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_FileTypeNotSupport),*this,0);
return;
}
TFileName nFileExt = aFileName.Right( aFileName.Length() - i - 1 );
nFileExt.ZeroTerminate();
iMainEngine.WriteLog16(nFileExt);
TFileName nAssociatedApp;
TBool nIsFindApp = GetAssociatedApp( nFileExt, nAssociatedApp );
if ( nIsFindApp == true)
{
if (nAssociatedApp.Find(KDefaultAppPath)!=KErrNotFound)
{
OpenFileBySystemDefaultL(aFileName);
}
else if ( nAssociatedApp.FindF( KCoCoAppPath )!=KErrNotFound)
{
//使用内部模块打开
OpenFileByInternal(aFileName);
}
else
{
OpenFileByApp(nAssociatedApp,aFileName);
}
}
else
{
//如果没有默认的打开方式
TInt nType=ParseExPathNum(aFileName);
#ifdef __SERIES60_3X__
if(nType==0 || nType==1 || nType==2 || nType==3)
#else
if(nType==0 || nType==1 || nType==2 || nType==3 || nType==4)
#endif
{
//使用内部模块打开
OpenFileByInternal(aFileName);
}
else
{
//采用系统默认方式打开
OpenFileBySystemDefaultL(aFileName);
}
}
}
else
{
//提示用户文件不存在
iMainEngine.ControlFactory().CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_FileNotExist),*this,0);
}
}