本文整理汇总了C++中TFileName::Trim方法的典型用法代码示例。如果您正苦于以下问题:C++ TFileName::Trim方法的具体用法?C++ TFileName::Trim怎么用?C++ TFileName::Trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TFileName
的用法示例。
在下文中一共展示了TFileName::Trim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __dlopen_r
//-----------------------------------------------------------------------------
//Function Name : void* __dlopen_r(const char* filename, int flag)
//Description : To open the given dll filename.
//Return Value : Valid handle value if no error, Null if dll couldn't be loaded
//-----------------------------------------------------------------------------
void* __dlopen_r(const char* filename,const int flag)
{
//convert filename to TFileName
TPtrC8 ptr8( (unsigned char*)filename);
TFileName fileNameBuf;
CnvUtfConverter::ConvertToUnicodeFromUtf8(fileNameBuf, ptr8);
TParsePtr filePathName(fileNameBuf);
//if file name contains wild character
if ( filePathName.IsWild() )
{
SetError(KDlOpenErrNoSupport);
return NULL;
}
//to load dll
RLibrary library;
TInt err;
TBool isLibraryLoaded = EFalse;
RFs fs;
err = fs.Connect();
if ( KErrNone == err )
{
TUint tempAtt;
//if path is there load from this path
if ( filePathName.PathPresent() )
{
err = fs.Att(filePathName.FullName(), tempAtt);
fs.Close();
if ( KErrNotFound != err && KErrPathNotFound != err)
{
err = library.Load(filePathName.FullName());
if ( KErrNone != err )
{
SetError(KDlOpenErrLoading);
return NULL;
}
isLibraryLoaded = ETrue;
}
}
else//if there is no path its only file name
{
TPtrC fileName(filePathName.NameAndExt());
char* envPathName = getenv("LD_LIBRARY_PATH");
if ( envPathName )
{
TPtrC8 tempPtr8((unsigned char*)envPathName);
TFileName envPathBuf;
CnvUtfConverter::ConvertToUnicodeFromUtf8(envPathBuf, tempPtr8);
TPtrC envPath(envPathBuf);
TChar delim(';');
TFileName fileToLoad;
TInt pos = envPath.Locate(delim);
//if delim does not found and still envPath contains value
//i.e. this one is last path without delim(';') so take
//this also, for this length is checked
while ( KErrNotFound != pos || envPath.Length())
{
//if there is no delim
if (KErrNotFound == pos )
{// so last path without delim
pos = envPath.Length();
}
TPtrC thisPath(envPath.Left(pos));
fileToLoad = thisPath;
fileToLoad.Trim();
//to check ";;" and "; ;"
if (fileToLoad.Length())
{
//if path does not conatin trailing \ add one
if ( L'\\' != fileToLoad[fileToLoad.Length()-1] )
{
fileToLoad.Append(TChar(L'\\'));
}
fileToLoad.Append(fileName);
err = fs.Att(fileToLoad, tempAtt);
if ( KErrNotFound != err && KErrPathNotFound != err)
{
//load file from this path
err = library.Load(fileToLoad);
if ( KErrNone == err )
{
// dll loaded successfully from thispath
isLibraryLoaded = ETrue;
break;
}
}
}
if ( pos == envPath.Length())
{
break;
}
else
{
envPath.Set(envPath.Mid(pos + 1));
//.........这里部分代码省略.........