本文整理汇总了C++中TParse::Drive方法的典型用法代码示例。如果您正苦于以下问题:C++ TParse::Drive方法的具体用法?C++ TParse::Drive怎么用?C++ TParse::Drive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TParse
的用法示例。
在下文中一共展示了TParse::Drive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckDiskSpace
// ---------------------------------------------------------
// CCookieManagerServer::CheckDiskSpace
// ---------------------------------------------------------
//
TBool CCookieManagerServer::CheckDiskSpace( RFs& aFileSystem,
const TDesC& aFileName ) const
{
TInt err;
TParse parse;
err = parse.SetNoWild( aFileName, NULL, NULL );
if ( err == KErrNone )
{
// This is in the form : drive-letter: (letter + semi-colon)
TBuf<2> driveBuf( parse.Drive() );
TCharF driveLetter( driveBuf[0] );
TCharF driveALetter( 'A' );
TDriveNumber driveNum = (TDriveNumber)( (TUint)(driveLetter) -
(TUint)(driveALetter) );
TBool noSpace = EFalse;
TRAP( err, noSpace = SysUtil::DiskSpaceBelowCriticalLevelL
( &aFileSystem, KCookieMaxFileLength, driveNum ) );
if ( err == KErrNone && noSpace )
{
err = KErrDiskFull;
}
}
return ( err == KErrNone ? ETrue : EFalse );
}
示例2: SetDefaultDir
TInt PosixFilesystem::SetDefaultDir (RFs& aFs)
{
TParse parse;
parse.Set(RProcess().FileName(), NULL, NULL);
#ifdef __SECURE_DATA__
return aFs.SetSessionToPrivate(TDriveUnit(parse.Drive()));
#else
return aFs.SetSessionPath(parse.DriveAndPath());
#endif
}
示例3: SetResPath
void CMainControlEngine::SetResPath()
{
TFileName fileName;
::CompleteWithAppPath(fileName);
TParse parse;
parse.Set(fileName,NULL,NULL);
iResPath.Zero();
iResPath.Append(parse.Drive());
iResPath.Append(KRESOURCEPATH);
}
示例4: CompleteWithAppPathM
void CompleteWithAppPathM(TDes &aPath)
{
TFileName fullAppName = RProcess().FileName();
TParse parse;
TParse parse1;
parse.Set(fullAppName, NULL, NULL);
parse1.Set(aPath, NULL, NULL);
if(parse1.DrivePresent())
{
aPath[0] = parse.Drive()[0];
}
else
{
aPath.Insert(0, parse.Drive());
}
#ifdef __WINS__
aPath[0] = 'c';
#endif
}
示例5: SetAppDrive
void CMainControlEngine::SetAppDrive()
{
#ifdef __WINS__
iDrive.Append(_L("C:"));
#else
TFileName fileName;
::CompleteWithAppPath(fileName);
TParse parse;
parse.Set(fileName,NULL,NULL);
iDrive.Zero();
iDrive.Append(parse.Drive());
#endif
}
示例6: 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;
}
示例7: DoFullFileNameL
/**
The method parses aFileName argument and constructs the full database file name (including the path) there.
The full file name will be constructed in aFileName input/output argument.
@param aDbFileName Input/Output. Database file name will be constructed there.
@param aSysDrivePrivatePath SQL server private path on the system drive.
@param aDrive Output parameter. The drive number.
@leave KErrBadName Missing file name.
@panic SqlDb 7 In _DEBUG mode - no drive in the final file path.
@internalComponent
*/
static void DoFullFileNameL(TDes& aDbFileName, const TDesC& aSysDrivePrivatePath, TDriveNumber& aDrive)
{
TParse parse;
__SQLLEAVE_IF_ERROR2(parse.Set(aDbFileName, &aSysDrivePrivatePath, NULL));
if(!parse.NamePresent())
{
__SQLLEAVE2(KErrBadName);
}
aDbFileName.Copy(parse.FullName());
TPtrC driveName = parse.Drive();
__ASSERT_DEBUG(driveName.Length() > 0, __SQLPANIC2(ESqlPanicInternalError));
TInt driveNumber = -1;
__SQLLEAVE_IF_ERROR2(RFs::CharToDrive(driveName[0], driveNumber));
aDrive = static_cast <TDriveNumber> (driveNumber);
}
示例8: PrintDiskUsage
void PrintDiskUsage(RFs& aFs, const TDesC& aPath, TInt aOffset = 0)
{
_LIT(KSpace, " ");
TheTest.Printf(_L("%*.*S%S\r\n"), aOffset, aOffset, &KSpace, &aPath);
TFindFile findFile(aFs);
CDir* fileNameCol = NULL;
TBuf<8> fileNameMask;
fileNameMask.Copy(_L("*.*"));
TInt err = findFile.FindWildByDir(fileNameMask, aPath, fileNameCol);
if(err == KErrNone)
{
do
{
const TDesC& file = findFile.File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case.
(void)TheParse.Set(file, NULL, NULL);
TPtrC driveName = TheParse.Drive();
if(aPath.FindF(driveName) >= 0)
{
TInt cnt = fileNameCol->Count();
for(TInt i=0;i<cnt;++i)
{
const ::TEntry& entry = (*fileNameCol)[i];
if(!entry.IsDir())
{
TheTest.Printf(_L("%*.*S %S, size=%d\r\n"), aOffset, aOffset, &KSpace, &entry.iName, entry.iSize);
}
else
{
TBuf<100> path;
path.Copy(aPath);
path.Append(entry.iName);
path.Append(_L("\\"));
PrintDiskUsage(aFs, path, aOffset + 4);
}
}
} // if(aPath.FindF(driveName) >= 0)
delete fileNameCol;
fileNameCol = NULL;
} while((err = findFile.FindWild(fileNameCol)) == KErrNone);//Get the next set of files
}
else
{
TheTest.Printf(_L(" FindWildByDir() failed with err=%d\r\n"), err);
}
}
示例9: FieldTypes
// -----------------------------------------------------------------------------
// MVPbkContactFieldSelector* CContactMatcher::CreateFieldTypeSelectorLC( )
// -----------------------------------------------------------------------------
MVPbkContactFieldSelector* CContactMatcher::CreateFieldTypeSelectorLC
( TInt aResId )
{
if ( !iResourceFileInitialized )
{
TFileName tmpName;
// Append the Resource Files Directory
tmpName.Append( KDC_RESOURCE_FILES_DIR );
// Append the Ressource File Name
tmpName.Append( KMsgCommonUtilsResourceFileName );
// Obtain the drive where the DLL is installed
TFileName dllDrive;
Dll::FileName( dllDrive );
// Obtain the Complete path for the Resource File
TParse parse;
parse.Set( dllDrive, NULL, NULL );
parse.Set( parse.Drive(), &tmpName, NULL );
TFileName fileName;
fileName.Append( parse.FullName());
iResourceFile.OpenL( *iFsSession, fileName );
iResourceFile.ConfirmSignatureL( 0 );
iResourceFileInitialized = ETrue;
}
HBufC8* dataBuffer = iResourceFile.AllocReadLC( aResId );
TResourceReader reader;
reader.SetBuffer( dataBuffer );
CVPbkFieldTypeSelector* fieldTypeSelector =
CVPbkFieldTypeSelector::NewL( reader,
FieldTypes() );
CleanupStack::PopAndDestroy( dataBuffer );
CleanupStack::PushL( fieldTypeSelector );
return fieldTypeSelector;
}
示例10: getImageDirL
// -----------------------------------------------------------------------------
// WebCannedImages::GetCannedImageDirL
// Gets the folder where the canned image is located
// -----------------------------------------------------------------------------
//
HBufC* WebCannedImages::getImageDirL( )
{
TFileName mbmDrive;
HBufC* mbmFile = NULL;
TParse parse;
// get the drive letter - MBM is on the same drive as this DLL
Dll::FileName( mbmDrive );
parse.Set( mbmDrive, NULL, NULL );
mbmDrive = parse.Drive();
// allocate memory for MBM file name
mbmFile = HBufC::NewL( KMaxFileName );
// assemble the MBM file name
TPtr ptr( mbmFile->Des() );
ptr.SetLength( 0 );
ptr.Append( mbmDrive );
ptr.Append( KDC_APP_BITMAP_DIR );
return mbmFile;
}
示例11: DatabaseExistsL
// -----------------------------------------------------------------------------
// CPosLmLocalDatabaseManager::DatabaseExistsL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TBool CPosLmLocalDatabaseManager::DatabaseExistsL(const TDesC& aDatabaseUri)
{
// validate URI
HBufC* uri = PosLmDatabaseUtility::CreateDatabaseUriL(aDatabaseUri);
CleanupStack::PushL(uri);
TPtrC ptr(uri->Des());
PosLmDatabaseUtility::RemoveProtocolFromUriL(ptr);
TParse parse;
User::LeaveIfError(parse.Set(ptr, NULL, NULL));
TFileName searchUri = parse.NameAndExt();
searchUri.UpperCase();
TInt drive;
User::LeaveIfError(RFs::CharToDrive(parse.Drive()[0], drive));
RDbs dbSession;
CleanupClosePushL(dbSession);
User::LeaveIfError(dbSession.Connect());
CDbDatabaseNames* names = dbSession.DatabaseNamesL(
static_cast<TDriveNumber>(drive), KPosLmDbSecureUid);
CleanupStack::PushL(names);
TBool exists(EFalse);
for (TInt i = 0; i < names->Count() && !exists; i++)
{
HBufC* databaseName = (*names)[i].AllocLC();
databaseName->Des().UpperCase();
if (searchUri == *databaseName)
{
exists = ETrue;
}
CleanupStack::PopAndDestroy(databaseName);
}
CleanupStack::PopAndDestroy(3, uri); //dbSession
return exists;
}
示例12: 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;
}
示例13: ConstructL
//.........这里部分代码省略.........
fileInit = ETrue;
drmContent = ETrue;
iCAFParameters->iEnableUI = stream.ReadInt32L();
}
else if (initUid == KMMFileSourceUid)
{
TInt length;
length = stream.ReadInt32L();
filename = HBufC::NewMaxLC(length);
TPtr ptr = filename->Des();
stream.ReadL(ptr, length);
length = stream.ReadInt32L();
if (length>0)
{
iCAFParameters->iUniqueId = HBufC::NewMaxL(length);
ptr.Set(iCAFParameters->iUniqueId->Des());
stream.ReadL(ptr, length);
}
CleanupStack::Pop(filename);
fileInit = ETrue;
drmContent = ETrue;
iFileHandle = EFalse;
iCAFParameters->iEnableUI = stream.ReadInt32L();
}
else
{
// TODO If the UID is unknown we should reject, but currently
// code also used for older calls that just supply filename.
// User::Leave(KErrNotSupported);
}
CleanupStack::PopAndDestroy(&stream);
if (!fileInit && aInitData.Length() == sizeof(TMMFFileHandleParams))
{
TMMFFileHandleParams params;
TPckgC<TMMFFileHandleParams> config(params);
config.Set(aInitData);
params = config();
if (params.iUid == KFileHandleUid)
{
fileInit = ETrue;
User::LeaveIfError(iHandle.Duplicate(*params.iFile));
TInt pos = 0;
// make sure the duplicate handle is at the start of the file - the usage of the file handle really requires this
User::LeaveIfError(iHandle.Seek(ESeekStart, pos));
iFileHandle = ETrue;
filename = HBufC::NewMaxLC(KMaxFileName);
filenamePushed = ETrue;
TPtr ptr = filename->Des();
User::LeaveIfError(iHandle.Name(ptr));
}
}
if (!fileInit) // do old case as last resort
{
TMMFFileParams params;
TPckgC<TMMFFileParams> config(params);
config.Set(aInitData);
params = config();
filename = params.iPath.AllocL();
fileInit = ETrue;
}
if (!filenamePushed)
{
// from now on it is assumed pushed.
CleanupStack::PushL(filename);
}
TParse parser ;
User::LeaveIfError(parser.Set(*filename, NULL, NULL));
CleanupStack::PopAndDestroy(filename);
if ( !( parser.NamePresent() ) && !( parser.ExtPresent() ) )
User::Leave( KErrBadName ) ;
iFullFileName.Copy( parser.FullName() ) ;
iFileName = parser.Name().AllocL() ;
iFileExt = parser.Ext().AllocL() ;
iFilePath = parser.Path().AllocL() ;
iFileDrive = parser.Drive().AllocL() ;
// in order to simulate old behaviour we are not passing error out
// but will try to create Content again during PrimeL()
if (fileInit && drmContent && aFileMode==ESourceMode)
{
TInt contentError;
if (iFileHandle)
{
TRAP(contentError,
iFile = CContentFile::NewL(iHandle, UniqueId(), iCAFParameters->iEnableUI);
);
}
示例14: HandleCommandL
//.........这里部分代码省略.........
myDate.HomeTime();
// Format date according to current locale settings
// Format string is universal, so that whatever the locale is,
// date is always formatted correctly
myDate.FormatL(myBuf, _L("%/0%1%/1%2%/2%3%/3%X"));
// Show formatted text
CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( myBuf );
}
break;
// Time
case ELocalizationCommandTime:
{
// buffer for localized text
TBuf<50> myBuf;
// Object for datetime data
TTime myTime;
// Set current datetime to object
myTime.HomeTime();
// Format time to current locale
// Format string is universal, so that whatever the locale is,
// time is always formatted correctly
myTime.FormatL(myBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B"));
// Show formatted text
CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( myBuf );
}
break;
// Text
case ELocalizationCommandText:
{
// buffer for string parameters that may change order
CDesCArrayFlat* strings = new CDesCArrayFlat( 2 );
CleanupStack::PushL( strings );
// Initialize parameter buffer
// First parameter
strings->AppendL( _L("Heidi") );
// Second parameter
strings->AppendL( _L("2") );
// Load a string from the resource file, and append parameters into it
HBufC* textResource = StringLoader::LoadL( R_LOC_COMMANDTEXT_TEXT, *strings );
CleanupStack::PushL( textResource );
// Show formatted text
CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( *textResource );
// Cleanupstack
CleanupStack::PopAndDestroy( textResource );
CleanupStack::PopAndDestroy( strings );
}
break;
// Image
case ELocalizationCommandImage:
{
// find the drive where the app has been installed
TParse parse;
parse.Set(Application()->AppFullName(),0,0);
// Load bitmap name from the resource file
HBufC* bmpFile = StringLoader::LoadLC( R_LOC_COMMANDIMAGE_BMPFILE, parse.Drive());
// bitmap pointer
CFbsBitmap* bitmap;
// Create and Load the Bitmap
bitmap = new( ELeave )CFbsBitmap;
CleanupStack::PushL( bitmap );
// Load the first bitmap (index 0) from multi-bitmap file
User::LeaveIfError(bitmap->Load( *bmpFile, 0 ));
CleanupStack::Pop( bitmap );
// Draw bitmap to screen
// ownership of bitmap is transferred to view
iAppView->DrawImage( bitmap );
// Cleanupstack
CleanupStack::PopAndDestroy( bmpFile );
}
break;
// Default case
default:
break;
}
}
示例15: DoTestName
LOCAL_C void DoTestName(const TDesC& aName,TInt anError)
//
// Check errors returned
//
{
TBuf<32> goodName=_L("\\GOODNAME.TXT");
TBuf<32> badName=_L("\\< > : \" / |");
TParse parser;
TInt r=parser.Set(aName,NULL,NULL);
test_Value(r, r == KErrNone || r==anError);
goodName.Insert(0,parser.Drive());
badName.Insert(0,parser.Drive());
TBuf<KMaxFileName> name; // We need an 8-bit name to test RFs::GetLongName() in
name.Copy(aName); // both builds
TFileName dummy; // To use as an argument to RFs::GetLongName() will store the
TBuf<12> dummyShortName; // To use as an argument to RFs::GetShortName()
TUint dumVal;
TTime dumTime;
TBool dumAnswer;
TEntry dumEntry;
CDir* dumDir;
TUidType dumUid;
TInt dumInt=0;
TFileName badPath=aName;
badPath.Append(_L("\\"));
// Test MKDIR with filename containing \000
TBuf<32> emptyName;
emptyName.Format(_L("\\%c\\"),0);
emptyName.Insert(0,parser.Drive());
r=TheFs.MkDir(emptyName);
TestReturnValue(r, anError);
emptyName.Format(_L("\\Big%cGreen\\"),0);
emptyName.Insert(0,parser.Drive());
r=TheFs.MkDir(emptyName);
TestReturnValue(r, anError);
r=TheFs.SetSessionPath(badPath);
TestReturnValue(r,KErrBadName); // Do not check drives
r=TheFs.MkDir(badPath);
TestReturnValue(r,anError);
r=TheFs.MkDirAll(badPath);
TestReturnValue(r,anError);
r=TheFs.RmDir(badPath);
TestReturnValue(r,anError);
r=TheFs.GetDir(aName,dumInt,dumInt,dumDir);
TestReturnValue(r,anError);
r=TheFs.GetDir(aName,dumInt,dumInt,dumDir,dumDir);
TestReturnValue(r,anError);
r=TheFs.GetDir(aName,dumUid,dumInt,dumDir);
TestReturnValue(r,anError);
r=TheFs.Delete(aName);
TestReturnValue(r,anError);
r=TheFs.Rename(aName,goodName);
TestReturnValue(r,anError);
r=TheFs.Rename(aName,badName);
TestReturnValue(r,anError);
r=TheFs.Rename(goodName,aName);
TestReturnValue(r,anError);
r=TheFs.Rename(badName,aName);
TestReturnValue(r,anError);
r=TheFs.Replace(aName,goodName);
TestReturnValue(r,anError);
r=TheFs.Replace(aName,badName);
TestReturnValue(r,anError);
r=TheFs.Replace(goodName,aName);
TestReturnValue(r,anError);
r=TheFs.Replace(badName,aName);
TestReturnValue(r,anError);
r=TheFs.Att(aName,dumVal);
TestReturnValue(r,anError);
r=TheFs.SetAtt(aName,dumInt,dumInt);
TestReturnValue(r,anError);
r=TheFs.Modified(aName,dumTime);
TestReturnValue(r,anError);
r=TheFs.SetModified(aName,dumTime);
TestReturnValue(r,anError);
r=TheFs.Entry(aName,dumEntry);
TestReturnValue(r,anError);
r=TheFs.SetEntry(aName,dumTime,dumInt,dumInt);
TestReturnValue(r,anError);
r=TheFs.IsFileOpen(aName,dumAnswer);
TestReturnValue(r,anError);
r=TheFs.GetShortName(aName,dummyShortName);
TestReturnValue(r,anError);
r=TheFs.GetLongName(name,dummy);
TestReturnValue(r,anError);
RFile f;
r=f.Open(TheFs,aName,EFileWrite);
TestReturnValue(r,anError);
r=f.Create(TheFs,aName,EFileWrite);
TestReturnValue(r,anError);
//.........这里部分代码省略.........